Skip to content

Instantly share code, notes, and snippets.

@jccovey
jccovey / Bookmarklets.js
Created February 2, 2017 06:51
General purpose JavaScript snippets that fit in 2048 characters or less.
// Arrow key nav for videos
// - Left: -5s
// - Right: +5s
// - Up: +30s
// - Down: -30s
javascript:var timeAdj = {'37': -5, '39': 5, '38': 30, '40': -30 }; document.addEventListener("keyup", function(e) { if (e.which > 36 || e.which < 41) { e.preventDefault(); document.querySelectorAll("video").forEach(function(vid) { vid.currentTime += timeAdj[e.which]; vid.play();});}});
function separateWords(stringVal) /* returns string */ {
return stringVal.split(/(?=[A-Z])/).join(' ');
}
function json($data)
{
$this->output->set_header('Content-type:application/json');
$this->output->set_output(json_encode($data));
}
@jccovey
jccovey / index.html
Last active December 10, 2015 09:59
Top bar for F2K layout?
<div class="grad"></div>
@jccovey
jccovey / git-aliases.sh
Created September 28, 2012 19:54
Git aliases
# Show files with conflicting changes
git config --global alias.conflicts '!git ls-files -u | cut -f 2 | sort -u'
@jccovey
jccovey / cmd-pattern.md
Created July 2, 2012 19:05
"CMD" Pattern

Quoting scrame in a comment on a "MOVE" design pattern as proposed (http://cirw.in/blog/time-to-move-on/ ):

In Java/Spring-MVC, there is a typical class hierarchy of Controller -> Manager/Service -> DAO. The extra level of indirection is a very handy place to put business logic, then each class in the tier has a dedicated function:

  • Controller - Parses input, delegates the action and returns the response (rendered by the view).
  • Manager - Handles sanitized data, encapsulates business logic and makes calls into the Model / Data layer.
  • DAO - Interfaces with the data store, makes sure only good data goes in, and appropriate responses are returned.

(via http://news.ycombinator.com/item?id=4190037)

@jccovey
jccovey / file_manager_ideas.md
Created June 5, 2012 02:58
Ideal GUI File Manager for Modern OSes

Ideal File Manager for Modern OSes

Interface

Tabbed, no menu bar, tool bar unique to each tab with following:

  1. Back button (cds to popd dir off stack)
  2. Foward button (cds to last popd dir off stack)
@jccovey
jccovey / Links from work - April 2012.txt
Created May 4, 2012 21:40
Links from work - April 2012
@jccovey
jccovey / HarvestDates.py
Created December 20, 2011 00:21
Sublime Text 2 plugin to find and copy all timestamps to a scratch buffer
import sublime, sublime_plugin
class HarvestDates(sublime_plugin.TextCommand):
def run(self, edit):
date_matches = self.view.find_all("\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}:\d{2} (am|pm)")
date_buffer = self.view.window.new_file()
date_buffer.insert(0, 0, date_matches)
@jccovey
jccovey / Monadic Parser Combinators.html
Created November 26, 2010 23:20
Paper by Graham Hutton and Erik Meijer
<html>
<head>
<title>Monadic Parser Combinators</title>
<meta name="source" content="http://www.cs.nott.ac.uk/~gmh/monparsing.pdf" />
</head>
<body>
<h1>Monadic Parser Combinators</h1>
<ul>
<li></li>
</ul>