December 20, 2011

rEFIt - Booting Linux with Bootcamp

rEFIt - An EFI Boot Menu and Toolkit

 

Posted by Paul Hollands pj at 01:10 PM | Comments (0)

December 07, 2011

Cast the results of a subquery as an array then join as a string

select p.*, 
array_to_string(array(select first_name||' '||last_name from publications.authors a where a.publication_id = p.id), ',') as aus ,
array_to_string(array(select first_name||' '||last_name from publications.editors e where e.publication_id = p.id), ',') as eds
from publications.publication_as_ris3 p
where p.av in ('Forthcoming','Published') and p.id in ((select publication_id from publications.authors where first_name = 'Tony' and last_name = 'Kinder')union(select publication_id from publications.editors where first_name = 'Tony' and last_name = 'Kinder'))

Tags: PostgreSQL

Posted by Paul Hollands pj at 12:31 PM | Comments (0)

November 26, 2011

Server replication in Postgres 9.1

Postgres slave server in five minutes

Files: Postgres_9.1_replication_standby_files.tar.gz

Binary Replication in 6 Steps

This 6-step guide, and all of the examples in this tutorial, assume that you have a master server at 192.168.0.1 and a standby server at 192.168.0.2 and that your database and its configuration files are installed at /var/lib/postgresql/data. Replace those with whatever your actual server addresses and directories are.

1. Edit postgresql.conf on the master to turn on streaming replication. Change these settings:

 listen_address = '*'
 wal_level = hot_standby
 max_wal_senders = 3

2. Edit pg_hba.conf on the master in order to let the standby connect.

 host  replication   all   192.168.0.2/32      trust

3. Edit recovery.conf and postgresql.conf on the standby to start up replication and hot standby. First, in postgresql.conf, change this line:

 hot_standby = on

Then create a file in the standby's data directory (which is often the same directory as postgresql.conf and pg_hba.conf, except on some Linux distributions such as Debian and Ubuntu), called recovery.conf, with the following lines:

 standby_mode = 'on'
 primary_conninfo = 'host=192.168.0.1'

4. Shutdown the master and copy the files. You want to copy most but not all files between the two servers, excluding the configuration files and the pg_xlog directory.

tar cvzhf /Users/paulhollands/Desktop/data.tgz --exclude 'pg_xlog' --exclude 'postgresql.conf' data/

5. Start the standby first, so that they can't get out of sync.

6. Start the master.

Tags: PostgreSQL

Posted by Paul Hollands pj at 12:10 PM | Comments (0)

November 25, 2011

Jython and Django Trial

# cd /Users/paulhollands/jython2.5.2/bin
# django-admin.py startproject dss
# jython manage.py runserver
Validating models...

0 errors found
Django version 1.3.1, using settings 'dss.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[25/Nov/2011 23:00:47] "GET / HTTP/1.1" 200 2045

Tags: Jython

Posted by Paul Hollands pj at 11:02 PM | Comments (0)

November 23, 2011

Is Solaris running in 64bit mode?

isainfo -v

 

Posted by Paul Hollands pj at 02:20 PM | Comments (0)

November 05, 2011

Spine JS Framework

Spine

Tags: JavaScript

Posted by Paul Hollands pj at 05:40 PM | Comments (0)

November 01, 2011

Cast a date to Unix timestamp in Postgres

'2012-04-01'::timestamp::abstime::int4

Tags: PostgreSQL

Posted by Paul Hollands pj at 11:31 AM | Comments (0)

October 30, 2011

Detect an iPad and provide a non-Flash alternative

try{ ["iPad","iPod","iPhone"].each(

  function(i){

    if(navigator.userAgent.indexOf(i) > -1){

      //Do iPad stuff here

      }

   }); } catch(e){ var meh = 'meh'; }

Tags: JavaScript , jQuery

Posted by Paul Hollands pj at 08:40 PM | Comments (0)

October 28, 2011

Jython and Django

Chapter 14: Web Applications With Django — Jython Book v1.0 documentation

Tags: Jython

Posted by Paul Hollands pj at 10:00 PM | Comments (0)

Groooooooooovy

Groovy - Home

 

Posted by Paul Hollands pj at 09:41 PM | Comments (0)

October 26, 2011

Matrix Asset Map for iOS

Zed Said Studio - Squiz Matrix Asset Map for iOS

 

Posted by Paul Hollands pj at 09:55 PM | Comments (0)

October 21, 2011

Textastic for iPad

Textastic Code Editor for iPad on the iTunes App Store

 

Posted by Paul Hollands pj at 10:40 PM | Comments (0)

October 19, 2011

Alternately colour the rows in a table with jQuery

var color = '#efefef';

var counter = 0;

function switch_bg(counter){ 

    if(eval(counter/2) == eval(counter/2).toFixed(0)){ return color; } 

    else { return 'white'; } 

    }

jQuery('tbody tr').each(

	function(){ 
	
		counter++;  
		
		jQuery(this).find('td').each(
		
			function(){ 
			
				jQuery(this).css({ 'background-color' : switch_bg(counter) }); 
				
				}
			
			);
			
		}
			 
	);

Tags: jQuery

Posted by Paul Hollands pj at 06:42 PM

October 11, 2011

Student class needs to be adjusted

	function get_hash_by_uun($uun){
		
		return $this->get_hash_by_id($this->get_id_by_uun($uun)); 
		
		}

	function get_id_by_uun($uun){

		$m = (int) str_replace('s', '', $uun);
		
		$reply = just::sql(sprintf("select student_id from student_full where matriculation_number = %d", $m));
		
		return $reply['first_row']['student_id'];		

		}
		
	function get_uun_by_id($id){
	
		$reply = just::sql(
			sprintf("select case
			when char_length(matriculation_number::varchar) = 5 then 's00'||matriculation_number
			when char_length(matriculation_number::varchar) = 6 then 's0'||matriculation_number
			else 's'||matriculation_number end as uun from student_full where student_id = %d", (int) $id)
			);
	
		return $reply['first_row']['uun'];
	
		}

Tags: PHP

Posted by Paul Hollands pj at 06:42 PM | Comments (0)

October 10, 2011

Kill runaway Postgres threads

kill `ps -ef | grep [p]ostgres | awk '{print $2}'`

Tags: PostgreSQL

Posted by Paul Hollands pj at 05:05 PM | Comments (0)

September 28, 2011

Symfony Framework

Symfony - Home

Tags: PHP

Posted by Paul Hollands pj at 11:27 PM | Comments (0)

Casting Unix timestamps to PostgreSQL timestamps

select *, to_timestamp(insert_date) as inserted from test where 1 limit 1;

Data Type Formatting Functions

Tags: PostgreSQL

Posted by Paul Hollands pj at 12:55 PM | Comments (0)

September 17, 2011

I love Python

import glob, os, re, string

def rename(dir, pattern):

    for path_filename in glob.glob(os.path.join(dir, pattern)):

        title, ext = os.path.splitext(os.path.basename(path_filename))

	new_title = '''%s''' %(re.sub(r'[\W]+','-',title))

	print new_title.lower()

        os.rename(path_filename, os.path.join(dir, new_title.lower() + ext))

rename(r'/home/phollan2/crc_papers_2011',r'*.pdf')

Tags: Python

Posted by Paul Hollands pj at 01:28 PM | Comments (0)

September 03, 2011

Cosign with Django

Django | Authentication using REMOTE_USER | Django documentation

Tags: Python

Posted by Paul Hollands pj at 06:53 PM | Comments (0)

July 25, 2011

Link bare URLs in a HTML element

function link_em(da_id){

    try{ var tml = document.getElementById(da_id).innerHTML; } catch(e){ return false; }

    var reg = /[^href\=\"](http|https):\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?\/?/gm;

    var list = [];

    list = tml.match(reg);

    var count = 0;

    for(i in list){

       if(list[i]){ if(list[i] != document.getElementById(da_id).innerHTML){ if( parseInt(list[i]) + '' != list[i]){

          count++;

          tml = tml.replace(list[i].replace(/\(/,''), '<a href="' + list[i].replace(/\(/,'') + '">' + list[i].replace(/\(/,'') + '</a>');

          }}}

       }

try{ if(list[0]){    

       document.getElementById(da_id).innerHTML = tml;

       } } catch(e){ var blah = ''; }

    }


Tags: JavaScript

Posted by Paul Hollands pj at 04:38 PM | Comments (0)

July 12, 2011

Online IDE for Node.js

Interwebs IDE hits the mother Node • The Register

Tags: JavaScript

Posted by Paul Hollands pj at 06:20 PM | Comments (0)