Skip to content

Instantly share code, notes, and snippets.

View kevinmarx's full-sized avatar

Kevin Marx kevinmarx

  • Microsoft
  • Minneapolis
  • 13:04 (UTC -06:00)
View GitHub Profile
@kevinmarx
kevinmarx / cocoLightBright.js
Created August 1, 2012 01:49
Mandelbrot for lightbright at Coco
<!DOCTYPE html>
<html>
<body>
<script>
// var sRandomLine = "####################################################################################";
// var sSolidRandomLine = "%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F%7F";
// var sEmptyLine = "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20";
// var asRandom = [
// sRandomLine, sRandomLine, sRandomLine, sRandomLine, sRandomLine,
// sRandomLine, sRandomLine, sRandomLine, sRandomLine, sRandomLine,
@kevinmarx
kevinmarx / .bash_profile
Last active October 11, 2015 08:08
bash_profile
# ALIASES FTW
alias ll='ls -Fla'
alias b='bundle'
alias be='bundle exec'
alias bed='bundle exec deploy'
alias bedable='bundle exec deployable'
alias silent-deploy='cap staging2 deploy:upload FILES=app/path/to/file/you/keep/changing.rb'
alias bepr='bundle exec pull-request'
alias benb='bundle exec new-branch'
alias g='git'
@kevinmarx
kevinmarx / thumbnail_replace.js
Created November 5, 2012 23:30
Remove the image size designator on the thumbnail image in the News Article page.
// For each image of the feed
$j('.newsPreviewThumb').each(function() {
var src = $j(this).attr('src');
// Find and replace the _thumb. so we have a large image to work with
$j(this).attr('src', src.replace(/_thumb\.(png|jpg|jpeg|gif)$/, '.$1'));
});
@kevinmarx
kevinmarx / use-rems.scss
Created November 9, 2012 20:18
Auto generate pixel fallback when using root-ems
@mixin use-rems($property, $size1, $size2:null, $size3:null, $size4:null) {
@if ($size4) {
#{$property}: $size1+px $size2+px $size3+px $size4+px;
#{$property}: ($size1/10)+rem ($size2/10)+rem ($size3/10)+rem ($size4/10)+rem;
} @else if ($size3) {
#{$property}: $size1+px $size2+px $size3+px;
#{$property}: ($size1/10)+rem ($size2/10)+rem ($size3/10)+rem;
} @else if ($size2) {
#{$property}: $size1+px $size2+px;
#{$property}: ($size1/10)+rem ($size2/10)+rem;
@kevinmarx
kevinmarx / oneof.js
Last active December 10, 2015 23:48
oneof block helper for handlebars.
var Handlebars = require('handlebars')
// Oneof block helper. Works like an `if` block helper but allows you to evalutate context against a set.
// You can also use this as a part of a "if else" statement.
// The `key` argument is optional, if not set the key is the context.
//
// {{#oneof foo set='bar, baz' key=foo}}{{/oneof}}
//
// {{#oneof foo set='bar, baz' key=foo}}<div/>{{else}}<div/>{{/oneof}}
@kevinmarx
kevinmarx / business_directory.js
Created March 11, 2013 17:30
2013 web challenge business directory
// Build the select dropdown
// This goes in the page where you would like the search to render.
<div id="searchHeader">
<ul>
<li>
<label for="filterByType">Filter By Type:</label>
<select id="filterByType">
</select>
</li>
<li style="display: none;">
[user]
name = Kevin Marx
email = [email protected]
[alias]
unstage = reset HEAD
aa = add .
AA = add -A
cm = commit -m
c = commit
b = branch
@kevinmarx
kevinmarx / js-dateMethods.js
Last active December 18, 2015 03:38
Some nice methods to add on to the js date interface
Date.prototype.stdTimeOffset = function() {
var jan = new Date(this.getFullYear(), 0, 1) // july and jan are currently in/out of DST in every timezone.
var jul = new Date(this.getFullYear(), 6, 1)
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset())
}
Date.prototype.isDST = function() {
return this.getTimezoneOffset() < this.stdTimeOffset()
}
@kevinmarx
kevinmarx / chunk.js
Last active December 19, 2015 18:18
Method for chunking arrays into a 2 dimensional array.
function(array, chunk) {
return [].concat.apply([],
array.map(function(elem, i) {
return i % chunk ? [] : [array.slice(i, i + chunk)]
})
)
}
@kevinmarx
kevinmarx / topic.js
Last active December 21, 2015 07:19
topic helper for handlebars templates.
var Handlebars = require('handlebars')
var _ = require('underscore')
/*
* Adds support for passing items into a context as variables
*
* USAGE: {{#topic this foo=bar baz=qux}}
* USAGE: {{#topic foo=bar}} no need for a context, this will create a new context object
*/