Skip to content

Instantly share code, notes, and snippets.

View jonahoffline's full-sized avatar

Jonah Ruiz jonahoffline

View GitHub Profile
@jonahoffline
jonahoffline / gateway_spec.coffee
Last active December 28, 2015 14:49
Added the done() callback to make the spec asynchronous. (from Jeff Dickley's "Trust, Tools, and Tripping Over Shoelaces While Dancing" blog post - http://archlever.blogspot.com/2013/11/trust-tools-and-tripping-over-shoelaces.html)
#= require 'gateway'
describe 'Gateway class', ->
beforeEach (done) ->
@subject = new window.meldd.Gateway()
@name = 'foo'
@value = $('body')
done()
@jonahoffline
jonahoffline / names_for_integration_testing.md
Last active September 13, 2017 22:35
Fake Names for integration testing

Fake Names for integration testing

Sometimes I get frustrated when doing Integration tests, so I made the following list to keep myself entertained (feel free to add to the list):

  • Alberto Verijas
  • Antonio Constipado
  • Benedicta Buduska
  • Brenda Maceta
  • Cabrón Figueroa
  • Canalla Rivera
@jonahoffline
jonahoffline / usgs_data.rb
Last active December 24, 2015 13:29
Refactoring of John's code without any external dependency.
require 'open-uri'
require 'json'
require 'ostruct'
# Usage example:
# require './usgs_data'
#
# quakes = Earthquake::Data.get_summary
# quakes.metadata
#=> {"generated"=>1380773976000,
@jonahoffline
jonahoffline / add_unaccent_pgsql_extension.rb
Created September 25, 2013 22:20
Migration to enabling postgresql extension for SoPR-platform. This will fix the current build error.
# Copy paste this motherfucker after running $ ./bin/rails g migration AddUnaccentPgsqlExtension
require_relative '20130921141716_add_unaccent_extension'
class AddUnaccentPgsqlExtension < ActiveRecord::Migration
def up
revert AddUnaccentExtension
enable_extension 'unaccent'
end
def down
@jonahoffline
jonahoffline / npm-run
Last active December 23, 2015 07:29
Script to run bin files for locally installed npm packages.
#!/usr/bin/env sh
#
# Description:
# Allows you to run bin files for locally installed npm packages.
#
# Author:
# jonahoffline (Jonah Ruiz) <jonah@pixelhipsters.com>
#
# Github:
# https://github.com/jonahoffline/shell_stuff
@jonahoffline
jonahoffline / spam_bitch.rb
Created September 2, 2013 21:05
Send SMS through gmail. Extracted from an irc-bot plugin I made. Currently works with Claro, AT&T and T-Mobile. Feel free to add more carriers :)
require 'mail'
module SpamBitch
module Phone
def self.carriers
{ claro: 'vtexto.com', att: 'txt.att.net', tmobile: 'sms.tmobile.net' }
end
def self.send_sms(telephone, msg, carrier)
options = {
@jonahoffline
jonahoffline / rspec_html.rake
Created August 7, 2013 02:13
Rake Task for generating a RSpec report in html.
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = '--format html --out reports/rspec_results.html'
end
namespace :rspec_report do
desc 'Run all specs and generate RSpec report in HTML'
task :html => :spec
@jonahoffline
jonahoffline / predicate_magic.rb
Last active December 19, 2015 14:18
Refactor example (Before / After) for Predicate method magic in a class I made for the link_shrink gem.
# Old:
module LinkShrink
class Options < Hash
def initialize(*args)
super(*args)
self.merge!(self.default)
end
def qr_code?
self.fetch(:qr_code, false)
@jonahoffline
jonahoffline / import_csv.rake
Last active December 18, 2015 15:58
Rake file for importing a CSV file into an Active Record table.
require "csv"
desc "Import CSV file into an Active Record table"
task :csv_model_import, [:filename, :model] => :environment do |task,args|
firstline=0
keys = {}
CSV.foreach(args[:filename]) do |row|
if (firstline==0)
keys = row
firstline=1
@jonahoffline
jonahoffline / temp_sensor_bluetooth.rb
Created April 9, 2013 20:06
Simple ruby script to read temperature / humidity (built with arduino) through bluetooth.
require 'serialport'
require 'eventmachine'
sp = SerialPort.new "/dev/tty.linvor-DevB"
EventMachine::run do
EventMachine::defer do
loop do
temp = sp.gets
next unless temp