A quick ruby command line to pretty-print piped json.
Put this somewhere in your path, with chmod +x
, then:
curl http://myapp.com/stuff.json | json
"""Draw a live bar graph of frequency data (from Arduino FHT).""" | |
import collections | |
import curses | |
import math | |
import serial # http://pyserial.sourceforge.net/ | |
import time | |
_SERIAL_DEVICE = '/dev/tty.usbmodemfa141' | |
_GRAPH_MAX_Y = 100 |
/* | |
Xively MQTT example | |
-Subscribes to Xively feed | |
-publishes current value to serial monitor | |
Based on Basic MQTT Example by knolleary | |
By Calum Barnes, Xively (c) 2013 |
/* | |
##Xively WiFi Sensor Tutorial## | |
This sketch is designed to take sensors (from photocell) and upload the values to Xively | |
at consistant intervals. At the same time it gets a setable value from Xively to adjust the brigthness | |
of an LED. This sketch is reusable and can be adapted for use with many different sensors. | |
Derived from Xively Ardino Sensor Client by Sam Mulube. | |
By Calum Barnes 3-4-2013 | |
BSD 3-Clause License - [http://opensource.org/licenses/BSD-3-Clause] | |
Copyright (c) 2013 Calum Barnes |
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed. | |
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies. | |
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module | |
# | |
# Deployment structure | |
# | |
# SERVER: | |
# /etc/init.d/nginx (1. nginx) | |
# /home/app/public_html/app_production/current (Capistrano directory) | |
# |
A quick ruby command line to pretty-print piped json.
Put this somewhere in your path, with chmod +x
, then:
curl http://myapp.com/stuff.json | json
require 'net/http'; require 'json'; JSON.parse(Net::HTTP.get(URI("http://duckduckgo.com/?q=#{query}&o=json"))) |
namespace :deploy do | |
desc "Hot-reload God configuration for the Resque worker" | |
task :reload_god_config do | |
sudo "god stop resque" | |
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}" | |
sudo "god start resque" | |
end | |
end | |
# append to the bottom: |
sudo su | |
bash <<(curl -s https://rvm.beginrescueend.com/install/rvm) | |
apt-get install zlib1g-dev libssl-dev libreadline5-dev | |
rvm install 1.9.2 | |
rvm 1.9.2 | |
add rvm script below to your .bashrc and to /root/.bashrc | |
# Load RVM if it is installed, | |
# first try to load user install | |
# then try to load root install, if user install is not there. |
require 'em-zeromq' | |
Thread.abort_on_exception = true | |
EM.run do | |
ctx = EM::ZeroMQ::Context.new(1) | |
socket = ctx.connect( ZMQ::PUSH, 'tcp://127.0.0.1:15000') | |
loop do # ZOMG you are blocking!? |
#Trouve les tweets de Centquarante contenant un nombre de caractères différent de 140 | |
#cf. http://twitter.com/#!/Centquarante/status/12787915516026880 | |
#ruby 1.9 requis pour la détection automatique de l'encodage | |
require 'twitter' | |
def get_tweets(user, options) | |
lastid = false | |
Twitter.user_timeline(user, options).each do |r| | |
puts r.text.size.to_s + ":#{r.id}:#{r.text}" if r.text.size != 140 |