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) {
@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
@osvalr
osvalr / create_x.509_cert.py
Created March 8, 2017 00:17 — forked from ril3y/create_x.509_cert.py
Python script that will generate a x.509 certificate
#!/usr/bin/python
from OpenSSL import crypto, SSL
from socket import gethostname
from pprint import pprint
from time import gmtime, mktime
from os.path import exists, join
CERT_FILE = "myapp.crt"
KEY_FILE = "myapp.key"
@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...

@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__":