Skip to content

Instantly share code, notes, and snippets.

View guzart's full-sized avatar

Arturo Guzman guzart

View GitHub Profile
@guzart
guzart / download
Created March 21, 2012 17:14
bash: Download and Compress Rails API
#!/bin/bash
rm -rf api.rubyonrails.org/
wget -r -k -p http://api.rubyonrails.org/
rm rails_api.rar
rar a -r rails_api.rar api.rubyonrails.org/
@guzart
guzart / load.js
Last active October 12, 2016 16:08
Load and unload homebrew plist files
#!/usr/bin/env node
var spawn = require('child_process').spawn;
var action = 'Load';
if (process.argv[2] === '-u') {
action = 'Unload';
}
for (var i = 0, f = process.argv.length; i < f; i += 1) {
var name = process.argv[i];
@guzart
guzart / arturo-guzman-pgpkey.txt
Created October 24, 2014 02:25
My PGP Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - https://gpgtools.org
mQENBFRJt8MBCACtqsE8GktrmbufzljppimupsRX+KMEzG5KWXJeI+xxi3QQssVt
4cLcZhAYSucsnEQiFFw0ye5VgQ/AZ3EdoMXct+2e/UExOLND5DJposPRWilLP+u1
pVW9Ko7QYg4k2y/K5dF3zyNxWAacqoyPA9NlmAY3kM1dIY9FQ3xyL/tpUaW6Zars
KsDwnltDWoPde+tb4Eak6+rtX3KpQUkTXnt9Q685QWCRbPa8oaMwT3wZspk6VNDD
0J2npYjanusgxUNRoTvK0Wlkn0zm4bxWJPqh9rC8EsaUNreB4laPsJM5xI1PS15r
hZBnoWENOllaD2jFXxGdw0L1FpkVJxvz1EbtABEBAAG0K0FydHVybyBHdXptYW4g
@guzart
guzart / react-component.cson
Created November 12, 2015 23:21
Atom Snippets
'.source.jsx':
'React Component':
'prefix': 'rcomp'
'body': '''
import React, { Component, PropTypes } from "react";
export default class $1 extends Component {
static get propTypes() {
return {
};

Reactive Programming

A practical example:

Whenever Foo does a network request, increment a counter in Bar.

The typical choice would be to write code inside Foo which calls method in Bar to increment the counter.

// foo.js
function findNamesInCommon(groupOne, groupTwo) {
const groupOneNames = groupOne.map(function (person) {
return person.get('name');
});
const groupTwoNames = groupTwo.map(function (person) {
return person.get('name');
});
const namesInCommon = groupOneNames.filter(function (g1Name) {

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
// @flow
import { flow } from 'lodash';
import { fromJS, Map } from 'immutable';
import type { User, ValidationErrors, WidgetAction } from 'pivot/types';
import * as t from './types';
import * as actions from './actions';
const EMPTY_ERRORS = new Map();
@guzart
guzart / capybara.rb
Last active April 5, 2021 20:13
Capybara configuration to run a webpack dev server for e2e testing
# spec/support/capybara.rb
require 'capybara/rails'
require 'capybara/rspec'
# port and url to webpack server
WEB_TEST_PORT = '5005'.freeze
WEB_TEST_URL = "http://localhost:#{WEB_TEST_PORT}".freeze
def capybara_wait_for_webpack_server
10.times.each do |_|
@guzart
guzart / init.sh
Last active April 16, 2017 00:53
Simple elm production builds
❯ mkdir src && touch src/index.js
❯ npm init
❯ npm install --save-dev neutrino neutrino-preset-elm