Skip to content

Instantly share code, notes, and snippets.

@runsun
runsun / process_pdf_bookmarks
Last active March 10, 2020 16:31
Process Pdf Bookmarks Extracted by JPdfBookmarks
######################################################################
## 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 March 14, 2018 17:05
Monty Hall Problem Simulation
## 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 January 20, 2018 04:47
Print function names in the given .scad file and prepare them for doctest
__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 )
<!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 September 27, 2015 07:18
Run an openscad file once or n times and save shape output to file(s)
##########################################################################
## 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 November 16, 2017 06:12
Find lines where a word is located in all files under a folder.
__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