Skip to content

Instantly share code, notes, and snippets.

View dawnerd's full-sized avatar
🌮

Troy Whiteley dawnerd

🌮
View GitHub Profile
@dawnerd
dawnerd / function.php
Last active August 29, 2015 13:56
Allows category and product to share a same base in woocommerce.
<?php
add_filter('request', function( $request ) {
$tax_qv = 'product_cat';
$cpt_name = 'product';
if(!empty( $request[$tax_qv])) {
$slug = basename($request[$tax_qv]);
// if this would generate a 404
if(!get_term_by('slug', $slug, $tax_qv)) {
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
@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');
RewriteEngine on
RewriteBase /
RewriteCond % {REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html
RewriteRule ^/([^/]+)\.html$ /$1/ [R=301,L]
@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",
@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 / 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 / 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 / App.js
Created June 20, 2012 01:14
Node Modules
var test = require('./title_var');
test.title = "kJSDBGKJSDBgkjdfg";
@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"