A running example of the code from:
- http://marcio.io/2015/07/handling-1-million-requests-per-minute-with-golang
- http://nesv.github.io/golang/2014/02/25/worker-queues-in-go.html
Small refactorings made to original code:
#!/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) |
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{} |
A running example of the code from:
Small refactorings made to original code:
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) |
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(',') |
# app/models/model_name.rb | |
class ModelName < ActiveRecord::Base | |
include Tokenable | |
end | |
# app/models/concerns/tokenable.rb | |
module Tokenable | |
extend ActiveSupport::Concern | |
included do |