Skip to content

Instantly share code, notes, and snippets.

@heronmedeiros
heronmedeiros / generator-sum.py
Created May 27, 2015 17:18
Using generators in Python
# a generator that yields items instead of returning a list
def firstn(n):
num = 0
while num < n:
yield num
num += 1
sum_of_first_n = sum(firstn(1000000))
@heronmedeiros
heronmedeiros / scope.js
Created May 6, 2015 19:05
How to encapsulate js code
(function() {
var x = '';
function myFunction() {
console.log('Hello: ' + x);
}
x = 'Bob';
myFunction();
@heronmedeiros
heronmedeiros / clock.sh
Created September 16, 2014 17:59
add date to global menu
gsettings set org.gnome.shell.clock show-date true
@heronmedeiros
heronmedeiros / exfat.sh
Created July 28, 2014 16:59
exfat support on ubuntu
sudo apt-add-repository ppa:relan/exfat
sudo apt-get update
sudo apt-get install fuse-exfat
var a = "teste"
, b = 10
, variable = new Something()
;
Ext.define('Book', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'title', type: 'string'},
{name: 'thumb_image_path', type: 'string'},
{name: 'user_id', type: 'int'}
],
proxy: { url: "/books", type: 'rest', format: "json" }
});
@heronmedeiros
heronmedeiros / jquery.ba-tinypubsub.js
Created November 12, 2012 13:59 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@heronmedeiros
heronmedeiros / reduce.clj
Created November 7, 2012 20:19
reduce example
(defn plus [alpha beta] (+ alpha beta))
(plus 3 4) ;; 7
(plus 3 [4 5]) ;; Exception
(reduce plus 3 [4 5] ) ;; 12
;;yay
@heronmedeiros
heronmedeiros / .tmux.conf
Created October 27, 2012 20:44
tmux configuration
# set C-a as PREFIX
set -g prefix C-a
# set delay for other programs
set -s escape-time 1
#set index start by 1 for window
set -g base-index 1
#set index start by 1 for panes
class Klass
def self.foo
File.open "filename", "w" do |file|
file.write("text")
end
end
end