Skip to content

Instantly share code, notes, and snippets.

View marcelaraujo's full-sized avatar

Marcel Araujo marcelaraujo

View GitHub Profile
@marcelaraujo
marcelaraujo / web-servers.md
Created August 30, 2017 05:40 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@marcelaraujo
marcelaraujo / server.js
Created August 2, 2017 00:36 — forked from garmjs/server.js
Simple SSR React, React Router v4 and Helmet with express
require('babel-register')
const express = require('express')
const React = require('react')
const ReactDOMServer = require('react-dom/server')
const ReactRouter = require('react-router')
const ServerRouter = ReactRouter.ServerRouter
const App = require('./src/App').default
const path = require('path')
const Helmet = require('react-helmet')
const compression = require('compression')
@marcelaraujo
marcelaraujo / actions.js
Created June 30, 2017 14:58 — forked from mksarge/actions.js
A minimal Redux-first routing implementation in <100 lines of code. Learn more: https://medium.com/@mksarge/98926ebf53cb
import { PUSH, REPLACE, GO, GO_BACK, GO_FORWARD, LOCATION_CHANGE } from './constants';
export const push = (href) => ({
type: PUSH,
payload: href,
});
export const replace = (href) => ({
type: REPLACE,
payload: href,
@marcelaraujo
marcelaraujo / gist:f29fa7c67c88e65cb257c6ebdf7292ca
Created June 28, 2017 06:58
Update all the git repositories that you have in a folder
Command
`find . -name .git -type d | xargs -n1 -P4 -I% git --git-dir=% --work-tree=%/.. remote update -p`
Using -type d prevents execution for ".git" files inside submodules. Using -P4 runs four fetches in parallel to speed things up a bit (and continues to make progress elsewhere if a single repository hangs). I prefer git remote update -p instead of git pull so that I can deal with merge conflicts later or rebase after I'm offline.
@marcelaraujo
marcelaraujo / ClientApp.jsx
Created May 12, 2017 18:08 — forked from btholt/ClientApp.jsx
react-router server-side rendering
const React = require('react')
const Landing = require('./Landing')
const Search = require('./Search')
const Layout = require('./Layout')
const Details = require('./Details')
const ReactRouter = require('react-router')
const data = require('../public/data')
const { Router, Route, hashHistory, IndexRoute } = ReactRouter
const Store = require('./Store')
const { store } = Store
@marcelaraujo
marcelaraujo / image.js
Created May 2, 2017 16:43
Image 1x1 blob
// From http://stackoverflow.com/questions/14967647/ (continues on next line)
// encode-decode-image-with-base64-breaks-image (2013-04-21)
function fixBinary (bin) {
var length = bin.length;
var buf = new ArrayBuffer(length);
var arr = new Uint8Array(buf);
for (var i = 0; i < length; i++) {
arr[i] = bin.charCodeAt(i);
}
@marcelaraujo
marcelaraujo / tmux.conf
Created April 7, 2017 12:08 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@marcelaraujo
marcelaraujo / actionCreators.js
Created November 3, 2016 16:04 — forked from cherta/actionCreators.js
redux-simple-router and sagas
export function retrieve(nodeId) {
return { type: 'RETRIEVE_NODE', payload: { nodeId: nodeId } }
}
export function show(nodes) {
return { type: 'SHOW_NODE', payload: { nodes: nodes } }
}
@marcelaraujo
marcelaraujo / redis.php
Created September 30, 2016 19:37
redis
<?php
$redis = new Redis();
$redis->connect( ‘localhost’, 6379 );
print_r($redis->info());
@marcelaraujo
marcelaraujo / setup.sh
Created September 19, 2016 23:55 — forked from Gazler/setup.sh
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb