Skip to content

Instantly share code, notes, and snippets.

@nmz787
nmz787 / brightness_tk.py
Last active August 29, 2015 14:11
Brightness adjustment slider GUI (wxPython or Tk)
"""
A super-simple GUI for setting my laptop backlight.
For some reason Ubuntu Answers couldn't tell me where to change the minimum brightness and step interval.
So I had to make something because my laptop can be MUCH dimmer than Ubuntu's minimum.
Added this version for tk, since it is such a simple GUI.
"""
import os
import subprocess
from Tkinter import *
@nmz787
nmz787 / rename_kicad_gerbers.py
Created October 16, 2015 11:30
Renames KiCad plot and drill files to the correct OSHpark file extensions, and also puts all these into a ZIP file.
"""
Renames KiCad plot and drill files to the correct OSHpark file extensions, and also puts all these into a ZIP file.
usage:
python rename_kicad_gerbers.py path/to/my/project/plot_output
returns:
kicad_out.zip (in the directory you ran the script from)
"""
import os
@nmz787
nmz787 / pdf bookmarklet uploader bookmar
Created May 7, 2013 07:40
pdf bookmarklet uploader
var testUrl = 'http://link.springer.com.ezproxy.rit.edu/content/pdf/10.1007/s11207-013-0286-8.pdf';
var xhr = new XMLHttpRequest();
xhr.open("GET", window.location, false);
xhr.send(null);
function crossDomainPost() {
// Add the iframe with a unique name
var iframe = document.createElement("iframe");
var uniqueString = "CHANGE_THIS_TO_SOME_UNIQUE_STRING";
document.body.appendChild(iframe);
import numpy as np
import cv2
import math
h=1000
w=1000
scaling = 20.
fin_w = 85
@nmz787
nmz787 / pycosat.c
Created June 29, 2016 23:53
pycosat.c extended with hacked Noddy class example
/*
Copyright (c) 2013, Ilan Schnell, Continuum Analytics, Inc.
Python bindings to picosat (http://fmv.jku.at/picosat/)
This file is published under the same license as picosat itself, which
uses an MIT style license.
*/
#define PYCOSAT_URL "https://pypi.python.org/pypi/pycosat"
#include <Python.h>
#include "structmember.h"
@nmz787
nmz787 / PDF uploader bookmarklet.js
Last active July 25, 2016 02:04 — forked from kanzure/bookmarklet.js
This bookmarklet downloads the PDF currently being viewed in a browser window then uploads it with a filename of your choice to a different web server. The included Flask-based web server takes the uploaded file and saves it to disk, then returns the resulting URL so the user can copy it with CTRL-C.
function copyToClipboard (text) {
window.prompt ("Copy to clipboard: Ctrl+C, Enter", text);
}
var xhr = new XMLHttpRequest();
xhr.onload = function(e) {
if (this.status == 200) {
var xhr2 = new XMLHttpRequest();
xhr2.onreadystatechange = function() {
switch (xhr2.readyState) {
case 0: // uninitialized
@nmz787
nmz787 / buildozer.spec
Created September 3, 2016 06:04
kivy test for HTC DualLens SDK
[app]
# (str) Title of your application
title = My Application
# (str) Package name
package.name = myapp
# (str) Package domain (needed for android/ios packaging)
package.domain = org.test
@nmz787
nmz787 / cryptominisat_router.py
Last active October 27, 2016 08:35
An attempt at making a point-to-point route solver for 3D grids, using DIMACS SAT clauses with cryptominisat
from collections import OrderedDict
import os
import subprocess
import sys
import multiprocessing
import itertools
def split_seq(iterable, size):
it = iter(iterable)
@nmz787
nmz787 / dump_regs.py
Last active March 10, 2017 08:10
tables and a function to print a CSV-style register dump, on an STM32 MCU running MicroPython. Just import and call the dump function, then copy the serial output from your terminal
"""
usage:
import dump_regs
dump_regs.dump_regs()
"""
import re
import stm
# basically this, with some deletions (FLASH, DBGMCU):
# {m for m in dir(stm) if '_' not in m}
@nmz787
nmz787 / monosat_router.py
Last active April 5, 2017 04:30
An attempt at making a point-to-point route solver for 3D grids, using graph reasoning through monosat
from collections import OrderedDict, defaultdict
import os
import sys
import subprocess
from copy import deepcopy
from monosat import *
from time import time
# enable using multiple levels of dict keys automatically, even if nested levels don't yet exist
NestedDict = lambda: defaultdict(NestedDict)