Skip to content

Instantly share code, notes, and snippets.

View Mparaiso's full-sized avatar

mparaiso Mparaiso

View GitHub Profile

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
var colors = ['#580201','#d9bd6a','#d9d49a','#037f8b','#025e73'];
var elems = [];
var body = document.getElementsByTagName('body')[0];
var xElems = window.innerWidth/30,
yElems = body.clientHeight/10,
fragment = document.createDocumentFragment();
for(var j = 0 ; j<yElems;j++){
@Mparaiso
Mparaiso / charge.js
Created March 9, 2013 07:11
Charge.js : simple script loader
/**
* @module Charge
* @author M.Paraiso
*/
(function(ns){
"use strict";
var C = {};
C.getXmlHttp = function(method,callback){
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange(function(event){
@Mparaiso
Mparaiso / gist:5159788
Created March 14, 2013 08:33
symfony/form validation constraint
// I am trying to put a validation constraint on an input field for inputting a username that it be unique -
//if the name is already present in the database I want the validation to fail.
//Is there an obvious way to go about this? Any hint in the right direction would be appreciated.
/*
Here's an example from one of my projects. This is from a registration
form, to check if the email is already used.
First, I make "app" a required option of my form type:
@Mparaiso
Mparaiso / .travis.yml
Created March 30, 2013 19:41
travis config file for haxe / NME
language: node_js
node_js:
- 0.6
before_install:
- sudo apt-get install python-software-properties -y # for the next command
- sudo add-apt-repository ppa:eyecreate/haxe -y
- sudo apt-get update
- sudo apt-get install haxe -y
- sudo apt-get install gcc-multilib g++-multilib -y # since VM is 64bit but hxcpp builds 32bit by default
@Mparaiso
Mparaiso / ServiceProviderDumper.php
Last active December 16, 2015 09:49
dump bundles into service provider
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
authRouteProvider.$inject = ['$routeProvider'];
function authRouteProvider ($routeProvider) {
/**
* Creates a controller bound to the route, or wraps the controller in param
* so the authentication check is run before the original controller is executed
* @param currentController
* @return {Function} The wrapper controller
*/
function redirectCtrlFactory (currentController) {
_ctrl.$inject = ['currentUser__', 'userRole__', '$location'];
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/