Skip to content

Instantly share code, notes, and snippets.

@zealinux
zealinux / sleeping-barber-problem.clj
Created August 21, 2017 23:10 — forked from kachayev/sleeping-barber-problem.clj
Resolve "Sleeping barber problem" with Clojure
(def open-for-business? (atom true))
(def haircut-count (agent 0))
(def waiting-room (ref []))
(def waiting-room-size 3)
(defn open-shop [duration]
(do (Thread/sleep duration) (swap! open-for-business? not)))
(defn add-customers []
(future
@zealinux
zealinux / tmux_ubuntu14.04.sh
Created August 11, 2017 13:34 — forked from VladSem/tmux_ubuntu14.04.sh
install tmux 2.0 on Ubuntu 14.04
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository -y ppa:pi-rho/dev
sudo apt-get update
sudo apt-get install -y tmux=2.0-1~ppa1~t
@zealinux
zealinux / cuda.env
Created August 10, 2017 13:40 — forked from knzm/cuda.env
install CUDA 7.0 and cuDNN 6.5 v2 on CentOS 7.0
export CUDA_HOME=/usr/local/cuda
export NVIDIA_HOME=/usr/local/nvidia
export PATH=${CUDA_HOME}/bin:${PATH}
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
@zealinux
zealinux / index.js
Created June 9, 2017 15:05 — forked from jfensign/index.js
NodeJS User Registration and Authentication
//index.js
var express = require('express'),
app = module.exports = express.createServer(),
mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/nodeAuth');
//configure app
app.configure(function() {
app.set('views', __dirname + '/views');
@zealinux
zealinux / .gitignore
Created April 30, 2017 02:18 — forked from smebberson/.gitignore
Nodejs static web server boilerplate
.DS_Store
node_modules/
@zealinux
zealinux / times.js
Created April 24, 2017 09:11 — forked from FGRibreau/times.js
Ruby .times & .upto & .downto methods in JavaScript
// Ruby = 5.times { |i| puts i }
// JS = (1).times(function(i){console.log(i);})
Number.prototype.times = function(cb) {
var i = -1;
while (++i < this) {
cb(i);
}
return +this;
@zealinux
zealinux / 1-server.md
Created April 13, 2017 14:01 — forked from dragonjet/1-server.md
Setup Web Server on EC2 Amazon Linux AMI

Step 1: Server Credentials

This assumes you are now connected to the server via SSH.

  • sudo -s Enter root mode for admin access
  • groupadd devgroup Create new group to be later granted access to /var/www/html

Creating a new Root User

  • useradd -G root,devgroup masterdev Create new root user. Also add to the devgroup
  • passwd masterdev Change password for the new root user
  • At this point, you'll need to input your new root user's new password
@zealinux
zealinux / rails http status codes
Created April 13, 2017 06:47 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
# install dependencies
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev
@zealinux
zealinux / cmd.sh
Created January 22, 2017 07:53 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/