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 / keybindings.json
Created July 19, 2017 20:09
Custom VSCODE keybindings for Ubuntu
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+m",
"command": "editor.action.jumpToBracket",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+\\",
"command": "-editor.action.jumpToBracket",
@evillemez
evillemez / example.js
Created October 16, 2016 01:32
This was an old hacky attempt at a promise-based API for running any function in a web worker. Never got around to fleshing it out.
//Code for async web worker
var fibonacciWorkerTask = function(iterations) {
var first,second,add;
for (var i=0; i<iterations; i++) {
if (i === 0) {
first = 1;
second = 2;
}
@evillemez
evillemez / wait-groups.go
Created October 16, 2016 00:50
Playing with WaitGroup in nested goroutines
package main
import (
"crypto/rand"
"fmt"
"math/big"
"os"
"sync"
"time"
)
@evillemez
evillemez / clean-csv.php
Created February 25, 2016 16:34
simple script to clean a csv file that has an expected structure
#!/usr/bin/env php
<?php
// Note: this script assumes a CSV structure of:
// email,firstName,lastName
//
// The script dudupes by email and trims all fields. Rows
// missing an email are discarded. Validity of email is otherwise
// not checked.
//
@evillemez
evillemez / shaded-bg-columns.less
Created July 12, 2015 19:58
Responsive full-width shaded left column for the Bootstrap 3 grid system
.shaded-bg-calc(@col) {
@shaded-bg-calc-xs: percentage((@col / @grid-columns));
@shaded-bg-calc-sm: ~"50% - (@{container-sm}/2) + ((@{container-sm} * @{col})/@{grid-columns})";
@shaded-bg-calc-md: ~"50% - (@{container-md}/2) + ((@{container-md} * @{col})/@{grid-columns})";
@shaded-bg-calc-lg: ~"50% - (@{container-lg}/2) + ((@{container-lg} * @{col})/@{grid-columns})";
}
.shaded-bg-xs-column(@col, @leftColor, @rightColor) {
.shaded-bg-calc(@col);
@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

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) ->
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 = [];
@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;
@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