Skip to content

Instantly share code, notes, and snippets.

View rhcarvalho's full-sized avatar
🎥
Building something new

Rodolfo Carvalho rhcarvalho

🎥
Building something new
View GitHub Profile
@rhcarvalho
rhcarvalho / lang__reader.rkt
Created October 7, 2011 23:47
Creating a custom #lang language
#lang s-exp syntax/module-reader
(planet rodolfo/ratematica/language)
#:read ratematica-read
#:read-syntax ratematica-read-syntax
(require (prefix-in ratematica- "../parser.rkt"))
# 2012/03/11 Rodolfo Carvalho
# Small demo showing how two bots connected with the same JID
# (and different resources) can communicate using xmpppy
import xmpp
import random
from getpass import getpass
from time import sleep
from threading import Thread, Event
@rhcarvalho
rhcarvalho / summarize.rkt
Created May 24, 2012 19:52
Summarizing a sequence with Racket
#lang racket
;; Summarizes a sequence of things
(define (summarize seq)
(foldl -append-element '() seq))
(define (-append-element el lst)
(match lst
['()
@rhcarvalho
rhcarvalho / counters-with-countinuations.rkt
Created June 8, 2012 03:19
Experiment with persistent continuations
#lang racket
;; Experiment with persistent continuations
(require db)
;; read-char* : like read-char but ignores \r and \n
(define (read-char* [in (current-input-port)])
(let ([v (read-char in)])
(case v
[(#\newline #\return) (read-char* in)]
@rhcarvalho
rhcarvalho / notes.rst
Created July 15, 2012 23:55
MongoDB São Paulo - 13/07/2012

MongoDB São Paulo - 13/07/2012

1. Welcome Keynote - Paul Pedersen (10gen)

  • Different kinds of applications nowadays
  • Focus on solving new problems
  • We can store queries just like any other object (JSON)
  • Replication: vertical scaling x Sharding: horizontal scaling
@rhcarvalho
rhcarvalho / gist:3236931
Created August 2, 2012 13:06
MongoDB convering indexes
$ mongo
MongoDB shell version: 2.0.4
connecting to: test
> doc = {_id: 42, name: "propedeutica", power: 0.92}
{ "_id" : 42, "name" : "propedeutica", "power" : 0.92 }
> db.foobar.insert(doc)
> db.foobar.ensureIndex({name: 1})
> db.foobar.find({name: "propedeutica"}).explain()
{
"cursor" : "BtreeCursor name_1",
@rhcarvalho
rhcarvalho / sqlite_matchinfo.go
Created July 30, 2013 20:05
Retrieve `matchinfo` from FTS4 table on SQLite.
package main
import (
"bytes"
"database/sql"
"encoding/binary"
_ "github.com/mattn/go-sqlite3"
"log"
)
@rhcarvalho
rhcarvalho / README.md
Created March 3, 2014 15:57
Finding typos in Django

Usage

  1. Run collectwords.py with file paths as arguments to build a database of words.
  2. Run spellcheck.py to mark misspells.
  3. Use sqlite3 shell or anything else to output misspelled words to a file.
  4. Go through the file eliminating false positives.
  5. Search through the codebase and fix typo by typo :-)
@rhcarvalho
rhcarvalho / glue.py
Created February 8, 2015 17:01
Glueing together independent WSGI apps
import random
from django_demo.wsgi import application as django_app
from falcon_demo.hello import app as falcon_app
falcon_prefix = r'/falcon'
random_prefix = r'/random'
def random_app(environ, start_response):
return random.choice([falcon_app, django_app])(environ, start_response)
{
"id": "foobar",
"kind": "List",
"apiVersion": "v1beta3",
"name": "foobar",
"items": [
{
"apiVersion" : "v1beta3",
"kind": "Service",
"metadata" : {