Skip to content

Instantly share code, notes, and snippets.

View noahp's full-sized avatar

Noah Pendleton noahp

  • Boston MA, USA
View GitHub Profile
# to generate a new password file-
civetweb64.exe -A .htpasswd localhost admin admin
# start the server with that password
civetweb64.exe -global_auth_file .htpasswd
# test in browser, or curl-
curl.exe --digest -u mydomain.com\admin:admin http://localhost:8080/somefile.file
@noahp
noahp / python_droplet.py
Created September 1, 2015 19:39
python_droplet
import sys
if __name__ == "__main__":
infile = sys.argv[1]
with open(infile, 'r') as f:
for line in f:
print 'first line: '
print line
@noahp
noahp / gcovr_cmd.bat
Last active February 23, 2016 21:04
gcovr pattern for *unittest.c files only
gcovr.py -r <rootdir> -f ".*?\.c" -e ".*unittests\.c" -e ".*c_unittester.*\.c" --html --html-details -o summary.html
# program and verify using elf/hex/s19. verify and reset
# are optional parameters
openocd -f openocd_atsam4s4b_stlink2.cfg -c "program filename.elf verify reset exit"
# binary files need the flash address passing
openocd -f openocd_atsam4s4b_stlink2.cfg -c "program filename.bin exit 0x08000000"
# https://docs.python.org/2/howto/logging-cookbook.html#logging-to-multiple-destinations
if not None:
# set up logging to screen and file
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s', filename='log.log')
# define a Handler which writes INFO messages or higher to the sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# set a format which is simpler for console use
formatter = logging.Formatter('%(asctime)s %(message)s')
# tell the handler to use this format
'''
Scans for serial ports, launches putty (default install path) if you pick
one.
'''
try:
from serial.tools import list_ports
except:
print 'Plz install pyserial, "pip install pyserial"'
exit(-1)
import itertools
import enchant
import sys
def getwords(letters, len):
words = []
d = enchant.Dict("en_US")
for w in [''.join(x) for x in itertools.permutations(letters, len)]:
if d.check(w):
words.append(w)
@noahp
noahp / 8821ce.sh
Last active October 11, 2020 11:03
install 8821ce driver
# NOTE: on ubuntu 20.10, first try `sudo apt install rtl8821ce-dkms`-
# you'll need a usb wifi adapter or download the .dpkg and copy over
# new instructions
# fwiw; newer kernels, ~ > 5.4, seem to work out of the box, possibly
git clone https://github.com/tomaspinho/rtl8821ce.git
cd rtl8821ce
make clean && make -j 6 && sudo make install
# reset the driver (if you need to) with this
@noahp
noahp / prepare-commit-msg
Created March 1, 2018 15:20
Grab jira ticket from current branch and prefix commit message with it; .git/hooks/prepare-commit-msg
#!/usr/bin/env bash
# Try to yank the JIRA ticket number from the current branch and prefix the commit message with it
EXISTING_PREFIX=$(rg -e "[a-zA-Z]+-[0-9]+" $1)
if [[ ! -z $EXISTING_PREFIX ]]; then
exit
fi
JIRA_TICKET=$(git symbolic-ref --short HEAD | rg -o -e "[a-zA-Z]+-[0-9]+" | awk '{print toupper($0)": "}')
sed -i.bak -e "1s/^/$JIRA_TICKET/" $1
@noahp
noahp / kconfig.patch
Created March 8, 2018 22:08
Patch v3.9.0.0 of kconfig-frontends (git://ymorin.is-a-geek.org/kconfig-frontends) to build on ubuntu 17.10
diff --git a/configure.ac b/configure.ac
index 814d8c8..5bc50fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -237,6 +237,22 @@ AS_IF(
[AC_MSG_ERROR([can not find a parser generator (such as yacc or bison)])]))
AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"])
+#----------------------------------------
+# gperf 3.1 generates functions with 'size_t' instead of 'unsigned int'