Skip to content

Instantly share code, notes, and snippets.

View adillera's full-sized avatar

Alfonso Juan Dillera adillera

  • Antipolo City, Philippines
View GitHub Profile
@adillera
adillera / pre-commit
Last active April 17, 2018 09:08
This pre-commit hooks run RSpec before every commit. Put both files inside .git/hooks. Ruby portion of the pre-commit hook. This handles running the spec and analyzing the spec log created. The pre-commit file is a direct port from the source at: https://gist.github.com/zewelor/2834349. It loads RVM and calls the rspec commit hook. For non-RVM u…
#!/bin/sh
# Run the RSPec githook.
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
@adillera
adillera / pre-commit
Created February 2, 2017 13:03
Pre-commit hook. Add this to your .git/hooks to be reminded if you placed a debugger somewhere. Add file types in FILES variable and the forbidden texts in FORBIDDEN
#!/bin/sh
FILES='(js|css|rb)'
FORBIDDEN='(binding.pry|console.log|debugger|byebug|\!important)'
GREP_COLOR='4;5;37;41'
if [[ $(git diff --cached --name-only | grep -E $FILES) ]]; then
git diff --cached --name-only | grep -E $FILES | \
xargs grep --color --with-filename -n -E $FORBIDDEN && \
echo "Looks like you are trying to commit something you shouldn't. Please fix your diff, or run 'git commit --no-verify' to skip this check, if you must." && \
exit 1
(function($) {
// Make jQuery's :contains case insensitive (like HTML5 datalist)
// Changed the name to prevent overriding original functionality
$.expr[':'].RD_contains = function(a, i, m) {
return $(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
};
$.fn.relevantDropdown = function(options) {
@adillera
adillera / pig_latin
Created October 16, 2013 10:13
One possible solution to the pig latin problem. It takes only lower cased words and a group of words.
def pig_latin(s)
vowels = %w(a e i o u)
words = s.split(' ')
@new_sentence = String.new
words.each_with_index do |w, i|
if vowels.include? w[0]
word = w + 'way'
word = i == (words.count - 1) ? word : word + ' '