Skip to content

Instantly share code, notes, and snippets.

View fidelisrafael's full-sized avatar
🏠
Working from home

Rafael Fidelis fidelisrafael

🏠
Working from home
  • Brasil
  • 01:16 (UTC -03:00)
View GitHub Profile
@fidelisrafael
fidelisrafael / bookshelf.md
Created July 7, 2016 15:14 — forked from zenorocha/bookshelf.md
My bookshelf
@fidelisrafael
fidelisrafael / ar_test.rb
Last active July 22, 2016 13:49
AR model definition
require 'active_record'
require 'pry'
class BaseClass
def self.model(&block)
@model ||= Class.new(ActiveRecord::Base, &block)
end
def initialize(options = {})
establish_database_connection
@fidelisrafael
fidelisrafael / clima_tempo.js
Last active September 6, 2016 15:50
Ordena(ASC) as capitais pela minima diaria
// http://www.climatempo.com.br/brasil
var tables = jQuery(".columns table.medium-6");
var getTableData = function(table) {
return jQuery.map(table.find('tbody > tr'), function(element, index) {
var _element = jQuery(element);
var scope = _element.find('td');
var city_name = scope.find('a.txt-blue').text(),
minimum = scope.find('span.txt-black').first().text(),
0815.ru
0815.ru0clickemail.com
0815.ry
0815.su
0845.ru
0clickemail.com
0-mail.com
0wnd.net
0wnd.org
10mail.com
/* VT100 terminal reset (<ESC>c) */
console.log('\033c');
/* numbers comparations */
> '2' == 2
true
> '2' === 2
@fidelisrafael
fidelisrafael / gist:a8cec73a7d6b1cad064d8716fc2990d2
Created January 19, 2017 19:55
Ruby AES Encryption using OpenSSL
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@fidelisrafael
fidelisrafael / sequel_en.yml
Created January 27, 2017 13:15
Sequel ORM validation error messages Internalization(I18n)
"en":
"sequel":
"validation_errors":
"exact_length": "is not %{exact} characters"
"format": "is invalid"
"includes": "is not in range or set: %{set}"
"integer": "is not a number"
"length_range": "is too short or too long. Range: %{range}"
"max_length": "is longer than %{max} characters"
"max_length_nil": "is not present"
@fidelisrafael
fidelisrafael / yield.js
Created February 2, 2017 16:22
Javascript Yield
function* process() {
console.log('Start process 1');
console.log('Pause process2 until call next()');
yield;
console.log('Resumed process2');
console.log('Pause process3 until call next()');
yield;
@fidelisrafael
fidelisrafael / game.rb
Last active September 15, 2017 08:47
A very simple and multi language "Rock-Paper-Scissor" (and "Rock-Paper-Scissor-Spock-Lizard") game written in plain Ruby only for fun ;) https://www.wikiwand.com/en/Rock%E2%80%93paper%E2%80%93scissors
require 'ostruct'
require 'irb'
# Some monkey patch to add colorized output in console
class String
COLORS_CODE = {
red: 31,
green: 32,
yellow: 33,
blue: 34,
@fidelisrafael
fidelisrafael / switch_touchscreen.sh
Created November 20, 2017 23:40
Disable touchscreen on OpenSuse Leap 42.2 and others linux distros (ATTENTION: You must install `xinput` package for your distro)
#! /bin/bash
# switch_touchscreen.sh
# https://ubuntuforums.org/showthread.php?t=2100744
# sudo chmod a+x switch_touchscreen.sh
DEVICE="Atmel Atmel maXTouch Digitizer"
STATUS=`xinput list-props "$DEVICE" | grep 'Device Enabled' | sed 's/.*\([0-9]\)$/\1/'`
if [ "$STATUS" = "1" ]
then