Skip to content

Instantly share code, notes, and snippets.

View h2rd's full-sized avatar

Igor Skrynkovskyy h2rd

View GitHub Profile
@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{}
@h2rd
h2rd / golang_job_queue.md
Created March 12, 2016 14:41 — forked from harlow/golang_job_queue.md
Job queues in Golang
@h2rd
h2rd / tmux.md
Created October 14, 2015 23:08 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

require 'json'
require 'csv'
raise Exception, 'you must provide a json file' unless ARGV[0]
buffer = File.open(ARGV[0]).read
buffer.gsub!("\n", '')
buffer.gsub!("\t", '')
json = JSON.parse!(buffer)
@h2rd
h2rd / parse.rb
Last active August 29, 2015 14:26
require 'json'
raise Exception, 'you must provide a json file' unless ARGV[0]
buffer = File.open(ARGV[0]).read
buffer.gsub!("\n", '')
buffer.gsub!("\t", '')
json = JSON.parse(buffer)
puts json.first.collect {|k,v| k}.join(',')
@h2rd
h2rd / Tokenable
Last active August 29, 2015 14:16
Ruby concerns example
# app/models/model_name.rb
class ModelName < ActiveRecord::Base
include Tokenable
end
# app/models/concerns/tokenable.rb
module Tokenable
extend ActiveSupport::Concern
included do