Skip to content

Instantly share code, notes, and snippets.

View osvalr's full-sized avatar

Osval Reyes osvalr

View GitHub Profile
@osvalr
osvalr / .t2drc
Last active December 20, 2016 23:13
t2drc: template configuration for travisfile2dockerfile
#!/bin/bash
# Copy and pase this file into your user home directory
# and also add in your .bashrc or .bash_profile: ". ~/.t2drc" (without quotes)
# main docker port
# IMPORTANT: replace the MAIN_PORT value
export DOCKER_PORT=MAIN_PORT
# secondary docker port
# It is used when you having troubles with the main one, uncomment when the main one fails
@osvalr
osvalr / t2d-bark.sh
Created December 24, 2016 06:49
barking docker containers for odoo instances using travisfile2dockerfile
#!/bin/bash
# Using travisfile2dockerfile this code will take charge to build your docker image and run your docker container for an
# Odoo instance just indicating the port you want to be mapped to web service as the only argument once your get into
# one folder travisfile2dockerfile created for you
# e.g.
#
# 1. run travisfile2dockerfile
# ~/ $ travisfile2dockerfile git@github.com:<ORG>/<REPOSITORY>.git <BRANCH>
#
# 2. get into your travisfile2dockerfile just-generated-folder
@osvalr
osvalr / validator.py
Created February 11, 2017 21:00 — forked from iiska/validator.py
Simple XML Schema validator in Python using lxml library
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
# Simple XML validator done while learning the use of lxml library.
# -- Juhamatti Niemelä <iiska AT iki DOT fi>
import lxml
from lxml import etree
if __name__ == "__main__":
@osvalr
osvalr / test-sunat.py
Created February 16, 2017 01:32
non-tested SUNAT
#!/bin/python
##
## This code have been taken from, and isn't tested yet by myself
## https://codeshare.io/nQXtS
## https://gitter.im/msolorzano/sunat2015
##
from suds.client import Client
from suds.wsse import *
import requests
import suds_requests
@osvalr
osvalr / x509_sign.py
Created February 25, 2017 19:36
Sign XML file in python with a x509 certificate
# coding: utf-8
from lxml import etree
from signxml import xmldsig
cert = open('cert.pem').read()
key = open('key.pem').read()
doc = etree.parse('sample.xml').getroot()
@osvalr
osvalr / gpg-import-and-export-instructions.md
Created March 1, 2017 02:35 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

#!/bin/bash
# This gist is mainly for export and import your gpg keys in order to backup them individualy,
# use somewhere else or whatever you want to do.
# usage:
# (1) $ export_gpg my-email@theserver.org fname
# NOTE: it will create two files: fname-gpg.txt, fname-gpg.key
#
# (2) $ import_gpg fname
@osvalr
osvalr / array_ordenado.c
Created March 1, 2017 03:42
Read an array and order lower to greater and viceversa
#include <stdio.h>
#include <stdlib.h>
int menor_a_mayor( const void * e1, const void * e2 ){
return ( *(int*)e1 - *(int*)e2 );
}
int mayor_a_menor( const void * e1, const void * e2 ){
return ( *(int*)e2 - *(int*)e1 );
}
// taken from a cached page of github.com
.date-selector .date-button {
position: absolute;
top: 0;
width: 18px;
height: 18px;
padding: 4px;
font-size: 12px;
line-height: 12px;
color: #4078c0;
@osvalr
osvalr / restore_2_container.sh
Last active September 1, 2017 19:47
Restore a psql dump in a randomed named database inside a container
#!/bin/bash
# Tested in archlinux
function restore_2_container() {
# Container name
container_name=$1
# Random database name
database_name="`shuf -n1 /usr/share/dict/cracklib-small`_`shuf -n1 /usr/share/dict/cracklib-small`"