Skip to content

Instantly share code, notes, and snippets.

Shavit shavit

  • USA
Block or report user

Report or block shavit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shavit
shavit / post-receive
Created Oct 20, 2014
Git deployment for Ruby on Rails applications in production
View post-receive
#!/bin/sh
APP_PATH=/var/www/app
# Production environment
export RAILS_ENV="production"
exit_with_error(){
echo "---> An Error Has Occurred!"
}
@shavit
shavit / install.sh
Created Aug 20, 2015
Compile Nginx with ramp module
View install.sh
./configure \
--user=nginx \
--group=nginx \
--prefix=/usr/share/nginx/nginx-1.7.12 \
--add-module=../nginx-rtmp-module-master \
--sbin-path=/usr/local/sbin/nginx \
--conf-path=/usr/share/nginx/nginx-1.7.12/conf/nginx.conf \
--pid-path=/var/run/nginx.pid \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/varlog/nginx/access.log
@shavit
shavit / export_table_to_csv.coffee
Created Jul 4, 2012
Export HTML table to CSV using javascript.
View export_table_to_csv.coffee
$("#btnExportHTMLToCSV").click((event) ->
$table = $("#tableToExport")
if !$table
return false
headers = []
csv = ""
$table.find("thead th").each(() ->
$th = $(this)
text = $th.text()
header = '"'+text+'"'
@shavit
shavit / post-receive
Created Jan 11, 2016
Git deployment for Go Revel application
View post-receive
#!/bin/sh
# /<REPOS-PATH>/<REPO-NAME>.git/hooks/post-receive
APP_PATH=/<APP-PATH>
exit_with_error(){
echo "---> An Error Has Occurred!"
}
echo "---> Receiving push as $USER"
git --work-tree=/<APP-PATH> --git-dir=/<REPOS-PATH>/<REPO-NAME>.git checkout -f
@shavit
shavit / go-revel-app.conf
Created Jan 11, 2016
Run Go Revel app in production as a service
View go-revel-app.conf
start on runlevel [2345]
stop on runlevel [!2345]
respawn
env PORT=<APP-PORT>
setuid <APP-NAME>
chdir /<APP-PATH>
@shavit
shavit / app
Created Jan 11, 2016
Nginx reverse proxy for Go Revel web application. Also redirects from www to non-www. You can also let Nginx handle the static files with another location block.
View app
upstream app {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name www.domain.com;
return 301 http://domain.com;
}
@shavit
shavit / ParseJSONFromURL.swift
Created Jan 16, 2016
Swift 2 Playground JSON from URL example
View ParseJSONFromURL.swift
//: Playground - noun: a place where people can play
import Cocoa
let url = NSURL(string: "http://localhost:3000/api/v2.1/libraries/latest.json")
let data = NSData(contentsOfURL: url!)
print("---> Response data")
if let json: NSDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as? NSDictionary {
@shavit
shavit / post-receive
Created Mar 9, 2016
Ruby on Rails post receive file for Git deployments.
View post-receive
#!/bin/sh
APP_PATH=$APP_ROOT
exit_with_error(){
echo "---> An Error Has Occurred!"
}
echo "---> Receiving push as $USER"
git --work-tree=$APP_PATH --git-dir=$GIT_DIR checkout -f
@shavit
shavit / server-power.sh
Last active Jun 25, 2016
Optimize Nginx and workers
View server-power.sh
# workers
# grep processor /proc/cpuinfo | wc -l
#
# workers connections
# ulimit -n
# Check the architecture
grep --color=always -iw lm /proc/cpuinfo
# Buid go workers
@shavit
shavit / post-receive
Created Jul 6, 2016
Deploy meteor app on Ubuntu
View post-receive
#!/bin/sh
#
# On your local machine
#
# local$ npm install --production
# local$ meteor build .build --architecture os.linux.x86_64
#
# On your server
You can’t perform that action at this time.