Skip to content

Instantly share code, notes, and snippets.

View antoniosb's full-sized avatar

Antônio Augusto antoniosb

View GitHub Profile
module Shoulda
module Matchers
module ActiveRecord
# https://gist.github.com/mackato/6972768
def have_store_accessor(key)
HaveStoreAccessor.new(key)
end
class HaveStoreAccessor
def initialize(key)
@antoniosb
antoniosb / perfectelementary.bash
Created May 11, 2016 03:41
HowTo Install the perfect Elementary-OS
#Download Elementary OS from here:
#http://sourceforge.net/projects/elementaryos/files/stable/
#First you update your system
sudo apt-get update && sudo apt-get dist-upgrade
#Install Google Chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
@antoniosb
antoniosb / arel_like_binary.rb
Created June 2, 2016 23:16
Monkey patching Arel v3.0.2 to provide a predicate that uses binary like. So we can use it to create a Ransack predicate to use on search forms.
module Arel
module Visitors
class ToSql
private
def visit_Arel_Nodes_BinaryMatches o
"#{visit o.left} LIKE BINARY #{visit o.right}"
end
end
end
end
Batman - Alef
Robin - Ruas
Majinbu - Lucas
Ben 10 - Gui
Psylocke - Laura
O Fera - Waldir
Honda - Cairo
Hancok - Tunico
Lanterna Verde - Leandrão
Hulk - Milk
@antoniosb
antoniosb / gist:50acd9bcbce5fec0d07799f49d4cc67b
Created March 8, 2017 18:25 — forked from bkimble/gist:1365005
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@antoniosb
antoniosb / pisco.rb
Created June 28, 2017 21:39
Pisco generation
rand_str = -> { (0...5).map { ('A'..'Z').to_a[rand(26)] }.join }
rand_number = -> { SecureRandom.random_number.to_s[-5..-1] }
code=rand_str.call
password=rand_number.call
school_id=85
PiscoDataGenerator.create(code, password, school_id)
@antoniosb
antoniosb / plugin.sh
Created April 5, 2018 13:03
Create rspec rails plugin
# http://stackoverflow.com/questions/8507798/rails-3-1-plugin-gem-dummy-test-app-rspec
# http://namick.tumblr.com/post/17663752365/how-to-create-a-gemified-plugin-with-rails-3-2-rspec
rails plugin new plugin_name --skip-test-unit --dummy-path=spec/dummy
cd plugin_name
# Add rspec-rails to gemspec dev deps
# s.add_development_dependency "rspec-rails"
bundle install
@antoniosb
antoniosb / debug.log
Created May 25, 2018 19:14
Output from your CI when using the --debug flag in your CI configuration
download: s3://appprova-test-coverage/coverage/34593036/codeclimate.1.json to coverage/codeclimate.1.json
DEBU[0000] posting request to https://api.codeclimate.com/v1/test_reports
DEBU[0000] {"data":{"type":"test_reports","attributes":{"ci_branch":"AP-3213/fix-student-report-xls-exportation","ci_build_identifier":"34593036","ci_build_url":"https://app.codeship.com/projects/95596/builds/34593036","ci_commit_sha":"c514a17255e80bc7c1a81e7c2e18304ebfc338c9","ci_committed_at":1527268414,"ci_service_name":"codeship","git_branch":"AP-3213/fix-student-report-xls-exportation","commit_sha":"c514a17255e80bc7c1a81e7c2e18304ebfc338c9","committed_at":1527268414,"run_at":1527274133,"covered_percent":96.13004666260905,"covered_strength":0,"environment":{"gem_version":"2.7.6","package_version":"","pwd":"/home/rof/clone","prefix":"/home/rof/clone","rails_root":"","reporter_version":"0.6.0","simplecov_root":""},"line_counts":{"missed":763,"covered":18953,"total":19716}}},"meta":null}
DEBU[0000] posting request to https://api.
@antoniosb
antoniosb / increment_weight.sh
Created February 19, 2020 00:09
Increment weights on front matter for Hugo content pages
#!/bin/bash
# USAGE:
# increment_weight.sh (with no params) will increment ALL pages with weight by 1.
# increment_weight.sh X (X is the param) will increment ALL pages with weight greather than X by 1.
MINIMUM_WEIGHT=$1
if [ -z $MINIMUM_WEIGHT ]; then
MINIMUM_WEIGHT=0
fi
@antoniosb
antoniosb / badges.md
Created July 7, 2022 13:34
Exemplos de badges de LinkedIn para colocar no seu perfil do GitHub
  • [![LinkedIn Badge](https://img.shields.io/badge/-[Texto do badge]-blue?style=flat-square&logo=Linkedin&logoColor=white&link=[Link perfil no LinkedIn])]([Link perfil no LinkedIn])

  • ``