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 / gen_smartpin_linux_arm64.b64
Created February 15, 2026 21:42
gen_smartpin Linux ARM64 binary (base64 encoded)
This file has been truncated, but you can view the full file.
@rafaelsales
rafaelsales / gen_smartpin_linux_x86_64.b64
Created February 15, 2026 21:42
gen_smartpin Linux x86_64 binary (base64 encoded)
This file has been truncated, but you can view the full file.
@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
loop do
begin
sleep 1
rescue Exception => e
puts "I'm STRONGER. Give up!"
end
end
# Run and try CTRL+C
@rafaelsales
rafaelsales / indexes_not_in_use.sql
Last active August 29, 2015 14:11
Postgres check indexes statistics
SELECT
relid::regclass AS table,
indexrelid::regclass AS index,
pg_size_pretty(pg_relation_size(indexrelid::regclass)) AS index_size,
idx_tup_read,
idx_tup_fetch,
idx_scan
FROM
pg_stat_user_indexes
JOIN pg_index USING (indexrelid)
@rafaelsales
rafaelsales / search.sh
Created September 2, 2014 15:55
Search and Replase
LC_ALL=C find . -type f -exec sed -i '' 's/search/replace/g' {} +