CV finns att hämta nedan.
Sånghäfte för kräftskivan
Här kan du ladda ner sånghäftet för kräftskivan.
Loppiskassan v1.2
Loppiskassan har blivit uppdaterad och stödjer nu redovisning av olika betalningsmetoder. De två betalningsmetoder som stöds är [Kontant, Swish].
Funktionen är densamma som tidigare version men gränssnittet är något ändrat.
Continue reading
Välkommen till världen
Grattis till barnet, kul att det blev en Vidar 🙂
Loppiskassan
Vad är loppiskassan?
Loppiskassan är ett litet program som hjälper till med kassahantering och redovisning för inlämningsloppisar.
En inlämningsloppis är ett smart sätt att locka kunder till en stor loppis där flera säljare samsas om lokal och delar på kostnader.
Som säljare lämnar man in sina varor innan loppisen öppnar, och hämtar pengar och eventuella osålda varor när loppisen är över.
Some aliases I use
In my daily work I often find myself doing repetitive tasks, some simple others more advanced.
Here are some of my favorite aliases I use for some of the simple tasks.
#Listing my IP addresses in a format so that I can easily copy the IP address I need. ips='/sbin/ifconfig | grep "Link encap" -A1 | sed "s/.*inet addr://" | sed "s/ .*//"' #Listing targets in an ant build.xml catb='cat build.xml | grep -e".*target name.*"' #finding java files (often used in conjunction with grep to look in files) findjava='find . -type f | grep -e".*\.java$"' #finding log files findlogs='export log=$$;find . -type f | grep -e".*\.log$" >/tmp/$log ; find . -type f | grep -e".*\.log\.[0-9]*$" >>/tmp/$log ; cat /tmp/$log | sort ' #Grepping in history (eg 'hgrep scp') hgrep='history | grep -v hgrep | grep '
Wrap SharedPreferences in an enum for easy access
Sometimes you need to share a couple of global preferences in your android application and one option is to use the SharedPreferences to accomplish this;
//get the preferences SharedPreferences prefs = myActivity().getSharedPreferences(“ConfigurationStore”, Context.MODE_PRIVATE); //store a value prefs.edit().putString(“user”, “Teddy”).commit(); //get the value prefs.getString(“user”, null);
I like my code simple so I wrote a very simple wrapper to hide the above, here is the result.
public enum ConfigurationStore { USER(“user”); private String key; private SharedPreferences prefs = //get this from your activity class ConfigurationStore(String key){ this.key = key; } public String get(){ return prefs.getString(key, null); } public void set(String value){ prefs.edit().putString(key, value).commit(); } }
The usage of the wrapper is shown below
//Set a value: ConfigurationStore.USER.set("Teddy"); //get a value ConfigurationStore.USER.get()
It’s easy to extend with new properties just by adding to the enum:
public enum ConfigurationStore { USER(“user”), DEPLOYMENT_TYPE(“deployment_type”); .... //Set a value: ConfigurationStore.DEPLOYMENT_TYPE.set("Beta-test"); //get a value ConfigurationStore.DEPLOYMENT_TYPE.get()
Note that this is strictly using Strings. Ideas how to extend this to support other primitives in a type safe way are most welcome!
Set proxy if @work
I got tired of manually setting http_proxy & ftp_proxy on my job computer that I sometimes use at work (proxy needed) or at home (no proxy needed) so I came up with this dirty, but workable pice of bash script.
The ip x.x.x.x in the script below is the office IP (assigned by DHCP, but always resolved to static IP address based on my MAC)
#Set proxy if in office ip=$(/sbin/ifconfig eth0 | grep -e".*inet addr.*" | sed -e "s/.*inet addr://g" | sed -e"s/ .*//g") if [ $ip = "x.x.x.x" ] then http_proxy="http://office.proxy.com:80" ftp_proxy="http://office.proxy.com:80" export http_proxy export ftp_proxy fi
The above is part of a bigger script (myVariables.sh) that set other stuff as well, and this script is called from my bash profile (~/.bashrc) so every time I create a bash shell I get this set.
ISP connection monitoring
I have had some issues with my internet connection lately so I made some scripts to monitor it from my NAS.
First, let’s look at my network topology to understand what we want to test. I have my NAS attached via LAN to my modem with built in router, in other words we will only check LAN connectivity (not WLAN) to Internet.
The scripts I wrote will first see if router is reachable, and if it isn’t ping test is aborted (no point testing ISP connection if we can’t get to the modem). If router is reachable we will in parallel try to ping a set of hosts. Let’s look at the pinghost.sh script first:
#!/bin/sh host=$1 count=$2 SUCCESS=$(ping -c $count $host | tail -2 | head -1 | grep -c -e".* 0% packet loss.*") if [ "${SUCCESS}" -lt 1 ];then echo "${host} is dead at $(date)" fi
The script above will ping a host a number of times, and return an error string if there is packet loss. Example: pinghosts.sh google.com 1
will send one ping message to google.com. Now to the main script, pingtest.sh
#!/bin/sh COUNT=1 pinghostcommand="pinghost.sh" hosts="bbb-router 127.0.0.1 isp-gateway ping.sunet.se google.com ping.funet.fi" routerdead=$("${pinghostcommand}" bbb-router 1) if [ "X" = "X${routerdead}" ]; then for host in $hosts do $("${pinghostcommand}" $host $COUNT > "/tmp/$host") & done fi sleep 11 for host in $hosts do cat /tmp/$host | grep dead >> /samba-share/stats/pingStats.txt rm /tmp/$host done
With the above script set in crontab
# m h dom mon dow command
0,10,20,30,40,50 * * * * /samba-share/scripts/pingtest.sh
I can check the ping stats log file to see if my sampling indicates packet loss to what hosts and at what time.
cat /samba-share/stats/pingStats.txt | tail -n 10
google.com is dead at Wed Sep 19 21:30:07 CEST 2012
ping.funet.fi is dead at Wed Sep 19 21:30:07 CEST 2012
google.com is dead at Wed Sep 26 04:50:11 CEST 2012
google.com is dead at Wed Sep 26 05:10:12 CEST 2012
ping.sunet.se is dead at Sat Sep 29 08:00:12 CEST 2012
ping.funet.fi is dead at Sat Sep 29 08:00:12 CEST 2012
ping.sunet.se is dead at Sat Sep 29 19:20:12 CEST 2012
google.com is dead at Wed Oct 3 15:50:12 CEST 2012
ping.funet.fi is dead at Mon Oct 8 19:00:11 CEST 2012
ping.funet.fi is dead at Tue Oct 9 21:20:11 CEST 2012