Skip to content

Instantly share code, notes, and snippets.

View phillipkregg's full-sized avatar
💭
Kick it!

Phil Lackey phillipkregg

💭
Kick it!
  • Nashville, TN
View GitHub Profile
@phillipkregg
phillipkregg / backbone-localstorage.js
Created December 21, 2011 16:55
Local storage for Backbone.js apps
// A simple module to replace `Backbone.sync` with *localStorage*-based
// persistence. Models are given GUIDS, and saved into a JSON object. Simple
// as that.
// Generate four random hex digits.
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
// Generate a pseudo-GUID by concatenating random hexadecimal.
@phillipkregg
phillipkregg / bootstrap-modal.js
Created December 21, 2011 17:15
Twitter's bootstrap-modal javascript widget
/* =========================================================
* bootstrap-modal.js v1.4.0
* http://twitter.github.com/bootstrap/javascript.html#modal
* =========================================================
* Copyright 2011 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@phillipkregg
phillipkregg / knockout-2.0.0.js
Created January 2, 2012 18:53
This is a copy of Knockout.js version 2.0.0
// Knockout JavaScript library v2.0.0
// (c) Steven Sanderson - http://knockoutjs.com/
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function(window,undefined){
function c(a){throw a;}var l=void 0,m=!0,o=null,p=!1,r=window.ko={};r.b=function(a,b){for(var d=a.split("."),e=window,f=0;f<d.length-1;f++)e=e[d[f]];e[d[d.length-1]]=b};r.l=function(a,b,d){a[b]=d};
r.a=new function(){function a(a,e){if("INPUT"!=a.tagName||!a.type)return p;if("click"!=e.toLowerCase())return p;var b=a.type.toLowerCase();return"checkbox"==b||"radio"==b}var b=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,d={},e={};d[/Firefox\/2/i.test(navigator.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"];d.MouseEvents="click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave".split(",");for(var f in d){var h=d[f];if(h.length)for(var g=0,i=h.length;g<i;g++)e[h[g]]=
f}var j=function(){for(var a=3,e=document.createElement("div"),b=e.getElementsByTagName("i");e.innerHTML="<\!--[if gt IE "+ ++a+"]
@phillipkregg
phillipkregg / routes-authors-books.txt
Created January 8, 2012 23:09
Rake Routes - simple Books-Authors example
C:\Sites\knockout-books>rake routes
root /(.:format) {:controller=>"authors", :actio
n=>"index"}
author_books GET /authors/:author_id/books(.:format) {:action=>"index", :controller=
>"books"}
POST /authors/:author_id/books(.:format) {:action=>"create", :controller
=>"books"}
new_author_book GET /authors/:author_id/books/new(.:format) {:action=>"new", :controller=>"
books"}
edit_author_book GET /authors/:author_id/books/:id/edit(.:format) {:action=>"edit", :controller=>
@phillipkregg
phillipkregg / routes-authors-books.txt
Created January 8, 2012 23:15
Rake Routes - simple Books-Authors example
C:\Sites\knockout-books>rake routes
root /(.:format) {:controller=>"authors", :actio
n=>"index"}
author_books GET /authors/:author_id/books(.:format) {:action=>"index", :controller=
>"books"}
POST /authors/:author_id/books(.:format) {:action=>"create", :controller
=>"books"}
new_author_book GET /authors/:author_id/books/new(.:format) {:action=>"new", :controller=>"
books"}
edit_author_book GET /authors/:author_id/books/:id/edit(.:format) {:action=>"edit", :controller=>
@phillipkregg
phillipkregg / books_controller.rb
Created January 8, 2012 23:17
Books Controller for simple example
class BooksController < ApplicationController
# GET /books
# GET /books.xml
def index
@books = Book.all
respond_to do |format|
format.json { render :json => @posts }
format.html # index.html.erb
format.xml { render :xml => @books }
@phillipkregg
phillipkregg / authors_controller.rb
Created January 8, 2012 23:39
Author controller for simple example
class AuthorsController < ApplicationController
# GET /authors
# GET /authors.xml
def index
@author = Author.includes(:books).find(params[:author_id])
respond_to do |format|
format.json { render :json => @authors }
format.html # index.html.erb
format.xml { render :xml => @authors }
@phillipkregg
phillipkregg / Csharp-String-Reversal.cs
Created March 13, 2012 17:05
C# Reverse String - First attempt at a class and method to reverse a string in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyLibrary
{
public class StringReverse
{
public string Reverse(string toBeReversed)
@phillipkregg
phillipkregg / frontendDevlopmentBookmarks.md
Created June 8, 2016 14:13 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.