Skip to content

Instantly share code, notes, and snippets.

View onema's full-sized avatar
👾

Juan Manuel Torres onema

👾
View GitHub Profile
@onema
onema / gist:6060077
Last active December 20, 2015 02:59 — forked from makasim/gist:3720535
Form PatchSubsciber for Symfony 2.3. This Form Event Subscriber will help prepare data for a PATCH request. It can be added in your CustomFormType::buildForm method.
<?php
namespace Acme\DemoBundle\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
/**
* Changes Form->submit() behavior so that it treats not set values as if they
@onema
onema / gist:6060893
Last active December 20, 2015 03:08
Get form errors. Symfony 2.3
<?php
namespace Acme\DemoBundle\Controller;
//...
class ApiController extends Controller
{
//...
@onema
onema / post.md
Created January 17, 2014 22:54 — forked from kbond/post.md

Install git:

sudo apt-get install git

Configure Git:

touch ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
git config --global user.name "Your Name"

git config --global user.email "Your Email"

@onema
onema / nginx.conf
Created April 3, 2014 06:31 — forked from leon/nginx.conf
server {
listen 80;
server_name localhost;
root /home/website/web;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
@onema
onema / Vagrantfile - MAC
Last active August 29, 2015 14:00
Vagrantfile - LAMP Development
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Config Github Settings
github_username = "fideloper"
github_repo = "Vaprobash"
github_branch = "1.1.0"
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
# Server Configuration
@onema
onema / gist:a5176f97a68d98f3a83c
Last active August 29, 2015 14:03
SDPHP Study Group - Test Controller
<?php
namespace SDPHP\PhotoOpBundle\Controller;
use GuzzleHttp\Client;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class DefaultController extends Controller
{
@onema
onema / Vagrantfile
Created July 8, 2014 22:51
Vagrantfile - OLD
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Custom Vagrantfile for LAMP development
# Taken from http://fideloper.github.io/Vaprobash/
#
# Modification:
# 1) Set custom path to synced_folder, defaults to '.'.
# 2) Add custom vhost. Simply add 'host' and 'docroot' to vhost hash.
# Other values are currently ignored.
@onema
onema / permutations.go
Last active August 29, 2015 14:17
Heap's algorithm to generate permutations
package main
/**
* Word permutations using Heap's algorithm
* http://en.wikipedia.org/wiki/Heap%27s_algorithm
*/
import (
"fmt"
"strings"
"bytes"
)
@onema
onema / zerome_out.go
Created April 14, 2015 17:59
An algorithm that sets in an MxN matrix the entire row and column to 0 if an element is 0.
/**
* Problem: Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
* Not a very elegant solution but it gets the job done on my way to learn go!
*/
// zerome_out.go
package main
import (
"fmt"
)
@onema
onema / bit_insert.go
Last active August 29, 2015 14:20
Bit insertion
// bit_manipulation.go
// You are given two 32-bit numbers, `N` and `M`, and two bit positions,
// `i` and `j`. Write a method to set all bits between `i` and `j` in `N`
// equal to `M` (e.g. , `M` becomes substring of `N` located at i and string at `j`).
//
// EXAMPLE:
// input: N = 10000000000, M, 10101, i = 2, j = 6
// Output: N = 100001010100
package main