Skip to content

Instantly share code, notes, and snippets.

$this->colorcache = new cache('favoritecolors', 'memcached', 'file');
if ( !isset($this->colorcache->tristan) ) {
$this->colorcache->tristan = 'blue';
}
echo $this->colorcache->tristan;
$upload = $this->input->files->avatar;
if ($upload && $upload->ext == 'png' && $upload->width <= 100 && $upload->height <= 100) {
$upload->move(DIR_PUBLIC.'avatars/');
}
@summer4096
summer4096 / wikipedia.sh
Created June 6, 2012 21:21
This snippet will download the May 2012 wikipedia dump, extract it, convert it to sql, and feed it to mysql, all at the same time.
curl http://dumps.wikimedia.org/enwiki/20120502/enwiki-20120502-pages-articles-multistream.xml.bz2 | bzcat | ./import.pl | mysql -f -uuser -ppass --default-character-set=utf8 wikipedia
@summer4096
summer4096 / parser.js
Created July 8, 2012 23:19
dAmn packet parser
function(rpkt, depth){
try {
rpkt = rpkt.toString();
depth = depth || 0;
var i;
var ppkt = {
cmd: null,
param: null,
args: {},
body: null,
&b\t \x1b[1m
&/b\t \x1b[22m
&i\t \x1b[3m
&/i\t \x1b[23m
&u\t \x1b[4m
&/u\t \x1b[24m
&s\t \x1b[9m
&/s\t \x1b[29m
g++ `pkg-config --cflags --libs gtkmm-3.0` -o ./thing ./thing.cpp
Sending: ["multiply",4,7,{"__type":"callback","id":"dHx9"}]
Recieved: ["callback","dHx9",[28]]
@summer4096
summer4096 / runner.js
Created October 17, 2012 06:10
Runner for streaming templates
var events = require('events');
var stream = require('stream');
var util = require('util');
var runner = function(template, output) {
stream.call(this);
this.readable = true;
this.writable = true;
var ws = require('websocket.io');
var net = require('net');
var server = ws.listen(3456);
server.on('connection', function(socket){
var google = net.connect({
host: 'google.com',
port: 80
});
// ==UserScript==
// @name dAmn.ws
// @namespace botdom.com
// @description Make the official client use WebSockets
// @author Henry Rapley <photofroggy@gmail.com>
// @version 1.0.3
// @include http://chat.deviantart.com/chat/*
// @include http://chat.deviantart.lan/chat/*
// ==/UserScript==