Skip to content

Instantly share code, notes, and snippets.

@datchley
datchley / react-redux-style-guide.md
Last active February 13, 2024 14:30
React + Redux Style Guide
@datchley
datchley / iframe-overlay.js
Created October 2, 2013 13:33
For each iframe on a page, build an overlay on top of it that captures click events and sends them to the document in the iframe. This is to allow mobile scrolling in webkit, since it seems touching the iframe when swiping won't bubble up the touch event to the main page and hence won't scroll the page. This only works if you control the content…
$(document).ready(function() {
"use strict";
var ident = 0; // generate unique element id
// Find all iframe DFP ads
$('iframe').each(function() {
var width = $(this).width(),
height = $(this).height(),
@datchley
datchley / app.js
Last active September 20, 2022 01:22
"Getting Functional with Javascript" Blog post source files
/**
* Primary application logic for our Functional Programming blog example
* See related blog series at: http://www.datchley.name/tag/functional-programming/
* Version: 2.0
*/
// A simple, resuable comparison for '>='
function greaterThanOrEqual(a, b) {
return a >= b
}
@datchley
datchley / gist:115a0fec6766a7592d7a66d48e915d3c
Last active August 4, 2022 15:41
Technical Screen - Front-end Developer
/**************\
* Algorithms *
\**************/
// Given an array of objects summarizing the number of fish in an aquarium,
// find the percent of fish where the species is unknown (the `species` is
// `undefined`). Return the percentage as a whole number between `0` and `100`.
// Example input:
@datchley
datchley / jsongrid.html
Created May 4, 2011 15:23
ExtJS 4.0 Json Grid
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<!-- Stylesheets to handle CSS -->
<link rel="stylesheet" type="text/css" href="js/extjs/resources/css/ext-all.css" />
<!-- Javascript for the applications -->
<!-- <script type="text/javascript" src="js/extjs/ext-all-debug.js"></script> -->
<script type="text/javascript" src="js/extjs/bootstrap.js"></script>
<script type="text/javascript">
@datchley
datchley / es6-eventemitter.js
Last active June 7, 2021 03:40
A straight forward EventEmitter implemented in Javascript using ES6
let isFunction = function(obj) {
return typeof obj == 'function' || false;
};
class EventEmitter {
constructor() {
this.listeners = new Map();
}
addListener(label, callback) {
this.listeners.has(label) || this.listeners.set(label, []);
WITH all_builds AS (
/*
* Set this up as a Materialized View after each "sync" process
* which allows querying by VIN # or build_id
*/
SELECT
'Base' as type,
s.header as header,
s.description as description,
null as value,
@datchley
datchley / template-parser.php
Last active September 26, 2019 16:49
Quick and Dirty Template parsing in PHP
<?php
// the template
$template = "<h1>{TITLE}</h1>";
// add any template placeholder key/values here
$map = array(
'TITLE' => "ExtJS Sucks"
);
// Quick and dirty template parser, replace occurences of '{KEY}' with
@datchley
datchley / gist:6234265
Last active July 1, 2019 02:29
Git pre-commit hook to make sure I don't leave console/debug statements in my code.
#!/bin/sh
#
# @file pre-commit
# @author David Atchley, <david.atchley@answers.com>
# @date Wed Dec 18 14:02:39 CST 2013
#
# Pre Commit checks for various syntax and cleaning prio
# to committing. Exits with non-zero to stop commit
#
#----------------------------------------------------------------------
@datchley
datchley / README.md
Last active March 23, 2019 21:00
Micro templating library for javascript

Micro-Template: README.md

Valid template expressions:

  • expressions can reference any property on the passed in context, including nested properties and indexed access to array properties.
     {{ name }}
 {{ obj.name }}