Michael Svanström

developer, photographer


Moving old files in Linux

Archiving might become a necessity when storing a lot of files on a server. This is a snippet which moves files older than a year to another directory. Note the -print0 and -0 (zero) which add null characters for escaping spaces and backslashes. find myfiles/ -mtime +365 -print0 |xargs -0 -I {} mv {} myfiles_old/

Salesforce and saving to server

Receiving the following error when Force.com IDE is started? com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor Try switching workspace - to the very same workspace! File -> Switch Workspace -> Other.. Select the same workspace, OK and voilá! Source

MVC 3 json post array workaround

Ajax-posting a JSON object containing arrays using jQuery work fine in PHP, but since ASP.NET expects the array to be posted with indeces a tiny workaround is required. Concider the following example. var jsonData = {'foo': 0, bar: [1,2]}; $.post('/post-url',postData, function(){ }); This will cause the post data to look like foo=0 bar[]=1 bar[]=2 PHP acceps this, but ASP.NET requires the post data to be foo=0 bar[0]=1 bar[1]=2 Here’s a workaround.

Using swftools to extract resources from flash swf files

There’s a nifty tool called Swftools out there which enables you to extract resource files out of an swf file (Adobe Flash). This little bash one-liner will extract all sounds from an swf file: for i inswfextract soundboard.swf |grep Sounds:|cut -c 24-|sed ’s/,//g’; do swfextract -s $i soundboard.swf

Your old backup is about to become unreadable

After spending a few hours in the past weekend, copying old photographs and various other files from CD’s and DVDs in the archive, I have sadly learned that discs do have a limited durability. Out of 24 CD-R’s my computer was unable to read 6 of them. For the record, the CD-R’s were burned in the years 2000 and 2001 and are of various brands. If you have precious data on CD’s or DVDs, my advice to you is to back it up on other media - now.

Group_concat in T-SQL

You may wish group_concat while working with MS SQL Server. Here’s a solution! Say you have these tables: a: id, content b: id, val rel_a_b: a_id, b_id The SQL query [default]select a.*, stuff( ( select cast(‘;’ as varchar(max)) + b.val from b inner join rel_a_b on b.id = rel_a_b.b_id and rel_a_b.a_id = a.id for xml path(“) ),1,1,”) as vals_combined from a[/default]

dvbloopback in Linux 2.6.38

Compiling and using sasc-ng and dvbloopback with Linux 2.6.38 is a hassle. Here’s how to get it working. Prequisites: Ubuntu Lucid Kernel 2.6.38-11-generic We need to patch both the kernel dvb module as well as the dvbloopback source. Download linux-2.6.38-dvb-mutex.patch to your home folder. $ sudo apt-get install linux-headers-uname -r Now let’s get the kernel source, patch it, and recompile the dvb-core module. $ cd /usr/src $ sudo apt-get source kernel-image-uname -r $ cd linux-2.