Skip to content

Instantly share code, notes, and snippets.

View dawnerd's full-sized avatar
🌮

Troy Whiteley dawnerd

🌮
View GitHub Profile
@dawnerd
dawnerd / simpleif.js
Created April 20, 2012 21:43
Simple If
function simpleIf(fun_if, fun_else) {
if(!fun_if()) fun_else();
}
//usage
simpleIf(function(){
console.log('doing stuff because Im true!');
return true;
}, function(){
console.log('some more stuff :(');
@dawnerd
dawnerd / mkv2mp4.sh
Created May 17, 2012 20:53
Converts an mkv to mp4
#!/bin/bash
# Converts a file from mkv to mp4.
# Shortcut for the following
# HandBrakeCLI --preset="Normal" -i Zombieland-720P.mkv -o Zombieland-720P.mp4 -O
#
# Usage: mkv2mp4 sourcefile.mkv
output=`echo $1|sed -e "s/.mkv/.mp4/gi"`
echo "Encoding $output"
@dawnerd
dawnerd / App.js
Created June 20, 2012 01:14
Node Modules
var test = require('./title_var');
test.title = "kJSDBGKJSDBgkjdfg";
@dawnerd
dawnerd / upload.js
Created July 10, 2012 00:47
Image upload for nodejs & formidable
var form = new formidable.IncomingForm(),
files = [];
form.uploadDir = config.tmpPath;
form.maxFieldsSize = config.maxUploadSize;
form
.on('file', function(field, file) {
files.push([field, file]);
})
@dawnerd
dawnerd / tooltip.class.js
Created July 12, 2012 19:58
Tooltip class for Fidel
/**
* Shows just the (tool)tip.
*
* Example:
*
* var tooltip = new TooltipClass({
* selector: '.tipped'
* });
*
* To inject content into the tooltip, place a data-tooltip attribute that matches the selector.
@dawnerd
dawnerd / .gitconfig
Created August 7, 2012 00:41
My local git config
[core]
autocrlf = input
[alias]
d=diff --color
lg=log --graph --oneline --no-merges --pretty=format:'%Cred%h%Creset - %s %Cgreen(%an - %cr)%Creset %C(yellow)%d%Creset' --abbrev-commit
lf=log --name-only --oneline --no-merges --pretty=format:'%Cred%h%Creset - %s %Cgreen(%an - %cr)%Creset %C(yellow)%d%Creset' --abbrev-commit
lb=!git l --branches
cmp = !sh -c 'git log --left-right --oneline --no-merges --pretty=format:\"%m %Cred%h%Creset - %s %Cgreen(%an - %cr)%Creset %C(yellow)%d%Creset\" $0...'
br="!sh -c 'git fetch origin;git checkout --no-track -b feature/${0/#feature\\//} origin/master'"
mb2=merge --squash
@dawnerd
dawnerd / sublime-text-2-user-v2.json
Last active October 8, 2015 14:18
Sublime Text 2 config
{
"color_scheme": "Packages/User/Espresso Soda.tmTheme",
"default_line_ending": "unix",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
"*.obj",
RewriteEngine on
RewriteBase /
RewriteCond % {REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html
RewriteRule ^/([^/]+)\.html$ /$1/ [R=301,L]
@dawnerd
dawnerd / image_loader.js
Created October 16, 2012 22:04
basic image loader
http.createServer(function(req, res){
var path = './images/' + Math.ceil(Math.random()*4)
var img = fs.readFileSync(path + '.jpg');
res.writeHead(200, {'Content-Type': 'image/jpg' });
res.end(img, 'binary');
}).listen(80, '127.0.0.1');
on run {input, parameters}
repeat with movieFile in input
try
if name extension of (info for movieFile) is "mp4" then
tell application "iFlicks"
import movieFile as QuickTime movie with deleting
end tell
else if name extension of (info for movieFile) is "mkv" then