Skip to content

Instantly share code, notes, and snippets.

View garo's full-sized avatar

Juho Mäkinen garo

View GitHub Profile
Hurjassa nuoruudessaan Susikoira Roi oli viinatrokarina Argentiinan arolla. Kovana panomiehenä Roi nautti tummien ja tulisten argentiinalaisnaisten suloista, mutta oudoksui näiden myötäsyntyistä karvaisuutta. Niinpä vielä vuosien perästä paikalliset naiset muistelivat: "Harva pimpan parturoi niin kuin pampan Pirtu-Roi..."
/**
* Checks if timestamp falls into a time period represented as a string
*
* String has the following options for format:
* - "1-7,00:00-23:59" means from mondays (1) to sundays (7)
* - "1,00:00-23:59" means that every monday
*
*
* @param ts Date
* @param period String
ruby_block "test" do
block do
# prints [:find_snapshot_id, :ec2, :instance_id, :instance_availability_zone]
Chef::Log.info("Opscode::Aws::Ec2.instance_methods(false) #{Opscode::Aws::Ec2.instance_methods(false)}")
# This throws "undefined method `ec2' for Opscode::Aws::Ec2:Module"
Chef::Log.info("ec2: #{Opscode::Aws::Ec2.ec2}")
# This throws undefined local variable or method `new_resource' for #<Object:0x0000000293b0a0>
credentials = data_bag_item "credentials", "aws"
aws_ebs_volume device do
aws_access_key credentials["aws_access_key_id"]
aws_secret_access_key credentials["aws_secret_access_key"]
device device
action [ :create, :attach ]
end
/*
Send a Start/Sop Recording command to the LANC port of a video camera.
Tested with a Canon XF300 camcorder
This code requires a simple interface see http://micro.arocholl.com
Feel free to use this code in any way you want.
Comprehensive LANC info: www.boehmel.de/lanc.htm
"LANC" is a registered trademark of SONY.
CANON calls their LANC compatible port "REMOTE".
@garo
garo / fib.cpp
Created February 27, 2015 18:29
#include <iostream>
template <unsigned N>
struct Fibonacci
{
enum
{
value = Fibonacci<N-1>::value + Fibonacci<N-2>::value
};
require 'sinatra/base'
require 'puma'
require 'rack'
require 'rack/server'
# Our simple hello-world app
class HelloApp < Sinatra::Base
configure do
set :server, :puma
class SinatraApp < Sinatra::Base
get '/test' do
"This works\n"
end
end
app = SinatraApp.new
# How to create a new routes into the app now? I would like to do something like this:
app.get "/hello" do
require "pp"
require "sinatra/base"
# A blank Sinatra app
class SinatraApp < Sinatra::Base
configure do
set :server, :puma
end
end
class Context
attr_accessor :foo
attr_accessor :bar
def to_s
"[Context: foo: #{foo}, bar: #{bar}]"
end
end