Skip to content

Instantly share code, notes, and snippets.

View Zacaria's full-sized avatar
🦀

Zacaria Chtatar Zacaria

🦀
View GitHub Profile
@Zacaria
Zacaria / gist:785a7ba27ba05dbbe4f8a48bbdcd2b8f
Created May 22, 2017 15:15
Kill all processes having name
killhard () {
ps -e | grep $1 | awk '{print $1}'
# For some reason there is no collision between the two $1 ...
kill -9 $(ps -e | grep $1 | awk '{print $1}')
}
@Zacaria
Zacaria / gist:321dce6f5a9cb86de84c086d63607875
Created April 11, 2017 09:31
Increase file watch capabilities for Webpack HMR
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf ; sudo sysctl -p
@Zacaria
Zacaria / .babelrc
Created February 21, 2017 10:09
React + webpack + karma + mocha
{
"presets": ["es2015", "react"]
}
@Zacaria
Zacaria / app.js
Created January 26, 2017 10:13
react component factory pattern
const CounterUi = ({value, increment, decrement}) => (
<div>
<p>
Counter : {value}
</p>
<div>
<button onClick={increment}>+</button>
<button onClick={decrement}>-</button>
</div>
</div>
@Zacaria
Zacaria / index.js
Last active January 25, 2022 15:21
Get keys of a collection of obejcts
const arr = [{"toto": 1, "tata": 4}, {"titi": 0}];
const res = arr.reduce((acc, e) => Array.prototype.concat(acc, Object.keys(e)), []);
console.log(res); // outputs: ["toto", "foo", "titi"]
@Zacaria
Zacaria / cluster.js
Created January 13, 2017 22:14
node app clustering
'use strict';
import cluster from 'cluster';
import os from 'os';
const numCPUs = os.cpus().length;
const stopSignals = [
'SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT',
'SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGTERM'
];
const production = process.env.NODE_ENV == 'production';
@Zacaria
Zacaria / .gitconfig
Last active January 8, 2017 22:04
my gitconfig
[push]
default = simple
[alias]
tree = log --graph --decorate --pretty=oneline --abbrev-commit --all
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
@Zacaria
Zacaria / index.html
Created January 5, 2017 14:06 — forked from anonymous/index.html
JS Bin // source http://jsbin.com/haruja
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="app"></div>
<script src="https://fb.me/react-15.1.0.js"></script>
@Zacaria
Zacaria / asyncSeries.js
Created December 29, 2016 14:12
async.series implementation
// Create async function array
const eFcts = ['f1', 'f2','f3'].map((url) =>
(err, cb) =>
setTimeout(() => {
cb(err, 'async ' + url)
}, 100)
);
// Wraps runner to keep track of results
const series = (pFcts, pDone) => {
@Zacaria
Zacaria / index.html
Last active December 28, 2016 10:51
Flex layout sticky head and foot
<section class="bloc">
<div class="title">
<h1>Titre</h1>
</div>
<div class="content">
<div class="content-title">
titre content
</div>
<div class="button-container">
Some button