Skip to content

Instantly share code, notes, and snippets.

View jose-lpa's full-sized avatar

José L. Patiño Andrés jose-lpa

View GitHub Profile
@patrickmmartin
patrickmmartin / PYTHON_DEFAULT.md
Created February 5, 2017 09:48
update-alternatives for python3 on Ubuntu

Ubuntu 16 default python is almost python 3

Loads of solutions exist, but for changing the system default, alias is not the way to go.

$ update-alternatives --list python update-alternatives: error: no alternatives for python

@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@marians
marians / CouchDB_Python.md
Last active May 21, 2024 20:53
The missing Python couchdb tutorial

This is an unofficial manual for the couchdb Python module I wish I had had.

Installation

pip install couchdb

Importing the module

@kissgyorgy
kissgyorgy / sqlalchemy_conftest.py
Last active May 6, 2024 08:06
Python: py.test fixture for SQLAlchemy test in a transaction, create tables only once!
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from myapp.models import BaseModel
import pytest
@pytest.fixture(scope="session")
def engine():
return create_engine("postgresql://localhost/test_database")
@NotSqrt
NotSqrt / settings_test_snippet.py
Last active May 1, 2022 01:34 — forked from nealtodd/settings_test_snippet.py
Another shot at this problem ..
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return "notmigrations"
MIGRATION_MODULES = DisableMigrations()
@ricardo-rossi
ricardo-rossi / ElasticSearch.sh
Last active December 1, 2023 04:55
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@premit
premit / imdb_next_page_spider.py
Created July 23, 2014 14:14
Scrapy reference: Crawling next pagination
'''
Spider for IMDb
- Retrieve most popular movies & TV series with rating of 8.0 and above
- Crawl next pages recursively
'''
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet
@alb-i986
alb-i986 / base.conf
Last active December 18, 2015 02:19
uWSGI conf for Django apps with virtualenv. Designed for uWSGI Emperor, for a multi-app hosting server, with separate Dev/Test/Prod machines. Following the DRY principle, the directives are split in 3 files: - /etc/uwsgi/templates/base.conf - /etc/uwsgi/templates/include/vars.ini - /etc/uwsgi/templates/include/vars_shared.ini Then, in /etc/uwsgi…
[uwsgi]
proj_name = %n
# load variables
ini = /var/local/django/%n/uwsgi/vars.ini
ini = /etc/uwsgi/templates/include/vars.ini
ini = /etc/uwsgi/templates/include/vars-shared.ini
@crmccreary
crmccreary / AESCipher.py
Created May 20, 2013 02:17
Encryption using pycrypto, AES, and PKCS5 padding
from Crypto.Cipher import AES
from Crypto import Random
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
class AESCipher:
def __init__( self, key ):
"""