Skip to content

Instantly share code, notes, and snippets.

@nivertech
nivertech / printer.py
Created November 1, 2012 11:48 — forked from ralight/printer.py
Print incoming MQTT messages with a maximum width of 32 characters.
#!/usr/bin/python
import mosquitto
import textwrap
def on_message(mosq, obj, msg):
for s in textwrap.wrap(msg.payload, width=32):
print(s)
mqttc = mosquitto.Mosquitto()
@nivertech
nivertech / gist:4014593
Created November 5, 2012 00:44 — forked from davatron5000/gist:2254924
Static Site Generators

Backstory: I decided to crowdsource static site generator recommendations, so the following are actual real world suggested-to-me results. I then took those and sorted them by language/server and, just for a decent relative metric, their Github Watcher count. If you want a heap of other projects (including other languages like Haskell and Python) Nanoc has the mother of all site generator lists. If you recommend another one, by all means add a comment.

Ruby

cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
wget https://github.com/elasticsearch/elasticsearch/archive/v0.20.1.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
"""
Automated installation of ejabberd with a postgresql backend inspired by this
article: http://www.planeterlang.org/en/planet/article/How_to_install_ejabberd_2.0.0_with_PostgreSQL_support/
"""
from fabric.api import run, sudo
EJABBERD_VERSION = '2.0.5'
EJABBERD_SOURCE_HOME = '~/dev/xmpp/oss'
POSTGRES_PSQL_PASSWORD = 'user'
rebar.config--
{sub_dirs, ["rel"]}.
{require_otp_vsn, "R13B04|R14"}.
{cover_enabled, true}.
{erl_opts, [debug_info, fail_on_warning]}.
{deps, [
#!/usr/bin/env python
#install the follow first:
#sudo easy_install pip
#sudo pip install -U boto
#sudo pip install configparser
$ brew update
$ cd `brew --prefix`
# Use erlang formula for Erlang R15B01
$ git checkout 6b8d25f Library/Formula/erlang.rb
$ brew install erlang
# Reset formula
$ git reset HEAD Library/Formula/erlang.rb
$ git checkout -- Library/Formula/erlang.rb
@nivertech
nivertech / app.rake
Created February 9, 2013 21:39 — forked from bleonard/app.rake
namespace :app do
desc "create a new app with the given name -- for example, app:create[new_app_name]"
task :create, [:name] => :environment do |t, args|
underscore = get_underscore(args)
name = underscore.camelize
directory = get_directory(args)
raise "#{directory} already exists!" if File.exists?(directory)
puts "Creating app #{name} in #{directory}"
### Most of the summary is taken from the awesome R twotorials at http://www.twotorials.com/ by Anthony Damico
### Some of it are my additions from my experience. This is intended so you can Ctrl+F and find what you want using
### common names of functions and concepts from other languages or statistics.
### Troubleshooting: Search http://tolstoy.newcastle.edu.au/R/ , http://www.r-bloggers.com/, http://www.rseek.org/
### Basics
traceback() # Get the call stack after an error, for debugging
32 %% 2 # == 0 mod operator
5 %/% 3 # == 1 integer division
#author: Davit Khaburdzania
#email: [email protected]
#github: github.com/davit-khaburdzania
fs = require "fs"
mongojs = require "mongojs"
db = mongojs 'mongodb://db_address', ['airports']
#countries in europe
eu_countries = ["austria", "belgium", "bulgaria", "cyprus", "czech republic", "denmark", "estonia", "finland", "france", "germany", "greece", "hungary", "ireland", "iceland", "italy", "latvia", "lithuania", "luxembourg", "malta", "netherlands", "norway", "poland", "portugal", "romania", "slovakia", "slovenia", "spain", "sweden", "switzerland", "united kingdom"]