This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createDeck() { | |
var suits = ['c','s','h','d'] | |
var values = ['A','2','3','4','5','6','7','8','9','10','j','q','k'] | |
var deck = [] | |
for(s in suits) { | |
for(v in values) { | |
deck.push(values[v] + suits[s]) | |
} | |
} | |
deck.push('j1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
## | |
## This scipt was inspired by http://serverfault.com/questions/65365/disable-local-delivery-in-sendmail/128450#128450 | |
## It stops webservers sending mail that is addressed to the local hostname to localhost and instead looks remotely for a mail server | |
## | |
## | |
# Install sendmail-cf as this is required to customise the config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ( $ ) { | |
$.fn.slugger = function(options) { | |
var that = this; | |
var settings = $.extend({ | |
target: null, | |
}, options ); | |
if(settings.target) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo $this->Paginator->numbers(array( | |
'before'=>'<ul class="pagination">', | |
'after'=>'</ul>', | |
'tag'=>'li', | |
'separator'=>false, | |
'currentClass'=>'active', | |
'currentTag'=>'a' | |
));?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install cdparanoia e.g apt-get install cdparanoia | |
# rip tracks individually | |
cdparanoia -B | |
# convert to mp3 in a loop | |
for t in track{01..18}*.wav; do lame $t; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app.js for simple express mvc | |
var express = require('express'); | |
var http = require('http'); | |
var path = require('path'); | |
var app = express(); | |
var fs = require('fs'); | |
var mongoose = require('mongoose'); | |
mongoose.connect('mongodb://locahost/dbname'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load aws sdk | |
var aws = require('aws-sdk'); | |
// load aws config | |
aws.config.loadFromPath('config.json'); | |
// load AWS SES | |
var ses = new aws.SES({apiVersion: '2010-12-01'}); | |
// send to list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose') | |
,Schema = mongoose.Schema | |
,ObjectId = Schema.ObjectId; | |
var userSchema = new Schema({ | |
email: String, | |
password: String, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'), | |
Schema = mongoose.Schema | |
var bcrypt = require('bcrypt') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* $str to search | |
* $query word to search for | |
* $words either side of first match to return | |
*/ | |
function highlightedExtract($str, $query, $words) { | |
$pos = stripos($str,$query); | |
$after = substr($str,$pos,$words); | |
$prior = explode($after,$str); |