Skip to content

Instantly share code, notes, and snippets.

@5thWall
5thWall / maze.rb
Created August 19, 2010 00:50
Simple recursive maze class
#!/usr/bin/env ruby
# maze.rb
class Integer
def odd?
self % 2 == 1
end
end
@5thWall
5thWall / unicorn
Created February 5, 2011 22:10
/etc/init.d script for unicorn and non-rails app
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by 5thWall@gmail.com http://github.com/5thWall
# based on https://gist.github.com/504875 by http://github.com/jaygooby
#
## A sample /etc/unicorn/my_app.conf
##
@5thWall
5thWall / kfix.rb
Created August 17, 2011 06:58
A little script for replacing classed spans with html tags for converting GoogleDocs documents to MOBI format.
require 'nokogiri'
@doc = Nokogiri::HTML File.open($*[0])
if $*[1] != nil
iclass = $*[1]
ital = @doc.css "span.#{iclass}"
ital.each do |n|
n['class'] = n['class'].gsub(/#{iclass}/, "").strip
i = Nokogiri::XML::Node.new "i", @doc
@5thWall
5thWall / msysgit_ssh_agent.sh
Created October 3, 2012 17:23
Auto launching ssh-agent on msysgit
# Originally written by Github:
# https://help.github.com/articles/working-with-ssh-key-passphrases
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
@5thWall
5thWall / Preferences.sublime-settings
Last active December 11, 2015 02:58
My Sublime Text 2 Settings
{
"color_scheme": "Packages/Solarized Color Scheme/Solarized (dark).tmTheme",
"detect_indentation": true,
"draw_indent_guides": true,
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
".tags*",
"*.pyc",
@5thWall
5thWall / styles.css
Last active December 21, 2015 01:29
CSS Stylsheet for /r/FATErpg
/* Change header size */
#header-img {
width: 150px;
height: auto;
}
/* end header */
/* Change vote icons */
.arrow.upmod {
background:url(%%votes%%);
@5thWall
5thWall / .bashrc
Created October 1, 2013 18:03
Dotfiles from work
export TERM=msys
# Aliases
alias please='sudo'
alias ls='ls --color=auto'
alias subl='/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe'
alias releasenotes="git log --oneline --no-merges `git describe --abbrev=0 --tags`..HEAD | cut -c 9- | sort | subl"
## Navigation
alias assets='cd ~/src/assets/'
// LINQ all the things
bool FilesValid(HttpFileCollection files, IEnumerable<String> allowedExtensions)
{
return files.AllKeys.Select(s => files[s])
.Any(fi => !AllowedExtensions.Any(s => fi.FileName.EndsWith(s)));
}
// LINQ some of the things
bool FilesValid(HttpFileCollection files, IEnumerable<String> allowedExtensions)
{
// Sort command for money columns with the stupidtable library.
// https://github.com/joequery/Stupid-Table-Plugin
$("selector").stupidtable({
"cash": function(a, b) {
reg = /\$(\d,?\d*\.\d{2})/;
aCash = reg.exec(a)[1].replace(',', '');
bCash = reg.exec(b)[1].replace(',', '');
return parseFloat(aCash) - parseFloat(bCash);
thinksyncDirectives = angular.module('thinksyncDirectives', []);
thinksyncDirectives.directive('tsTouchstart', function() {
return function(scope, element, attr) {
element.on('click', function(event) {
scope.$apply(function() {
fn(scope, {$event:event});
});
});
};