Skip to content

Instantly share code, notes, and snippets.

View johnpapa's full-sized avatar
💭
🐺Winter is coming

John Papa johnpapa

💭
🐺Winter is coming
View GitHub Profile
@johnpapa
johnpapa / main.js - now with less calories
Created June 27, 2012 14:07
main.js - now with less calories
(function () {
// Establish the root object, `window` in the browser, or `global` on the server.
var root = this;
requirejs.config(
{
baseUrl: 'scripts/app', /* script default location */
}
);
registerNonAmdLibs();
@johnpapa
johnpapa / EFRepository<T>
Created July 19, 2012 14:40
EF Repository Foundations
public class EFRepository<T> : IRepository<T> where T : class
{
public EFRepository(DbContext dbContext)
{
if (dbContext == null)
throw new ArgumentNullException("dbContext");
DbContext = dbContext;
DbSet = DbContext.Set<T>();
}
@johnpapa
johnpapa / model.attendance.js
Created August 7, 2012 01:56
model.attendance.js
define('model.attendance',
['ko'],
function (ko) {
var attendanceMakeId = function (personId, sessionId) {
return (personId + ',' + sessionId);
};
var Attendance = function () {
var self = this;
@johnpapa
johnpapa / gist:3342697
Created August 13, 2012 17:40
async command issues
saveCmd = ko.asyncCommand({
execute: function (complete) {
if (canEditSession()) {
setTimeout(function() {
$.when(datacontext.sessions.updateData(session()))
.always(complete);
}, 3000);
return;
}
@johnpapa
johnpapa / keybindings.json
Created October 13, 2015 01:19
Getting back the standard CMD+= zoom in VS Code
{
"key": "cmd+=",
"command": "workbench.action.zoomIn"
},
{
"key": "cmd+-",
"command": "workbench.action.zoomOut"
}
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u @ \w$\[\033[32m\]\$(parse_git_branch)\[\033[00m\] \n$ "
define(function () {
var mapper = {
mapDtosToEntities: mapDtosToEntities
};
return mapper;
function mapDtosToEntities(manager, dtos, entityName) {
// Map an array of DTO's for a type of entity
// to an array of Breeze entities that are managed by
@johnpapa
johnpapa / gist:4770826
Created February 12, 2013 15:51
Partial Entity Mapper. Now accepts the key name (only supports single names) and the additional object property and value pairs you want to map. The latter defaults to {isPartial:true}
define(
function () {
var defaultExtension = { isPartial: true };
var mapper = {
mapDtosToEntities: mapDtosToEntities
};
return mapper;
/**
@johnpapa
johnpapa / package.json
Last active December 29, 2015 15:11
running browser sync to launch an angular2 app with history fallback
{
"name": "angular2-getting-started",
"version": "1.0.0",
"description": "",
"scripts": {
"tsc": "tsc -p src -w"
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-alpha.44",
@johnpapa
johnpapa / foo.html
Last active January 13, 2016 05:48
Material Design Lite Snackbar / Toast
<div class="paper-snackbar">
Your message was sent
</div>