Skip to content

Instantly share code, notes, and snippets.

View pdf bookmarklet uploader bookmar
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);
@nmz787
nmz787 / PDF uploader bookmarklet.js
Last active Jul 25, 2016 — 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.
View PDF uploader bookmarklet.js
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 / brightness_tk.py
Last active Aug 29, 2015
Brightness adjustment slider GUI (wxPython or Tk)
View brightness_tk.py
"""
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 / each_cell_on_its_own_line
Last active Mar 2, 2021
git-xlsx-textconv-python
View each_cell_on_its_own_line
import xlrd
import sys
if __name__ == '__main__':
if len(sys.argv) != 2:
print "Usage: git-xlsx-textconv file.xslx"
excelFileName = sys.argv[1]
xlFile = xlrd.open_workbook(excelFileName)
@nmz787
nmz787 / rename_kicad_gerbers.py
Created Oct 16, 2015
Renames KiCad plot and drill files to the correct OSHpark file extensions, and also puts all these into a ZIP file.
View rename_kicad_gerbers.py
"""
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
View diffractive lens nanopillar outlines via openCV
import numpy as np
import cv2
import math
h=1000
w=1000
scaling = 20.
fin_w = 85
View duplicate STL for printing multiple copies
# most of the following code is from here: https://github.com/WoLpH/numpy-stl#combining-multiple-stl-files
# but instead of combining STLs, I'm just copying and replicating the same one
import math
import stl
from stl import mesh
import numpy
# find the max dimensions, so we can know the bounding box, getting the height, width, length (because these are the step size)...
def find_mins_maxs(obj):
@nmz787
nmz787 / pycosat.c
Created Jun 29, 2016
pycosat.c extended with hacked Noddy class example
View pycosat.c
/*
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 / main.py
Last active Sep 6, 2019
Half-decent LED-PWM and capacitive-sense GPIO coroutines (in micropython, on GHI Electronics G30TH -- essentiall Nucleo F401 but with different pins and pin names)
View main.py
import pyb
from pyb import Timer
# timer 2 will be created with a frequency of 10 kHz
tim=pyb.Timer(4,freq=10000);
# attach the timer to the LED GPIO, turning the brightness OFF to begin
tchannel = tim.channel(3, Timer.PWM, pin=pyb.Pin.board.JP32, pulse_width_percent=0)
# setup comm channel, for debug prints
# uart = pyb.UART(2, 9600) # init with given baudrate
@nmz787
nmz787 / buildozer.spec
Created Sep 3, 2016
kivy test for HTC DualLens SDK
View buildozer.spec
[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