Skip to content

Instantly share code, notes, and snippets.

View paularmstrong's full-sized avatar
🐈‍⬛
Codes with cats

Paul Armstrong paularmstrong

🐈‍⬛
Codes with cats
View GitHub Profile
@paularmstrong
paularmstrong / Preloader.js
Created May 13, 2009 16:31
Preloader class for jQuery
$.extend(Function.prototype, {
use: function() {
var method = this, args = Array.prototype.slice.call(arguments), object = args.shift();
return function() {
return method.apply(object, args.concat(Array.prototype.slice.call(arguments)));
}
},
useEL: function() {
var method = this, args = Array.prototype.slice.call(arguments), object = args.shift();
return function(event) {
function password_strength(password, username) {
var p = password
, u = username
;
if(
/^[a-z]*$/.test(p)
|| /^[A-Z]*$/.test(p)
|| /^[0-9]*$/.test(p)
) {
@paularmstrong
paularmstrong / Timezone.js
Created July 24, 2010 15:31
JavaScript GMT offsets by TZ code
TZ = {
getTimezoneOffset: function(timezone)
{
var dst = (TZ.isDSTObserved()) ? 'dst' : 'std';
return TZ.zones[timezone][dst];
},
isDSTObserved: function()
{
// 2nd sunday of march
#!/bin/bash
DIR=$1
ACTION='backup'
if [ $# -eq 2 ]; then
ACTION=$2
fi
if [ $ACTION = 'delete' ]; then
rsync -rv --delete --size-only backup@files::$DIR/ /mnt/group1/media/$DIR/
else
@paularmstrong
paularmstrong / runtests.js
Created September 19, 2010 17:14
simple nodejs script to work with nodeunit to find all *.test.js files and execute them
#!/usr/bin/env node
/*
Run nodeunit tests
Simple node.js script to find all *.test.js files and execute them through nodeunit.
Without arguments, will search recursively through the current directory for tests.
Supply arguments of directories or specific tests to run.
Sample Usage:
$ ./runtests.js
@paularmstrong
paularmstrong / pre-commit
Created November 25, 2010 20:43
Pre-Commit Hook for Git to add the SHA to a file in your working directory.
#!/usr/bin/env node
var child_process = require('child_process'),
fs = require('fs'),
root = __dirname + '/../../',
configFile = root + 'config/config.js',
jslint = require(root + 'lib/jslint/jslint.js');
function setPushVersion() {
child_process.exec('git rev-parse HEAD', { cwd: root }, function (error, stdout, stderr) {
@paularmstrong
paularmstrong / installClang.sh
Created March 11, 2011 18:09
Installs Clang Static Analyzer
#!/bin/bash
installonly=no
while [ $# -gt 0 ]
do
case "$1" in
(-i) installonly=yes;;
(-*) echo "$0: error - urecognized option $1" 1>&2; exit 1;;
(*) break;;
// What does this return?
(function() {
function f() { return 1; }
return f();
function f() { return 2; }
})();
// What is x?
var y = 1, x = y = typeof x;
@paularmstrong
paularmstrong / a_star.js
Created May 12, 2011 21:22 — forked from jminor/a_star.js
A* path finding algorithm for impactjs game engine
// A* path finding algorithm for impactjs game engine
// adapted from http://stormhorse.com/a_star.js
// via http://46dogs.blogspot.com/2009/10/star-pathroute-finding-javascript-code.html
// impact-ified by jminor - http://pixelverse.org/
/* Example:
this.pathFinder = new PathFinder();
var start = [((this.pos.x+this.size.x/2) / tilesize).floor(), ((this.pos.y+this.size.y/2) / tilesize).floor()];
var destination = [((target.pos.x+target.size.x/2) / tilesize).floor(), ((target.pos.y+target.size.y/2) / tilesize).floor()];
@paularmstrong
paularmstrong / a_star.js
Created May 27, 2011 02:33 — forked from jminor/a_star.js
A* path finding algorithm for impactjs game engine
/**
* AStar
*
* Created by Paul Armstrong on 2011-05-26.
* Copyright (c) 2011 Paul Armstrong Designs. All rights reserved.
*
* Based on: https://gist.github.com/827899
*/
ig.module('plugins.a-star')