Skip to content

Instantly share code, notes, and snippets.

View headsrooms's full-sized avatar
🦊

Pablo Cabezas headsrooms

🦊
  • SNGULAR
  • Madrid
  • 11:58 (UTC +02:00)
View GitHub Profile
@nik-hil
nik-hil / fabric deployment script
Created November 24, 2015 10:11
Fabric Script to deploy code on django+uwsgi+nginx on aws server
from __future__ import with_statement
from fabvenv import virtualenv
from fabric.api import *
from fabric.contrib.console import confirm
# http://stackoverflow.com/questions/1180411/activate-a-virtualenv-via-fabric-as-deploy-user
# http://stackoverflow.com/questions/30964502/python-fabric-nested-roles
@macournoyer
macournoyer / Output
Last active January 9, 2023 15:12
A Neural Network framework in 25 LOC
$ python xor.py
Training:
Epoch 0 MSE: 1.765
Epoch 100 MSE: 0.015
Epoch 200 MSE: 0.005
* Target MSE reached *
Evaluating:
1 XOR 0 = 1 ( 0.904) Error: 0.096
0 XOR 1 = 1 ( 0.908) Error: 0.092
1 XOR 1 = 0 (-0.008) Error: 0.008
@justanr
justanr / _core.py
Last active September 10, 2024 19:53
Clean Architecture In Python
from abc import ABC, ABCMeta, abstractmethod
from collections import namedtuple
from itertools import count
PayloadFactory = namedtuple('PayloadFactory', [
'good', 'created', 'queued', 'unchanged', 'requires_auth',
'permission_denied', 'not_found', 'invalid', 'error'
])
"""
@treyhunner
treyhunner / time_dict_merge.py
Last active November 3, 2023 08:13
Test performance of different dictionary merging functions in Python
"""
Results:
multiple_update: 33 ms
copy_and_update: 27 ms
dict_constructor: 29 ms
kwargs_hack: 33 ms
dict_comprehension: 33 ms
concatenate_items: 81 ms
union_items: 81 ms
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Integralist
Integralist / Python Asyncio Timing Decorator.py
Last active December 30, 2024 22:10
Python Asyncio Timing Decorator
import asyncio
import time
def timeit(func):
async def process(func, *args, **params):
if asyncio.iscoroutinefunction(func):
print('this function is a coroutine: {}'.format(func.__name__))
return await func(*args, **params)
else:
@ekiara
ekiara / django-getting-a-model-from-a-string.md
Last active August 13, 2024 07:49
django-getting-a-model-from-a-string
@roadsideseb
roadsideseb / async_schedule.py
Last active August 11, 2022 09:49
A slightly modified version of the 'schedule' Python package that works with asyncio 😎
import emoji
import schedule
import asyncio
import inspect
from datetime import datetime
class Job(schedule.Job):
@Eucrow
Eucrow / pyenv_python_django_gunicorn_circus_nginx.md
Last active August 7, 2022 15:01
pyenv + python + django + gunicorn + circus + nginx in ubuntu 16.04

pyenv + python + django + gunicorn + circus + nginx in ubuntu 16.04

Install dependencies (TODO: check dependencies)

sudo apt-get install -y postgresql-9.5 postgresql-contrib-9.5 postgresql-server-dev-9.5 nginx git circus make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils python-setuptools

Users

Create user for the app

sudo adduser app
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.