Skip to content

Instantly share code, notes, and snippets.

View ramalho's full-sized avatar
🚄
operador de trem

Luciano Ramalho ramalho

🚄
operador de trem
View GitHub Profile
@ramalho
ramalho / objetojs.py
Last active August 29, 2015 14:21
ObjetoJS: emulação básica de um objeto JavaScript
"""
=========================================================
Classe ObjetoJS: imitação simples de um objeto JavaScript
=========================================================
Uma instância é construída passando argumentos nomeados:
>>> o = ObjetoJS(z=33, x=11, y=22)
A representação textual de uma instância parece a chamada do
def backtracking_sort(input_list, output_list, level):
print(level * ' ', input_list, output_list);
# Reject - this path doesn't lead to any solution
if len(output_list) > 1 and output_list[-2] > output_list[-1]:
return False
# Accept - one solution
@ramalho
ramalho / simple_exception_example.py
Created September 7, 2015 21:29
Simple exception example
while True:
response = input('Enter a number: ')
try:
n = float(response)
except ValueError:
print('%r is not a number' % response)
else:
break
print('Nice number. Thanks!')
@ramalho
ramalho / file_exception.py
Last active September 7, 2015 21:51
Simple file handling exception example
while True:
filename = input('Enter the name of a file to open: ')
try:
# open for reading in binary mode, so any file will do
fin = open(filename, 'rb')
except OSError as exc:
print('Something untoward happened [%r]' % exc)
else:
break
https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=16&size=600x300&maptype=hybrid&key=AIzaSyApIx-jA9MblvDcvwBB3VxzKhGEWwLsY1k
@ramalho
ramalho / genius.py
Created October 22, 2015 21:03
Genius clone on Raspberry Pi with Pingo.io, edited live on Midori
import time
import random
import pingo
import itertools
rpi = pingo.detect.get_board()
class Buzzer(object):

Keybase proof

I hereby claim:

  • I am ramalho on github.
  • I am ramalho (https://keybase.io/ramalho) on keybase.
  • I have a public key whose fingerprint is CAF0 10C6 5EED B222 EB8B 044A D284 12E9 7687 D71E

To claim this, I am signing this object:

@ramalho
ramalho / RethinkDB-why-we-failed.md
Created January 19, 2017 14:46
RethinkDB: why we failed
layout title
post
RethinkDB: why we failed

Posted on Github by Slava Akhmechet

When we [announced][shutdown-announcement] that RethinkDB is shutting down, I promised to write a post-mortem. I took some time to process the experience, and I can now write about it clearly.

@ramalho
ramalho / gnome-version.py
Last active May 1, 2017 01:29
Simple script to display Gnome 3 version
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
tags = 'platform minor micro'.split()
doc = ET.parse('/usr/share/gnome/gnome-version.xml')
print('.'.join(doc.find(tag).text for tag in tags))
@ramalho
ramalho / pense-como-pythonista.html
Created July 22, 2017 16:51
Pense como uma pythonista
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>Pense como uma pythonista</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
/*!
*
* Twitter Bootstrap