Skip to content

Instantly share code, notes, and snippets.

@runsun
runsun / process_pdf_bookmarks
Last active Mar 10, 2020
Process Pdf Bookmarks Extracted by JPdfBookmarks
View process_pdf_bookmarks
######################################################################
## process_pdf_bookmarks.py
## by Runsun Pan, 20190310
##
## Process pdf bookmarks extracted from a pdf file by JPdfBookmarks
## JPdfBookmarks version: 2.5.2
#
## The bookmark file dumped by JPdfBookmarks has lots of styling
## codes that shouldn't be there. This py takes care of that. Other
## features included.
@runsun
runsun / monty.py
Created Mar 14, 2018
Monty Hall Problem Simulation
View monty.py
## Monty Hall Problem
## https://en.wikipedia.org/wiki/Monty_Hall_problem
##
## A simulation intended to prove the Monty Hall Solution wrong
## (that switching selection after one door is revealed increases
## the odd from 1/3 to 2/3), ended up proving it right.
##
## Result of running run(1000) 100 times: 0.67(+-)0.02
##
@runsun
runsun / get_openscad_funcs_for_doctest.py
Last active Jan 20, 2018
Print function names in the given .scad file and prepare them for doctest
View get_openscad_funcs_for_doctest.py
__description__ = "Print function names in the given .scad file and prepare them for doctest."
__author__= "Runsun Pan"
__version__= "180119-1"
'''
When an openSCAD file gets larger, it may contain too many functions and trying
to list them for doctest(https://bitbucket.org/runsun/doctest.scad), like:
[ //index_test( mode, opt ) // to-be-coded
, getdeci_test( mode, opt )
View web-audio-scheduler playing notes example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>web-audio-scheduler playing notes example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript">
@runsun
runsun / runscad.py
Created Sep 27, 2015
Run an openscad file once or n times and save shape output to file(s)
View runscad.py
##########################################################################
## runscad.py
##
## Run an openscad file once or n times and save shape output to file(s)
##
## by Runsun Pan (2015.9.25)
###########################################3##############################
import sys, os, re
narg = len(sys.argv)
@runsun
runsun / find.py
Last active Nov 16, 2017
Find lines where a word is located in all files under a folder.
View find.py
__description__ = "Find lines where a word is defined in a folder."
__version__= "171115-1"
__author__= "Runsun Pan"
'''
>>> py find.py -h
usage: find.py [-h] [--version] [-f folder] [-p prefix] [-a activeModule]
[-i includePrefix] [-x fileExt]
word