Skip to content

Instantly share code, notes, and snippets.

View h2rd's full-sized avatar

Igor Skrynkovskyy h2rd

View GitHub Profile
var a = [1,2,3,4,5,6,7,8];
Array.prototype.map = function(callback) {
var mapped = [];
for (var i = 0; i < this.length; i++) {
mapped[i] = callback.call(null, this[i]);
}
return mapped;
};
@h2rd
h2rd / gist:1699842
Created January 29, 2012 17:55 — forked from alright/gist:1698905
Vkontakte API class
<?php
class Vkapi {
protected $_access_token = '%access_token%';
protected $_client_id = 0;
public static function factory ()
{
$class = get_class();
@h2rd
h2rd / renamer.php
Created March 9, 2012 15:59
Translite with php
<?php
function slugify($text) {
return strtolower(strtr(trim($text), array(' '=>'_') ));
}
function translit($str){
static $tbl= array(
'а'=>'a', 'б'=>'b', 'в'=>'v', 'г'=>'g', 'д'=>'d', 'е'=>'e', 'ж'=>'g', 'з'=>'z',
'и'=>'i', 'й'=>'y', 'к'=>'k', 'л'=>'l', 'м'=>'m', 'н'=>'n', 'о'=>'o', 'п'=>'p',
#! /usr/bin/env python
from os import fork, chdir, setsid, umask
from sys import exit
def main():
while 1:
#main daemon process loop
# Dual fork hack to make process run as a daemon

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

Compiling/Installing Node 0.8.4 (and Python 2.6, required by Node) on CentOS 5

Update system packages -- will migrate system forward to CentOS 5.8. (Optional?)

$ sudo yum update

Install the EPEL Repo:

# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import sys, time, json, logging
import pika
hostname = 'localhost'
logging.getLogger('pika').setLevel(logging.ERROR)
class RabbitMQ(object):
def __init__(self, hostname, queue, exchange = ''):
self.hostname = hostname
@h2rd
h2rd / qr.py
Created October 24, 2013 16:00
from argparse import ArgumentParser
from math import sqrt
from urllib import urlencode
import sys
MAX_SIZE = 300000
def main():
@h2rd
h2rd / thrift.rb
Created January 3, 2014 11:19 — forked from cypres/thrift.rb
require 'formula'
class Thrift < Formula
homepage 'http://thrift.apache.org'
# The thrift.apache.org 0.9.1 archive is missing PHP ext, fixed in THRIFT-2129
# By grapping the source from git instead, it's fixed, but we need to bootstrap
url 'https://git-wip-us.apache.org/repos/asf/thrift.git', :branch => "0.9.1"
version "0.9.1"
head do
@h2rd
h2rd / doit
Created March 6, 2014 13:22 — forked from stantonk/doit
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
yum groupinstall "Development tools"
yum install zlib-devel
yum install bzip2-devel openssl-devel ncurses-devel
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar xf Python-2.7.3.tar.bz2
cd Python-2.7.3