Skip to content

Instantly share code, notes, and snippets.

commit 06c98bcc273915737b4e0751fa4be1a32727087b
Author: James Cartledge <jcartledge@gmail.com>
Date: Mon May 12 11:36:26 2014 +1000
tweak study area import script:
1. correctly associate topics, study areas and related study areas
2. correctly associate study areas with courses
diff --git a/src/drupal/sites/all/modules/custom/vu_courses/modules/vu_course_study_areas/vu_course_study_areas.install b/src/drupal/sites/all/modules/custom/vu_courses/modules/vu_course_study_areas/vu_course_study_areas.install

Some notes about ruby syntax

Optional parens

When calling a function or method, parens are optional, so:

puts msg

Automatically selecting a facet the user didn't click is not really possible in the current technical design, but more importantly has UX/IxD implications we need to work out - e.g.

  • When the user selects a facet the page URL updates so you can link to a filtered list - how does this affect that? Do they get the URL with or without the automatically selected option?
  • What happens if the user follows a link to the page that's filtered by ATAR range? Do we redirect to one that's filtered by atar and no atar or respect the original url?
  • What if the user a) selects a range (+ the auto item they did not select), deselects the auto item, deselects the range, then selects the range again? Does this only happen the first time, or all subsequent times?
  • What if in the above scenario the user selects a different range at the last step? Do we add the auto item then or only the first time?
  • What if the user selects multiple ATAR ranges? Does the automatically selected item stay selected until they deselect i
@jcartledge
jcartledge / a2serve
Created February 6, 2011 03:45
UBUNTU: Quickly set up a named vhost to serve the directory you are in
#!/bin/bash
sudo sh -c "echo \"127.0.0.1 $1\" >> /etc/hosts"
DIR=`pwd`
sudo sh -c "echo \"<VirtualHost *:80>
ServerName $1
DocumentRoot $DIR
</VirtualHost>\" > /etc/apache2/sites-available/$1"
sudo a2ensite $1
sudo /etc/init.d/apache2 restart
@jcartledge
jcartledge / csv2sqlite.php
Created June 30, 2011 00:52
CSV -> SQLite
<?php
$db = new PDO('sqlite:./my.sqlite');
$csv = fopen('my.csv', 'r');
$columns = strtolower(
str_replace(' ', '_',
preg_replace('/\r?\n$/', '',
fgets($csv)
)));
@jcartledge
jcartledge / gist:1326870
Created October 31, 2011 03:49
Markov watch spam
Clique saw.
Submitted by encuroalbubre on 28 April 2011 - 8:27am.
And me sat time. From no portland the unscenic replica of that trailblazers with broken uniform watched. I whom? One replica sword over thousand away - and - up zelda. The - i smoothly was - cartier on his roadster? I paused asked. There gave marc all because the jacobs. Replica feels slowly. Watches the it well they're. Its divers stood two toward empty watches. exact copies of timepiecesIt has,' nodded watches. Them was the frederique watches of a doodlebug's thirty what's straight. They cannot alone eerie - replica, handbags - fendi, but his up - leather glancing is survived i of possible chins. You was his omega for your watches and i heard at pre-owned interrogative eyes. They, tommy hilfigher. The frank muller looking after the sniffing watches had of the cigarette rest were descending. Pig said. At his mortars understanding out that ballast, mrs was these bedrooms in every flamethrower to the sleeveless, tearfully choked of - replica des
SELECT
node.`type`,
node.`sticky` AS `pinned`,
node.`promote` AND NOT ISNULL(`field_homepage_image_data`) AS `front_page`,
node_revisions.`title`,
node_revisions.`teaser`,
content_field_homepage_image.`field_homepage_image_data` AS `homepage_image`,
content_field_level_1_image.`field_level_1_image_data` AS `level_1_image`,
content_field_small_image.`field_small_image_data` AS `small_image`,
CONCAT('/', url_alias.`dst`) AS `url`,
function querystring(str) {
var qs = {};
str.match(/^[\?]?(.*)$/)[1].split('&').map(function(pair) {
pair = pair.split('=');
qs[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
});
return qs;
}
@jcartledge
jcartledge / quine.php
Created May 15, 2012 04:11
PHP Quine
<?php $a = '<?php $a = \'!\';
echo preg_replace(\'/!/\', addslashes($a), $a, 1);';
echo preg_replace('/!/', addslashes($a), $a, 1);