Skip to content

Instantly share code, notes, and snippets.

@jcartledge
jcartledge / a2serve
Created February 6, 2011 03:45
UBUNTU: Quickly set up a named vhost to serve the directory you are in
#!/bin/bash
sudo sh -c "echo \"127.0.0.1 $1\" >> /etc/hosts"
DIR=`pwd`
sudo sh -c "echo \"<VirtualHost *:80>
ServerName $1
DocumentRoot $DIR
</VirtualHost>\" > /etc/apache2/sites-available/$1"
sudo a2ensite $1
sudo /etc/init.d/apache2 restart
@jcartledge
jcartledge / ~_.config_terminator_config
Created April 27, 2011 04:31
terminator config solarized
[global_config]
title_transmit_bg_color = "#839496"
title_inactive_fg_color = "#93a1a1"
title_transmit_fg_color = "#eee8d5"
title_inactive_bg_color = "#586e75"
[keybindings]
[profiles]
[[default]]
palette = "#073642:#d30102:#859900:#b58900:#6c71c4:#d33682:#2aa198:#839496:#586e75:#cb4b16:#859900:#b58900:#268bd2:#d33682:#2aa198:#93a1a1"
login_shell = True
@jcartledge
jcartledge / FUJI-XEROX-ApeosPort-IV-C3370.sh
Created May 9, 2011 04:23
What I did to get our new office MFD installed in Ubuntu
#!/bin/bash
# n.b. I haven't tested this version - see comments at https://gist.github.com/gists/962048
# download the driver rpm
wget http://download.fujixerox.co.jp/pub/exe/apeosport/c4300series/fxlinuxprint-1.0.3-2.i386.rpm
# alien will convert the rpm to a deb we can install
sudo aptitude install alien
sudo alien --scripts -k fxlinuxprint-1.0.3-2.i386.rpm
@jcartledge
jcartledge / csv2sqlite.php
Created June 30, 2011 00:52
CSV -> SQLite
<?php
$db = new PDO('sqlite:./my.sqlite');
$csv = fopen('my.csv', 'r');
$columns = strtolower(
str_replace(' ', '_',
preg_replace('/\r?\n$/', '',
fgets($csv)
)));
@jcartledge
jcartledge / gist:1326870
Created October 31, 2011 03:49
Markov watch spam
Clique saw.
Submitted by encuroalbubre on 28 April 2011 - 8:27am.
And me sat time. From no portland the unscenic replica of that trailblazers with broken uniform watched. I whom? One replica sword over thousand away - and - up zelda. The - i smoothly was - cartier on his roadster? I paused asked. There gave marc all because the jacobs. Replica feels slowly. Watches the it well they're. Its divers stood two toward empty watches. exact copies of timepiecesIt has,' nodded watches. Them was the frederique watches of a doodlebug's thirty what's straight. They cannot alone eerie - replica, handbags - fendi, but his up - leather glancing is survived i of possible chins. You was his omega for your watches and i heard at pre-owned interrogative eyes. They, tommy hilfigher. The frank muller looking after the sniffing watches had of the cigarette rest were descending. Pig said. At his mortars understanding out that ballast, mrs was these bedrooms in every flamethrower to the sleeveless, tearfully choked of - replica des
SELECT
node.`type`,
node.`sticky` AS `pinned`,
node.`promote` AND NOT ISNULL(`field_homepage_image_data`) AS `front_page`,
node_revisions.`title`,
node_revisions.`teaser`,
content_field_homepage_image.`field_homepage_image_data` AS `homepage_image`,
content_field_level_1_image.`field_level_1_image_data` AS `level_1_image`,
content_field_small_image.`field_small_image_data` AS `small_image`,
CONCAT('/', url_alias.`dst`) AS `url`,
function querystring(str) {
var qs = {};
str.match(/^[\?]?(.*)$/)[1].split('&').map(function(pair) {
pair = pair.split('=');
qs[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
});
return qs;
}
@jcartledge
jcartledge / quine.php
Created May 15, 2012 04:11
PHP Quine
<?php $a = '<?php $a = \'!\';
echo preg_replace(\'/!/\', addslashes($a), $a, 1);';
echo preg_replace('/!/', addslashes($a), $a, 1);
@jcartledge
jcartledge / bee.rb
Created August 22, 2012 10:05
Homebrew formula for bee
require 'formula'
class Bee < Formula
homepage 'https://github.com/jcartledge/bee/'
url 'https://github.com/jcartledge/bee/tarball/master'
sha1 '7095c5c9ecd2e4040f92e32edb8c8d3a89864d05'
version '0.1'
def install
bin.install("src/bee")
@jcartledge
jcartledge / bash.sh
Created September 30, 2012 13:17
My git prompt is better than any other one I've seen anywhere.
# prompt
function _git_prompt() {
local git_status="`git status -unormal 2>&1`"
if ! [[ "$git_status" =~ Not\ a\ git\ repo ]]; then
if [[ "$git_status" =~ Changed\ but\ not\ updated ]] || [[ "$git_status" =~ Untracked\ files ]] || [[ "$git_status" =~ Changes\ not\ staged ]] || [[ "$git_status" =~ Unmerged\ paths ]]; then
local color="0;31" # red
elif [[ "$git_status" =~ Changes\ to\ be\ committed ]]; then
local color="0;32"
else
local color="1;32"