Skip to content

Instantly share code, notes, and snippets.

View PatrickJS's full-sized avatar

PatrickJS PatrickJS

View GitHub Profile
  • 100 "continue"
  • 101 "switching protocols"
  • 102 "processing"
  • 200 "ok"
  • 201 "created"
  • 202 "accepted"
  • 203 "non-authoritative information"
  • 204 "no content"
  • 205 "reset content"
  • 206 "partial content"
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
# Docker
172.16.42.43 localdocker
@PatrickJS
PatrickJS / Paginated.js
Created February 22, 2014 23:51
Paginated Backbone collection
var Paginated = Backbone.Collection.extend({
pagination : function(perPage, page) {
page = page-1;
var collection = this;
collection = _(collection.rest(perPage*page));
collection = _(collection.first(perPage));
return collection.map( function(model) { return model.toJSON() } );
}
});
var Promise = require('bluebird');
var facebookAsync = function() {
var dfd = Promise.defer();
FB.login(function(err, user) {
if (err) {
dfd.reject(err);
} else {
@PatrickJS
PatrickJS / $q.js
Created March 4, 2014 07:56
decorator for q style promises
app.config(['$provide', function($provide) {
$provide.decorator('$q', function ($delegate) {
var defer = $delegate.defer;
console.info('Q');
var all = $delegate.all;
$delegate.defer = function () {
var deferred = defer();
deferred.promise.success = function (fn) {
deferred.promise.then(function (value) {
fn(value);
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Preloading Images In AngularJS With Promises
</title>
</head>
<body ng-controller="AppController">
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({port: 8080});
var jwt = require('jsonwebtoken');
/**
The way I like to work with 'ws' is to convert everything to an event if possible.
**/
function toEvent (message) {
try {
var slice = Array.prototype.slice;
function curry(fn)
return function(args1) {
if (fn.length > arguments.length) {
args1 = slice.apply(arguments);
returrn function(args2) {
args2 = slice.apply(arguments);
return fn.apply(null, agrs1.concat(args2));
angular.module('myMdl', []).config(['$httpProvider', function($httpProvider) {
$httpProvider.responseInterceptors.push([
'$q', '$templateCache', 'activeProfile',
function($q, $templateCache, activeProfile) {
// Keep track which HTML templates have already been modified.
var modifiedTemplates = {};
// Tests if there are any keep/omit attributes.
var HAS_FLAGS_EXP = /data-(keep|omit)/;
@PatrickJS
PatrickJS / dabblet.css
Created June 12, 2014 19:57 — forked from chriscoyier/dabblet.css
Triangle with Shadow
/*
Triangle with Shadow
*/
.triangle-with-shadow {
width: 50px;
height: 100px;
position: relative;
overflow: hidden;
box-shadow: none