This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rexml/document" | |
# in this case monkey patch to be able to read Inkscape "plain svg" files | |
# make the namespace stack start out to have inkscape: and sodipodi: | |
module REXML | |
module Parsers | |
class BaseParser | |
alias_method :old_stream, :stream= | |
def stream=(source) | |
old_stream(source) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
exec curl -X POST -H "Content-Type: application/json" -d "$(cat $0 | tail +3)" http://host/path | |
{ | |
"some": { | |
"json": "here" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEMP=`mktemp /tmp/dbusconf.XXXXXX` | |
# generate dbus config that allows everything | |
echo '<busconfig><type>system</type><listen>d</listen><auth>ANONYMOUS</auth><allow_anonymous/><policy context="default"><allow send_destination="*" eavesdrop="true"/><allow eavesdrop="true"/><allow own="*"/></policy></busconfig>' > $TEMP | |
dbus-daemon --nofork --config-file $TEMP --address tcp:bind=0.0.0.0,port=1234 | |
rm $TEMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name bla; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 443 ssl; | |
server_name bla; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mattias@cocospro:ansible (master *)$ pwd | |
/Users/mattias/src/youtube-audio-dl/ansible | |
mattias@cocospro:ansible (master *)$ vagrant up | |
Bringing machine 'default' up with 'virtualbox' provider... | |
==> default: Box 'precise64' could not be found. Attempting to find and install... | |
default: Box Provider: virtualbox | |
default: Box Version: >= 0 | |
==> default: Adding box 'precise64' (v0) for provider: virtualbox | |
default: Downloading: http://files.vagrantup.com/precise64.box | |
==> default: Successfully added box 'precise64' (v0) for 'virtualbox'! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Output select query as insert statements | |
# | |
# Ex: insert all users from database1 into database2 but replace password with "dummy" | |
# ./mysqlselectdump username database1 "SELECT id, name, \"dummy\" as password FROM users" users password | mysql -u username -ppassword database2 | |
USERNAME="$1" | |
DATABASE="$2" | |
QUERY="$3" | |
INSERTTABLE="$4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# requires that you use "set :deploy_via, :remote_cache" in deploy.rb | |
while read oldrev newrev ref | |
do | |
if [ "$ref" = "refs/heads/master" ] ; then | |
echo "Master branch pushed, deploying to staging" | |
# seams to be set to "." for hooks, unset to make things more normal | |
unset GIT_DIR | |
# deploy path, where "current", "releases", "shared" etc are |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WARNING: don't just use this without testing! | |
# This is not a database migration but i think it's quite convenient to do as a migration | |
# multiple styles has not been tested but should work | |
class ChangeAttachmentPaths < ActiveRecord::Migration | |
AttachmentPath = Rails.root.join("public", "system") | |
def self.paperclip_change_path(table, column, old_opt, new_opt) | |
model = table.to_s.classify.constantize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a bit hackish way of merging two wav files, assumes raw samples. | |
#import <Foundation/Foundation.h> | |
#define RIFF_ID 0x52494646 // "RIFF" | |
#define RIFF_FMT_ID 0x666d7420 // "fmt " | |
#define RIFF_DATA_ID 0x64617461 // "data" | |
typedef struct riffChunkHeader { | |
UInt32 rsc_id; // big endian |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env awk -f | |
# print class and instance methods declarations from implementation | |
# Usage: ./printmethods.awk class.m or awk -f printmethods.awk class.m | |
/^[[:space:]]*@implementation/ { | |
implementation = 1; | |
} | |
/^[[:space:]]*@end/ { | |
implementation = 0; |
OlderNewer