Skip to content

Instantly share code, notes, and snippets.

import Server from 'server';
import Logger from 'logger';
import Slack from 'slackNotifier';
import sinon from 'sinon';
it('should log startup errors and send them to slack', () => {
sinon.spy(Logger, 'logException');
Slack.notify = sinon.spy(() => {});
Server.create({ port: 5000 });
import Server from 'server';
import Queue from 'queueWorker';
import Resizer from 'fileResizer';
Server.create({ port: 5000 });
Queue.create({ port: 5001 });
Resizer.create({ port: 5002 });
@pkriete
pkriete / gist:6212796
Last active December 20, 2015 23:29 — forked from NickToye/gist:6207573
<section class="related_projects">
<h2>Related Projects</h2>
{projects_related}
{if projects_related:no_results}
There are no related projects.
{/if}
{if projects_related:count == "1"}
<ul class="slats">
@pkriete
pkriete / gist:2425817
Created April 20, 2012 03:52
PHP Tail Recursion
function tailrec($func)
{
$acc = array();
$recursing = FALSE;
$func = new ReflectionFunction($func);
return function() use ($func, &$acc, &$recursing) {
$acc[] = func_get_args();
@pkriete
pkriete / welcome.php
Created March 13, 2012 16:41
Sparks Example
class Welcome extends CI_Controller {
protected $user = 'github';
public function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->spark('restclient/2.0.0');
@pkriete
pkriete / Nonsense.php
Created November 12, 2010 17:54
Same class, separate instances, can change sibling object's private variables. What the hell, PHP?
<?php
ini_set('display_errors', true);
class Car
{
private $make;
public function __construct($make)
{
// sorta like manual profiling.
// peek into your jquery method calls to see why they are being called so much
// usage:
// $.logCallsTo('append');
// $.logCallsTo('curCSS',true);
// output:
// http://gyazo.com/40cec25d875a7a767e95fd7a2f451b32.png
@pkriete
pkriete / jquery.ajax_queue.js
Created June 17, 2009 20:45
jQuery 1.3 compatible version of the ajax queue plugin.
/**
* Ajax Queue Plugin
*
* Original Homepage: http://jquery.com/plugins/project/ajaxqueue
* Original Documentation: http://docs.jquery.com/AjaxQueue
*/
jQuery.ajaxQueue = function(o){
var _old = o.complete;
o.complete = function(){
var apps = $('#applications');
var off_top = apps.offset().top;
apps.css({
position: 'absolute',
top: off_top
});
Oauth basics for JR:
The goal is to give a third party app authenticated access to your api using a token in place of a user's credentials.
To do that, the third party app first gets a consumer key and secret from your app. These are used to sign all requests, so no other third party can pretend to be that service.
The same thing needs to happen for individual users. Here it gets a little more complicated. The third party app first gets a request token for that user. This is used in all requests so we know who we're dealing with.
Once they have a request token for that user they redirect him/her to your authentication page (passing the token along in the url). The user logs in to your app and approves the third party service. Your app then sends them back to the third party. At this point the third party application knows that the user is ok with giving them access to their data.