Skip to content

Instantly share code, notes, and snippets.

View jfunez's full-sized avatar

Juan Funez jfunez

  • iib-institut.de
  • Berlin, Germany
View GitHub Profile
@bessarabov
bessarabov / gist:674ea13c77fc8128f24b5e3f53b7f094
Last active March 27, 2024 07:46
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
@pydanny
pydanny / django_local_settings.py
Last active December 12, 2018 12:31
running local unverified SSL on Django and Flask (don't do this in production!!!)
from .common import * # noqa
DEBUG = True
INSTALLED_APPS += ('django_extensions',)
# Snip all the other stuff
@mixxorz
mixxorz / services.py
Last active January 21, 2020 16:52
Django Service Objects
from django import forms
from django.core.exceptions import ValidationError
from django.db import transaction
class InvalidInputsError(Exception):
def __init__(self, errors, non_field_errors):
self.errors = errors
self.non_field_errors = non_field_errors
@rochacbruno
rochacbruno / Makefile
Last active June 22, 2022 23:35
Python Setup Tips and Tricks http://j.mp/setup_py
.PHONY: test install pep8 release clean
test: pep8
py.test --cov -l --tb=short --maxfail=1 program/
install:
python setup.py develop
pep8:
@flake8 program --ignore=F403 --exclude=junk
@rochacbruno
rochacbruno / mainpython.md
Last active July 22, 2024 19:03
Use of __main__.py

The use of __main__.py to create executables

myprojectfolder/
    |_ __main__.py
    |_ __init__.py

Being __main__.py:

print("Hello")

@leommoore
leommoore / mongodb_setting_up_a_replica_set.md
Last active December 8, 2021 09:58
MongoDB - Setting up a Replica Set

#MongoDB - Setting up a Replica Set

cd \mongodbdir\

mkdir db1
mkdir db2
mkdir db3

###Primary mongod --dbpath ./db1 --port 30000 --replSet "demo"

@audreyfeldroy
audreyfeldroy / pypi-release-checklist.md
Last active February 23, 2023 15:03
My PyPI Release Checklist
  • Update HISTORY.md
  • Commit the changes:
git add HISTORY.md
git commit -m "Changelog for upcoming release 0.1.1."
  • Update version number (can also be minor or major)
bumpversion patch
from apps.polidata.models import Politician
twitter_data = {
"00512": "@PepeSolari",
"00405": "@JAIMETROBO",
"05851": "@AlfredoAsti",
"00161": "@JuanRaFerreira",
"05262": "@dpayss1",
"05137": "@juliocesilveira",
"00197": "@Luisaheber",
@vmihailenco
vmihailenco / tastypie_logging.py
Created April 14, 2012 08:29
Logging mixin for Django tastypie
class LoggingMixin(object):
def dispatch(self, request_type, request, **kwargs):
logger.debug(
'%s %s %s' %
(request.method, request.get_full_path(), request.raw_post_data))
try:
response = super(LoggingMixin, self).dispatch(
request_type, request, **kwargs)
except (BadRequest, fields.ApiFieldError), e: