Skip to content

Instantly share code, notes, and snippets.

View jsdario's full-sized avatar

Jesús Darío jsdario

View GitHub Profile
@jsdario
jsdario / index.js
Created September 11, 2018 11:05
IndianredVibrantChapters created by jsdario - https://repl.it/@jsdario/IndianredVibrantChapters
const fetch = require('node-fetch')
fetch('https://api.github.com/repos/netbeast/dashboard/git/trees/master?recursive=1')
.then(r => r.json())
.then(data => {
const h = turnGitHubTreeIntoD3Hierarchy(data)
console.log(h)
})
.catch(console.error)
@jsdario
jsdario / adbx.js
Created August 9, 2018 08:22
Run adb commands in multiple devices at the same time, useful for React Native commands and other mobile developers
const {exec} = require('child_process')
exec('adb devices', (err, stdout, stderr) => {
if (err) {
console.error(err)
return
}
if (stderr) {
console.warn(stderr)
@jsdario
jsdario / Preferences.sublime-settings
Last active September 20, 2018 14:20
Sublime Preferences
{
"color_scheme": "Packages/Naomi/Candyman.tmTheme",
"draw_white_space": "all",
"folder_exclude_patterns":
[
".gradle",
".git",
"lcov-report",
"build/intermediates",
"build/outputs",
@jsdario
jsdario / observable-store.md
Created January 17, 2018 16:30
Redux notes

The store API is meant to be extensible. This is why it needs to be as orthogonal as possible. The methods shouldn't duplicate functionality because otherwise creating extensions to it like Redux DevTools becomes harder. If extensions want to do something to the state before passing it to the consumer, they'll now have to do it in two different places (three if we add two parameters!) which is error prone.

The solution is simple: don't use subscribe directly! It's a low level API. If you want it to behave as an Observable, write a function that turns it into an observable! It isn't hard to do:

function toObservable(store) {
  return {
    subscribe({ onNext }) {
      let dispose = store.subscribe(() => onNext(store.getState()));
      onNext(store.getState());
      return { dispose };
@jsdario
jsdario / bigfoot-sensor-client.js
Created November 17, 2017 15:54
Bigfoot Smart Home samples
const bigfoot = require("@netbeast/bigfoot")
bigfoot.hunt().then(function (devices) {
const sensor = devices['motion-sensor-01']
const plug = devices['raspberry-light-01']
bigfoot.listen(sensor, function (state) {
if (state.motion === 'motionstart') {
bigfoot.setState(plug, {power: 1})
} else if (state.motion === 'motionend') {
@jsdario
jsdario / motion-sensor.js
Last active November 17, 2017 15:53
Bigfoot Smart Home Samples
const bigfoot = require("@netbeast/bigfoot")
const five = require("johnny-five")
const board = new five.Board()
const options = {id: 'motion-sensor-01', topic: 'Motion'}
let state = { motion: "uncalibrated" }
board.on("ready", function() {
const motion = new five.Motion(7)
const device = bigfoot.alive(options, function (commit, params) {
@jsdario
jsdario / bedlight-switch.js
Last active November 16, 2017 23:49
Bigfoot Smart Home samples
const bigfoot = require('@netbeast/bigfoot')
const gpio = require('rpi-gpio')
const device = {
id: 'raspberry-light-01',
name: 'Bedtime light',
topic: 'Bulb',
}
let state = {}
@jsdario
jsdario / nuke-deps.sh
Last active December 12, 2023 08:36
Script to clean watchman, remove node_modules, clean cache and restart packager for React Native troubleshooting.
#!/bin/bash
# Stop cached listeners
watchman watch-del-all
# Remove installed modules
rm -rf node_modules
# Remove yarn meta files
rm yarn*
@jsdario
jsdario / automatedBuildAndUploadToTestflight.sh
Created February 22, 2017 10:18 — forked from djacobs/automatedBuildAndUploadToTestflight.sh
Automated Xcode build and upload to TestFlight.
#!/bin/sh
# Current as working as of 2012/4/17
# Xcode 4.3.2
PROJECT_ROOT="$HOME/SomeDirWhereYourProjectLives/XXXXXXXX"
WORKSPACE="$PROJECT_ROOT/XXXXXXXX.xcodeproj/project.xcworkspace"
CONFIG="AdHoc"
SCHEME="XXXXXXXX"
@jsdario
jsdario / .travis.yml
Created February 21, 2017 18:41 — forked from johanneswuerbach/.travis.yml
Deploy an iOS app to testflight using Travis CI
---
language: objective-c
before_script:
- ./scripts/travis/add-key.sh
after_script:
- ./scripts/travis/remove-key.sh
after_success:
- ./scripts/travis/testflight.sh
env:
global: