Skip to content

Instantly share code, notes, and snippets.

View hcarvalhoalves's full-sized avatar

Henrique Carvalho Alves hcarvalhoalves

View GitHub Profile
@hcarvalhoalves
hcarvalhoalves / iterm.sh
Created March 17, 2017 02:43
Shell functions to command iTerm2 via AppleScript
#!/bin/env bash
function tt() {
osascript &>/dev/null <<EOF
tell application "iTerm2"
tell current window
create tab with default profile command "$@"
end tell
end tell
EOF
import sys
import os
from pdb import Pdb
banner = """Usage:
%(command)s @<module>:<linenumber> ... <filename> <args>
Use @<module>:<linenumber> to set one or multiple breakpoints.
<module> may be an absolute path to a module file, or relative to sys.path.
@hcarvalhoalves
hcarvalhoalves / oblique.sh
Last active January 3, 2017 01:04
Oblique strategies tip of the day
#!/usr/bin/env bash
# From: https://en.wikipedia.org/wiki/Oblique_Strategies
strategies=(
"(Organic) machinery"
"A line has two sides"
"A very small object Its center"
"Abandon desire"
"Abandon normal instructions"
// Uses https://github.com/krasimir/EventBus
var app = (function (document, bus) {
function appInit(event, appstate) {
var response = prompt("Foo?");
if (response == "foo") {
bus.dispatch("render", this, {"status": "ok"});
} else {
bus.dispatch("render", this, {"status": "errou-mane"});
from scipy.spatial.distance import euclidean
import numpy as np
from __future__ import division
def periodic_distance(a, b, period=12):
"""
Euclidean distance w/ periodic boundaries.
>>> A = np.array([1, 12, 1])
>>> B = np.array([12, 1, 1])
$ tail -f /var/log/celery/live-celeryd.log
[2014-01-09 17:24:59,335: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-2288.xml
[2014-01-09 17:24:59,339: INFO/MainProcess] Generating OLX feed for negociaoimoveis.com.br...
[2014-01-09 17:25:00,207: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-2788.xml
[2014-01-09 17:25:00,210: INFO/MainProcess] Generating OLX feed for insigniaci.com.br...
[2014-01-09 17:25:02,054: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-3418.xml
[2014-01-09 17:25:02,057: INFO/MainProcess] Generating OLX feed for imoveisbaixada.com.br...
[2014-01-09 17:25:03,385: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-4174.xml
[2014-01-09 17:25:03,389: INFO/MainProcess] Generating OLX feed for mundialimoveis.net.br...
[2014-01-09 17:25:11,698: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-3354.xml
>>> from colibri.feeds.tasks import generate_olx_feed_task
>>> generate_olx_feed_task()
[09/Jan/2014 16:20:22] INFO Generating OLX feed for angelaalvesimoveis.com.br...
[09/Jan/2014 16:20:27] INFO Saved OLX feed at /Users/hcarvalhoalves/Projetos/colibri/media/cache/feeds/4086.xml
[09/Jan/2014 16:20:27] INFO Generating OLX feed for brewimoveis.com.br...
[09/Jan/2014 16:20:30] INFO Saved OLX feed at /Users/hcarvalhoalves/Projetos/colibri/media/cache/feeds/2944.xml
[09/Jan/2014 16:20:30] INFO Generating OLX feed for bomimoveis.com.br...
[09/Jan/2014 16:20:42] INFO Saved OLX feed at /Users/hcarvalhoalves/Projetos/colibri/media/cache/feeds/3409.xml
[09/Jan/2014 16:20:42] INFO Generating OLX feed for flavioelecyimoveis.com.br...
[09/Jan/2014 16:20:45] INFO Saved OLX feed at /Users/hcarvalhoalves/Projetos/colibri/media/cache/feeds/1446.xml
>>> def wat(obj):
... sys.stdout.write("WAT")
...
>>> sys.displayhook = wat
>>> "I broke the REPL"
WAT>>>
class Player
def initialize
@max_health = 20
@last_health = @max_health
@taking_damage = false
@directions = [:backward, :forward]
@current_direction = :forward
@reached_wall = false
end
from unicodedata import normalize, category
def unaccent(s):
return unicode(
filter(
lambda c: category(c) != 'Mn',
normalize('NFKD', s.decode('utf-8'))
)
).encode('utf-8')