Skip to content

Instantly share code, notes, and snippets.

View onema's full-sized avatar
👾

Juan Manuel Torres onema

👾
View GitHub Profile
@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
@onema
onema / graceful_int_handler.py
Created November 5, 2015 17:53 — forked from nonZero/graceful_int_handler.py
GracefulInterruptHandler
import signal
class GracefulInterruptHandler(object):
def __init__(self, sig=signal.SIGINT):
self.sig = sig
def __enter__(self):
self.interrupted = False
@onema
onema / Vagrantfile-VMWare
Last active December 7, 2015 22:40
Vaprobash `Vagrantfile` for VMWare Fusion + Ubuntu 14.04
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Config Github Settings
github_username = "fideloper"
github_repo = "Vaprobash"
github_branch = "1.4.0"
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
# Server Configuration
@onema
onema / gist:eb5fbd8200882569a43b
Created December 8, 2015 00:54
Prevent vagrant from asking for password
sudo /bin/bash -c "echo 'Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports' >> /etc/sudoers"
sudo /bin/bash -c "echo 'Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart' >> /etc/sudoers"
sudo /bin/bash -c "echo 'Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports' >> /etc/sudoers"
sudo /bin/bash -c "echo '%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE' >> /etc/sudoers"