Skip to content

Instantly share code, notes, and snippets.

@olvap
olvap / example.rb
Last active August 29, 2015 14:02
Cliente para Xively
def create_on_xively
client = XivelyClient.new({ service: params[:service],
domain: params[:domain] })
response = client.post devise.json_for_xively
response["devices"].first
end
@olvap
olvap / Objetivos.md
Last active August 29, 2015 14:01
Tutoria.rb

Objetivo:

Generar una nueva funcionalidad en el proyecto https://github.com/bluelemons/archivo

Modalidad

La idea es que una vez a la semana se defina un objetivo y lo discutamos entre todos, cada uno debe investigar por su cuenta. Si se traban en algo o no saben como seguir lo discutimos en persona o por chat. No se asusten si no saben algo, son muchas cosas y puede parecer super difícil pero todo está documentado o lleno de alternativas.

require 'json'
require 'mqtt'
class Command
attr_accessor :options, :response, :thread
def initialize
self.response = ""
end
require 'oauth2'
client_id = "2991b1d948ba1aed69144fb3a34474216d6a374cb876f02d51a2f40d3b783bd3"
secret_client = "d528cf49d607b476ea27b9c662615b50b29605cb5151626bc378948606e60149"
redirect_uri = "http://localhost:3000"
site = "http://lutron.herokuapp.com/"
client = OAuth2::Client.new(client_id, client_secret, :site => site)
client.auth_code.authorize_url(:redirect_uri => redirect_uri)
@olvap
olvap / new.rb
Last active January 3, 2016 12:39
ActiveForce refactor.
class Account < ActiveForce::SObject
...
has_many :medications,
where: "(Date_Discontinued__c > #{ Date.today.strftime("%Y-%m-%d") } or Date_Discontinued__c = NULL)"
...
end
class PortalUser < ActiveRecord::Base
...
def medications
@olvap
olvap / config.yml
Created September 7, 2013 16:04
config fiel for flexget
tasks:
rlslog_yify:
rss: http://yify-torrents.com/rss/0/1080p/All/0
imdb:
min_score: 6.1
download: ~/torrents/
rlslog_dvdrips:
rlslog: http://www.rlslog.net/category/movies/dvdrip/
imdb:
module Comparable
def hola
puts "hola jose"
end
end
class Person
include Comparable
end

Ruby para no programadores

Tema: Introducción a Ruby

Descripción: Como la gente que no programa puede ahorrar tiempo automatizando cosas. Como trabajar con archivos de texto, generar planillas y más!.

Disertantes: Pablo Oldani

Duración: 15 minutos.

@olvap
olvap / salida.rb
Last active December 14, 2015 15:29
#Agosto - 2012
irb(main):012:0> AppointmentRequest.where("created_at > '2012-08-01' and created_at < '2012-08-31'").count
(19.3ms) SELECT COUNT(*) FROM `appointment_requests` WHERE (created_at > '2012-08-01' and created_at < '2012-08-31')
=> 543
#Septiembre - 2012
irb(main):011:0> AppointmentRequest.where("created_at > '2012-09-01' and created_at < '2012-09-31'").count
(19.0ms) SELECT COUNT(*) FROM `appointment_requests` WHERE (created_at > '2012-09-01' and created_at < '2012-09-31')
=> 471
require 'csv'
accounts = CSV.read('data.csv')
accounts.shift # Get rid of the header
accounts.each do |account|
domain = account[-2].split(' ').first #toma la primera palabra
chargify_id = account[0]
a = Account.search(domain_contains: domain).first