Skip to content

Instantly share code, notes, and snippets.

View trevorhreed's full-sized avatar

Trevor trevorhreed

  • Utah
  • 15:41 (UTC -06:00)
View GitHub Profile
function dir(o, d){
var s = '';
var t = d || '';
console.log('|' + t + '|');
for(var p in o){
if(typeof o[p] == 'object'){
l = (Object.prototype.toString.call(o[p]) === '[object Array]') ? '[array]' : '[object]';
s += t + p + ': ' + l + '\n';
s += dir(o[p], t + ' ')
}else{
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.charset.StandardCharsets;
['$filter', function($filter){
return function(array, expression, comparator){
var filterIf = function(check){
var filtered = [];
for(var i=0; i < array.length; i++){
var value = array[i];
if(check(value)){
filtered.push(value);
}
}
.check{
display:inline-block;
height:1.4em;
width:1.4em;
border-radius:.7em;
border:solid 1px #aaa;
box-shadow:inset 0px 0px 2px #aaa;
padding:1px;
margin:0em .5em;
vertical-align:middle;
define([
], function (
) {
return [function formValidator() {
return {
require: '^form',
scope: {
formData: '=',
validateAll: '='
},
function(){
var
MIN_IMAGE_RESOLUTION = 800,
MAX_CANVAS_SIZE = 375
;
return {
restrict: 'E',
scope: {
showMessage: '&onmessage',
api: '='
/*
Author: Trevor
Date: 2015.03.27
A mock database class. All models should inherit from mdb.MockModel
mdb.Get<T>(Guid id)
- Returns the model with an id matching 'id' from the mock database
mdb.All<T>()
function isRelative(url){
if (/^(((file:|https?:)?\/\/?)?[a-z0-9][a-z0-9-]*(\.([a-z0-9-]*[a-z0-9]))+(:\d+)?|((file:|https?:)?\/\/\/?[a-z0-9][a-z0-9-]*(\.([a-z0-9-]*[a-z0-9]))*))+(:\d+)?/i.test(url)) return false;
return true;
if(!url) return true;
if(/^\/\/[^\/]+\.[^\/]/.test(url)) return false;
if(/^\/\/\/[^\/]+/.test(url)) return false;
if(/^https?:\/\//.test(url)) return false;
var dot = url.indexOf('.'),
slash = url.indexOf('/');
def get(self, key, fallback):
if key == None:
return fallback
else:
node = self.obj
keys = key.split('.').reverse()
while(len(keys)):
k = keys.pop()
@trevorhreed
trevorhreed / thumbnailMaker.cs
Created October 23, 2015 18:30
Thumbnail Maker
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace ThumbnailGenerator