Skip to content

Instantly share code, notes, and snippets.

@rcarmo
rcarmo / Bottle and REST
Created December 4, 2012 16:46
api_users.py
#!/usr/bin/env python
# encoding: utf-8
import os, sys, logging, json
log = logging.getLogger()
from bottle import route, get, put, post, delete, request, response, abort
import api
from models.users import Users
@rcarmo
rcarmo / socks.py
Created November 19, 2012 22:42 — forked from e000/socks.py
socksipy + urllib2 handler
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
@rcarmo
rcarmo / gist:3342087
Created August 13, 2012 15:50
2012-08-13 CM10 encore steps
@rcarmo
rcarmo / build.sh
Created July 19, 2012 16:08
dbcm's Qt5 brew
#!/bin/sh
# install cross-compiler
# sudo apt-get install gcc-arm-linux-gnueabihf
# cd ~/Development
# git clone git://gitorious.org/qt/qt5.git qt5
apt-get update
apt-get install "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev \
@rcarmo
rcarmo / Generic_pt.kcm
Created July 13, 2012 16:40
Android Portuguese Keymap
# Copyright (C) 2010 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@rcarmo
rcarmo / sample.php
Created March 30, 2012 10:33
Naïve image color sampling
<?php
function get_color_palette($name, $count = 8) {
$fmap = array(
'gif' => 'imagecreatefromgif',
'png' => 'imagecreatefrompng',
'jpg' => 'imagecreatefromjpg',
'jpeg' => 'imagecreatefromjpg'
);
$path = pathinfo($name);
@rcarmo
rcarmo / Tweet.scpt
Created March 14, 2012 15:04
Tweet the current playing track in iTunes, complete with Grooveshark URL (use as Quicksilver trigger)
-- get properties of the playing track
tell application "iTunes"
set thisTrack to current track
set trackAlbum to the album of thisTrack
set trackYear to the year of thisTrack
set trackName to the name of thisTrack
set trackArtist to the artist of thisTrack
end tell
--
-- change the status message to your liking here:
@rcarmo
rcarmo / wasabi.php
Created February 8, 2012 15:01
O Tal Canal
<?php
echo "<pre>
Adoro a tua luz, a tua cor, o teu sinal
Mas o que mais adoro em ti é o Tal Canal
Adoro a tua voz, a tua escrita, a tua oral
Mas o que mais adoro em ti é o Tal Canal
Adoro o teu olhar, teu gaguejar, teu ar fatal
Mas o que mais adoro em ti é o Tal Canal
Adoro a tua grelha, a tua taxa, o teu jornal
@rcarmo
rcarmo / ansistrm.py
Created January 12, 2012 23:24 — forked from vsajip/ansistrm.py
Python logging: colourising terminal output
#
# Copyright (C) 2010, 2011 Vinay Sajip. All rights reserved.
#
import logging
import os
class ColorizingStreamHandler(logging.StreamHandler):
# color names to indices
color_map = {
'black': 0,
@rcarmo
rcarmo / webkit-fs.py
Created September 20, 2011 16:48
Fullscreen webkit or PDF windows across any number of displays
from Quartz import *
from AppKit import *
from Foundation import *
import WebKit
import objc
import time
windows = {}
views = {}