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:
A running example of the code from:
Small refactorings made to original code:
| package main | |
| import ( | |
| "fmt" | |
| "reflect" | |
| ) | |
| //function types | |
| type mapf func(interface{}) interface{} |
| . | |
| ├── actions | |
| ├── stores | |
| ├── views | |
| │ ├── Anonymous | |
| │ │ ├── __tests__ | |
| │ │ ├── views | |
| │ │ │ ├── Home | |
| │ │ │ │ ├── __tests__ | |
| │ │ │ │ └── Handler.js |
| 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 |
| ROUND((RAND() * (max-min))+min) |
| #!/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 |
| // 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 | |
| // |
| docker ps --all | tail -n +2 | awk '{print $1}' | xargs docker rm |
| #!/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 <( |
| FROM ubuntu:latest | |
| ADD start.sh /bin/start.sh | |
| RUN chmod +x /bin/start.sh | |
| # Add crontab file in the cron directory | |
| ADD crontab /etc/cron.d/thecron | |
| # Give execution rights on the cron job | |
| RUN chmod 0644 /etc/cron.d/thecron |