Proxying HTTP traffic via SSH

On your local machine:

ssh -ND 3333 username@remote_server_data_is_proxyed_through

Then just set up your browser with a Socks5 proxy to 127.0.0.1:3333

Making eclipse look good on Linux

Found at http://ubuntuforums.org/showthread.php?t=1465712

Add the following to ~/.gtkrc-2.0

style "gtkcompact" {
GtkButton::default_border={0,0,0,0}
GtkButton::default_outside_border={0,0,0,0}
GtkButtonBox::child_min_width=0
GtkButtonBox::child_min_heigth=0
GtkButtonBox::child_internal_pad_x=0
GtkButtonBox::child_internal_pad_y=0
GtkMenu::vertical-padding=1
GtkMenuBar::internal_padding=0
GtkMenuItem::horizontal_padding=4
GtkToolbar::internal-padding=0
GtkToolbar::space-size=0
GtkOptionMenu::indicator_size=0
GtkOptionMenu::indicator_spacing=0
GtkPaned::handle_size=4
GtkRange::trough_border=0
GtkRange::stepper_spacing=0
GtkScale::value_spacing=0
GtkScrolledWindow::scrollbar_spacing=0
GtkTreeView::vertical-separator=0
GtkTreeView::horizontal-separator=0
GtkTreeView::fixed-height-mode=TRUE
GtkWidget::focus_padding=0
}
class "GtkWidget" style "gtkcompact"

Change GNOME’s menu spacing

I’m using the theme Ambiance, I edited its file directly at:

/usr/share/themes/Ambiance/gtk-2.0/gtkrc

style "menu-item" = "menu"
{
        xthickness = 0
        ythickness = 5

        engine "murrine"
        {
                roundness = 0
        }
}

To:

style "menu-item" = "menu"
{
        xthickness = 0
        ythickness = 0

        engine "murrine"
        {
                roundness = 0
        }
}

Latex on Ubuntu

Installed the following packages:
texlive-base
texlive-fonts-recommended
texlive-latex-recommended

Found this awesome makefile for Latex at

http://www.acoustics.hut.fi/u/mairas/UltimateLatexMakefile/

Simply drop it into your folder with your tex documents and run ‘make pdf’ I changed ‘latex’ to ‘pdflatex’ in the script
so that I’d only have to run ‘make’

Setting up netboot

Based on http://wiki.debian.org/DebianLive/Howto/Creating_a_Netboot_Image

apt-get install live-helper
apt-get install nfs-kernel-server # You need the package nfs-kernel-server. Apparently, nfs-user-server does not work with netboot
apt-get install dhcp3-server
apt-get install tftpd-hpa
apt-get install xinetd

ifconfig eth1 192.168.0.1

mkdir /srv/debian-live
echo “/srv/debian-live *(rw,sync,no_root_squash)” >> /etc/exports

mkdir mydeblive; cd mydeblive
lh_config
lh_config -a i386
lh_config –binary-images net
lh_config –net-root-path “/srv/debian-live”
lh_config –net-root-server “192.168.0.1”

lh_config –binary-images net \
–net-root-path “/srv/debian-live” \
–net-root-server “192.168.0.1”
lh_build

cp -R binary/ /srv/debian-live
mv /srv/debian-live/binary/live /srv/debian-live

cp -R tftpboot/* /var/lib/tftpboot
mv /var/lib/tftpboot/boot-screens/* /var/lib/tftpboot

iptables -t nat -F
# eth0 is outgoing internet connection (NOT the LAN iface for the netboot machines)
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

edit /etc/default/tftpd-hpa to make sure
RUN_DAEMON=”yes”

vim /etc/xinetd.d/tftp

service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /var/lib/tftpboot
disable = no
bind = 192.168.0.1
}

/etc/init.d/xinetd restart

or just run

in.tftpd -l -a 192.168.0.1 -v -v -p -s /var/lib/tftpboot/

You can place any executable scripts in:
config/chroot_local-hooks

Which will be executed when the image is being created, if you add more
scripts in here or change them, make sure to run lh_clean before lh_build, otherwise
they will NOT be run.

Useful script to go in:

#!/bin/bash
echo “I: update password”
echo “root:nopasswd” | chpasswd

Setting up public key access to SSH host

Rather than manually creating the authorized_keys file in the ‘.ssh’ directory on the host computer
you want to set up public key access for, you can instead use:

ssh-copy-id -i rsa.pub user@host

Which will use the rsa.pub public key and automatically create the file
in the correct users directory.

Android developing under linux

If you get ‘???????? no permissions’ after running ‘adb devices’

In /etc/udev/rules.d/51-android.rules you need to add
SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″

Then:
./adb kill-server
./adb start-server

C Indentation

The following if my preferred C formatting, created with the GNU Indent command:

indent -linux -brf SRC.c -cli8

e.g.

void main(int argc, char ** argv){
<tab>printf(“bonjour”);
<tab>switch(2){
<tab><tab>case 2:
<tab><tab><tab>printf(“2″);
<tab><tab><tab>break;
<tab>}
}

Human Random Number Generation

By making use of Amazon’s Mechanical Turk I was able to obtain large quantities of random numbers generated by people.

I used http://www.fourmilab.ch/hotbits/ to obtain 310 bytes of random numbers obtained from radioactive decay. The following text shows various statistics obtained using a program called ‘ent’.


Entropy = 7.256475 bits per byte.

Optimum compression would reduce the size
of this 310 byte file by 9 percent.

Chi square distribution for 310 samples is 282.93, and randomly
would exceed this value 25.00 percent of the times.

Arithmetic mean value of data bytes is 130.4645 (127.5 = random).
Monte Carlo value for Pi is 2.901960784 (error 7.63 percent).
Serial correlation coefficient is 0.071475 (totally uncorrelated = 0.0).


The following shows the entropy of 310 bytes of random numbers based on those from humans.

Entropy = 7.322698 bits per byte.

Optimum compression would reduce the size
of this 310 byte file by 8 percent.

Chi square distribution for 310 samples is 253.20, and randomly
would exceed this value 50.00 percent of the times.

Arithmetic mean value of data bytes is 116.3226 (127.5 = random).
Monte Carlo value for Pi is 3.294117647 (error 4.86 percent).
Serial correlation coefficient is -0.017168 (totally uncorrelated = 0.0).

Simply download all particular files from a webpage

wget -e robots=off -r -l1 --no-parent -A.<file type> <URL>

<file type> – e.g. mp4, exe, …

« Older entries

Follow

Get every new post delivered to your Inbox.