Skip to content

Instantly share code, notes, and snippets.

View pedrocicoleme's full-sized avatar

Pedro Leme pedrocicoleme

  • Sao Paulo - BR
View GitHub Profile
@aklos
aklos / default_filtering.py
Created January 5, 2016 15:49
Flask SQLAlchemy default model filters
# Example model
class User(Base):
__tablename__ = 'user'
@classmethod
def _base_filters(self, obj):
# Add this method to your model if you want base filtering, otherwise leave it out
# import and_ from sqlalchemy package
# this is a base filter for ALL queries
return and_(
@xiyoulaoyuanjia
xiyoulaoyuanjia / request.py
Created October 9, 2015 14:26
Timeout for python requests.get entire response
import requests
import eventlet
eventlet.monkey_patch()
with eventlet.Timeout(10):
requests.get("http://ipv4.download.thinkbroadband.com/1GB.zip", verify=False)
##### r = requests.get("get("http://ipv4.download.thinkbroadband.c", verify=False, timeout=10)
@jarutis
jarutis / ubuntu.sh
Last active November 9, 2020 09:01
Theano and Keras setup on ubuntu with OpenCL on AMD card
## install Catalyst proprietary
sudo ntfsfix /dev/sda2
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK
sudo apt-get remove --purge fglrx*
sudo apt-get install linux-headers-generic
sudo apt-get install fglrx xvba-va-driver libva-glx1 libva-egl1 vainfo
sudo amdconfig --initial
## install build essentials
sudo apt-get install cmake
@fredyr
fredyr / flatfile.clj
Last active August 9, 2019 16:15
Parsing flat files in Clojure
;; Code for blog article at
;; http://www.lexicallyscoped.com/2015/01/05/parsing-flat-files-in-clojure.html
(ns flatfile.core
(:use [clojure.java.io])
(:import [java.io PushbackReader]))
(defn load-rulebook [file]
(with-open [r (reader file)]
(read (PushbackReader. r))))
@john2x
john2x / 00_destructuring.md
Last active November 21, 2025 02:39
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@staltz
staltz / introrx.md
Last active January 23, 2026 10:31
The introduction to Reactive Programming you've been missing
@acturcato
acturcato / ACT_HT6P20B_RX-04.ino
Last active December 24, 2023 22:35
Since the data previously encrypted using the encoder HT6P20B. The main idea of this sketch is to decode the values ​​received via an RF receiver module connected to Arduino. For more details, access: http://acturcato.wordpress.com/2014/01/04/decoder-for-ht6p20b-encoder-on-arduino-board-english/
/*
TITLE: DECODER FOR HT6P20B ENCODER
CREATED BY: AFONSO CELSO TURCATO
DATE: 18/JUN/2014
E-MAIL: acturcato (at) gmail.com
LICENSE: GPL
REV.: 04
DESCRIPTION:
http://acturcato.wordpress.com/2014/01/04/decoder-for-ht6p20b-encoder-on-arduino-board-english/
@ohpauleez
ohpauleez / sample.clj
Last active January 25, 2017 19:33
The Leap Motion example code using the clojure-leap library
(ns sample
(:require [clojure-leap.core :as leap]
[clojure-leap.hand :as l-hand]
[clojure-leap.pointable :as l-pointable :refer [tip-position]]))
(defn process-frame [frame]
(let [_ (println "Frame id:" (.id frame) "timestamp:" (.timestamp frame)
"hands:" (leap/hands frame) "fingers:" (leap/fingers frame) "tools:" (leap/tools frame))]
(when-let [hand (and (leap/hands? frame) (leap/hand frame 0))]
(let [fingers (leap/fingers hand)
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active January 20, 2026 18:03
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@bowsersenior
bowsersenior / stooge_loader.rb
Created May 18, 2011 23:18
A demo of YAML anchors, references and nested values
require 'rubygems'
require 'yaml'
# A demonstration of YAML anchors, references and handling of nested values
# For more info, see:
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/
stooges = YAML::load( File.read('stooges.yml') )
# => {
# "default" => {