Skip to content

Instantly share code, notes, and snippets.

View okorz001's full-sized avatar

Oscar Korz okorz001

  • San Jose, CA
  • 10:50 (UTC -07:00)
View GitHub Profile
@okorz001
okorz001 / polygon.py
Last active September 1, 2022 18:55
Generate SVG of regular polygons
#!/usr/bin/env python
import argparse
import math
parser = argparse.ArgumentParser(description="""
Generates a SVG of a regular polygon. By default, a convex polygon is generated,
but the --advance option may be used to generate star polygons instead.
""")
parser.add_argument('points', type=int, metavar='POINTS',
@okorz001
okorz001 / emacs-gnutls-windows.txt
Created October 11, 2017 06:10
Installing GnuTLS for Emacs on Windows for downloading packages over HTTPS
Download Emacs dependencies from GNU for your architecture:
http://ftp.gnu.org/gnu/emacs/windows/emacs-25-x86_64-deps.zip
http://ftp.gnu.org/gnu/emacs/windows/emacs-25-i686-deps.zip
The following DLLs need to be installed into Emacs's bin directory:
libffi-6.dll
libgmp-10.dll
libgnutls-30.dll
@okorz001
okorz001 / caps-lock-control.reg
Created October 8, 2017 06:56
Map Caps Lock to Control on Windows. Note that since this is a registry setting it will affect all users.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
@okorz001
okorz001 / QueryBuilder.java
Last active November 18, 2015 03:41
OO SQL Query Builder
import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
@okorz001
okorz001 / promisify.js
Created October 15, 2015 02:59
Convert function with node style callback into a one that returns a Promise
var slice = Array.prototype.slice;
function promisify(f) {
return function() {
// Save arguments and promote to real Array.
var args = slice.call(arguments);
return new Promise(function(resolve, reject) {
// Add our callback to argument list.
args.push(function(err, result) {
@okorz001
okorz001 / once.js
Created September 27, 2015 02:38
Run a JS promise exactly once
// Sentinel value that indicates Promise has not executed.
var empty = {};
function once(f) {
var result = empty;
var promise = null;
return function() {
// If we've saved something already, resolve it immediately.
if (result !== empty) {