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, the model

If someone had asked me some time ago about bicycle frame geometry I would have answer simply in terms of 19”, 20” for MTB or 56, 58 for a road bike. I was of course aware of basic measurements such as Top Tube length or Standover Height and have passed a few times my measurements through a fit calculator but I haven’t given much thought from a geometric, or trigonometric to be more precise, point of view....

November 18, 2012 · 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

JBoss migration – Quartz

This is a continuation of the previous article regarding some migration points (1, 2) from JBoss 4.2.2-GA to JBoss 7.1.1 and, presumably, Tomcat 7. 3. Quartz Quartz migration has been the simplest of all, by far. 3.1 JBoss 4.2.2 In JBoss 4.2.2 Quartz was configured using a MBean with a simple configuration: <pre lang="xml"> <?xml version="1.0" encoding="UTF-8"??> <server> <mbean code="org.quartz.ee.jmx.jboss.QuartzService" name="user:service=QuartzService,name=QuartzService"> <depends>jboss.jca:service=DataSourceBinding,name=XOracleDS</depends> <depends>jboss.web.deployment:war=/X</depends> <attribute name="Properties"> org.quartz.scheduler.instanceName = DefaultQuartzScheduler org.quartz.scheduler.rmi.export = false org....

July 20, 2012 · len

JBoss migration – the HAR archive

This is a continuation of the previous article regarding some migration points from JBoss 4.2.2-GA to JBoss 7.1.1 and, presumably, Tomcat 7. 2. The HAR archive The HAR archive was a nice mechanism which allowed hibernate integration. A ${name}.har file was created, containing all the mappings (*.hbm.xml) and data classes (*.class), allong with a hibernate-service.xml (later renamed to service-hibernate.xml in JBoss 5). This took care of creating the SessionFactory and making it accessible through JNDI....

July 20, 2012 · len