Skip to content

Instantly share code, notes, and snippets.

View greggnakamura's full-sized avatar

Gregg Nakamura greggnakamura

View GitHub Profile
@greggnakamura
greggnakamura / gist:3779783
Created September 25, 2012 03:15 — forked from padolsey/gist:527683
Javascript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@greggnakamura
greggnakamura / Fetch.sublime-settings
Created September 25, 2012 03:18 — forked from t8g/Fetch.sublime-settings
SublimeText2: Nettuts Fetch
{
"files":
{
"cycle": "http://malsup.github.com/jquery.cycle.all.js",
"infinite_scroll": "https://github.com/paulirish/infinite-scroll/blob/master/jquery.infinitescroll.min.js",
"jquery": "http://code.jquery.com/jquery.min.js",
"localscroll": "http://flesler-plugins.googlecode.com/files/jquery.localscroll-1.2.7-min.js",
"raphael": "http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js",
"reset": "http://meyerweb.com/eric/tools/css/reset/reset.css",
"scrollorama": "https://github.com/johnpolacek/scrollorama/blob/master/js/jquery.scrollorama.js",
@greggnakamura
greggnakamura / gist:3782862
Created September 25, 2012 16:13
CSS: Image Replacement
img {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background: url(test.png);
width: 300px;
height: 75px;
}
@greggnakamura
greggnakamura / Github OAuth ASP.Net MVC
Created September 25, 2012 18:12 — forked from codeimpossible/Github OAuth ASP.Net MVC
MVC: Github OAuth callback for ASP.Net MVC. Set yourapp.com/github/callback as the OAuth callback URL when you setup your application. If the users chooses to grant you permission, this controller/action get called to complete the transaction. See http://
public class GithubController : Controller
{
/// <summary>
/// Github OAuth Callback
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public JsonResult callback(string code)
{
var clientId = "[insert yours]";
@greggnakamura
greggnakamura / function-definition.js
Last active October 11, 2015 10:07
Javascript: functions
// Define a function within itself
var myfunction = function fun(number) {
myfunction = function( number ) {
return ++number;
};
return number * 2;
};
alert(myfunction(10)); // 20
alert(myfunction(10)); // 11
@greggnakamura
greggnakamura / JobsController.cs
Created October 9, 2012 00:51 — forked from codeimpossible/JobsController.cs
MVC: JobsController from Proggr; Implicitly cast to POCOs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Proggr.Controllers.Filters;
using Proggr.Controllers.Responses;
namespace Proggr.Controllers
{
@greggnakamura
greggnakamura / gist:3870135
Created October 11, 2012 04:18
MVC: Bind null reference when attempting to register the IProductsRepository with the DI container
using Ninject;
using Ninject.Modules;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Concrete;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
@greggnakamura
greggnakamura / peta_poco.cs
Created October 17, 2012 01:10 — forked from codeimpossible/peta_poco.cs
MVC: PetaPoco Example
[PetaPoco.TableName("People")]
[PetaPoco.PrimaryKey("Id")]
public class Person
{
public int Id { get; set; }
// .. some other fields
}
public ActionResult Create( Person person )
{
@greggnakamura
greggnakamura / gist:4112355
Created November 19, 2012 18:01
MVC: Simple Export to CSV file
var db = new PetaPoco.Database(ConnectionHelper.ConnectionStringName);
var internalUsers = db.Fetch<InternalUser>("Order by InternalUserID");
StringWriter sw = new StringWriter();
sw.WriteLine("\"UserID\",\"FirstName\",\"LastName\",\"EmailAddress\"");
foreach (var user in internalUsers)
{
sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\"",
user.UserID,
@greggnakamura
greggnakamura / index.html
Created December 21, 2012 15:30 — forked from anonymous/index.html
Countdown Clock
<div class="container">
<ul class="flip minutePlay">
<li>
<a href="#">
<div class="up">
<div class="shadow"></div>
<div class="inn">0</div>
</div>
<div class="down">
<div class="shadow"></div>