Skip to content

Instantly share code, notes, and snippets.

@ghecho
ghecho / scince_2020.sh
Created October 4, 2021 15:53 — forked from diegovalle/scince_2020.sh
Script to download shapefiles from 2020 Mexican census (including demographic data)
#!/usr/bin/env bash
# Author: Diego Valle-Jones
# Web: http://www.diegovalle.net
# Script to download shapefiles from 2020 Mexican census (including demographic data)
# tested on ubuntu 20.04
# Exit on error, undefined and prevent pipeline errors
set -euo pipefail
IFS=$'\n\t'
# The directory from which the script is running
@ghecho
ghecho / js_linux.py
Created August 14, 2018 01:19 — forked from rdb/js_linux.py
Access joysticks/game controllers from Python in Linux via the joystick driver. See https://www.panda3d.org/forums/viewtopic.php?f=8&t=16767
# Released by rdb under the Unlicense (unlicense.org)
# Based on information from:
# https://www.kernel.org/doc/Documentation/input/joystick-api.txt
import os, struct, array
from fcntl import ioctl
# Iterate over the joystick devices.
print('Available devices:')
<?php
$cfdi = '<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nomina="http://www.sat.gob.mx/nomina" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd http://www.sat.gob.mx/nomina http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina11.xsd" version="3.2" fecha="2015-11-06T18:15:32" folio="123 - 1063" serie="A" subTotal="24113.81" descuento="0.00" motivoDescuento="Deducciones de nómina" total="20000.00" Moneda="MXN" condicionesDePago="Contado" NumCtaPago="No identificado" tipoDeComprobante="egreso" noCertificado="00001000000307566366" certificado="MIIFNzCCBB+gAwIBAgIUMDAwMDEwMDAwMDAzMDc1NjYzNjYwDQYJKoZIhvcNAQELBQAwggGKMTgwNgYDVQQDDC9BLkMuIGRlbCBTZXJ2aWNpbyBkZSBBZG1pbmlzdHJhY2nDs24gVHJpYnV0YXJpYTEvMC0GA1UECgwmU2VydmljaW8gZGUgQWRtaW5pc3RyYWNpw7NuIFRyaWJ1dGFyaWExODA2BgNVBAsML0FkbWluaXN0cmFjacOzbiBkZSBTZWd1cml
extension NSRegularExpression {
func actuallyUsableMatch(in string: String) -> (fullMatch: String, captures: [String])? {
let nsString = string as NSString
let range = NSMakeRange(0, nsString.length)
guard let match = firstMatch(in: string, range: range) else {
return nil
}
let fullMatch = nsString.substring(with: match.range)
var captures: [String] = []
@ghecho
ghecho / offscreen.m
Last active August 29, 2015 14:14 — forked from chrisjdavis/offscreen.m
- (IBAction)getImageFromWeb:(id)sender {
// grab the width and height of the document in our mobileView.
CGSize contentSize = CGSizeMake(
[[mobileView stringByEvaluatingJavaScriptFromString:@"document.body.scrollWidth;"] floatValue],
[[mobileView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"] floatValue]
);
// create a new window, offscreen.
NSWindow *hiddenWindow = [[NSWindow alloc] initWithContentRect: NSMakeRect( -1000,-1000, contentSize.width, contentSize.height )
styleMask: NSTitledWindowMask | NSClosableWindowMask backing:NSBackingStoreNonretained defer:NO];