Skip to content

Instantly share code, notes, and snippets.

View h2rd's full-sized avatar

Igor Skrynkovskyy h2rd

  • Route4Me
  • Lviv, Ukraine
View GitHub Profile
@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
#!/usr/bin/env python
# echo '{ "title": "Бумажки: простая игра на сегодняшний вечер / Блог компании Мосигра / Хабрахабр", "url": "http://habrahabr.ru/company/mosigra/blog/207906/" }' | python json2query.py | pbcopy
# curl -d'url=http%3A%2F%2Fhabrahabr.ru%2Fcompany%2Fmosigra%2Fblog%2F207906%2F&title=%D0%91%D1%83%D0%BC%D0%B0%D0%B6%D0%BA%D0%B8%3A+%D0%BF%D1%80%D0%BE%D1%81%D1%82%D0%B0%D1%8F+%D0%B8%D0%B3%D1%80%D0%B0+%D0%BD%D0%B0+%D1%81%D0%B5%D0%B3%D0%BE%D0%B4%D0%BD%D1%8F%D1%88%D0%BD%D0%B8%D0%B9+%D0%B2%D0%B5%D1%87%D0%B5%D1%80+%2F+%D0%91%D0%BB%D0%BE%D0%B3+%D0%BA%D0%BE%D0%BC%D0%BF%D0%B0%D0%BD%D0%B8%D0%B8+%D0%9C%D0%BE%D1%81%D0%B8%D0%B3%D1%80%D0%B0+%2F+%D0%A5%D0%B0%D0%B1%D1%80%D0%B0%D1%85%D0%B0%D0%B1%D1%80' http://localhost:3333/page
import sys
import urllib
import json
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-shared-compat-5.6.16-1.el6.x86_64.rpm
rpm -i MySQL-shared-compat-5.6.16-1.el6.x86_64.rpm
yum install php55w php55w-opcache
<?php
// Headings and rows
$headings = array('ID', 'Name', 'Colour');
$array = array(
array(1, 'Apple', 'Green'),
array(2, 'Banana', 'Yellow'),
array(3, 'Orange', 'Orange'),
);
#!/usr/bin/env python
# unicode: utf-8
from __future__ import print_function
from math import radians, sqrt, sin, cos, atan2
import sys
def get_distance(point1, point2):
lat1, lon1 = point1.strip().split(',')
@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
"""
[pow(2, n) for n in xrange(10000)]
0.108330011368 sec
[p(2, n) for n in xrange(10000)]
0.289177894592 sec
[bp(2, n) for n in xrange(10000)]
19.3486168385 sec
"""
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <[email protected]> (based off yumupdatesd)
# Jason Koppe <[email protected]> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
# Mikhail Mingalev <[email protected]> Merged
# redhat-init-jkoppe and redhat-sysconfig-jkoppe, and
@h2rd
h2rd / q.py
Last active August 29, 2015 14:00
#!/usr/bin/env python
from __future__ import print_function
import time
def profile(f):
def wrapper(*arg):
start = time.time()
f(*arg)
# http://en.wikipedia.org/wiki/Blood_alcohol_content
# BAC Chart Values
# 0.00 – 0.03% Normal behavior, no impairme nt
# 0.03 – 0.06% Mild euphoria and impairment; decreased inhibitions
# 0.06 – 0.10% Buzzed, euphoric, increased impairment
# 0.10 – 0.20% Drunk, emotional swings, slurred speech, nausea, loss of reaction time and motor control
# 0.20 – 0.30% Confused, nauseated, poor mentation, black out
# 0.30 – 0.40% Possibly unconscious, unarrousable, loss of bladder function, risk of death
# Above 0.40% Unconscious, coma, impaired breathi ng, risk of death