Skip to content

Instantly share code, notes, and snippets.

View swrh's full-sized avatar
🏠
Working from home

Fernando Silveira swrh

🏠
Working from home
View GitHub Profile
@joshbalfour
joshbalfour / rds-global-database-cluster.ts
Last active February 7, 2024 16:47
RDS Global Database Cluster CDK example
import { DatabaseCluster, CfnGlobalCluster, DatabaseClusterProps, CfnDBCluster } from 'aws-cdk-lib/aws-rds'
import { Construct } from 'constructs'
export class GlobalDatabaseCluster extends DatabaseCluster {
public readonly globalCluster: CfnGlobalCluster
constructor(scope: Construct, id: string, props: DatabaseClusterProps) {
super(scope, id, props)
this.globalCluster = new CfnGlobalCluster(this, 'global-cluster', {
@fernandoaleman
fernandoaleman / fix-libv8-mac.txt
Created May 5, 2016 15:14
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
@fmasanori
fmasanori / QEduAvancada.py
Created June 28, 2015 15:57
QEdu Exemplo de Busca Avançada: escolas, em funcionamento, sem energia, água e esgoto
import urllib.request
import json
url = 'http://educacao.dadosabertosbr.com/api/escolas/buscaavancada?situacaoFuncionamento=1&energiaInexistente=on&aguaInexistente=on&esgotoInexistente=on'
resp = urllib.request.urlopen(url).read()
resp = json.loads(resp.decode('utf-8'))
print ('Número de Escolas em funcionamento sem energia, água e esgoto:', resp[0])
for x in resp[1]:
print (x['nome'], x['cod'])
print (x['cidade'], x['estado'], x['regiao'])
print ()
@fmasanori
fmasanori / QEduEscolas.py
Created June 28, 2015 15:54
QEdu Busca Simples por Escolas
import urllib.request
import json
url = 'http://educacao.dadosabertosbr.com/api/escolas?nome='
escola = 'embraer'
resp = urllib.request.urlopen(url+escola).read()
resp = json.loads(resp.decode('utf-8'))
for x in resp[1]:
print (x['nome'])
print ('Código:', x['cod'])
print (x['cidade'], x['estado'])
@pankajp
pankajp / serve_http.py
Last active September 10, 2024 19:52
Simple Python HTTP Server with multi-threading and partial-content support
#! /usr/bin/env python
# Standard library imports.
from SocketServer import ThreadingMixIn
import BaseHTTPServer
import SimpleHTTPServer
import sys
import json
import os
from os.path import (join, exists, dirname, abspath, isabs, sep, walk, splitext,
@vogonistic
vogonistic / repl_bot.js
Created January 25, 2013 04:15
REPL example bot for mineflayer. Allows testing javascript over CLI to speed up development.
// REPL example bot for mineflayer
//
// Connects to server but doesn't have any built in logic. The terminal where
// it was started is now a REPL (Read-Eval-Print-Loop). Anything typed will be
// interpreted as javascript printed using util.inspect. Don't forget to try
// tab completion. These variables are exposed as local:
//
// var mineflayer = require('mineflayer');
// var bot = mineflayer.createBot({ username: 'REPL' });
//
@jamescasbon
jamescasbon / template.py
Created December 11, 2011 16:37
Pure python templates using with statement
"""
A really stupid python template language inspired by coffeekup, markaby.
Do not use this code, it will ruin your day. A byproduct of insomnia.
TL;DR
-----
This module defines a template language that allows us to do:
d = Doc()