Skip to content

Instantly share code, notes, and snippets.

<?php
trait EventGenerator
{
protected $pendingEvents = array();
protected function raise($event)
{
$this->pendingEvents[] = $event;
}
<?php
class PostEntity
{
private $id;
private $user;
private $title;
private $content;
private $date;
from django.contrib.sites.models import Site
class Object(object):
def __init__(self, model, key):
self.model = model
self.key = key
def __call__(self, *args, **kwargs):
params = {}
@johnnncodes
johnnncodes / gist:9725c0702762e41ad68b
Created December 11, 2014 23:55
Multiple apps directory structure for AngularJS
projectname/
README.md
.gitignore
bower.json
package.json
node_modules/
bower_components/
bin/
script1
script2
var HEADER_NAME = 'MyApp-Handle-Errors-Generically';
var specificallyHandleInProgress = false;
angular.module('myApp').factory('RequestsErrorHandler', ['$q', function($q) {
return {
// --- The user's API for claiming responsiblity for requests ---
specificallyHandled: function(specificallyHandledBlock) {
specificallyHandleInProgress = true;
try {
return specificallyHandledBlock();
@johnnncodes
johnnncodes / upload.js
Last active August 29, 2015 14:10 — forked from thekarel/upload.js
var util = require('util');
it('should upload file', function() {
var fileToUpload = '../some/path/foo.txt';
var absolutePath = path.resolve(__dirname, fileToUpload);
$('input[type="file"]').sendKeys(absolutePath);
$('#uploadButton').click();
});
/**
* Interceptor
* Implements functionality to catch various requests and fire events when they happen. This is generally to ensure
* that responses from the server are handled in a uniform fashion across the application. Also, by firing events
* it allows to have any number of handlers attach to the response.
*
* @author Kirk Bushell
* @date 28th March 2013
*/
var module = angular.module('core.interceptor', []);
## Customized for Laravel 4
# setting worker_processes to CPU core count
worker_processes 1;
daemon off;
events {
worker_connections 1024;
}
## Customized for Laravel 4
# setting worker_processes to CPU core count
worker_processes 1;
daemon off;
events {
worker_connections 1024;
}
'use strict';
/**
*
* An Angular Jasmine testing utility
*
* @copyright 2013 Chris Sattinger
* MIT License
*
* automatically injects these services:
* '$httpBackend', '$rootScope', '$controller', '$compile'