Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘
rockin'

Germán Larraín glarrain

🤘
rockin'
View GitHub Profile
@glarrain
glarrain / requirements.txt
Last active Apr 10, 2020
pip - install from GitHub repo
View requirements.txt
# For commits, prefer full hash
# https://pip.pypa.io/en/stable/reference/pip_install/#git
-e git+ssh://git@github.com/fyntex/lib-cl-sii-python.git@995af20f289c41c690d47c35720a6005b93287ba#egg=cl-sii
-e git+ssh://git@github.com/fyntex/lib-cl-sii-python.git@master#egg=cl-sii
-e git+ssh://git@github.com/fyntex/lib-cl-sii-python.git@v1.5#egg=cl-sii
-e git+ssh://git@github.com/fyntex/lib-cl-sii-python.git@refs/pull/123/head#egg=cl-sii
@glarrain
glarrain / convert_json_to_yaml.py
Last active Oct 15, 2017
Python script to load a JSON file and print its contents converted to YAML.
View convert_json_to_yaml.py
#!/usr/bin/env python3
"""Load a JSON file and print its contents converted to YAML.
Based on:
- https://stackoverflow.com/questions/15941996/dump-json-into-yaml/28506011#28506011
- https://gist.github.com/sbp/985889
"""
import json
import sys
@glarrain
glarrain / create-ec2-key-and-generate-pem-file.sh
Last active Oct 4, 2017
Create EC2 key pair and "generate" PEM file
View create-ec2-key-and-generate-pem-file.sh
#!/usr/bin/env bash
# Tools:
# - aws-cli version 1.11.143
# - jp version 0.1.3
# https://github.com/jmespath/jp
# Notes:
# - 'sed' pattern
# https://stackoverflow.com/questions/13610639/tr-command-how-to-replace-the-string-n-with-an-actual-newline-n/13611446#13611446
View create-gif-from-images.sh
# Ubuntu 14.04: requires pkg 'imagemagick'.
convert -resize 50% -delay 100 -loop 0 *.png myimage.gif
@glarrain
glarrain / connect-heroku-app-to-postgres-rds-with-ssl.md
Last active Mar 26, 2021 — forked from jonyt/connect_heroku_to_amazon_rds
How to connect a Heroku application to an Amazon RDS PostgreSQL instance, forcing SSL and certificate chain verification
View connect-heroku-app-to-postgres-rds-with-ssl.md

1 - Download the RDS certificates (root plus region-specific intermediate ones) bundle:

wget -O config/rds-combined-ca-bundle.pem https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

2 - Add config/rds-combined-ca-bundle.pem to the repository and redeploy to Heroku.

3 - Update the DATABASE_URL env var:

@glarrain
glarrain / simplest_wsgi_server.py
Created Dec 21, 2015
simplest HTTP (using WSGI) server ever
View simplest_wsgi_server.py
#!/usr/bin/env python3
from datetime import datetime
from wsgiref.simple_server import make_server
def my_application(environ, start_response):
path = environ['PATH_INFO']
method = environ['REQUEST_METHOD']
print("received a HTTP request. path: %s, method: %s" % (path, method))
@glarrain
glarrain / generate_django_secret_key.py
Created Oct 22, 2015
Generate a 50-char random string, adequate for Django's `SECRET_KEY`
View generate_django_secret_key.py
#!/usr/bin/env python
# coding: utf-8
"""Generate a 50-char random string, adequate for Django's ``SECRET_KEY``.
source: part of
https://github.com/django/django/blob/1.8.5/django/utils/crypto.py
"""
from __future__ import absolute_import, print_function, unicode_literals
@glarrain
glarrain / get-ubuntu-installed-packages.sh
Last active Sep 9, 2015
Write list of manually installed packaged (and when) in a Ubuntu system by looking in dpkg logs
View get-ubuntu-installed-packages.sh
#!/bin/bash
# source: https://help.ubuntu.com/community/ListInstalledPackagesByDate
#creates text file with a list of all packages installed by date
#first append all info from archived logs
i=2
mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l)
nlogs=$(( $mycount + 1 ))
View screenshot_web.py
# -*- coding: utf-8 -*-
import sys
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
class Screenshot(QWebView):
def __init__(self):
self.app = QApplication(sys.argv)
View open_pc.py
#!/usr/bin/env python
# Librerias necesarias
import paramiko
import os
# Datos para la conexion SSH
ssh_servidor = '10.0.70.44'
ssh_usuario = 'tuusuario'
ssh_clave = 'tucontraseña'