Skip to content

Instantly share code, notes, and snippets.

View jwilm's full-sized avatar

Joe Wilm jwilm

View GitHub Profile
@jwilm
jwilm / mongodb.service
Created June 22, 2013 22:49
MongoDB systemd service unit configuration
[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target
[Service]
Type=forking
PIDFile=/var/run/mongodb/mongod.pid
ExecStart=/usr/local/bin/mongod --config /etc/mongod.conf
ExecReload=/bin/kill -HUP $MAINPID
@jwilm
jwilm / mktemp.coffee
Created January 12, 2014 20:33
CoffeeScript make temporary dir function for node - uses Bluebird promises and child_process.spawn.
spawn = require('child_process').spawn
Bluebird = require 'bluebird'
mktemp = (pattern) ->
deferred = Bluebird.defer()
out = []
s = spawn('mktemp', ['-t', pattern, '-d'])
s.stderr.setEncoding 'utf8'
s.stdout.setEncoding 'utf8'
@jwilm
jwilm / Preferences.sublime-settings
Last active January 3, 2016 11:49
My ST3 settings
{
"font_face": "monaco",
"ignored_packages": [
"Vintage"
],
"rulers": [
80
],
"scroll_past_end": true,
"tab_size": 2,
@jwilm
jwilm / mkdirp.c
Created April 14, 2015 21:48
c mkdirp
// assumes path of the form foo/bar/baz.png
// This function is not very generic
int mkdirp(const char *path) {
char *buf = (char*)alloca(strlen(path));
char *last = strrchr(path, '/');
int res = 0;
// Bail if there's no directories to make
if (last == NULL) {
return 0;
@jwilm
jwilm / rust-backtrace
Created January 16, 2016 05:47 — forked from kmcallister/rust-backtrace
Run a Rust program and print a stack backtrace on failure (old)
#!/bin/bash
### NOTE ### You probably don't need this anymore!
# Just set RUST_BACKTRACE=1
# Usage: rust-backtrace ./my-rust-prog args...
exec gdb -batch -n -x /dev/fd/3 --args "$@" 3<<ENDGDB
set height 0
set breakpoint pending on
@jwilm
jwilm / impl_deserialize_fromstr.rs
Created May 13, 2016 18:48
Macro for implementing Deserialize on simple enums relying on FromStr
#[macro_export]
macro_rules! impl_deserialize_fromstr {
($tyname:ident) => {
impl ::serde::de::Deserialize for $tyname {
/// Deserialize this value given this `Deserializer`.
fn deserialize<D>(deserializer: &mut D) -> ::std::result::Result<Self, D::Error>
where D: ::serde::de::Deserializer
{
struct VariantVisitor<__D> {
_marker: ::std::marker::PhantomData<__D>,
@jwilm
jwilm / improved_println.rs
Last active June 29, 2016 20:05
Improved println!
/// Improved println! macro that allows specifying stdout or stderr
///
/// # Examples
///
/// Printing to stdout works like normal
/// ```rust
/// zprintln!("Hello, zprintln!");
/// ```
///
/// Printing to stderr works by passing a special argument
web_push_test! {
web_push_response_created => {
response: web::Response::Created { uri: String::new() },
remaining: 0,
successful: 1,
errored: 0,
sending_done: true,
},
web_push_response_accepted => {
response: web::Response::Accepted { uri: String::new() },
@jwilm
jwilm / text.f.glsl
Created December 14, 2017 23:50 — forked from raphlinus/text.f.glsl
text compositing fragment shader
// Copyright 2017 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@jwilm
jwilm / refinery.diff
Created February 10, 2022 23:07
Detecting large refinery events
diff --git a/route/route.go b/route/route.go
index d0f7ee8..0a92708 100644
--- a/route/route.go
+++ b/route/route.go
@@ -396,6 +396,29 @@ func (r *Router) processEvent(ev *types.Event, reqID interface{}) error {
WithField("request_id", reqID).
WithString("api_host", ev.APIHost).
WithString("dataset", ev.Dataset)
+ var err error
+