Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe Wilm jwilm

View GitHub Profile
@jwilm
jwilm / text.f.glsl
Created Dec 14, 2017 — forked from raphlinus/text.f.glsl
text compositing fragment shader
View text.f.glsl
// 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,
View declarative_tests.rs
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 / improved_println.rs
Last active Jun 29, 2016
Improved println!
View improved_println.rs
/// 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
@jwilm
jwilm / impl_deserialize_fromstr.rs
Created May 13, 2016
Macro for implementing Deserialize on simple enums relying on FromStr
View impl_deserialize_fromstr.rs
#[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 / rust-backtrace
Created Jan 16, 2016 — forked from kmcallister/rust-backtrace
Run a Rust program and print a stack backtrace on failure (old)
View rust-backtrace
#!/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
View mkdirp.c
// 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;
View Preferences.sublime-settings
{
"font_face": "monaco",
"ignored_packages": [
"Vintage"
],
"rulers": [
80
],
"scroll_past_end": true,
"tab_size": 2,
@jwilm
jwilm / mktemp.coffee
Created Jan 12, 2014
CoffeeScript make temporary dir function for node - uses Bluebird promises and child_process.spawn.
View mktemp.coffee
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 / mongodb.service
Created Jun 22, 2013
MongoDB systemd service unit configuration
View mongodb.service
[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
You can’t perform that action at this time.