Skip to content

Instantly share code, notes, and snippets.

View davidhq's full-sized avatar
🎯
Focusing

davidhq

🎯
Focusing
View GitHub Profile
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/
"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]
@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)
@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 / 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}'";
worker_processes 1;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@davidhq
davidhq / .gitignore
Last active August 29, 2015 13:57 — forked from adamgit/.gitignore
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# Version 2.0
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
#
# NB: if you are storing "built" products, this WILL NOT WORK,
@davidhq
davidhq / gist:3bd6c9601e91b0186593
Created May 19, 2014 23:02
startup script rbenv
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
CONFIG_FILE=/etc/default/thinking_sphinx
. $CONFIG_FILE || exit
PATH=/home/$USER/.rbenv/shims:/home/$USER/.rbenv/bin:$PATH
...
echo "Starting $PROGRAM_NAME"
@davidhq
davidhq / faye.rb
Last active August 29, 2015 14:04
ENV['RAILS_ENV'] = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
require ::File.expand_path('../config/environment', __FILE__)
require 'faye'
require 'eventmachine'
require 'redis'
class NumberHelper
extend ActionView::Helpers::NumberHelper
### Keybase proof
I hereby claim:
* I am davidhq on github.
* I am davidhq (https://keybase.io/davidhq) on keybase.
* I have a public key whose fingerprint is ED2F A352 E886 BC83 5B5D C011 274F 83D3 1421 DB54
To claim this, I am signing this object: