Skip to content

Instantly share code, notes, and snippets.

View colinodell's full-sized avatar

Colin O'Dell colinodell

View GitHub Profile
function type(obj) {
var obj_type = typeof obj;
return({ is : function(type) { return obj_type === type; },
is_object : function() { return obj_type === "object"; },
is_func : function() { return obj_type === "function"; },
is_string : function() { return obj_type === "string"; }});
};
function maybe(item) {
@jrf0110
jrf0110 / class.js
Created April 23, 2012 22:05
Simple extendable classes in javascript
/* This WAS a two-line function until an awesome reddit user pointed out my logical flaw. Now It's a 5-line function :( */
var Class = function(d){
d.constructor.extend = function(def){
for (var k in d) if (!def.hasOwnProperty(k)) def[k] = d[k];
return Class(def);
};
return (d.constructor.prototype = d).constructor;
};
@neilalbrock
neilalbrock / splitmysqldump.pl
Created April 1, 2012 19:39
Split MySQL dump into a file per database
#!/usr/bin/perl -w
#
# splitmysqldump - split mysqldump file into per-database dump files.
use strict;
use warnings;
my $dbfile;
my $dbname = q{};
my $header = q{};
while (<>) {
@davidalexander
davidalexander / gist:1086455
Last active September 7, 2023 07:42
Magento Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@wowo
wowo / config_test.yml
Created June 14, 2011 21:28
Doctrine sqlite in memory for tests purposes
doctrine:
dbal:
driver: pdo_sqlite
path: :memory:
memory: true
orm:
auto_generate_proxy_classes: true
auto_mapping: true
@czarneckid
czarneckid / gist:762065
Created January 1, 2011 22:45
Creating high score leaderboards with Redis
NOTE: You will need at least Redis 2.1.6 to use the ZREVRANGEBYSCORE method.
Add players to HIGHSCORES table:
fossil:~ dczarnecki$ redis-cli
redis> zadd HIGHSCORES 1 player_1
(integer) 1
redis> zadd HIGHSCORES 2 player_2
(integer) 1
redis> zadd HIGHSCORES 3 player_3