Skip to content

Instantly share code, notes, and snippets.

View jordic's full-sized avatar
🐛
python

Jordi Collell jordic

🐛
python
  • https://tmpo.io
  • Barcelona, ES
View GitHub Profile
@jordic
jordic / MAkefile
Created November 24, 2016 11:57
Debug NG Build
ramfs:
rm -r tmp
mkdir tmp
sudo mount -t tmpfs -o size=512m tmpfs ./tmp
clean:
rm -r tmp/*
rm dist/build.js
@jordic
jordic / ssh.go
Created May 27, 2014 14:03
golang mysql throught a tunnel
package main
// based on gist
// https://gist.github.com/ir4y/11146415
// http://stackoverflow.com/questions/21417223/simple-ssh-port-forward-in-golang
// obro conexio ssh amb el server remot.
// tot el que envio al port local ho copio al port remote
// a traves de la conexio remota. Per tant he d'obrir un
// port a la maquina remota?
@jordic
jordic / index.py
Created December 6, 2020 20:33
guillotina asgi server side python render with zpt
from . import templates
from guillotina.entrypoint import app as guillo
from starlette.applications import Starlette
from starlette.responses import PlainTextResponse
from starlette.responses import JSONResponse
from guillotina.component import get_utility
from guillotina.interfaces import IApplication
from guillotina.utils.content import get_database
from guillotina.utils.content import navigate_to
from guillotina import task_vars
@jordic
jordic / arpc.py
Created September 13, 2020 19:55
asgi rpc proto
from functools import partial
from imaplib import Int2AP
from starlette.responses import JSONResponse
from starlette.applications import Starlette
from starlette.routing import Route
import httpx
import json
import pydantic as pd
import random
@jordic
jordic / Dockerfile
Created October 25, 2020 06:58
CatotronCPU
FROM python:3.7.3
# based on a git clone from https://github.com/CollectivaT-dev/catotron-cpu
# plus embedding voices.
# also fixed requirements.txt
# -matplotlib==2.1.0
# +numba==0.48
# +matplotlib==3.3.2
# numpy==1.18.0
# inflect==0.2.5
import textwrap
sql = textwrap.dedent("""
SELECT t1.field1,
t2.field2,
t3.field3
FROM table1 t1
INNER JOIN table2 t2 using(id_relation)
WHERE t1.pk = $1
""")
@jordic
jordic / gist_gitadd
Created July 26, 2012 11:12
Bash function git add & commit and push to server
ga () {
git add .
git commit -am "$*"
git push origin master
}
@jordic
jordic / snippets.jsx
Created December 5, 2019 08:53
React
const MyFunctionnalComponent: React.FC = props => {
useEffect(() => {
// Using an IIFE
(async function anyNameFunction() {
await loadContent();
})();
}, []);
return <div></div>;
docker run --rm -e 'TESTING=jenkins' -e 'DATABASE=postgres' -v /var/run/docker.sock:/var/run/docker.sock checkout:PR-173.1 'py.test checkout/tests/ -x -s -v'
Traceback (most recent call last):
File "/usr/local/bin/py.test", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py", line 61, in main
config = _prepareconfig(args, plugins)
File "/usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py", line 182, in _prepareconfig
config = get_config()
File "/usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py", line 156, in get_config
pluginmanager.import_plugin(spec)
@jordic
jordic / modeladmin_changelist.py
Last active September 12, 2019 14:07
ModelAdmin + Changelist as ClassBased views
'''
Class Based changelist, composition
'''
class MisOfertas(ModelAdmin):
list_display = ( 'get_estado', 'nombre', 'origen_', 'destino_', 'owner_',
'caducidad', 'editar', 'borrar')
list_filter = ( 'status', CargadorFilter, OrigenFilter, DestinoFilter )
search_fields = ( 'nombre', 'owner__business_name', 'owner__comercial_name',