Skip to content

Instantly share code, notes, and snippets.

View benlumley's full-sized avatar

Ben Lumley benlumley

View GitHub Profile
{"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/1082794631/133195601-48014b398077eb7104b38ef53ce54bec_4c46fd60-full_normal.jpg","created_at":"Fri, 30 Jul 2010 14:07:28 +0000","from_user":"levi_alpha","metadata":{"result_type":"recent"},"to_user_id":null,"text":"\u8ab0\u3044\u308b\u306e\u30fc\uff1f RT @K1_ICE: @Raven8492 \u306a\u3093\u3060\u3063\u305f\u3089\u3053\u3063\u3061\u304f\u308b\u30fc\uff1f\u606f\u629c\u304d\u306b\u306a\u308b\u304b\u3082\u3088\u30fc","id":19911951483,"from_user_id":81931583,"geo":null,"iso_language_code":"ja","source":"<a href="http://twitman.channel.or.jp/auth/" rel="nofollow">TWIT-MAN</a>"},{"profile_image_url":"http://a2.twimg.com/profile_images/1024228130/___normal.png","created_at":"Fri, 30 Jul 2010 14:06:32 +0000","from_user":"papapoto","metadata":{"result_type":"recent"},"to_user_id":116859875,"text":"@RAVEN_Alhazerd \u5de6\u3082\u30ed\u30de\u30f3\u6b66\u5668\u3068\u8a00\u3046\u624b\u3082\u3042\u308b\u3093\u3060\u304c\u30fb\u3
<IfModule mod_rewrite.c>
RewriteEngine On
# if it doesn't work, or you use a subfolder type path, you may need to edit/uncomment below
#RewriteBase /
# in short, this bit says "does this request map to a file or folder? if not, send it to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
http://t.co/@"onmouseover="$("a[href*='@']").remove();"class="modal-overlay"style="z-index:999999;font-size:99999px"/
// ==UserScript==
// @name hotpotato
// @namespace hotpotato
// @description hotpotato
// @include http://hotpotato.heroku.com/*
// ==/UserScript==
// Add jQuery
@benlumley
benlumley / gist:1270317
Created October 7, 2011 13:45
mysqldump over ssh
sudo ssh -p port -C u@h mysqldump -u mysqlu --password=mysqlp dbname | mysql -u mu dbname
@benlumley
benlumley / rename.sh
Created November 6, 2011 09:03
Shell script to help moving/renaming a symfony module - replaces in files and renames files
#!/bin/bash
#
# Aims to rename a symfony1 module, including renaming files and directories and replacing all usages within files
#
# Usage
#
# CD to module folder (ie: modules/old_module) and run. Then rename the module dir itself.
#
# If you are brave, may also work in modules folder and will then rename module dir too.
# But will replace in all modules - which may be a problem.
@benlumley
benlumley / imaginesf14.php
Created January 24, 2012 19:22
Imagine (or any namespaced library) in symfony 1.4
<?php
// in the top of config/projectconfiguration.php you should have
require_once dirname(__FILE__).'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
// Immediately beneath, add this:
require_once dirname(__FILE__).'/../lib/util/NsAutoload.class.php';
// then within ProjectConfiguration::setup() add:
@benlumley
benlumley / folderwatch.sh
Created January 25, 2012 17:30
Run a command, and then watch a folder and re-run whenever folder contents change - kind of poor mans inotify
#!/bin/sh
#
# Usage: ./folderwatch.sh /folder/to/watch cmdtorun
#
check() {
dir="$1"
cmd="$2";
chsum1=`find $dir -type f -exec md5sum {} + | md5sum | awk '{print $1}'`
@benlumley
benlumley / retrieveemail.sh
Created March 4, 2012 08:37
Retrieve an email from postfix queue
# first, find the email using mailq or postqueue -p
#
# Then, get the message id - its the random data string in left hand column of first line for each email.
#
# then, run:
#
postcat -q MESSAGEID | sed -n '/MESSAGE CONTENTS/,$p' | grep -v "MESSAGE CONTENTS" | sendmail you@domain.com
@benlumley
benlumley / BundlesUrlWorker.php
Created May 5, 2012 09:57
Assetic worker to write asset urls back to the standard sf /bundles urls when in debug mode in order to speed things up
<?php
namespace You\YourBundle\Assetic\Worker;
use Assetic\Asset\AssetInterface;
use Assetic\Factory\Worker\WorkerInterface;
/**
* Maps assetic urls back to the standard sf /bundle urls when debug / dev mode is on, as finding it's too damned slow to run through the controller, and 'assetic:dump --watch' takes too long to notice changes.
* It will likely mean certain assetic stuff doesn't work/has issues though - if you use bits of assetic that I'm not using (I use it to combine and minify css and js primarily)