Skip to content

Instantly share code, notes, and snippets.

@foota
foota / tetration.py
Created May 13, 2012 15:57
Tetration fractal (Python)
#!/usr/bin/env python
import sys, os, math, time
from PIL import Image
def tetration(l, t, w, h, sw, sh, mit):
data = []
for ky in range(sh):
for kx in range(sw):
x = l + w * kx / (sw - 1)
@letanure
letanure / estados-cidades.json
Last active May 16, 2025 17:00
JSON estados cidades do brasil, dividido por estados. segunda lista atualizada em 2020, dados do IBGE
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@impressiver
impressiver / raven-config.html
Last active October 26, 2024 15:03
Raven.js configuration for logging JavaScript exceptions to Sentry (https://getsentry.com/). Without the added ignore options, you'll quickly find yourself swamped with unactionable exceptions due to shoddy browser plugins and 3rd party script errors.
<!-- Raven.js Config -->
<script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script>
<script type="text/javascript">
// Ignore list based off: https://gist.github.com/1878283
var ravenOptions = {
// Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion.
// See: https://github.com/getsentry/raven-js/issues/73
ignoreErrors: [
// Random plugins/extensions
'top.GLOBALS',
#!/usr/bin/env python
"""
Auto Cookie Clicker by foota, 2013.09.21
ref. http://orteil.dashnet.org/cookieclicker/
"""
import sys, os, time, threading
from pymouse import PyMouse
import ImageGrab
#!/bin/bash
baseDirs=( /d/Git/ /d/Projects/ )
let i=1
echo
echo "Pulling git repositories..."
echo
for baseDir in "${baseDirs[@]}"; do
cd $baseDir
echo "$((i++)) - Base directory '$baseDir'"
@alexfu
alexfu / DividerItemDecoration.java
Last active February 9, 2023 05:09
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 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
@cassiozen
cassiozen / NeuralNetwork.lua
Created July 17, 2014 20:05
Lua Neural Network
ACTIVATION_RESPONSE = 1
NeuralNetwork = {
transfer = function( x) return 1 / (1 + math.exp(-x / ACTIVATION_RESPONSE)) end --This is the Transfer function (in this case a sigmoid)
}
@alexandre
alexandre / virtualenv.md
Last active August 26, 2016 18:18
Apenas uma receita de bolo para utilizar virtualenvwrapper em uma distribuição GNU/Linux...

Por que usar?

Com o virtualenv, nós temos um ambiente isolado para cada projeto. E com isso, podemos ter diversas versões diferentes, seja do Python ou do pacote (e.g. Flask). E você precisa instalar o virtualenv apenas para uma versão do Python, já que pode especificar qual versão o seu projeto (ambiente virtual) utilizará. =]

Mas por que o virtualenvwrapper?

Ele facilita bastante tanto a criação quando o acesso ao seu projeto:

  • Ao criar o projeto ele já ativa o seu ambiente virtual;
  • A função workon facilita bastante para acessar o seu "venv" de qualquer diretório
@alexandre
alexandre / word_counter.py
Last active August 29, 2015 14:08
word counter
from itertools import groupby
def word_counter(*words):
'''Write a Python program that inputs a list of words, separated by white-
space, and outputs how many times each word appears in the list.
'''
return {word: len(list(word_group)) for word, word_group in
groupby(sorted(words), key=lambda x: x)}
┐┌┐┌┐
┘└┘└┘\ₒ/
┐┌┐┌┐ ∕ Friday
┘└┘└┘ノ)
┐┌┐┌┐ deploy,
┘└┘└┘
┐┌┐┌┐ good
┘└┘└┘
┐┌┐┌┐ luck!
│││││