Skip to content

Instantly share code, notes, and snippets.

View rafaelsales's full-sized avatar
💻
Compiling...

Rafael Sales rafaelsales

💻
Compiling...
View GitHub Profile
@rafaelsales
rafaelsales / jQueryfy_for_Tampermonkey
Created December 15, 2012 15:22
jQueryfy is a Tampermonkey <http://goo.gl/19Fxy> script for enabling jQuery in any page dynamically. The script is published at http://userscripts.org/scripts/show/154225 where you can easily install in your Tampermonkey. Whenever the script is active, the jQuery is loaded after the page loads. If the page has already defined jQuery, it's not lo…
// ==UserScript==
// @name jQueryfy
// @namespace http://rafasales.com
// @version 0.1
// @description Loads jQuery in any page
// @match http*://*
// @copyright 2012+, Rafael Sales
// ==/UserScript==
if (typeof(unsafeWindow.jQuery) != 'undefined') {
return;
@rafaelsales
rafaelsales / ruby-bug.rb
Created November 29, 2018 23:13
Ruby bug with keyword arguments in the initializer being used via method(:new)
hash = {
1 => { c: 2 },
2 => { c: 4 },
}
class Works
def do(a, c:)
puts "a: #{a.inspect}; c: #{c.inspect}"
end
end
@rafaelsales
rafaelsales / ws.js
Created June 9, 2018 19:40
node websockets proxy with session
@dougwilson thanks for the quick response. Yeah, I've read most of the session lib source and couldn't see a reason for it not work.
I found a way, by manually calling session on the express websockets upgrade request handler:
```js
import Express from 'express'
import ExpressSession from 'express-session'
import proxy from 'http-proxy-middleware'
const session = ExpressSession({ ... })

Problem: HTTParty sometimes fail with Mios API

How to reproduce

host='vera-us-oem-relay31.mios.com'
path='/relay/relay/relay/device/45025220/session/000000043F62005B183D2DABD0DD8B175A866F/port_3480/data_request?DeviceNum=3&Variable=PinCodes&id=variableget&serviceId=urn%3Amicasaverde-com%3AserviceId%3ADoorLock1'
HTTParty.get("https://#{host}#{path}")
@rafaelsales
rafaelsales / example1.rb
Last active June 22, 2016 21:29
What I dislike in SimpleDelegator
class Funky
def good_method
"I'm good"
end
def method_missing(*args)
"I'm bad"
end
end
> Funky.new.good_method
@rafaelsales
rafaelsales / 1 General info.md
Created April 22, 2016 17:48 — forked from igorsantos07/1 General info.md
CSS tools on React

Main comparison

  1. Traditional CSS

  • Simple approach, known API
  • we would have to deal with namespace conflicts
  • leverages browser caching, storing the entire app style in the first load and reducing following reloads
  1. Style-based implementations
@rafaelsales
rafaelsales / new_gist_file
Created November 1, 2013 17:15
Jenkins retest this please
Jenkins retest this please
@rafaelsales
rafaelsales / id_rsa.pub
Created October 30, 2013 22:01
My Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBmH6hVyGPPyQ4E7YtrBPWfhGlvNQs1lzBsQRi4L1U2VoaH+/jO4YipCT7vEFh6TH9RUsobQTjrTHhDdRqXDj3s1c9ZEV5OE6rE4PYEIYFcZFZJz0NZfvHMicKePJ0rrgjRVpCyaoxSdYHikQxcyLfFvyvv/cf6UYc9NvC6nUYqXcnmauEsduYVL7KGX6ba49cIbXfi+zkBverdlWaDV3yADFlaM0PGzVsEZglAiLFNg3nsNP61vVXB9UlxnQfl6s/bVfs+LlHWi2QjHZwMjE5HEyX8xhmPAtnczfwpKV8zxWmF+dhYQJwkffWeYPGvXd+tV5oIc2vwJPaJ57KoXUb sales@desktop
@rafaelsales
rafaelsales / gist:5518618
Created May 4, 2013 20:21
Replaces 'identifier' by 'code' in files containing 'identifier'
ack -l identifier | xargs -L1 sed -i '' "s/identifier/code/g"
@rafaelsales
rafaelsales / proxylocal_initializer.rb
Last active December 15, 2015 01:19
Create local proxy server associated with public url whenever starting rails server in development mode. It uses proxylocal.com service and gem to generate the public url.
# This initializer creates a local proxy server that makes the local web server accessible
# via a public host generated by ProxyLocal service - http://www.proxylocal.com
Rails.application.config.after_initialize do
server_running = defined?(WEBrick) || defined?(Rails::Server) || defined?(PhusionPassenger) ? true : false
next unless Rails.env.development? && server_running
Thread.new do
ProxyLocal::Client.run({
server_host: 'proxylocal.com',