Skip to content

Instantly share code, notes, and snippets.

View danesparza's full-sized avatar
:octocat:
The best way to predict the future is to invent it - Alan Kay

Dan Esparza danesparza

:octocat:
The best way to predict the future is to invent it - Alan Kay
View GitHub Profile
@danesparza
danesparza / ConfigManager.cs
Created January 12, 2016 19:08
C# configuration manager
/// <summary>
/// Simple manager for config items
/// </summary>
public static class ConfigManager
{
/// <summary>
/// Get the config value for the given key/name
/// </summary>
/// <typeparam name="T">The expected type of the config values</typeparam>
/// <param name="configKey">The configuration key to get</param>
@danesparza
danesparza / gcal.html
Created November 20, 2015 07:24
Google client side calendar API
<html>
<head>
<script type="text/javascript">
/*
Sample code taken shamelessly (and modified)
from https://developers.google.com/google-apps/calendar/quickstart/js
*/
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
@danesparza
danesparza / Program.cs
Created July 22, 2015 15:03
TPL data flow test
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
namespace TPLDataflowTest
@danesparza
danesparza / randomsequence.go
Created July 14, 2015 15:18
Generates a random sequence of letters/numbers (for a sessionid or something)
package main
import (
"flag"
"fmt"
"math/rand"
"time"
)
var letters = []rune("abcdefghijklmnopqrstuvwxyz-+=.ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
@danesparza
danesparza / negroni-gorilla.go
Last active December 16, 2020 12:36
Negroni with Gorilla mux subrouter
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"log"
"net/http"
)
@danesparza
danesparza / PrettyJsonTest.cs
Created September 24, 2013 18:21
Pretty printing JSON data to a file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using ServiceStack.Text;
namespace PrettyJsonTest
# -*- coding: utf-8 -*-
require 'fileutils'
require 'date'
require 'yaml'
require 'uri'
require 'rexml/document'
include REXML
doc = Document.new File.new(ARGV[0])
@danesparza
danesparza / gist:1093992
Created July 19, 2011 23:21
Javascript date range overlap
var e1start = e1.start.getTime();
var e1end = e1.end.getTime();
var e2start = e2.start.getTime();
var e2end = e2.end.getTime();
return (e1start > e2start && e1start < e2end || e2start > e1start && e2start < e1end);
@danesparza
danesparza / gist:1085398
Created July 15, 2011 19:41
More fun with Javascript - using deep copy
// First object, with a simple string property
args1 = {};
args1.test1 = "blah";
// Second object, deep copied from the first
args3 = $.extend(true, {}, args1)
// As you might expect...
// args3.test1 is "blah"
@danesparza
danesparza / gist:1085394
Created July 15, 2011 19:39
Fun with Javascript ... pointers?
// First object, with a simple string property
args1 = {};
args1.test1 = "blah";
// Second object, 'created' from the first
args2 = args1;
// As you might expect...
// args2.test1 is "blah"