Skip to content

Instantly share code, notes, and snippets.

@nishantmodak
nishantmodak / spree-gemfile
Created March 24, 2014 05:08
spree-gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails'
gem 'arel'
gem 'sqlite3'
gem 'minitest'
GEMFILE
system 'bundle'
1.9.3p362 :001 > Line.cached_foreign(1)
Line Load (1.1ms) SELECT "lines".* FROM "lines" WHERE "lines"."foreign_id" = 1
=> [#<Line id: 1, no: 1, foreign_id: 1, created_at: "2012-09-28 09:18:14", updated_at: "2012-09-28 09:18:14">, #<Line id: 3, no: 3, foreign_id: 2, created_at: "2012-09-28 09:25:41", updated_at: "2012-09-28 09:25:41">, #<Line id: 4, no: 4, foreign_id: 2, created_at: "2012-09-28 09:26:00", updated_at: "2012-09-28 09:26:00">]
1.9.3p362 :002 > Line.cached_foreign(1)
Line Load (1.6ms) SELECT "lines".* FROM "lines" WHERE "lines"."foreign_id" = 1
=> [#<Line id: 1, no: 1, foreign_id: 1, created_at: "2012-09-28 09:18:14", updated_at: "2012-09-28 09:18:14">, #<Line id: 3, no: 3, foreign_id: 2, created_at: "2012-09-28 09:25:41", updated_at: "2012-09-28 09:25:41">, #<Line id: 4, no: 4, foreign_id: 2, created_at: "2012-09-28 09:26:00", updated_at: "2012-09-28 09:26:00">]
@nishantmodak
nishantmodak / dino.rb
Last active December 18, 2015 18:00
Dino LED Blink
require 'dino'
board=Dino::Board.new(Dino::TxRx::Serial.new)
led = Dino::Components::Led.new(pin: 13, board: board)
[:on, :off].cycle do |switch|
led.send(switch)
sleep 1
end
@nishantmodak
nishantmodak / rad.rb
Created June 20, 2013 11:21
Ruby Arduino Development Example Blink
class HelloWorld < ArduinoSketch
output_pin 13, :as => :led
def loop
blink led, 100
end
end
@nishantmodak
nishantmodak / serialport.rb
Created June 20, 2013 11:17
Serial Port Ruby
require "serialport"
#params for serial port
port_str = "/dev/ttyUSB0" #may be different for you
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
@nishantmodak
nishantmodak / blink.ino
Created June 20, 2013 11:14
Blink LED on 13
@nishantmodak
nishantmodak / tic_tac_toe_arduino_ir.ino
Last active December 17, 2015 05:49
TV Remote (Sony) Controlled Arduino Uno , Tic Tac Toe
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int i = 0;
int blinkarray[11];
int user=0;
void setup()
{
for(i=2;i<11;i++)