Skip to content

Instantly share code, notes, and snippets.

View edcrypt's full-sized avatar

Eduardo de Oliveira Padoan edcrypt

View GitHub Profile
@edcrypt
edcrypt / crawler.py
Created April 28, 2012 01:36 — forked from jmoiron/crawler.py
Simple gevent/httplib2 web crawler.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple async crawler/callback queue based on gevent."""
import traceback
import logging
import httplib2
import gevent
function fish_prompt --description Based\ on\ \'Simple\ Pythonista\',\ displays\ GIT\ and\ Job\ count\ info\ as\ well.
set_color yellow
printf '%s' (whoami)
set_color normal
printf ' at '
set_color magenta
printf '%s' (hostname|cut -d . -f 1)
set_color normal
printf ' in '
function fish_greeting --description "Greet the user with the shell's version, and a complementary colorful cow."
set_color --bold; fish -v; set_color normal
set cows cowsay\ {-b,-d,-g,-p,-s,t,-w,-y}
set chosen_cow_index (math (random)%8+1)
set chosen_cow $cows[$chosen_cow_index]
fortune -a -s | eval $chosen_cow | lolcat
end
@edcrypt
edcrypt / init.el
Last active December 11, 2015 16:10
Display a fortune, with commented lines, on the scratch buffer
;; Fortune on scratch buffer
;; Add this to your ~/.emacs.d/init.el
(require 'fortune)
(setq fortune-dir "/usr/local/Cellar/fortune/9708/share/games/fortunes/")
(setq fortune-file "/usr/local/Cellar/fortune/9708/share/games/fortunes/")
(setq fortune-program "/usr/local/bin/fortune")
;; next two funcs from http://datko.net/2013/07/08/slight-enhancement-to-fortune-el/
(defun fortune-message (&optional file)
"Display a fortune cookie to the mini-buffer.
@edcrypt
edcrypt / nav-keys.el
Last active February 1, 2016 01:26
Right-hand cursor movement on the homerow (better than Vi-style)
;; funcs from http://www.emacswiki.org/emacs/OpenNextLine
;; Textmate Shift+Enter
(global-set-key [S-return] 'ed/open-next-line)
(global-set-key [C-S-return] 'ed/open-previous-line)
;; Map cursor movement keys to right hand's homerow, WASD-style
;; C-n, C-p, C-f, C-b, M-f and M-b still works
;; see my .Xmodmap gist
(global-set-key (kbd "H-i") 'previous-line)
(global-set-key (kbd "H-j") 'backward-char)
@edcrypt
edcrypt / .Xmodmap
Created February 1, 2016 01:24
Turn capslock in ctrl, ctrl into HYPER
clear lock
clear control
clear mod1
clear mod2
clear mod3
clear mod4
clear mod5
keycode 37 = Hyper_L
keycode 66 = Control_L
add control = Control_L Control_R

Keybase proof

I hereby claim:

  • I am edcrypt on github.
  • I am edcrypt (https://keybase.io/edcrypt) on keybase.
  • I have a public key whose fingerprint is AFBA B812 9AAB 1D6E F8E4 3120 718C 6D87 7DF2 FAD6

To claim this, I am signing this object:

@edcrypt
edcrypt / io_examples.io
Last active August 12, 2016 23:23 — forked from jezen/Io Example Problems
The example problems have gone missing from the Io language website, so here’s a backup.
#Sample code
#Hello world
"Hello world!" print
#Factorial
factorial := method(n, if(n == 1, 1, n * factorial(n - 1)))
99 bottles of beer
# There are a dozen ways to implement the Prototype/Properties Pattern in Python.
#
# You could use copy.copy(), or program with classes and classmethods only.
# for example.
#
# But if you want to use an existing library in this style, and don't want to loose
# Python's flexibility (multiple inheritance, etc) I believe this solution works best.
#
# Prototypes, in Pythonic terms, are objects that behave like instances and classes/types,
# unifying instantiation and inheritance. So the most obvious solution, even if wasteful,
import pykka
class Prototype(pykka.ThreadingActor):
def __init__(self, *args, **kw):
import treedict
self.properties = treedict.TreeDict()
self.properties.pykka_traversable = True
super().__init__(*args, **kw)
def clone(self):
new_obj = Prototype.start().proxy()
new_obj.properties.attach(self.properties, copy=False).get()