fredag 8 februari 2013
Install tiny webserver on archlinux
# pacman -S darkhttpd
# mkdir /var/httpd
# chmod a+rx /var/httpd
# echo > /var/httpd/start-server.sh \
'darkhttpd /var/httpd --log /var/log/httpd.log --uid daemon --chroot --daemon'
# chmod 0700 /var/httpd/start-server.sh
# echo Hello > index.html
# chmod a+r index.html
# /var/httpd/start-server.sh
torsdag 31 januari 2013
Multiple ipv6 addresses on an interface
To prevent being tracked on the intertubes, ipv6 has security extensions that, (if they are enabled via sysctl net.ipv6.conf.all somewhere), from time to time creates random a address, and expire the old ones for outgoing traffic. To see the addresses do
ip -6 addr
and look for temporary. The expired addresses (that still work) have the word "deprecated". If you get sick of seeing them, delete an address from an interface with
ip -6 addr del dev eth0
or delete all deprecated addresses like this
ip -6 addr | awk '/deprecated/ {print "ip -6 addr del " $2 " dev eth0"}' | sudo bash -s
ip -6 addr
and look for temporary. The expired addresses (that still work) have the word "deprecated". If you get sick of seeing them, delete an address from an interface with
ip -6 addr del
or delete all deprecated addresses like this
ip -6 addr | awk '/deprecated/ {print "ip -6 addr del " $2 " dev eth0"}' | sudo bash -s
Virtual X11 display
x11vnc -create -forever -localhost
-create launches Xvfb (on DISPLAY=:20 or something like that)
-forever enables reconnection
-localhost only listens to local connections, so you'll have to forward the port (5900+nr) for instance over ssh.
Then one may need a windowmanager too, for instance
DISPLAY=:10 fluxbox
You may put fluxbox in the .xinitrc file too.
-create launches Xvfb (on DISPLAY=:20 or something like that)
-forever enables reconnection
-localhost only listens to local connections, so you'll have to forward the port (5900+nr) for instance over ssh.
Then one may need a windowmanager too, for instance
DISPLAY=:10 fluxbox
You may put fluxbox in the .xinitrc file too.
torsdag 17 januari 2013
posting to xen-devel
example
git format-patch 73edc26b69803cdbce62513c7be8010c829e4274^..73edc26b69803cdbce62513c7be8010c829e4274
git send-email --in-reply-to '<1358428780 .13856.57.camel=".13856.57.camel" zakaz.uk.xensource.com="zakaz.uk.xensource.com">' --from lra@sics.se --to xen-devel@lists.xensource.com --smtp-server smtp.sics.se 0001-Set-register-values-and-comment-in-early-init_uart-t.patch1358428780>
tisdag 15 januari 2013
inplace quicksort in python
https://gist.github.com/4537928
def quicksort(l):
work = [(0,len(l)-1)]
while work:
(left,right) = work.pop()
if right < left:
continue
i_piv = left
piv = l[i_piv]
l0,r0 = left, right
while left < right:
while l[left] <= piv and left < right: left += 1
while l[right] > piv: right -= 1
if left < right: l[left], l[right] = l[right], l[left]
l[i_piv], l[right] = l[right], piv
work.append((l0,right-1))
work.append((right+1,r0))
onsdag 19 december 2012
Python is_prime using Miller-Rabin
from random import randrange
def is_prime(n, trials=6):
""" Miller-Rabin probabilistic prime test.
"""
if n < 2:
return False
i = 0
while i < trials:
i+=1
a = randrange(1, n)
if pow(a, n-1, n) != 1: # (a**(n-1)) % n
return False
return True
# or as a tiny-font-one-liner
def is_prime(n, trials=6):
return n >= 2 and (trials == 0 or (pow(randrange(1, n), n-1, n) == 1 and is_prime(n, trials - 1)))
onsdag 12 december 2012
uboot pogoplug netconsole
I used this tip to set up my pogoplug to send the uBoot prompt
via udp to my laptop
(see: Use netconsole to troubleshoot uBoot without a serial cable
http://forum.doozan.com/read.php?3,14,14)
Now, to get the boot prompt from pogoplug (192.168.1.74) to my laptop (192.168.1.72)
I do (on my laptop)
to set an ip alias (remove with -alias), and then
nc -lu 192.168.1.72 6666 & nc -u 192.168.1.74 6666
to communicate with the pogoplug.
via udp to my laptop
(see: Use netconsole to troubleshoot uBoot without a serial cable
http://forum.doozan.com/read.php?3,14,14)
Now, to get the boot prompt from pogoplug (192.168.1.74) to my laptop (192.168.1.72)
I do (on my laptop)
ifconfig en0 alias 192.168.1.72 255.255.255.0
to set an ip alias (remove with -alias), and then
nc -lu 192.168.1.72 6666 & nc -u 192.168.1.74 6666
to communicate with the pogoplug.
Prenumerera på:
Inlägg (Atom)