This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int LDR = 0; // select the input pin for the LDR | |
int lightOnPin = 13; // select the pin for the LED | |
int val = 0; // variable to store the value coming from the sensor | |
int turnOnValue = 1000; | |
void setup() { | |
pinMode(LDR, INPUT); // declare the LDR as an INPUT | |
pinMode(lightOnPin, OUTPUT); // declare the ledPin as an OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
require 'rest_client' | |
require 'json' | |
DB = 'http://localhost:5984/notes' | |
get '/' do | |
data = RestClient.get "#{DB}/_all_docs?include_docs=true" | |
result = JSON.parse(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# do not make noise | |
set bell-style none | |
export PATH=~/.gem/ruby/1.8/bin/:$PATH | |
# Mysql | |
alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &' | |
alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown' | |
# http://pastebin.com/f7a69dcd7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
require 'rubygems' | |
require 'curl' | |
require 'net/http' | |
URL = "URL HERE" | |
Benchmark.bm do|b| | |
b.report("CURL") do | |
1000.times do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# On CRON: | |
# 00,15,30,45 * * * * /home/user/project/reload.sh >> /home/user/log/release_web.log 2>&1 | |
echo "Rebuilding" > /home/user/project/current/public/index.html | |
# Update the code | |
svn update /home/user/project/current | |
# Run migrations | |
cd /home/user/project/current | |
rake RAILS_ENV=$RAILS_ENV db:migrate; | |
# Restart memcached. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'memcache' | |
memcache_options = { | |
:namespace => 'agp:test:key', | |
:multithread => true | |
} | |
memcached_servers = [ ENV['MEMCACHED_LOCATION'] || '0.0.0.0:12211'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on: | |
# http://github.com/bmizerany/heroku-sinatra-app | |
# http://www.sinatrarb.com/book.html#heroku | |
# trial-and-error | |
# | |
# I tried using Blake's sample code from github, | |
# but for some reason my Heroku.com app was running in | |
# a directory called /mnt. This did not correspond to the | |
# name of my app. The code below is more explicit when it | |
# comes to the name of the app file. That is the only difference. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
before_filter :set_views_paths_for_layout | |
# Add new paths to templates paths. | |
def set_views_paths_for_layout | |
paths = [] | |
... | |
paths << create_a_new_path("#{RAILS_ROOT}/app/views/shared") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
open('http://feeds.feedburner.com/Rubyconf2008-Confreaks') do |f| | |
Hpricot.XML(f).search("link").each do |link| | |
puts "Downloading #{link.inner_text}" | |
`wget -c #{link.inner_text}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "sinatra" | |
require "render" | |
Sinatra::EventContext.send :include, Render | |
SVN_REPO_PATH = "/home/tiago/projects/repo/trunk" | |
get "/" do | |
render :cache => true, :expire => 60 do |