Skip to content

Instantly share code, notes, and snippets.

View evillemez's full-sized avatar

Evan Villemez evillemez

  • Global Professional Search
  • Washington, DC
View GitHub Profile
@evillemez
evillemez / gist:8735382
Last active August 29, 2015 13:55
traits, magic methods and inheritance
<?php
trait Methods
{
public function __call($name, $args)
{
if (property_exists($this, $name)) {
return $this->$name;
}
@evillemez
evillemez / gist:9667390
Created March 20, 2014 16:09
Idea for generating fixtures - this is generation only, not about persistence
<?php
namespace AC\Fixtures;
/**
* Factories use Definitions and Pools to create and store (not persist) object instances.
*/
interface Factory
{
public function define($name); //create and returns Definition
@evillemez
evillemez / gist:9858646
Created March 29, 2014 17:34
anonymous functions and stuff
var logSomething = function(something) {
console.log(something);
};
function do_math(foo, bar, baz) {
return foo + bar + baz;
};
function do_math_then(foo, bar, baz) {
@evillemez
evillemez / gist:9859256
Created March 29, 2014 18:07
getting file contents in node/php

Logging the contents of a file, and printing some random stuff:

JS (in node):

var fs = require('fs');

fs.readFile('/foo.txt', function(contents) {
	console.log(contents);
});
setTimeout(function() {
console.log("2 seconds");
}, 2000);
setTimeout(function() {
console.log("now??");
}, 0);
console.log("now");
@evillemez
evillemez / fixtures.php
Created April 4, 2014 17:39
Brainstorming for a very small fixture generation library.
<?php
namespace AC\Fixtures;
/**
* Factories use Definitions and Pools to create and store (not persist) object instances.
*/
interface Factory
{
public function define($name); //create and returns Definition
@evillemez
evillemez / interfaces.php
Created April 29, 2014 19:21
Prototype interfaces for a simpler Authentication framework.
<?php
namespace AC\Authentication;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
gulp.task('build:bundles', function() {
var promises = [];
glob.sync('bundles/*/*/').forEach(function(dir) {
promises.push(cubeBuildBundle(dir, 'build/'+dir));
});
return Q.all(promises);
});
gulp.task('build:apps:dev', ['build:bundles'], function() {
var promises = [];

AngularStrap Modal Wrapper

This describes a provider/service for wrapping the AngularStrap $modal service. It allows for somewhat easier programatic usage.

Usage

First, you define a modal using the provider. Modals are named, and have default configuration for the underlying $modal service:

angular.module('app', ['app.modals']).config (modalsProvider) ->
@evillemez
evillemez / gist:cbde6b26f0bafe72f41a
Created August 25, 2014 16:14
An API for validation that I would like...
#empty validator
validator = new Validator()
#custom app validator
validator.constraint 'unique-name', (val, ops = {}) ->
namelist = [] #... array of names in system
return "Name already exists!" if namelist.indexOf val > -1
return true
#another custom validator