Monday, 26 May 2014
Thursday, 12 December 2013
How to add an administrator to IPMI interface
[root@olsnba08 ~]# modprobe ipmi_devintf [root@olsnba08 ~]# ipmitool user list 1 ID Name Callin Link Auth IPMI Msg Channel Priv Limit 1 false false true ADMINISTRATOR 2 root false true true ADMINISTRATOR 3 test1 false false true ADMINISTRATOR 4 test2 false false true ADMINISTRATOR 5 test3 false false true ADMINISTRATOR 6 gbitzes true true true ADMINISTRATOR [root@olsnba08 ~]# ipmitool user set name 7 admin [root@olsnba08 ~]# ipmitool user set password 7 Password for user 7: Password for user 7: [root@olsnba08 ~]# ipmitool channel setaccess 1 7 link=on ipmi=on callin=on privilege=4 [root@olsnba08 ~]# ipmitool user enable 7
Wednesday, 13 November 2013
How to see content of a package under Linux
For an rpm file not yet installed:
rpm -qlp /path/to/file.rpmFor a package that is already installed: Red Hat:
repoquery -lq package_nameUbuntu, Debian:
dpkg-query --listfiles package_name
Thursday, 31 October 2013
BMC is in FW Transfer Mode
This is a message that I get when trying to remotely update the BIOS on Jefferson Pass systems equipped with Intel S2600JF mother boards and Intel E5-2690 Sandy Bridge CPUs.
The solution is to do BMC cold reset using ipmi and wait for 30 seconds:
ipmitool mc reset coldIf IPMI kernel module happens not to be loaded, then load it with this command:
modprobe ipmi_devintf
Friday, 30 August 2013
How to compare two directory trees
When you want to see which files differ without further details:
Cheers.
diff -qr path/1/ path/2/With a separate diff for each differing file:
diff -r path/1/ path/2/
Cheers.
Tuesday, 13 August 2013
How to find out the number of global variables in a binary
nm your-binary-file | grep '[0-9A-Fa-f]* [BCDGRS]' |cut -d ' ' -f 3 | grep -ve '__.*' | grep -v @@ | wc -l
Thursday, 30 May 2013
How to install a network printer at CERN under Ubuntu
Installing a driver at CERN is kind of a puzzle, unless you run Windows or SLC. Unfortunately there are no tutorials how to do that. This is why I came up with the following, somewhat hackerish, solution:
- Install packages libnet-ldap-perl and cups on your system using apt-get
- Download the lpadmincern RPM package.
- Unpack it.
- Replace inside lpadmincern.pl
my $cupsc='/sbin/service cups reload';
withmy $cupsc='/usr/sbin/service cups reload';
Replace
- install libnet-ldap-perl
- Find your desired printer at CERN printing service
- Move the whole directory to /usr/share/lpadmincern, otherwise it would complain about a missing directory.
- Run
perl lpadmincern.pl --add [your-printer-name-here]
$command="LC_ALL=C /usr/sbin/lpadmin -p $prt->{printerName} -L \"$prt->{location}\" -D \"$prt->{description}\" -v $uri $duplex $media -o printer-is-shared=false -E";with
$command="LC_ALL=C /usr/sbin/lpadmin -p $prt->{printerName} -L \"$prt->{location}\" -P $prt->{ppdfile} -D \"$prt->{description}\" -v $uri $duplex $media -o printer-is-shared=false -E";Apparently this got replaced in the meanwhile.
How to check number of cores per CPU
echo $(($((`cat /proc/cpuinfo | grep 'processor' | sort -n | wc -l`))/$((`cat /proc/cpuinfo | grep "physical id" | sort -n | uniq | wc -l`))))
Monday, 18 February 2013
How to do a platform-independent path join in Java
Today I had to join a file path with its parent directory path. I could this simply by joining strings with "/", but this solution is not portable to non *nix systems. In Python I would write:
import os.path parent = "a/b/c" filename = "efg" joined = os.path.join(parent, filename)But what is Java equivalent? It turns out that the best way is to use java.io.File. One can do:
File parent = new File("a/b/c");
File file = new File("efg");
String joined = new File(parent, file).getPath();
The last line is to go back to String world, but possibly you don't have to.
Tuesday, 12 February 2013
Tuesday, 8 January 2013
Synchronized print in Python
Today I faced a problem where I had to print to the standard output in a synchronized way. I put the following code in a file named rpython.py
from __future__ import print_function
from threading import Lock
_global_lock = Lock()
_old_print = print
def print(*a, **b):
with _global_lock:
_old_print(*a, **b)
Now, in every Python module that requires synchronized printing I typed:
from __future__ import print_function from rpython import printAlternatively, if you don't want to shadow the default printing you can type:
from __future__ import print_function from rpython import print as rprintHave a nice, synchronized day.
EDIT:
I should have started with a clear statement that Python's print is not synchronized in any way. Multiple threads writing concurrently to any stream can interfere and usually they do that, so as an effect you get a random mixture of massages which looks really ugly.
Monday, 7 January 2013
util.NativeCodeLoader: Unable to load native-hadoop library for your platform.
Problem: when launching a hadoop-based app one can encounter message
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicableSolution: type following command in the command line. The path may vary depending on your platform and hadoop version
export LD_LIBRARY_PATH=/usr/lib/hadoop-0.20-mapreduce/lib/native/Linux-amd64-64
How to build jar with Maven containing nothing but dependencies
Today I came across a problem where I had to split my project into two jars: one containing my project's classes and the other one with dependencies. The former got changed every time I made some changes in the source files. The latter was basically constant throughout the development.
This facilitates me the deployment of my application. Previously after each improvement I had to transfer a big-fat-and-ugly *-jar-with-dependencies.jar and that took ten good minutes as the file weights 189MB. It turned out that dependencies weight.. 189MB and my compiled classes 45KB.
Below the xml that I placed in src/main/resources/assemblies/only-deps.xml
and a profile that I added to the main pom.xml:only-deps jar false / false true runtime
only-deps
org.apache.maven.plugins
maven-assembly-plugin
src/main/resources/assemblies/only-deps.xml
package
create-my-bundle
single
Run the whole thing with mvn install -P only-deps.
Sunday, 25 November 2012
How to make Windows executable from a Python script
Recently I faced a problem that I always wanted to stay away from. My brother asked me to write a simple GUI app, which isn't a big deal, but it has to be run in Windows.
Holy shit. I develop all the staff in Linux and suddenly I have to prepare a Windows-compatible app. As Python is a language of my choice, I picked it also this time. I wrote an app under Linux and then I made a research on how to port it to Windows without a need to install Python on the target machine. I found cx_Freeze which seemed to be suitable. Having read a really good cx_Freeze tutorial I wrote a setup.py script which looked like this:
#!/usr/bin/env python
from cx_Freeze import setup, Executable
exe = Executable(
script="google_check.pyw",
base="Win32GUI",
)
setup(
name = "googleCheck",
version = "0.1",
description = "google check app",
executables = [exe]
)
then run
pawel@pawel-asus:/media/5841-E712/seba$ python ./setup.py build running build running build_exe Traceback (most recent call last): File "./setup.py", line 13, inUhhh.. I can't freeze an app for Windows under Linux. My bad. There is no way to "cross-compile" an app on Linux without having a Python installation on Windows partition that would be visible from Linux. If you have one, you can use PyInstaller. I had no Python on my Windows so I had to install it first.. which is a pain in the ass. Here is what to do:executables = [exe] File "/usr/lib/pymodules/python2.7/cx_Freeze/dist.py", line 278, in setup distutils.core.setup(**attrs) ... File "/usr/lib/pymodules/python2.7/cx_Freeze/freezer.py", line 186, in _GetBaseFileName raise ConfigError("no base named %s", name) cx_Freeze.freezer.ConfigError: no base named Win32GUI
- Go to Python for Windows download page, download an installation file and install it.
- Add your Python/scripts path to the PATH variable (go to My computer/properties/Advanced/Environmental Variables/Path/Edit then paste the path with an extra semicolon as the last entry.
- Get Easy install installer and install it.
- Open command line and type easy_install cx_Freeze
Friday, 23 November 2012
Machine learning at Twitter
Recently we had a discussion on paper about machine learning at Twitter. You won't find there discoveries that would move the horizon of science. It presents a model of computation for big data which I found particularly useful, though. There are only two authors listed, but one can easily notice contribution of countless engineers.
You do not appear to be using the NVIDIA X driver. Please edit your X configuration file (just run `nvidia-xconfig` as root), and restart the X server.
This message kept poping up when I tried to run nvidia-settings. This happened by the way when my maximal resolution was 640x480 and number of colours was dramatically limited. I was unable to run my second screen either (xrandr was constantly crashing because of lack of randr extension). I found a solution and modified it according to my needs.
sudo apt-get install linux-headers-$(uname -r) sudo ldconfig sudo update-initramfs -u sudo nvidia-xconfig sudo rebootWelcome back, nVidia.
How to upgrade your Ubuntu distribution from terminal
Recently I encountered a major Xfce crash. There was no windows decorations nor menus in the graphical environment. I was unable to move windows, as well as close them. It made me realize when I updated my system for the last time. Enough to say that I don't remember this fact.
I left the computer for the night to download all packages from 11.04 (Natty Narwhal) and install them (there was surprisingly no option to go directly for 12.04). In the morning my computer was unable to boot with WM and I was left with recovery console... My next easy-to-do option was to try to update to 12.04. Here is what to do (supposing we go from 10.04 (Lucid Lynx) to 12.04 (Precise Pangolin):
sudo sed -i.bak -e s/lucid/precise/g /etc/apt/sources.list sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgradeThis will not install packages that were earlier not installed. You may have to install for instance kernel image and headers by hand.
Subscribe to:
Posts (Atom)
