Skip to content

Instantly share code, notes, and snippets.

#...esse eh um teste do gist public,,,, para ver se ele deleta depois
require 'privacy'
#! /bin/bash
NAME=mongodb
TRIGGER='/etc/init.d/mongodb start'
PIDFILE=/var/run/$NAME.pid
DAEMON=/usr/bin/mongod
ensure_running() {
if ! running ; then
echo "Starting at: `date`"
"the uggglyest thing i ever build to sort random... but thats it
let l:new_list = []
for item in g:kata_1
let l:indx = Urndm(0,5)
let l:item_to_move = deepcopy(g:kata_1[l:indx])
call remove(g:kata_1, l:indx)
call add(g:kata_1, l:item_to_move)
endfor
g:kata_1 = deepcopy(l:new_list)
# get path do ... end
snippet get
get '/${1:path}'${2:, options} do
${3:# ...}
end
# post path do ... end
snippet post
post '/${1:path}'${2:, options} do
${3:# ...}
end
@tcha-tcho
tcha-tcho / gist:917013
Created April 13, 2011 05:33
A vim help to grep using the git root
let g:gitgrepprg="git\\ grep\\ -n"
let g:gitroot="`git rev-parse --show-cdup`"
function! GitGrep(args)
let grepprg_bak=&grepprg
exec "set grepprg=" . g:gitgrepprg
execute "silent! grep! -i -I -n " . a:args . " " . g:gitroot
botright copen
let &grepprg=grepprg_bak
exec "redraw!"
@tcha-tcho
tcha-tcho / sse.js
Created November 10, 2012 03:19
Server Sent Events tip
;(function (global) {
if ("EventSource" in global) return;
var reTrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g;
var EventSource = function (url) {
var eventsource = this,
interval = 500, // polling interval
lastEventId = null,
@tcha-tcho
tcha-tcho / jquery.browser.js
Created April 25, 2013 21:32
jQuery Browser support - from migration
/* Jquery Browser */
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
@tcha-tcho
tcha-tcho / fix_ratio.js
Created May 7, 2013 18:20
Fix ratio when using background images.
function fix_ratio(ele){
var img_ratio = 1.6;//ele.width()/ele.height(); 1920/1200
var window_ratio = $(window).width()/$(window).height();
if(img_ratio>window_ratio){
ele.css("height","100%").css("width","auto");
}else{
ele.css("width","100%").css("height","auto");
}
}
<div id="colunistas_box" style="display: block;">
<div id="colunistas">COLUNISTAS</div>
<div id="colunistas_prev">
<img src="./img/colunistas_home/arrow_prev.gif">
</div>
<div id="colunistas_next">
<img src="./img/colunistas_home/arrow_next.gif">
</div>
@tcha-tcho
tcha-tcho / prev_next.js
Created June 21, 2013 04:37
Solução para os títulos no Prev Next
function title_tip(next) {
var iframe = $(".fancybox-iframe").attr("src");
if (next) {
var title = $(".fancy[href='"+iframe+"']").next().find(".news_t").text();
} else {
var title = $(".fancy[href='"+iframe+"']").prev().find(".news_t").text();
};
if (title == "") title = (next?"Próxima matéria":"Matéria anterior");
return title;