Skip to content

Instantly share code, notes, and snippets.

@dukeofgaming
dukeofgaming / LinusTalk200705Transcript.wiki
Created March 21, 2012 17:54 — forked from lorn/LinusTalk200705Transcript.wiki
Linus google tech talk transcript

This is transcript of Tech Talk: Linus Torvalds on Git at Google on YouTube.


Andrew:

Thank you, for coming everybody, some of you probably already have heard of Linus Torvalds, those of you who haven't, you are the people with Macintoshes on your laps.

@dukeofgaming
dukeofgaming / api_request.php
Last active August 29, 2015 14:02
Single function REST request API
<?php
set_time_limit(900);
function api_request($url, $method = null, $data = null, &$result_http_code = null){
$curl = curl_init();
if($method === null){
$method = $_SERVER['REQUEST_METHOD'];
}
@dukeofgaming
dukeofgaming / gist:e7aa7f35dfc90240fa9b
Created June 9, 2014 04:07
Grant MySQL permissions to restricted host
use mysql;
grant all on *.* to user@'123.45.67.89' identified by 'password';
flush privileges;
@dukeofgaming
dukeofgaming / gist:e658616610b0feeb9b91
Created June 9, 2014 04:07
Deleting untracked files in git
git status --porcelain|sed -r 's:\?\?\s(.*):\1:g'|xargs rm
@dukeofgaming
dukeofgaming / os.capture
Created June 9, 2014 04:08
Capture console output from Lua system call
---
-- Function to retrieve console output
--
function os.capture(cmd, raw)
local handle = assert(io.popen(cmd, 'r'))
local output = assert(handle:read('*a'))
handle:close()
if raw then
@dukeofgaming
dukeofgaming / gist:972288f2d997bacdc130
Created June 9, 2014 04:08
Directory Tree when there is no tree command
find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/'
@dukeofgaming
dukeofgaming / gist:90041eed50cbf1ec6f66
Created June 9, 2014 04:09
List all binary files' extensions under a directory
#List all binary files' extensions under a directory
find . -type f|xargs file|grep -v text|sed -r 's:.*\.(.*)\:.*:\1:g'
@dukeofgaming
dukeofgaming / gist:04e3217bbe195acc9d6d
Created June 9, 2014 04:09
A shell script to encrypt a file so that only a SSL site's private key can decrypt
#Taken from http://dpaste.de/61O8/
set -e
echo "Encrypting $2 for $1."
# make a directory to store results for this site
mkdir -p results/$1
# get that site's SSL certificate, validating it with the cacert.pem we have
@dukeofgaming
dukeofgaming / gist:76e9752ffe8009a1d0e0
Created June 9, 2014 04:10
Create bootable USB in WIndows
#Create bootable drive, via: http://thelazyadmin.com/blogs/thelazyadmin/archive/2009/01/08/installing-windows-7-via-usb-or-sd-media.aspx
diskpart
list disk (find the disk number for the removable media)
select disk #
clean
create partition primary
select partition 1
active
format fs=fat32 quick
@dukeofgaming
dukeofgaming / gist:8361b752a782826fdb8c
Created June 9, 2014 04:11
Inheritable PHP Singleton
<?php
class Object{
//...
private static $singletons = array();
public static function &singleton(){
$class = get_called_class();
if(!array_key_exists($class, self::$singletons)){
self::$singletons[$class] = new $class();
}
return self::$singletons[$class];