Skip to content

Instantly share code, notes, and snippets.

View h2rd's full-sized avatar

Igor Skrynkovskyy h2rd

View GitHub Profile
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 <mmcgrath@redhat.com> (based off yumupdatesd)
# Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
# Mikhail Mingalev <mingalevme@gmail.com> 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
<script type="text/javascript">
$(function(){
$('input#submit').click(function(){
var file = $('input[type="file"]').val();
var exts = ['doc','docx','rtf','odt'];
// first check if file field has any value
if ( file ) {
// split file name at dot
var get_ext = file.split('.');
// reverse name to check extension
import re
def fff(url):
query = re.search('\?(.*)', url)
return query and query.group() or '/'
def fff2(url):
query = re.search('(https?://)?\w/(.*)', url)
return "/%s" % (query and query.group(2) or "", )