Skip to content

Instantly share code, notes, and snippets.

View bobbysmith007's full-sized avatar

Russ Tyndall bobbysmith007

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<style>
.world {padding:50px; position:relative;}
.floor{width:calc(200px * 3); height:calc(60px * 3); border:1px solid #EEF; position:relative; margin:0; padding:0; line-height:calc(6px * 3); overflow:visible; vertical-align:top;}
.floor-bg{width: calc((147px + 2px) * 3);
height: calc(60px * 3); border:1px solid black; position:absolute; margin:0; padding:0; overflow:visible;}
.row{ overflow:visible; display:block; height:calc(6px * 3); text-align:left; clear:both;}
@bobbysmith007
bobbysmith007 / Heap GC Helper
Created May 30, 2018 14:40
If the Heap size exceeds a certain limit, garbage collect till you are below it again
(defun current-heap-size-megs (&key (spaces '(:static :dynamic :read-only))
&aux (total-mem 0) (total-cnt 0))
(iter (for s in spaces)
(iter (for (mem cnt type) in (sb-vm::type-breakdown s))
(incf total-mem mem)
(incf total-cnt cnt)))
(values (ceiling (/ total-mem (expt 2 20)))
total-cnt))
(defun gc-till-heap-available ( &key
@bobbysmith007
bobbysmith007 / promise-based-resource-management.js
Last active April 7, 2017 20:08
Promise Based Resource Pool
var pool = {
create: create,
release: release,
acquire: acquire,
useItem: useItem,
runTest: runTest,
items: [],
checkedOut: [],
waiting: [],
idx: 0
@bobbysmith007
bobbysmith007 / somecode.cs
Last active February 17, 2017 18:31
How creating nested hash tables explicitly/imperitively was much simpler than LINQ expressions
// This is the code that replaced all the code below this function:
protected override IDictionary<int, Dictionary<string, string>> GroupAndFlatten(IEnumerable<PassengerImport> imports) {
var paxImports = imports.GroupBy(x => x.PassengerId);
var paxes = new Dictionary<int,Dictionary<string,string>>();
foreach(var row in imports){
var paxid = row.PassengerId;
if (!paxes.ContainsKey(paxid)) paxes[paxid] = new Dictionary<string,string>();
var paxHash = paxes[paxid];
if(paxHash.ContainsKey(row.Key)) paxHash[row.Key] += " "+ row.Value;
else paxHash[row.Key] = row.Value;
@bobbysmith007
bobbysmith007 / JSPackager.js
Created November 30, 2016 16:36
JSPacakger
// Only want one JSPackager in existance, so lets only create
// one if we need to
if (typeof(JSPackager) == "undefined") window.JSPackager = {
// the head tag of the document
_head : document.getElementsByTagName('head')[0],
// a script tag to clone
_script : (function(){
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
// defer doesnt seem to work with this scheme and so we defer manually in removeLoadedDeps
@bobbysmith007
bobbysmith007 / gist:7d2b403b111fa7165f8e82e8a24c0efe
Created September 15, 2016 20:07
Python Threaded Stream Multiplexer / Writer
class ThreadedStreamWriter (Thread):
def __init__(self, target):
self.target = target
self.output_stream = BytesIO()
self.output_thread = Thread(target=self.target, args=(self.output_stream,))
self.output_thread.start()
class TeeEndPoint(EndPoint):
"Base class to inherit from for endpoints."
@bobbysmith007
bobbysmith007 / gist:1070355
Created July 7, 2011 19:40
asd with system connections
;; -*- lisp -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
(unless (find-package :clsql-helper.system)
(defpackage :clsql-helper.system
(:use :common-lisp :asdf))))
(in-package clsql-helper.system)
(eval-when (:compile-toplevel :load-toplevel :execute)