Skip to content

Instantly share code, notes, and snippets.

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

Bruno Germano egermano

🏠
Working from home
View GitHub Profile
@egermano
egermano / ytevents.js
Created May 13, 2014 14:38
YT Embed API events implements
var thePlayer = new YT.Player('yt-embed', {
height: '360',
width: '540',
videoId: 'bScJ8bbwMNM',
events: {
'onStateChange': function(e){
switch (e.data) {
case YT.PlayerState.ENDED:
clearWatcherVideo();
break;
@egermano
egermano / _placehoder.scss
Created May 19, 2014 15:42
Input Placeholder Compass Mixin
@mixin placeholder() {
&::-webkit-input-placeholder {
@content;
}
&:-moz-placeholder {
@content;
}
&::-moz-placeholder {
@egermano
egermano / Default (OSX).sublime-keymap
Created May 27, 2014 19:04
HTML Entities Key bind for Sublime Text 2
{"keys": ["super+shift+h"], "command": "encode_html_entities"}
@egermano
egermano / check-cpf.js
Created August 19, 2014 21:47
Validate CPF
function checkCPF( val ) {
val = $.trim(val);
val = val.replace('.','');
val = val.replace('.','');
cpf = val.replace('-','');
while(cpf.length < 11) cpf = "0"+ cpf;
var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;
var a = [];
var b = new Number;
@egermano
egermano / tomcat-tool.sh
Created September 5, 2014 23:01
Tool to start dynamically tomcat
#!/bin/bash
# limpa a pasta antiga
rm -rf ~/Sites/apache-tomcat-6.0.37/work/Catalina/localhost/
FOLDER=$(pwd)
LocalHostFolder="~/Sites/apache-tomcat-6.0.37/conf/Catalina/localhost/"
ROOTFile=$LocalHostFolder"ROOT.xml"
XMLTemplate="<Context docBase=\"$FOLDER/web\" path=\"\">
</Context>"
/**
* jQuery.preload
*
* Preload images using the promise pattern.
*
* Usage:
*
* $.preload(img_uri, img_uri, ...).done(function(img, img, ...) {
* // Do stuff with the arguments
* });
@egermano
egermano / timemachine.sh
Created May 15, 2015 22:19
Cloud time machine
#!/bin/sh
date=`date "+%Y-%m-%dT%H_%M_%S"`
HOME=/Users/path
rsync -azP \
--delete \
--delete-excluded \
--exclude-from=$HOME/.Trash \
--exclude-from=$HOME/.cache \
@egermano
egermano / bind.js
Created August 31, 2012 15:58
bind to change the function scope
// bind to change the function scope and send arguments for the functions
Function.prototype.bind = function(context) {
var __method = this,
args = Array.prototype.slice.call(arguments, 1);
return function() {
var a = Array.prototype.concat(Array.prototype.slice.call(arguments), args);
return __method.apply(context, Array.prototype.slice.call(a));
}
};
@egermano
egermano / gist:3556046
Created August 31, 2012 17:16
Fixing the “unix:///var/mysql/mysql.sock” not found error on MAMP
sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
@egermano
egermano / linear.search.js
Created September 11, 2012 14:59
Linear search
function linearSearch(values, target) {
for(var i = 0; i < values.length; ++i){
if (values[i] == target) { return i; }
}
return -1;
}