Skip to content

Instantly share code, notes, and snippets.

View h2rd's full-sized avatar

Igor Skrynkovskyy h2rd

View GitHub Profile
@h2rd
h2rd / kill-rmq-connections.sh
Created November 14, 2017 13:45 — forked from thiagooak/kill-rmq-connections.sh
kill ALL rabbitmq connections
rabbitmqctl list_connections pid port state user vhost recv_cnt send_cnt send_pend name | awk '{print "rabbitmqctl close_connection \"" $1 "\" \"manually closing idle connection\"" | "/bin/bash" }'
@h2rd
h2rd / create-registry-secret.sh
Created September 17, 2017 23:55 — forked from olalonde/create-registry-secret.sh
Create a registry secret in Kubernetes
#!/bin/bash
rm /tmp/image-pull-secret.yaml
login_cmd=$(aws ecr get-login)
username=$(echo $login_cmd | cut -d " " -f 4)
password=$(echo $login_cmd | cut -d " " -f 6)
endpoint=$(echo $login_cmd | cut -d " " -f 9)
auth=$(echo "$username:$password" | /usr/bin/base64)
configjson="{ \"auths\": { \"${endpoint}\": { \"auth\": \"${auth}\" } } }"
@h2rd
h2rd / cors-nginx.conf
Created September 3, 2017 20:35 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs docker rmi --force
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@h2rd
h2rd / HaversinFormula.go
Created July 27, 2017 22:16 — forked from cdipaolo/HaversinFormula.go
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
//
@h2rd
h2rd / install-parallel-centos-6.sh
Created June 12, 2017 16:19 — forked from bzz/install-parallel-centos-6.sh
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
ROUND((RAND() * (max-min))+min)
@h2rd
h2rd / throttle.py
Created March 3, 2017 19:39 — forked from ChrisTM/throttle.py
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
.
├── actions
├── stores
├── views
│   ├── Anonymous
│   │   ├── __tests__
│   │   ├── views
│   │   │   ├── Home
│   │   │   │   ├── __tests__
│   │   │   │   └── Handler.js
package main
import (
"fmt"
"reflect"
)
//function types
type mapf func(interface{}) interface{}