Skip to content

Instantly share code, notes, and snippets.

View filiperocha's full-sized avatar

Filipe Rocha filiperocha

View GitHub Profile
@filiperocha
filiperocha / colors.css
Created January 3, 2014 20:10
colors.css
table .blue {
color: #049cdb;
border-bottom-color: #049cdb;
}
table .green {
color: #46a546;
border-bottom-color: #46a546;
}
table .red {
color: #9d261d;
@filiperocha
filiperocha / yoump3.sh
Created December 12, 2013 11:46 — forked from include/yoump3.sh
#!/bin/bash
URL_LIST=$*
YOUTUBE_DL="/usr/local/bin/youtube-dl"
YOUTUBE_DL_OPTS="--title --restrict-filenames --write-thumbnail --extract-audio --audio-format mp3 --audio-quality 0 --continue --no-overwrites"
${YOUTUBE_DL} ${YOUTUBE_DL_OPTS} ${URL_LIST}
#!/bin/bash
# A Shell Script To Convert All .flac Files To .MP3 Format
# Note: I found this script somewhere on usenet and I've modified it for my needs
METAFLAC=/usr/local/bin/metaflac
FLAC=/usr/local/bin/flac
#ID3=/usr/bin/id3
LAME=/usr/local/bin/lame
FIND=/usr/bin/find
t=$(${FIND} . -type f -iname "*.flac")
#!/usr/bin/env node
function primeNumbers(n) {
arr = [];
for (var i = 2; arr.length < n; i++) {
var is_div = false;
for (var count = 2; count < i; count++) {
if (i % count === 0) {
is_div = true;
break;
@filiperocha
filiperocha / pkg_control.sh
Created July 16, 2012 17:07
pkg_control.sh
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
@filiperocha
filiperocha / my_template.rb
Created May 17, 2012 14:09 — forked from xavierRiley/my_template.rb
Kyan Custom Admin Template for Padrino
project :test => :rspec, :orm => :activerecord, :adapter => :postgres, :mock => :none, :script => :jquery, :renderer => :erb, :stylesheet => :none, :admin_renderer => :erb
# include additional generators
inject_into_file destination_root('config/boot.rb'), "\# include additional generators\nPadrino::Generators.load_paths << Padrino.root('generators', 'kyan_admin_page_generator.rb')\nPadrino::Generators.load_paths << Padrino.root('generators', 'kyan_admin_generator.rb')\n\n", :before => "Padrino.load!"
say "Cloning custom generators from [email protected]:xavierRiley/Kyan-Padrino-Admin-Generators.git", :red
remove_dir destination_root('generators')
run "git clone [email protected]:xavierRiley/Kyan-Padrino-Admin-Generators.git " + destination_root('generators')
#generate :model, "account username:string password:string"
if params[:_search] == "true" && params[:filters].present?
filters = Hash.new
j = JSON.parse(params[:filters])
i=0
until j.fetch("rules").size == i
k = j.fetch("rules").to_a[i].values_at("field", "op", "data", "groupOp")
if k[1] == "cn"
k[1] = "matches"
#Selector de idioma
#dependencias:
# 1 - Rack locale del paquete Rack-contrib [1]
# USO: Se usa para detectar el idioma definido por el usuario en su browser ['HTTP_ACCEPT_LANGUAGE']
# Esplicado aquí http://guides.rubyonrails.org/i18n.html#using-accept-language
# [1] http://github.com/rack/rack-contrib
# 2 - Routing-filter [1]
# USO: Establecer el locale en las URLs ej.: www.mysite.com/es/foo/bar
# NOTA: Si tambien quieres traducir las URL's usa la gema de Raul Murciano Translate_routes [2] (De momento sin cobertura para Rails3)
module CouchDBAttachments
def attachment(*args)
lambda do |env|
request = ActionDispatch::Request.new(env)
doc = DocWithAttachments.get(request.params[:doc])
serve_attachment(doc, request.params[:path])
end
end
private
module CouchDBAttachments
def attachment(*args)
lambda do |env|
request = ActionDispatch::Request.new(env)
doc = DocWithAttachments.get(request.params[:doc])
serve_attachment(doc, request.params[:path])
end
end
private