Skip to content

Instantly share code, notes, and snippets.

View fchevitarese's full-sized avatar

Frederico Rodrigues Chevitarese fchevitarese

View GitHub Profile
@fchevitarese
fchevitarese / elefante.py
Last active February 20, 2017 13:14
Canta a musiquinha do elefante que incomoda muita gente.
"""Música do elefante.
Digite a quantidade de vezes que vai contar, preferencialmente um número par.
"""
elefantes = int(input('Digite quantos elefantes quer contar: '))
ini = '{0} {1} {2} muita gente!'
ini_plural = '{0} elefantes {1}muito mais!'
for i in range(0, elefantes + 1):
if i == 0:
Preparing environment :
--------------------------------------------------------------------------------
+ HEADS UP:
+ This is the first build for this project and will take longer than usual.
+ Future builds will pull from the cache and will be much faster.
--------------------------------------------------------------------------------
Building runtime :
@fchevitarese
fchevitarese / exception_handler.py
Created January 27, 2017 14:24
custom_exception_handler.py
# encoding: utf-8
def custom_exception_handler(job, exc_type, exc_value, traceback):
with open('test.log', 'rw') as f:
f.write(job)
f.write(exc_type)
f.write(exc_value)
f.write(traceback)
f.close()
@fchevitarese
fchevitarese / Untitled-1
Created January 11, 2017 11:40
indexView2.py
class indexView2(ListView):
queryset = Post.objects.order_by('-data')
template_name = "post_list.html"
paginate_by = 3
def form_valid(self, form):
# Faça sua lógica aqui
return super(DenunciaMixin, self).form_valid(form)
def get_context_data(self, **kwargs):
# Modelo A
class Modelo(model.Models):
user = models.ForeignKey('user.User')
# MODELO B
def other_function(instance):
modelos = Modelo.objects.filter(user=instance.client)
print(modelos)
@fchevitarese
fchevitarese / estados-cidades.json
Created September 1, 2016 01:59 — forked from letanure/estados-cidades.json
JSON estados cidades
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
simpleflow standalone --domain TestDomain examples.basic.BasicWorkflow --input '[1, 5. "meu texto"]'
2016-08-03T19:17:41 INFO [process=MainProcess, pid=20415]: using task list basic-b4cdf1cd38c949d48815f97af9a5e530
starting workflow examples.basic.BasicWorkflow
2016-08-03T19:17:41 INFO [process=Process-2, pid=20421]: starting <bound method ActivityPoller.start of <simpleflow.swf.process.worker.base.ActivityPoller object at 0x7fbcf678fdc0>>
2016-08-03T19:17:41 INFO [process=Process-1, pid=20420]: starting <bound method DeciderPoller.start of DeciderPoller(TestDomain, basic-b4cdf1cd38c949d48815f97af9a5e530, basic)>
2016-08-03T19:17:41 INFO [process=Process-2:1, pid=20423]: starting ActivityPoller(basic) on domain TestDomain
2016-08-03T19:17:41 INFO [process=Process-2:3, pid=20426]: starting ActivityPoller(basic) on domain TestDomain
2016-08-03T19:17:41 INFO [process=Process-2:2, pid=20425]: starting ActivityPoller(basic) on domain TestDomain
2016-08-03T19:17:41 INFO [process=Process-1:2, pid=20424]: starting De
@fchevitarese
fchevitarese / new_key.sh
Created July 30, 2016 00:10 — forked from Miserlou/new_key.sh
Generate a new Django SECRET_KEY
python -c 'import random; import string; print "".join([random.SystemRandom().choice(string.digits + string.letters + "!#$%&\()*+,-./:;<=>?@[]^_{|}~" ) for i in range(100)])'
@fchevitarese
fchevitarese / untitled
Created June 20, 2016 20:36
modelo.py
class Esporte(models.Model):
"""(Esporte description)"""
nome = models.CharField(blank=True, max_length=100)
sexo = models.CharField(blank=True, max_length=1, choices=['M', 'F'])
idade = models.IntegerField()
def __unicode__(self):
return u"Esporte"
@fchevitarese
fchevitarese / 0_reuse_code.js
Created May 3, 2016 16:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console