Skip to content

Instantly share code, notes, and snippets.

View dcabines's full-sized avatar

David Cabiness dcabines

View GitHub Profile
@dcabines
dcabines / about
Created April 21, 2012 16:42
This is the base Todo application.
This is the todo application.
It uses Backbone's sync to talk to my JSON REST API.
@dcabines
dcabines / about
Created April 21, 2012 17:00
This is the login component.
This is the login component.
It uses the Facebook component as a login provider.
It doesn't need a template file because the template is part of the index page.
@dcabines
dcabines / about
Created April 21, 2012 17:04
This is how the about page works.
This is the about page.
It uses the Facebook component to pull my public information and populate a table with it.
It caches the data so it is only fetched once.
@dcabines
dcabines / about
Created April 21, 2012 17:09
This is the facebook interface for my app.
This is the Facebook component of my app.
This is the only component that is allowed to talk to the Facebook API directly.
@dcabines
dcabines / CookieHelp.cs
Created October 16, 2012 17:48
CookieHelp
using System;
using System.Web;
using System.Collections.Specialized;
namespace WebData {
public static class CookieHelp {
public static void Add(string name, DateTime expiration, NameValueCollection data) {
var cookie = new HttpCookie(name) {Expires = expiration};
foreach (string key in data.Keys) cookie[key] = data[key];
HttpContext.Current.Response.Cookies.Add(cookie);
@dcabines
dcabines / Cloud-Storage-Prices.js
Created November 18, 2012 00:59
Prices of Cloud Storage Line Chart. Paste it into the Google Code Playground. See an example at http://i.imgur.com/p7QqV.png
// Amazon Glacier has a 3 to 5 hour access time.
// Glacier Archive and Restore Requests are $0.05 per 1,000 requests
// Glacier is designed with the expectation that restores are infrequent and unusual, and data will be stored for extended periods of time.
// You can restore up to 5% of your average monthly Glacier storage (pro-rated daily) for free each month.
// If you choose to restore more than this amount of data in a month, you are charged a restore fee starting at $0.01 per gigabyte.
// Amazon charges 0.01 per 1,000 requests (10,000 for GET requests).
// Azure charges 0.01 per 100,000 transactions.
// To make the Azure and Amazon lines not overlap, I added one one hundredth of a penny to the Amazon prices.
public bool ExportWorkbookToPdf(string workbookPath, string outputPath)
{
// If either required string is null or empty, stop and bail out
if (string.IsNullOrEmpty(workbookPath) || string.IsNullOrEmpty(outputPath))
{
return false;
}
// Create COM Objects
Microsoft.Office.Interop.Excel.Application excelApplication;
@dcabines
dcabines / TopWords.cs
Last active December 16, 2015 13:48
List the top words used in a file and the number of times they are used.
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace TopWords {
internal class Program {
private static void Main(string[] args) {
const int maxWords = 298;
const int minWordLength = 4;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Data.SqlClient;
namespace Greenshades.Online.Data.Settings {
@dcabines
dcabines / Plaindrome
Created May 9, 2014 16:23
Know it. Memorize it.
/// <summary>
/// Determines whether the string is a palindrome.
/// </summary>
public static bool IsPalindrome(string value) {
int min = 0;
int max = value.Length - 1;
while (true) {
if (min > max) {
return true;
}