Skip to content

Instantly share code, notes, and snippets.

View helsont's full-sized avatar
🎯

Helson Taveras helsont

🎯
View GitHub Profile
@helsont
helsont / .eslintrc.js
Last active June 5, 2016 19:11 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
module.exports = {
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
@helsont
helsont / syncPromise.js
Created August 11, 2016 20:43
Utility to in order iterate through an array of promises and return an array of results after completion.
'use strict';
/**
* Sync promise
*
* Utility to in order iterate through an array of promises and return
* an array of results after completion.
*
* Usage:
*
version: '2.0'
services:
web:
build: .
ports:
- "8000:8000"
links:
- mysql
volumes:
- .:/app
web_1 | [Tue Oct 11 01:51:26 2016] 172.18.0.1:43048 [200]: /images/riley-99-banner.jpg
Exception in thread Thread-3:
Traceback (most recent call last):
File "threading.py", line 810, in __bootstrap_inner
File "threading.py", line 763, in run
File "compose/cli/log_printer.py", line 149, in tail_container_logs
File "compose/cli/log_printer.py", line 179, in wait_on_exit
File "compose/container.py", line 239, in wait
File "site-packages/docker/utils/decorators.py", line 21, in wrapped
File "site-packages/docker/api/container.py", line 441, in wait
@helsont
helsont / on-jsx.markdown
Last active September 14, 2017 16:51 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@helsont
helsont / ActionCreator.js
Last active September 19, 2017 19:28
The main file (real code) is ActionCreator.js
/**
* A redux object with data on the action being sent
* @param {String} actionType The "type" of the redux action
* @param {Object} data Any data that will passed to the reducer
* @return Object The redux action
*/
const action = (actionType, data) => {
return {
type: actionType,
receivedAt: Date.now(),
<?php
public function assertKeys($expected, $array)
{
// we want to find if there are differences between the expected keys
// and what the $array has provided. array_diff_key does the job but
// it is incomplete because it is unidirectional:
//
// array_diff_key(['a', 'b'], []) !== array_diff_key([], ['a', 'b']);
// [] !== ['a', 'b']
@helsont
helsont / auto_purge.sh
Last active January 15, 2018 17:07
Moves backups from a primary disk to a secondary disk when primary becomes full. Removes the oldest file from the secondary drive when secondary becomes full.
PRIMARY_DIR=/mnt/primary
SECONDARY_DIR=/mnt/secondary
is_almost_full() {
DIR_NAME=$1
cd $DIR_NAME
# Get percent usage of current directory in bytes
PERCENT=$(df -B1 `pwd` | awk 'END{print $5}')