Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<title>Map demo</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.draw.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.draw-src.js"></script>
#!/bin/sh
TMPDIR="$(mktemp -d)"
# Capture the default shell options, before we enter POSIX mode
set +o | sort > "$TMPDIR/shellopts.old"
echo "set -$-" >> "$TMPDIR/shellopts.old"
set -o posix
# Capture global variables
#!/usr/bin/env python
# Copyright (C) 2019 Woods Hole Oceanographic Institution
#
# This file is part of the CGSN Mooring Project ("cgsn-mooring").
#
# cgsn-mooring is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
#!/usr/bin/env python
import random
# Here is our plaintext message
message = 'THISISATESTITISONLYATEST'
# Insert random spaces into the message
while len(message) < 72:
i = random.randrange(len(message))
@rgov
rgov / gist:77d71681ae3a9cee6792d90fb490dd16
Created April 16, 2019 17:09
crash course in managing a database with django-admin
# See also:
# https://docs.djangoproject.com/en/2.2/intro/tutorial01/
# Install Django
python -m pip install django
# This creates a blank new Django project in mysite/
django-admin startproject mysite
cd mysite/
@rgov
rgov / gist:32acd7005c175fed68e86a82d58d5b81
Created April 16, 2019 17:09
crash course in managing a database with django-admin
# See also:
# https://docs.djangoproject.com/en/2.2/intro/tutorial01/
# Install Django
python -m pip install django
# This creates a blank new Django project in mysite/
django-admin startproject mysite
cd mysite/
@rgov
rgov / tc32-asm.py
Created April 13, 2019 17:47
Telink TC32 instructions
'''
This is a list of opcodes for the TC32 MCU, as disassembled by the objdump
binary provided (without source) with the Telink IDE.
The format is (value, mask, assembly).
See
http://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=opcodes/arm-dis.c;hb=HEAD#l2508
'''
[
@rgov
rgov / gist:f1fb93a34a6ec30fe88cf6602776b620
Created April 13, 2019 17:34
Ghidra - Dump array of structures
# Quickly written script to enumerate an array of structures and dump them
# as a Python object for further processing.
#
# This is NOT a good example of Ghidra scripting; I basically figured out
# the API by brute force. Hopefully there is a more elegant way to do this.
#@author Ryan Govostes
#@category Data
#@keybinding
#@menupath
@rgov
rgov / gist:7e1135bd697790a2d9f09308fe2aaa11
Created March 27, 2019 23:34
Z3 example of finding parameters to a CRC-16 algorithm
import crcmod
from z3 import *
# This is a CRC-16 algorithm coded to be able to use Z3's symbolic types
def crc16_py(buffer, initial, poly, xorout):
crc = initial
for b in buffer:
crc = crc ^ (b << 8)
for i in range(8):
crc = If(crc & 0x8000 != 0, (crc << 1) ^ poly, crc << 1)
@rgov
rgov / gist:cbee899187e6db489ef9a8460e8e6167
Created March 24, 2019 15:51
write to stdout after closing it?
/* doesn't work */
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main() {
close(STDOUT_FILENO);
if (open("/dev/null", O_WRONLY) != STDOUT_FILENO) {
fprintf(stderr, "Could not open /dev/null as fd %d", STDOUT_FILENO);