Skip to content

Instantly share code, notes, and snippets.

@orientalperil
orientalperil / ack_sed.sh
Created February 18, 2011 08:04
use ack and sed to find and replace
ack --print0 -irl 'replace_me' location/ | xargs -0 -L1 sed -i '' 's/replace_me/with_me/g'
@orientalperil
orientalperil / simple_web_server.py
Created August 3, 2011 03:24
start a Web server to share the current directory
# start a Web server to share the current directory
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
@orientalperil
orientalperil / ember_upgrade_flags.js
Created May 22, 2012 21:36
Ember.js upgrade flags
ENV = {};
ENV.CP_DEFAULT_CACHEABLE = true;
ENV.VIEW_PRESERVES_CONTEXT = true;
(function() {
/*global __fail__*/
if ('undefined' === typeof Ember) {
Ember = {};
if ('undefined' !== typeof window) {
window.Em = window.Ember = Em = Ember;
}
}
@orientalperil
orientalperil / bookmarklet.js
Created July 8, 2012 02:19 — forked from jonjaques/bookmarklet.js
jQuery Bookmarklet Template w/ Async Loading
// You create your bookmarklet by instantiating
// a new Bookmarklet function, then pass in the options like so.
// This example checks to see if the var is already defined, and makes
// sure not to overwrite it. This could happen if the user clicks on
// the bookmarklet more than once.
var MyBookmarklet = MyBookmarklet || new Bookmarklet({
// debug: true, // use debug to bust the cache on your resources
css: ['/my/style.css'],
js: [],
@orientalperil
orientalperil / title.js
Created November 6, 2012 21:22
SelectWithOptgroups: a subclass of Ember.Select
App.SelectWithOptgroups = Ember.Select.extend({
// A version of Ember.Select that supports optgroup tags.
// content can contain objects that represent the options or the optgroups
// Example of an optgroup object:
// Ember.Object.create({
// optgroup_label: 'foo',
// content: [Ember.Object.create({label: 'First Name', value: 'first_name'}), Ember.Object.create({label: 'Last Name', value: 'last_name'})]
// })
defaultTemplate: Ember.Handlebars.compile('{{#if view.prompt}}<option>{{view.prompt}}</option>{{/if}}{{#each view.content}}{{#if optgroup_label}}<optgroup {{bindAttr label="optgroup_label"}}>{{#each content}}{{view Ember.SelectOption contentBinding="this"}}{{/each}}</optgroup>{{else}}{{view Ember.SelectOption contentBinding="this"}}{{/if}}{{/each}}'),
options: function() {

TMUX - Single window group, multiple session.

So I have been using tmux for a while and have grown to like it and have since added many many customizations to it. Now once you start getting the hang of it, you'll naturally want to do more with the tool.

Now tmux has a concept of window-group and session and if you are like me you'll want multiple session that connects to the same window group instead of a new window group every time. Basically I just need different views into the same set of windows that I have already created, I don't want to create a new set of windows every time I fire up my terminal.

This is the default case if you simply use the tmux command as your login shell, effectively creating a new group of windows every time you start tmux.

This is less than ideal because, if you are like me, you fire up one-off terminals all the time and you don't want all those one-off jobs to stay running in the background. Plus sometimes you need information fro

#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@orientalperil
orientalperil / template_graph.py
Created December 10, 2014 18:15
Create Graphviz diagrams of Django templates
import os
import functools
import fnmatch
import re
import collections
import pydot
def Walk(root='.', recurse=True, *patterns):
"""
@orientalperil
orientalperil / sssl.js
Last active September 20, 2015 03:27 — forked from aFarkas/sssl.js
simple, small script loader
/*!
* SSSL: smallest, simpelst script loader
* version: 1.0.1
*
* API:
* Normal usage
* sssl(source [,complete]);
*
* Example:
* sssl('jquery.js', function(){