Skip to content

Instantly share code, notes, and snippets.

View osvalr's full-sized avatar

Osval Reyes osvalr

View GitHub Profile
@osvalr
osvalr / Terminal.sublime-settings
Created February 25, 2021 11:58 — forked from kujiy/Terminal.sublime-settings
open git bash using `terminal` plugin for sublime
{
// The command to execute for the terminal, leave blank for the OS default
// On OS X the terminal can be set to iTerm.sh to execute iTerm
"terminal": "C:\\Program Files\\Git\\git-bash.exe",
// A list of default parameters to pass to the terminal, this can be
// overridden by passing the "parameters" key with a list value to the args
// dict when calling the "open_terminal" or "open_terminal_project_folder"
// commands
"parameters": ["-c", "cd \"%CWD%\" && \"C:\\Program Files\\Git\\bin\\sh.exe\" -i -l"]
@osvalr
osvalr / app_version.gradle
Created October 25, 2019 11:17 — forked from IlyaEremin/app_version.gradle
Npm version for gradle
def getVersionName = { getVersionProps()['appVersionName'] }
def getVersionProps() {
def versionPropsFile = file('gradle.properties')
if (!versionPropsFile.exists()) {
versionPropsFile.createNewFile()
}
def versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
return versionProps
@osvalr
osvalr / AvoidSpinnerDropdownFocus.java
Created March 19, 2019 22:28 — forked from kakajika/AvoidSpinnerDropdownFocus.java
Avoid taking window focus by Android Spinner's Dropdown to keep setSystemUiVisibility flags (such as Immersive Mode).
import android.widget.ListPopupWindow;
import android.widget.PopupWindow;
import android.widget.Spinner;
public static void avoidSpinnerDropdownFocus(Spinner spinner) {
try {
Field listPopupField = Spinner.class.getDeclaredField("mPopup");
listPopupField.setAccessible(true);
Object listPopup = listPopupField.get(spinner);
if (listPopup instanceof ListPopupWindow) {
#!/usr/sbin/python
def raise_tef(res):
aa = []
try:
print("Raising")
bb = aa[0]
except IndexError:
print("Exception Raised")
return res
@osvalr
osvalr / gaps.py
Last active September 22, 2017 15:34
recognize gaps in a list of sequences of numbers, and group them
#!/usr/sbin/python
# Taken from Python examples: https://docs.python.org/2.6/library/itertools.html#examples
from operator import itemgetter
from itertools import groupby
data_list = [[1,3], [1, 2, 3], [3]]
for data in data_list:
for k, g in groupby(enumerate(data), lambda ix :ix[0]-ix[1]):
print map(itemgetter(1), g)
@osvalr
osvalr / badzipfile.py
Created September 1, 2017 02:40
test if a zipfile is ok
from sys import argv
import zipfile
from zipfile import BadZipFile
message = "zip file okay"
try:
the_zip_file = zipfile.ZipFile(argv[1])
except BadZipFile:
message = "Bad file detected"
finally:
@osvalr
osvalr / gen_pfx_cer.sh
Last active July 10, 2024 21:12
Generate pfx and cer certificates
## PFX Creation taken from https://github.com/Azure/azure-xplat-cli/wiki/Getting-Self-Signed-SSL-Certificates-(.pem-and-.pfx)
## PEM to CER (DER encoded) taken from http://stackoverflow.com/a/405545
## PFX from PEM FIles taken from https://www.ssl.com/how-to/create-a-pfx-p12-certificate-file-using-openssl/
# Install `openssl` package
# Generating a private key:
openssl genrsa 2048 > private_key.pem
@osvalr
osvalr / billService.wsdl
Created April 10, 2017 21:26
billService.wsdl
<?xml version="1.0" encoding="utf-8"?>
<!-- taken from https://github.com/erickorlando/openinvoiceperu/blob/develop/OpenInvoicePeru/OpenInvoicePeru.Servicio.Soap/Service%20References/Documentos/billService.wsdl -->
<wsdl:definitions xmlns:wsp200607="http://www.w3.org/2006/07/ws-policy" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns0="http://service.gem.factura.comppago.registro.servicio.sunat.gob.pe/" xmlns:ns1="http://service.sunat.gob.pe" xmlns:wsp200409="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://service.sunat.gob.pe" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema>
<xsd:import schemaLocation="billService.xsd2.xsd" namespace="http://service.sunat.gob.pe" />
</xsd:schema>
</wsdl:types
@osvalr
osvalr / server_certificates_to_pem.md
Created April 8, 2017 20:01 — forked from stevenhaddox/server_certificates_to_pem.md
Convert .crt & .key files into .pem file for HTTParty

Two ways to do it, but only worked for me so I'll put it first and the second for reference:

$ openssl pkcs12 -export -in hostname.crt -inkey hsotname.key -out hostname.p12
$ openssl pkcs12 -in hostname.p12 -nodes -out hostname.pem

Other options for this method in comments below:

# Note, the -certfile root.crt appends all CA certs to the export, I've never needed these so it's optional for my personal steps
$ openssl pkcs12 -export -in hostname.crt -inkey hsotname.key -certfile root.crt -out hostname.p12

Note, I've always had my hostname.crt as part of my .pem, so I keep my certs but apparently you may not have to, hence the nocerts flag being an extra option in this sample

from collections import defaultdict
magia = defaultdict(self.env['account.tax'])
for i in self.tax_line_ids:
magia[i.tax_group_id.name] += i