Old laptop, broken charger, limited frequency

I have an old laptop with a broken charger. The laptop works on the charger but it does not charges the battery. This should not be a problem since the battery is broken also. However I’ve noticed the laptop is very slow. After further investigation I noticed that the cpu maxfreq is always equal the the low frequency no matter the governor: cat cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq I installed cpufreq and tried setting the governor to performance, no luck....

January 2, 2014 · len

Let’s decrypt

AES encrypt in java and decrypt in java, flex, python, C#. Encrypt: java <pre lang="java">public static void encrypt(InputStream is, OutputStream out, String secret) throws Exception { SecretKey secretKey = new SecretKeySpec(Hex.decodeHex(secret.toCharArray()), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); out.write(cipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV()); CipherOutputStream cipherOutputStream = new CipherOutputStream(out, cipher); int bufLength = KEY_LENGTH/8 * 100; byte buf[] = new byte[bufLength]; int bytesRead = 0; while((bytesRead = is.read(buf)) != -1 ) { cipherOutputStream.write(buf, 0, bytesRead); } cipherOutputStream....

December 20, 2013 · len

A few notes about external hdd encryption

When storing your backups on an external drive you occasionally take with you it is a very good idea to encrypt your backups. Here are some personal conclusions after trying 2 different solutions. eCryptFs Advantages (reasons to choose): stacked – can be used on top of another filesystem, even on top of NTFS allocated on the fly – no need to pre-allocate your space, it will be allocated on the fly....

December 7, 2013 · len

Trunc dates in postgresql to 10s

Ever needed to check if a date matches another within a certain range? If you need to trim to hours, minutes or seconds the date_trunc function in postgres does the job just fine. How about if you need to trunc to 10s? The following function should be of assistance: <pre lang="sql">create function date_trunc_x(timestamp with time zone, numeric) returns text AS $$ select substring(extract('hour' from $1)||':'||extract('minute' from $1)||':'||(extract('second' from $1)::int/$2) from 0 for 8) $$ LANGUAGE SQL; In can be used as in the following example:...

October 21, 2013 · len

Archive all files modified in the last 24h

find . -mtime 1 -type f -print0 | tar -czvf $SYNC_DIR/$BFILE -T - --null

October 1, 2013 · len

Checking badblocks in soft raid setup

Use case 2 hdd in raid 1 using md, smartd signals: Device: /dev/sda [SAT], 8 Currently unreadable (pending) sectors Actions 1. Run smartctl on each disk, wait and check the results smartctl -t long /dev/sda smartctl -t long /dev/sdb #wait a looong time smartctl -l selftest /dev/sda smartctl -l selftest /dev/sdb sdb is ok but sda confirms the smartd error: # 2 Extended offline Completed: read failure 60% 4832 2519297024 2....

January 22, 2013 · len

Checking badblocks with smartmontools

… and some other observations. Warning: use at your own risk! I used to keep some of my photo backups on an external Seagate 500G drive which I also use for travel. Today however as I tried to access it I noticed some problems so I quickly ran: smartctl -t long /dev/sdb #followed by smartctl -l selftest #the result Extended offline Completed: <strong>read failure</strong> 90% 109 <strong>414996448</strong> I started using this useful guide to correct the problems by repeatedly running smartctl, calculating the offset, finding the file with debugfs, forcing reallocation with dd and so on....

January 2, 2013 · len

Frame sketcher, introduction

I am searching for a new bicycle. Partly as a gift to one self, partly to make sure if the current one fails I will not be under pressure to buy one fast. As such I have done a lot of research into the subject. One of the elements I have found is that I could achieve a better price/quality ration buying online especially from German based online shops. This poses a big problem on testing since frame geometry differs a lot from manufacturer to manufacturer....

November 13, 2012 · len

Pride

Sometimes I look on what I have done and feel very good. This is an example :)) : <pre lang="bash"> IFS=$(echo -en "\n\b") && c=60 && for i in $(ls -1v);do let c=$c+1; name=$(echo $i | cut -c3-80); nname=$c$name; echo mv \"$i\" \"$nname\" >> mv.sh; done && chmod a+x mv.sh

October 18, 2012 · len

A bit of L2TP debuging

The problem was to connect to a L2TP server from linux, no windows available. The required packages: <pre lang="bash">apt-get install l2tp-ipsec-vpn reboot Done the needed configuration but the connection was not established. The gui said error 500. The log said much but apparently not enough. Here is what could be considered as an error: Oct 3 18:55:36 purple xl2tpd[4162]: setsockopt recvref[30]: Protocol not available Oct 3 18:55:36 purple xl2tpd[4162]: This binary does not support kernel L2TP....

October 3, 2012 · len