Skip to content

Instantly share code, notes, and snippets.

View h2rd's full-sized avatar

Igor Skrynkovskyy h2rd

  • Route4Me
  • Lviv, Ukraine
View GitHub Profile
@cdipaolo
cdipaolo / HaversinFormula.go
Created April 15, 2015 01:31
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//
@Golpha
Golpha / IP-Guide.md
Created August 23, 2014 02:25
The PHP IP Guide

The PHP IP Guide

This guide shows you common practices to convert IPv4- and IPv6-Addresses into their binary representation.

Who is responsible for this ?

This guide has been written by Matthias Kaschubowski, a autodidactical software developer from germany with about 14 years of practice converting coffee to code. He works in his free time as a php evangelist on a lot of platforms ( last shown as tr0y on php.de, a german PHP related forum and as himself as an adminstrator at the largest PHP-related facebook group ).

Basics

@bzz
bzz / install-parallel-centos-6.sh
Last active March 30, 2019 01:18
Install GNU Parallel on CentOS 6
#!/bin/bash
# Install parallel on CentOS 6.
# Assumes you are root. Prefix w/ sudo if not.
cd /etc/yum.repos.d/
#wget http://download.opensuse.org/repositories/home:tange/CentOS_CentOS-5/home:tange.repo
wget http://download.opensuse.org/repositories/home:/tange/CentOS_CentOS-6/home:tange.repo
yum install parallel
@asika32764
asika32764 / mysql-rand-between-two-values.sql
Created August 16, 2014 07:41
Mysql Rand() between 2 values
ROUND((RAND() * (max-min))+min)
@ashleydw
ashleydw / nginx.conf
Last active January 5, 2025 13:23
Laravel nginx conf file
server {
listen 80 default_server;
server_name example.com www.example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
root /srv/www/example.com/public;
index index.php index.html;
@iomz
iomz / duplicate_dynamodb_table.py
Created March 26, 2014 00:21
Duplicate a table in AWS DynamoDB (for renaming or manual fix)
from boto.dynamodb2.exceptions import ValidationException
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.layer1 import DynamoDBConnection
from boto.dynamodb2.table import Table
from boto.exception import JSONResponseError
from time import sleep
import sys
if len(sys.argv) != 3:
print 'Usage: %s <source_table_name> <destination_table_name>' % sys.argv[0]
@cypres
cypres / thrift.rb
Last active December 25, 2015 06:48
Fixed formular to install thrift 0.9.1, with working PHP lib and extension.
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
@peat
peat / examples.clj
Last active April 26, 2017 13:20
Fun with Clojure and Futures.
; To run these examples (assuming you have homebrew installed):
;
; $ brew install leiningen
; ...
; $ lein repl
;
; ... this drops you into the Clojure REPL (Read, Evaluate, Print, Loop).
;
; Copy and paste the lines below and play around.
@ChrisTM
ChrisTM / throttle.py
Created June 21, 2013 21:33
Python decorator for throttling function calls.
class throttle(object):
"""
Decorator that prevents a function from being called more than once every
time period.
To create a function that cannot be called more than once a minute:
@throttle(minutes=1)
def my_fun():
pass
# 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