Skip to content

Instantly share code, notes, and snippets.

View silasrm's full-sized avatar

Silas Ribas Martins silasrm

View GitHub Profile
@silasrm
silasrm / nginx.conf
Created July 22, 2016 05:07 — forked from atma/nginx.conf
Nginx + nodejs + socket.io websockets
# Add to nginx.conf http section
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
@silasrm
silasrm / pdf.py
Last active July 16, 2016 12:05
Generate many pdf files using a tuple of filename
from fpdf import FPDF
import re
import os
"""
Generate many files based on a tuple of data for sample.
@gist https://gist.github.com/silasrm/ff4733ecfa6bf1c6782c3513b89f10c4
@version 0.1
"""
@silasrm
silasrm / mongo-autostart-osx.md
Created June 30, 2016 02:39 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

@silasrm
silasrm / install.sh
Created June 1, 2016 23:49 — forked from solar/install.sh
install redis with supervisord
#!/bin/sh
version="2.6.3"
priority="20603"
sudo mkdir -p /var/redis /var/log/redis
curl -sL http://redis.googlecode.com/files/redis-${version}.tar.gz | tar zx
cd redis-${version}/
make
sudo make PREFIX=/usr/local/redis/${version} install
@silasrm
silasrm / one-liners.js
Last active May 17, 2016 03:04 — forked from nepsilon/5-handy-javascript-one-liners.md
5 handy Javascript one-liners
//1. Generate a random string:
Math.random().toString(36).substr(2);
//This simply generates a random float, casts it into a String using base 36 and remove the 2 first chars 0 and ..
//2. Clone an array:
var newA = myArray.slice(0);
//This will return a copy of the array, ensuring no other variables point to it.
//3. Remove HTML tags:
"<b>A</b>".replace(/<[^>]+>/gi, "");
@silasrm
silasrm / remove-docker-containers.md
Created April 28, 2016 21:03 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
@silasrm
silasrm / elasticsearch.md
Created March 6, 2016 05:45 — forked from nicolashery/elasticsearch.md
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
@silasrm
silasrm / 1-Readme.md
Created December 1, 2015 03:23 — forked from FlYos/1-Readme.md
Redirection user by roles after login/logout in symfony2

Description of this Gist

This is the how to for redirection implementation by roles after login or logout in Symfony2

Step

  1. Copy AfterLoginRedirection.php and AfterLogoutRedirection.php to your bundle under the "Redirection" directory
  2. Edit your services.yml file in your bundle and copy/paste the content of services.yml
  3. Edit your security.yml file...
  4. ... add success_handler: redirect.after.login in form_login: section
  5. ... add success_handler: redirect.after.logout in logout: section
@silasrm
silasrm / 1. infrastructure.php
Created November 30, 2015 21:09 — forked from Koc/1. infrastructure.php
Doctrine2 bulk inserts
<?php
use Doctrine\ORM\Persisters;
class DoctrineHelper
{
protected $entityManagers = array();
public function bulkCommit(EntityManager $em, array $entities)
{
@silasrm
silasrm / wp-query-ref.php
Created September 29, 2015 21:48 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(