View main.go
package main
import (
"flag"
"fmt"
"log"
"regexp"
"sort"
"strconv"
"strings"
View ghopen.php
#!/usr/bin/env php
<?php
$cwd = getcwd();
$dirs = explode(DIRECTORY_SEPARATOR, $cwd);
$opened = [ ];
for( $i = count($dirs); $i >= 1; $i-- ) {
$set = array_slice($dirs, 0, $i);
$path = implode(DIRECTORY_SEPARATOR, $set);
View day7.go
package main
import (
"fmt"
"strconv"
"strings"
)
var input = `bn RSHIFT 2 -> bo
lf RSHIFT 1 -> ly
View FixITunesPlayedCount.applescript
tell application "iTunes"
(* this prevents an error on no tracks being found on the set below *)
set played count of first track where played count = 1 to 0
(* sometimes it leaves this if we don't wait *)
delay 1
set played count of every track where played count = 0 and played date ³ (date "Thursday, June 1, 2000 at 12:00:00 AM") to 1
end tell
View mblen.php
#!/usr/bin/env php
<?php
mb_internal_encoding('UTF-8');
$string = '';
if( count($argv) > 1 ) {
$string .= implode(' ', array_slice($argv, 1));
} else {
while( $line = fgets(STDIN) ) {
View cp-branch
#!/bin/zsh
set -e
if [ $# -lt 3 ]
then
echo "Not Enough Arguments"
return 1
fi
View fast-patch.php
#!/usr/bin/env php
<?php
if( count($argv) < 3 ) {
echo "Requires at least two arguments\n";
die(1);
}
$dir = realpath($argv[1]);
if( !is_dir($dir) ) {
View http.go
package utils
import (
"encoding/base64"
"net/http"
"strings"
)
func BasicAuth(handler http.HandlerFunc, username, password string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
View branch-be-gone.php
#!/usr/bin/env php
<?php
`git fetch -p --all`;
$branches = `git branch -vv`;
preg_match_all('%^\ +(?P<branch>[\w/=\-.#]+)\ +(?P<hash>[0-9a-fA-F]+)\ \[[\w/=\-.#]+:\sgone\]%smx', $branches, $result, PREG_PATTERN_ORDER);
foreach( $result['branch'] as $index => $branch ) {
$output = [ ];
View QuerySampler.php
<?php
$timeout = 1800; //seconds
$sleep = 100000; //microseconds
$start = time();
$link = mysql_connect('[[HOST]]', '[[USERNAME]]', '[[PASSWORD]]');
if( !$link ) {
die('Could not connect: ' . mysql_error());
}