Skip to content

Instantly share code, notes, and snippets.

View douglasmiranda's full-sized avatar
👽

Douglas Miranda douglasmiranda

👽
  • Earth, Brazil
View GitHub Profile
String.prototype.title_case = function () {
return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
};
r = '';
$('#IdModelo option').each(function(){
r += 'u\''+$(this).text().title_case()+'\', ';
});
console.log(r);
@douglasmiranda
douglasmiranda / gist:3992171
Created November 1, 2012 06:23
Compress/Extract Files with 'tar' command - Terminal
# Compress Files
tar -zcvf foo.tar.gz /home/douglas/foo
# Extract files
tar -zxvf foo.tar.gz
@douglasmiranda
douglasmiranda / friends_recommender.py
Created November 7, 2012 03:42 — forked from marcelcaraciolo/friends_recommender.py
Twitter Friends Recommender
#-*-coding: utf-8 -*-
'''
This module represents the recommender system for recommending
new friends based on 'mutual friends'.
'''
__author__ = 'Marcel Caraciolo <caraciol@gmail.com>'
from fabric.api import *
# current_git_branch = local('git symbolic-ref HEAD', capture=True).split('/')[-1]
# === Environments ===
def development():
env.env = 'development'
env.settings = '{{ project_name }}.settings.development'
sudo apt-get build-dep python-numpy python-scipy python-libsvm python-matplotlib
pip install numpy
pip install scipy
pip install python-libsvm
pip install matplotlib
@douglasmiranda
douglasmiranda / popup_example.py
Created November 29, 2012 04:02
working with pop-up (adapted)
from splinter.browser import Browser
browser = Browser()
browser.visit('http://media.douglasmiranda.com/labs/exemplos/splinter_pop-up/')
parent_window = browser.current_window # Save the parent window
browser.find_by_id('open-popup').first.click()
for window in browser.windows:
# Switch to a different window (the pop-up)
@douglasmiranda
douglasmiranda / gist:4264363
Created December 12, 2012 02:32
hello new gist :)
hello new gist :)
@douglasmiranda
douglasmiranda / gist:4338849
Created December 19, 2012 18:01
Installing the latest stable version of VLC on ubuntu
sudo add-apt-repository ppa:videolan/stable-daily
sudo apt-get update
sudo apt-get install vlc
@douglasmiranda
douglasmiranda / gist:4488794
Last active December 10, 2015 20:28
Gnome Extensions I use. (just a reminder)
https://extensions.gnome.org/extension/37/quicklaunch/
https://extensions.gnome.org/extension/354/maximus/
https://extensions.gnome.org/extension/307/dash-to-dock/
https://extensions.gnome.org/extension/2/move-clock/
# This is a really old post, in the comments (and stackoverflow too) you'll find better solutions.
def find(key, dictionary):
for k, v in dictionary.iteritems():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):