Skip to content

Instantly share code, notes, and snippets.

Avatar

Christopher Mina christophermina

  • CMConsulting LLC
  • Boulder, CO
View GitHub Profile
@christophermina
christophermina / MazeHasExit.js
Last active Dec 27, 2015
Given some parameters to create a maze out of a grid of 0's and 1's, determines if we can get from a start point to an exit.
View MazeHasExit.js
/**
* The purpose of this is to randomly generate a grid of preset height and width (dimensionX, dimensionY)
* with each cell either a 0 or a 1. There is a randomly assigned start and exit position, and you must
* determine if, by following a trail of contiguous ones in the up, down, left, right positions, you can
* get from the start to the exit.
*
* Assumptions:
* 1. the start coordinates fall within valid grid
* 2. You can only move up, down, left, right
* 3. You cannot jump a 0.
View gist:d4e55ecf60466f35fbcb
var lastHeights = [];
var i;
for (i = 0; i < this.numColumn; i++) {
lastHeights[i+1] = this.gapMargin;
}
if (cardElems.length > 0) {
var x
, y
, l
View asyncmodule.js
define([
'/path/to/a/dependency'
], function(myDependcy) {
var module = angular.module('asyncModule', [myDependency.name]);
module.directive('asyncDirective', ['$http'', function($http) {
return {
link: function(scope, element, attrs) {
View gist:7a5785224f8818d31121
define([
'bower_packages/ocLazyLoad/dist/ocLazyLoad'
], function() {
var module = angular.module('mainApp', ['oc.lazyload']);
module.config(['$ocLazyLoadProvider', function ($ocLazyLoadProvider) {
$ocLazyLoadProvider.config({
loadedModules: ['mainApp'],
asyncLoader: require
View gist:18ea87f20145b68e5267
getSignedRequest: function(container, resourceKey, expirationTimeInSeconds, fn) {
if (_.isFunction(expirationTimeInSeconds)) {
fn = expirationTimeInSeconds;
expirationTimeInSeconds = 3600;
}
if (process.env.SL_STORAGE_URL == null) {
request.get(slConfigs.SL_STORAGE_AUTH_URL_V1, {
headers: {
'X-Auth-User':slConfigs.SL_STORAGE_USERNAME,
View gist:ed78ae1b00481db295da
var post = request.post(storageUrl, {
headers: {
'X-Auth-User': slConfigs.SL_STORAGE_USERNAME,
'X-Auth-Token': token,
'X-Account-Meta-Temp-Url-Key': slConfigs.SL_TEMP_URL_KEY
}
}, function(err, value) {
if (value.statusCode == 204) {
return fn(null, "OK")
View gist:9a92a48e9033b67c38ba
_getClient: function() {
return pkgcloud.storage.createClient({
provider: 'openstack',
username: slConfigs.SL_STORAGE_USERNAME,
password: slConfigs.SL_STORAGE_PASS,
authUrl: slConfigs.SL_STORAGE_AUTH_URL,
version: 1,
useServiceCatalog: false
});
}
View gist:425d68bf99d58c776140
var request = require('request');
request.get(slConfigs.SL_AUTH_URL_V1, {
headers: {
'X-Auth-User':slConfigs.SL_STORAGE_USERNAME,
'X-Auth-Key':slConfigs.SL_STORAGE_PASS
}
}, function(err, value) {
if (value.statusCode == 200) {
var token = value.headers['x-auth-token'];
View Example Global.cs
public class Global : System.Web.HttpApplication
{
private static MSLogger log = MSLogger.GetLogger(typeof(Global));
public Global()
{
}
@christophermina
christophermina / gist:4138575
Created Nov 24, 2012
Example function for R support
View gist:4138575
line.plot.fun<-function(data1, space.columns=1,
num.major.horiz=4,
num.major.verts=5,
x.unit="Month of Year",
new.x.vals=FALSE,
line.width=3,
line.type=1, ylab="set y label in params",
xlab="Month of year",