Skip to content

Instantly share code, notes, and snippets.

View spalenza's full-sized avatar

Rodolfo Spalenza spalenza

  • RDStation
  • Vitória - ES - Brazil
View GitHub Profile
@spalenza
spalenza / pre-commit
Last active May 30, 2017 18:24
Git hook for commit. Add in .git/hooks/pre-commit
#!/usr/bin/env ruby
# .git/hooks/pre-commit
# Git pre-commit hook that catches errors that I commonly make.
#
# To intentionally ignore the hook (i.e., when adding an alert call), commit
# from the command line with "--no-verify"
#
# Loosely based on Henrik Nyh's <http://henrik.nyh.se> work (2011-10-08)
# under the MIT License.
@spalenza
spalenza / randompass.sh
Created August 11, 2014 12:27
Generate radon password - Linux
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1
@spalenza
spalenza / update-vim-bundles.sh
Created July 11, 2014 12:47
Update all vim's bundles.
for i in *; do cd $i && git pull && cd ..; done
@spalenza
spalenza / store_controller.rb
Created July 10, 2014 21:31
Access controller's methods in anywhere.
module StoreController
@@controllers = Hash.new
Finalizer = lambda { |id|
@@controllers.delete id
}
class << self
def set_controller(controller)
unless @@controllers.has_key?(Thread.current.object_id)
@spalenza
spalenza / download.sh
Created May 25, 2014 14:30
Split and download files with wget
# Split string by '|'
IFS='|' read -a array <<< "strig"
# Download
for element in "${array[@]}"; do wget "$element"; done
@spalenza
spalenza / my.cnf
Last active January 4, 2016 16:59
brew mysql with thinking sphinx
# /etc/my.cnf
[mysqld]
sort_buffer_size = 512M
sort_buffer = 512M
innodb_file_per_table
[mysql]
default-character-set = utf8
@spalenza
spalenza / ckeditor-fixes.js
Created January 24, 2014 12:58
CKEditor Solutions
// HTML special characters
$(document).ready(function() {
CKEDITOR.on('instanceReady', function(){
// liquidize_template é o nome da campo para o CKEditor
CKEDITOR.instances.liquidize_template.on('mode', function(ev) {
if (ev.editor.mode == 'source') {
var str = ev.editor.getData();
str = str.replace(/&amp;/g, "&")
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<")
ul.token-input-list-bootstrap {
cursor: text;
overflow: hidden;
height: auto !important;
margin: 0;
list-style-type: none;
border: 1px solid #cccccc; }
ul.token-input-list-bootstrap {
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
@spalenza
spalenza / define_method.rb
Created February 7, 2013 00:42
Ruby create methods with define_method
# normal
class Library
attr_accessor :games
def each(&block)
games.each(&block)
end
def map(&block)
games.map(&block)
@spalenza
spalenza / gist:4511407
Last active December 10, 2015 23:39
Fix Duplicate or Old Item on "Open With..." List in Mac OSX

Run Command

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local\-domain system -domain user

Relaunch Finder

⌃ ⌥ CLick on Finder icon in the Dock