Skip to content

Instantly share code, notes, and snippets.

View davidhq's full-sized avatar
🎯
Focusing

davidhq

🎯
Focusing
View GitHub Profile
@davidhq
davidhq / get_guid_from_oauth
Last active December 18, 2015 23:28
get user id from oauth token for elgg with elgg_social_login
<?php
function get_guid_from_oauth($provider, $token) {
global $CONFIG;
$identifier = strtolower($provider);
foreach (array("LinkedIn", "MySpace", "AOL") as $prov) {
$identifier = str_replace(strtolower($prov), $prov, $identifier);
}
$identifier = ucfirst($identifier) . "_" . $token;
$query = "SELECT entity_guid from {$CONFIG->dbprefix}private_settings where name = 'plugin:user_setting:elgg_social_login:uid' and value = '{$identifier}'";
@davidhq
davidhq / it-ebooks.rb
Created June 8, 2013 11:26
Traverse and download all books from http://it-ebooks.info
require 'nokogiri'
require 'open-uri'
MARK_FILE = "mark.dat"
def wait_for_threads(threads)
print "Waiting for downloads to finish..."
threads.each { |t| t.join }
puts " ok"
end
@davidhq
davidhq / gist:3556485
Created August 31, 2012 17:51
Unpermute (reverse Burrows-Wheeler transform)
# calculates BW(T)
def bw(t):
m = sorted(t[-i:] + t[:-i] for i in range(len(t)))
return "".join(m[i][len(t)-1] for i in range(len(t)))
# for a given string return index with nth occurence of char
def n_occurence_index(string, char, n):
vector = [string[:index+1].count(char) for index in range(0, len(string))]
return vector.index(n)
"si":
date:
formats:
default: "%d. %m. %Y."
short: "%e %b"
long: "%B %e, %Y"
only_day: "%e"
day_names: [Nedelja, Ponedeljek, Torek, Sreda, Četrtek, Petek, Sobota]
abbr_day_names: [Ned, Pon, Tor, Sre, Čet, Pet, Sob]
Xcode
http://developer.apple.com/technology/xcode.html
[OR]
Mac OS X install disc 2
GNU wget
http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
Git
http://code.google.com/p/git-osx-installer/