Skip to content

Instantly share code, notes, and snippets.

View x0bandeira's full-sized avatar

Rafael Bandeira x0bandeira

View GitHub Profile
var obj;
var compound;
obj = function(name) {
var instance = {
name: name,
componenttype: obj,
};
var components = compound(instance);
instance.components = components;
instance.event = function(name, args) {
@x0bandeira
x0bandeira / README.md
Created September 11, 2016 10:03
Lapis MacOS installation instructions LUA web development
LUAR
  • Download and install lua 5.1
  • Download and install luarocks
  • luarocks install luacrypto OPENSSL_DIR=/usr/local/opt/openssl OPENSSL_INCDIR=/usr/local/opt/openssl/include
  • luarocks install lapis
# See https://bugsnag.com/docs/api
# Usage:
# client = BugsnagApiClient.with_token('<your account token>')
# data = client.with_error('<error id>').events(start_time: 5.days.ago, per_page: 30).map {|e| e['meta_data']['Custom']['target_id'] }
class BugsnagApiClient
attr_reader :rest_client
def self.with_token(bugsnag_auth_token)
rc = RestClient::Resource.new('https://api.bugsnag.com', headers: {'Authorization' => "token #{bugsnag_auth_token}"})
new(rc)
@x0bandeira
x0bandeira / remove_scheduled_resque_job.rb
Last active February 16, 2016 23:34
While using resque-scheduler 2.0.1, you have to delete scheduled jobs by hand
def remove_scheduled_resque_job(&block)
[].tap do |processed|
$redis.scan_each(match: "resque:delayed:*") do |key|
$redis.lrange(key, 0, -1).each do |value|
begin
payload = ActiveSupport::JSON.decode(value)
if yield(payload)
$redis.lrem(key, 1, value)
processed << value
end
@x0bandeira
x0bandeira / tags-fix-attempt
Last active March 18, 2016 21:29
`ctags` doesn't seem to play well with namespaced ruby class names out of the box. Even trying with `--extra=q`. `ripper-tags` seems to fix it.
#!/usr/bin/env ruby
`/usr/bin/env ctags -R #{ENV["PWD"]}/app`
tags_file = "#{ENV["PWD"]}/tags"
tags = File.read(tags_file)
fixed_tags = tags.split(/\n/).map do |line|
is_rb = line =~ /\.rb/
if is_rb
name = line.gsub(/^.+(?:class|module) ([a-zA-Z0-9:]+).+$/, '\1')
@x0bandeira
x0bandeira / gist:cb2f3c76d412fa0814d9
Created July 10, 2015 19:43
Share counter client-side
https://github.com/ollieglass/share-counter/blob/master/lib/share-counter.rb
https://urls.api.twitter.com/1/urls/count.json?url=http://www.getmdl.io/&callback=foo
https://api.facebook.com/method/fql.query?format=json&query=select%20share_count%20from%20link_stat%20where%20url=%22http://www.getmdl.io/%22&callback=foo
https://www.linkedin.com/countserv/count/share?url=http://www.getmdl.io/&callback=foo
https://gist.github.com/jonathanmoore/2640302#google-plus
https://gist.github.com/michielvaneerd/5989839
@x0bandeira
x0bandeira / shuffle_resque_queue.rb
Created June 10, 2015 21:58
Shuffle resque queue
redis = Redis.current
key = "resque:queue:bulk"
total = redis.llen(key)
batch = []
total.times do |i|
entry = redis.lpop(key)
batch << entry
if batch.size == 1000
puts "re-inserting batch..."
@x0bandeira
x0bandeira / analysis.markdown
Created November 28, 2014 18:01
Uniqush MySQL driver
  • DatabaseConfig.Engine should control which engine is initialized for pushDatabaseOpts, and not be validated inside the engine driver as it currently is
  • why should the db wrapper (pushDatabaseOpts) control locks when each engine has different lock mechanisms and requirements that may or may not allow things to be written and read at the same time. Shouldn't that go into the engine driver?
- http://www.creativitypost.com/create/banish_excuses_and_boost_your_mood_to_feel_more_creative
A good mood is the best way to boost creativity, and here are some tips on how to get to a good mood
@x0bandeira
x0bandeira / probe.rb
Last active August 29, 2015 14:07
Probe into all instance method calls for a given class
# will look into all method call in instances of given class
module Probe
def self.instances(klass, opts = {})
methods = if opts.is_a?(Array)
opts
else
methods_list(klass, opts)
end
methods.uniq.each do |m|