Skip to content

Instantly share code, notes, and snippets.

View Morgul's full-sized avatar
🎮
Being Awesome

Christopher S. Case Morgul

🎮
Being Awesome
View GitHub Profile
@Morgul
Morgul / gist:6043382
Created July 20, 2013 01:04
Potential fix for Bootstrap's poor menu detection of screen edges.
$(".dropdown-toggle").click(function(e) {
var menu = $(this).next('.dropdown-menu'),
mousex = e.pageX + 20, //Get X coodrinates
mousey = e.pageY + 20, //Get Y coordinates
menuWidth = menu.width(), //Find width of tooltip
menuHeight = menu.height(), //Find height of tooltip
menuVisX = $(window).width() - (mousex + menuWidth), //Distance of element from the right edge of viewport
menuVisY = $(window).height() - (mousey + menuHeight); //Distance of element from the bottom of viewport
if (menuVisX < 20) { //If tooltip exceeds the X coordinate of viewport
@Morgul
Morgul / gist:6312678
Created August 22, 2013 20:55
omega-logger crash
ERROR: Exception while logging to "ConsoleHandler" handler { level: 'DEBUG' }: TypeError: Cannot read property 'setLoggingContext' of null
at Context.<anonymous> (/home/morgul/Development/report-manager/node_modules/omega-logger/lib/context.js:44:19)
at Array.forEach (native)
at Context.message (/home/morgul/Development/report-manager/node_modules/omega-logger/lib/context.js:42:19)
at formatReplacement (/home/morgul/Development/report-manager/node_modules/omega-logger/util/strformat.js:17:27)
at String.replace (native)
at format (/home/morgul/Development/report-manager/node_modules/omega-logger/util/strformat.js:25:25)
at ConsoleHandler.onMessage (/home/morgul/Development/report-manager/node_modules/omega-logger/lib/handlers/console.js:55:17)
at ConsoleHandler.log (/home/morgul/Development/report-manager/node_modules/omega-logger/lib/handlers/base.js:35:14)
at eachHandler (/home/morgul/Development/report-manager/node_modules/omega-logger/logging.js:184:29)
@Morgul
Morgul / myapp.conf
Created November 21, 2013 14:36
A small upstart script I can use as a template. Edit it, and put it in /etc/init.
#!upstart
description "My Application's description here."
author "Chris Case <chris.case@g33xnexus.com>"
# Depending on what this is, you mat consider `start on started network-services`
start on startup
# May not need a stop on clause
stop on shutdown
@Morgul
Morgul / Chariel
Created January 3, 2014 23:47
This is the DB representation of a dnd character, which was magically deleted.
{
"baseChar":"cjTQvE9aorvUt1GB",
"conditions":[
{
"_$id":"eoCoo6ms7FFm5dtI"
},
{
"_$id":"aByRxFLUW2i7OfX1"
}
],
@Morgul
Morgul / example_spec.erl
Last active January 4, 2016 08:19
An example erlang test module, written using a Jasmine/Mocha-like BDD module, which doesn't exist yet. As this is all theoretical, this is very much open to some discussion.
%%% @doc Tests for the `example' module.
%%%
%%% This uses an as-of-yet unwritten BDD framework for Erlang.
%%% --------------------------------------------------------------------------------------------------------------------
-module(example_spec).
-include ("bdd.hrl").
-export([spec/0]).
<!-- ng-class style -->
<button class="btn btn-default" ng-keypress="{enter: doStuff, up-arrow: doStuff2}">Activate Me!</button>
<!-- dual attribtues -->
<button class="btn-default" ng-keypress="doStuff" key="up-arrow">Activate Me!</button>
@Morgul
Morgul / atom.py
Last active July 13, 2021 19:50
Atoms/Symbols in Python
class atom(object):
"""An implementation of the atom concept, inspired by Erlang.
Modified from here: http://www.me.net.nz/blog/atoms-slash-symbols-in-python/
"""
def __init__(self, a):
self._a = intern(a)
def __eq__(self, other):
@Morgul
Morgul / client.js
Last active August 29, 2015 14:00
Proposed websocket-based client/server protocol
// Example client interface
var socket = SocketFramework.connect("http://localhost:3000");
// Listen for the some event
socket.on('some event', function(data) {
console.log('got data:', data);
});
// Listen for an event that expects a reply
@Morgul
Morgul / 1-LowLevel.md
Last active August 29, 2015 14:01
Omega Models Fluent API

Low-Level Fluent API Proposal

Proposed API

A couple of design points:

  • OmegaDB itself is not stateful; instead, all configuration resides in the connection object.

CollectionSelector

@Morgul
Morgul / orderby_test.js
Created July 21, 2014 23:27
Thinky OrderBy issue
// ---------------------------------------------------------------------------------------------------------------------
// Testing OrderBy on a joined model
//
// @module orderby_test.js
// ---------------------------------------------------------------------------------------------------------------------
var util = require('util');
var thinky = require('thinky')({ db: 'orderby_test' });
var r = thinky.r;