Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Daniel Pereira kriansa

🏠
Working from home
View GitHub Profile
@kriansa
kriansa / exec_with_timeout.rb
Last active Aug 29, 2015
Tiny helper to execute a external command with a timeout.
View exec_with_timeout.rb
# Open stdout and stderr streams and start external executable with timeout.
# The timeout is given in seconds.
#
# Block form:
#
# exec_with_timeout(timeout, [env,] cmd... [, opts]) {|stdout, stderr|
# stdout.read
# ...
# }
#
@kriansa
kriansa / gist:5885902
Created Jun 28, 2013
Simple Javascript template parser
View gist:5885902
/**
* Replaces any ${variables} in the template string by the data object
*/
var parseTemplate = function(template, data) {
return template.replace(/\$\{([\w\d]+)\}/g, function(token, variable){
return data[variable];
});
}
@kriansa
kriansa / CitiesController.rb
Created Aug 14, 2013
Automatizando a seleção de Municípios/UF
View CitiesController.rb
class CitiesController < ApplicationController
def all_by_state_id
uf = params[:id]
cities = City.joins(:state).where('states.id' => uf).select('cities.id, cities.name')
render :json => { data: { cities: cities } }
end
end
View keybase.md

Keybase proof

I hereby claim:

  • I am kriansa on github.
  • I am kriansa (https://keybase.io/kriansa) on keybase.
  • I have a public key whose fingerprint is BC27 7BE0 9E8A 6F10 59C3 911B 3E78 8475 6312 F945

To claim this, I am signing this object:

@kriansa
kriansa / string-normalize.js
Created Jul 25, 2013
Function to translate accented characters to ASCII equivalents. Stripped out from SugarJS. (https://github.com/andrewplummer/Sugar/)
View string-normalize.js
/**
* Returns the string with accented and non-standard Latin-based characters converted into ASCII approximate equivalents.
*
* @returns {String}
*/
String.prototype.normalize = function() {
var NormalizeSource = {
'A': /[AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ]/g,
'B': /[BⒷBḂḄḆɃƂƁ]/g,
'C': /[CⒸCĆĈĊČÇḈƇȻꜾ]/g,
@kriansa
kriansa / evdev
Created Apr 15, 2019
XKB keyboard multimedia function keys
View evdev
# Append this content to the file /usr/share/X11/xkb/rules/evdev
#
# Custom options patch by Kriansa
! option = symbols
custom:multimedia_fn_keys = +media(multimedia_fn_keys)
custom:scroll_lock_key_usable = +media(scroll_lock_key_usable)
@kriansa
kriansa / myezbkp.sh
Created Oct 31, 2011
Easy MySQL incremental backups
View myezbkp.sh
#!/bin/sh
# ========================================================= #
# MyEzBkp
# Easy and simple backup of your entire MySQL Server.
#
# Ver: 1.0
# By: Kriansa
#
# This script requires root privileges to run!
# Tested only in RHEL based distros (Fedora & CentOS)
@kriansa
kriansa / openssl_tls_1.2.patch
Last active Apr 14, 2020
Source patch to add support to TLS 1.1 and 1.2 to Ruby 1.9.3 - https://garajau.com.br/2015/07/tls-1-1-and-1-2-support-for-ruby-1-9-3
View openssl_tls_1.2.patch
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -107,6 +107,18 @@
OSSL_SSL_METHOD_ENTRY(TLSv1),
OSSL_SSL_METHOD_ENTRY(TLSv1_server),
OSSL_SSL_METHOD_ENTRY(TLSv1_client),
+#if defined(HAVE_TLSV1_2_METHOD) && defined(HAVE_TLSV1_2_SERVER_METHOD) && \
+ defined(HAVE_TLSV1_2_CLIENT_METHOD)
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2_server),
You can’t perform that action at this time.