Skip to content

Instantly share code, notes, and snippets.

View cosmicexplorer's full-sized avatar
🎨
building some software right now you will probably end up using at some point

Danny McClanahan cosmicexplorer

🎨
building some software right now you will probably end up using at some point
View GitHub Profile
@cosmicexplorer
cosmicexplorer / make-pants-zinc-native-image.bash
Created March 16, 2019 03:01
make a native image of the pants zinc wrapper
#!/usr/bin/env bash
set -euxo pipefail
# NB: `mx` needs to be on $PATH!
if [[ ! -d 'openjdk1.8.0_202-jvmci-0.56' ]]; then
if [[ "$(uname)" == 'Linux' ]]; then
_jvmci_url_component='linux'
else
@cosmicexplorer
cosmicexplorer / async-fetch.py
Created September 25, 2016 22:39
example of fetching multiple webpages at once using asynchrony with grequests
# need to 'pip install grequests'
import grequests
from html.parser import HTMLParser
class FetchTitleTag(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.inTitle = False
def handle_starttag(self, tag, attrs):
if tag == 'title':
@cosmicexplorer
cosmicexplorer / Makefile
Last active February 2, 2016 06:39
makefile with lots of fun magic and dollar signs
.PHONY: all train test clean
SRC_DIR := cs362
IN_JAVA := $(wildcard $(SRC_DIR)/*.java)
OUT_JAVA := $(IN_JAVA:.java=.class)
all_past_n = $(wordlist $(1),$(words $(2)),$(2))
JAVAC_OPTS := -Xdiags:verbose
JAVA_CP := "commons-cli-1.2.jar:commons-math3-3.2.jar:."
@cosmicexplorer
cosmicexplorer / wrapExceptions.coffee
Last active February 2, 2016 07:13
catch asynchronous exceptions in node without losing the stack history
getCalledStack = (fun) ->
prevErr = new Error "memoized stack frame"
(args...) -> try fun args... catch err then throw [prevErr].concat err
memoizedFn = -> throw new Error "i'm an exception!"
beginStack = ->
memo = getCalledStack memoizedFn
# creating new stack frame
process.nextTick ->