Skip to content

Instantly share code, notes, and snippets.

View mspanish's full-sized avatar

Stacey Reiman mspanish

View GitHub Profile
@DeepInTheCode
DeepInTheCode / GetJSON.sql
Created May 30, 2013 19:53
SQL table to JSON Object
/****** Object: StoredProcedure [dbo].[GetJSON] Script Date: 5/28/2013 4:31:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[GetJSON]
(
@table_name varchar(50),
@jwaltonmedia
jwaltonmedia / dust-helper-formatDate.js
Created May 27, 2013 18:24
Dustjs helper for formatting javascript date strings in templates (server-side).
dust.helpers.formatDate = function(chunk, context, bodies, params) {
var value = dust.helpers.tap(params.value, chunk, context),
timestamp,
month,
date,
year;
timestamp = new Date(value);
month = timestamp.getMonth() + 1;
date = timestamp.getDate();
year = timestamp.getFullYear();
@wout
wout / gist:5188265
Last active July 29, 2021 18:04
Zoom in and out with svg viewbox for http://svgjs.dev
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>svg.js</title>
<style type="text/css" media="screen">
#buttons {
position: absolute;
right: 0;
@tvandervossen
tvandervossen / environment.js
Last active April 2, 2024 20:18
Here’s an example of my current web app user agent, device, and/or feature detection approach. I tend to inline this in the page header just before the stylesheet as part of the distribution build. A benefit of this approach is that detection is done early without any external dependencies. It’s also straightforward to modify or extend while you…
env = (function() {
var flags = {}, ua = navigator.userAgent, el = document.createElement('div'), video = document.createElement('video'), audio = document.createElement('audio'), root = document.documentElement, i
function flag(names) {
names = names.split(' ')
for (i = 0; i < names.length; i++)
flags[names[i]] = true
}
function classnames() {
var names = [], name
for(name in flags) if (flags.hasOwnProperty(name))
@seltzered
seltzered / IllustratorSaveAsSVGs.jsx
Last active December 15, 2024 22:06
Quick little script to batch-convert Illustrator .ai's to .svg's, based on Adobe's sample 'save to pdf's' script. Save it to a jsx, and load it under illustrator. Intended for Illustrator CS6.
/**********************************************************
ADOBE SYSTEMS INCORPORATED
Copyright 2005-2010 Adobe Systems Incorporated
All Rights Reserved
NOTICE: Adobe permits you to use, modify, and
distribute this file in accordance with the terms
of the Adobe license agreement accompanying it.
If you have received this file from a source
@toddself
toddself / regions.js
Created December 6, 2012 03:51
region manager
(function($, _){
var Region = function(el){
this.el = el;
this.$el = $(el);
};
_.extend(Region.prototype, {
show: function(view){
// clean up...
this.clear();
@feedmypixel
feedmypixel / xmlToJson
Created November 27, 2012 10:41
Convert XML to JSON. This is a version that provides a JSON object without the attributes and places textNodes as values rather than an object with the textNode in it.
/**
* Originally from http://davidwalsh.name/convert-xml-json
* This is a version that provides a JSON object without the attributes and places textNodes as values
* rather than an object with the textNode in it.
* 27/11/2012
* Ben Chidgey
*
* @param xml
* @return {*}
*/
@apcomplete
apcomplete / Backtrace.js
Last active July 21, 2018 08:11
Simple backbone routing without hash URLs
r(function() {
Backtrace = {};
Backtrace.Router = (function() {
Router.prototype.optionalParam = /\((.*?)\)/g;
Router.prototype.namedParam = /:\w+/g;
@iwek
iwek / find-in-json.js
Created October 20, 2012 21:43
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
window.addEventListener("mousedown", handleClick, false);
window.addEventListener("contextmenu", function(e) { e.preventDefault(); }, false);
function handleClick(e) {
e.preventDefault();
if(e.button === 0) Reveal.next();
if(e.button === 2) Reveal.prev();
}