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 / 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 / post-receive
Created Mar 9, 2016
Ruby on Rails post receive file for Git deployments.
View post-receive
echo "---> An Error Has Occurred!"
echo "---> Receiving push as $USER"
git --work-tree=$APP_PATH --git-dir=$GIT_DIR checkout -f
shavit /
Last active Jun 25, 2016
Optimize Nginx and workers
# 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 / post-receive
Created Jul 6, 2016
Deploy meteor app on Ubuntu
View post-receive
# On your local machine
# local$ npm install --production
# local$ meteor build .build --architecture os.linux.x86_64
# On your server
shavit / recommended_posts.sql
Created Jul 28, 2016
Recommended posts example in PostgreSQL using full text search, based on a single post
View recommended_posts.sql
shavit / search.sql
Last active Jul 29, 2016
Full text search for WordPress with MySQL
View search.sql
thumbnail.meta_value) AS picture,
MATCH (post_title) AGAINST ('term') AS title_score,
MATCH (post_excerpt) AGAINST ('term') AS excerpt_score,
MATCH (post_content) AGAINST ('term') AS content_score
FROM wp_posts
shavit / CreateCappedCollection.js
Created Sep 2, 2016
Create a tailable MongoDB capped collection
View CreateCappedCollection.js
db.createCollection("jobs", {
capped: 1,
size: 100000,
max: 10
shavit / worker_mongodb_queue.go
Created Sep 3, 2016
Go worker with MongoDB capped collection
View worker_mongodb_queue.go
package main
import (
shavit / haiku.ex
Created Sep 20, 2016 — forked from friggeri/haiku
random heroku-like name generator in Elixir
View haiku.ex
def generate_name do
# [[64][64]]
[["autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",
shavit / custom_template_functions.go
Created Sep 20, 2016
Create custom helpers for HTML and XML templates in Go
View custom_template_functions.go
content, err = ioutil.ReadFile("templates/rss.xml")
if err != nil {
//Custom template helpers
fm := template.FuncMap{"number": func(n int) string {
return strconv.Itoa(n)
}, "float": func(f float64) string {
return strconv.FormatFloat(f, 'f', -1, 64)
You can’t perform that action at this time.