Skip to content

Instantly share code, notes, and snippets.

View glarrain's full-sized avatar
🤘
rockin'

Germán Larraín glarrain

🤘
rockin'
View GitHub Profile
@glarrain
glarrain / requirements.txt
Last active April 10, 2020 17:00
pip - install from GitHub repo
# 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 July 23, 2023 16:08
Python script to load a JSON file and print its contents converted to YAML.
#!/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 October 4, 2017 21:32
Create EC2 key pair and "generate" PEM file
#!/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
@glarrain
glarrain / create-gif-from-images.sh
Created March 2, 2017 17:59
Create GIF using images
# 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 January 4, 2023 14:01 — 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

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 December 21, 2015 21:14
simplest HTTP (using WSGI) server ever
#!/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 October 22, 2015 15:44
Generate a 50-char random string, adequate for Django's `SECRET_KEY`
#!/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 September 9, 2015 20:53
Write list of manually installed packaged (and when) in a Ubuntu system by looking in dpkg logs
#!/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 ))
# -*- 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)
#!/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'