Skip to content

Instantly share code, notes, and snippets.

@stevenpack
stevenpack / wranger-tail.sh
Last active February 23, 2022 04:12
Pipe wrangler tail log messages to console
wrangler tail | jq -r ".logs[].message[0]"
#!/usr/bin/env python
# Copyright (C) 2013 Remy van Elst
# This program 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 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@stevenpack
stevenpack / ExpiringCache.rs
Created March 19, 2016 05:00
Lifetime Problem
use std::collections::{BTreeMap, HashMap};
use std::hash::Hash;
use std::cmp::Ordering;
pub struct Cache<'a, K: 'a,V: 'a> where K : Eq + Hash, V: Ord {
map: HashMap<K,V>,
keys: BTreeMap<&'a V, &'a K>
}
impl<'a, K,V> Cache<'a, K,V> where K : Eq + Hash, V: Ord {
fn accept_udp_connection(mio_server: &MioServer) {
println!("the server socket is ready to accept a UDP connection");
let mut buf = Vec::<u8>::new();
let mut mut_slice_buf = MutSliceBuf::wrap(&mut buf);
match mio_server.udp_server.recv_from(&mut mut_slice_buf) {
Ok(Some(addr)) => {
println!("remaining is {}", mut_slice_buf.remaining());
match String::from_utf8(buf) {
Ok(str) => {
@stevenpack
stevenpack / batch_promise.js
Created September 2, 2015 01:36
Execute promises in batches
/**
* Created by steve on 1/09/15.
*/
var q = require('q');
function Task(fn, arg) {
this.fn = fn;
this.arg = arg;
}
@stevenpack
stevenpack / Logs Style 1
Created December 12, 2011 20:28
NullReferenceExceptions from monodroid 4.0 with no stack trace
Error Style 1 (99% of the time)
===============================
2011-12-10 07:51:00.618 I 19579/ActivityThread: Publishing provider
com.xxxdictionary.android.__mono_init__: mono.MonoRuntimeProvider
2011-12-10 07:51:00.628 D 19579/dalvikvm: Trying to load lib
/data/data/com.xxxdictionary.android/lib/libmonodroid.so 0x44e02450
2011-12-10 07:51:00.658 D 19579/dalvikvm: Added shared lib