Skip to content

Instantly share code, notes, and snippets.

@rg3915
rg3915 / nome_cap.md
Last active March 28, 2024 11:52
Colocar a primeira letra de cada palavra em maiúsculo, exceto em preposições 'da', 'de', 'di', 'do', 'du', 'para' ... - nome - pyladies - python

Tratar nomes com preposições

PyLadiesSP

Objetivo: colocar a primeira letra de cada palavra em maiúsculo, exceto em preposições 'da', 'de', 'di', 'do', 'du', 'para' ...

Texto: minicurso de python para mulheres

Resultado esperado: Minicurso de Python para Mulheres

anonymous
anonymous / gist:c3bdbd8402f318c70694
Created November 24, 2015 18:20
def test_login_page(self):
"""
Test Login Page
"""
response = self.client.get(reverse("login"))
self.assertEqual(response.status_code, 200)
# Usuário não existe
response = self.client.post(reverse("login"), {'username': 'unknown', 'password': 'doesnotexist'})
@jsheedy
jsheedy / iter_file.py
Last active June 16, 2024 15:27
Sometimes you need a file-like object when all you have is an iterator, for instance when using psycopg2's cursor.copy_from. This class will handle the impedance mismatch.
import io
import sys
class IteratorFile(io.TextIOBase):
""" given an iterator which yields strings,
return a file like object for reading those strings """
def __init__(self, it):
self._it = it
self._f = io.StringIO()
@miku
miku / Makefile
Last active September 10, 2021 20:53
Multiple outputs workaround luigi.
all:
python main.py ProcessFiles --local-scheduler
clean:
rm -rf tmp/ zip.filelist.*
@nbremer
nbremer / README.md
Last active May 28, 2024 08:30
Circle Packing at its most Basic - Canvas & D3.js

This is the first step of my first attempt to learn canvas. I want to improve a piece a made a few weeks ago about the division of occupations. The d3.js version has so many DOM elements due to all the small bar charts that it is very slow. Therefore, I hope that a canvas version might improve things.

In this block I create a static circle pack layout that still uses a lot of D3 code, but eventually it is the canvas that draws it to the screen

I wrote a more extensive tutorial around what I learned while doing this project in my blog Learnings from a D3.js addict on starting with Canvas in which this can be seen as step 1. See the next version that has less D3 but less overall code as well

If you want to see the final result, with everything up and running in canvas look [here](http://www.visualcinnamon.com/occupation

@dabeaz
dabeaz / aecho.py
Last active October 17, 2023 03:26
Live-coded examples from my PyCon Brasil 2015 Keynote
# aecho.py
from socket import *
import asyncio
loop = asyncio.get_event_loop()
async def echo_server(address):
sock = socket(AF_INET, SOCK_STREAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
@jniltinho
jniltinho / send_mail.py
Last active November 23, 2015 15:52
Send Mail plugin for Nagios
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Script Send Mail Nagios (send_mail.py)
Copyrighted by Nilton OS <jniltinho at gmail.com>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
Version: 0.1
Put this script in Nagios plugins folder
@andrefreitas
andrefreitas / docker-compose.yml
Last active October 8, 2016 02:41
sentry docker-compose
redis:
image: redis
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=sentry
- POSTGRES_USER=sentry
volumes:
- /var/lib/postgresql/data
@victorfsf
victorfsf / awscli.md
Last active June 12, 2017 14:44
Downloading and uploading from/to a S3 Bucket using AWS CLI

Installing & Configuring

$ sudo pip install awscli (or: sudo apt-get install awscli)
$ aws configure

You'll need to fill the following settings: