Skip to content

Instantly share code, notes, and snippets.

View idmontie's full-sized avatar

Ivan Montiel idmontie

View GitHub Profile
// Usage as a Component
import React, { Component } from 'react';
import Feature from 'react-feature-flags/components';
import { MY_FEATURE_FLAG } from '../flags/constants';
export default class MyComponent extends Component {
render() {
return (
@idmontie
idmontie / mixing_recordings.md
Created November 16, 2017 01:05 — forked from ktoraskartwilio/mixing_recordings.md
Mixing Recordings

When mixing the tracks, we need to consider that they might (and probably have) started at different times. If we were to merge tracks without taking this into account, we would end up with synchronization issues. In our example, since Bob got in the room a good 20s (and that’s really a huge time for synchronization of audios), mixing both Alice’s and Bob’s audio tracks together would end up having one speaking over the other.

To make merging easier, the start time of all tracks from the same room is the creation of the room itself. Let’s get the start times for all the tracks from this room

Get Alice's audio start time

@idmontie
idmontie / settled.js
Created March 16, 2018 22:08
Like Promise.all, but it doesn't fail if one of the promises fails.
function settled(promises) {
const alwaysFulfilled = promises.map((p) => {
return p.then((value) => {
return { state: 'fulfilled', value: value };
}, (reason) => {
return { state: 'rejected', reason: reason };
});
});
return Promise.all(alwaysFulfilled);
};
@idmontie
idmontie / thenable.js
Created March 16, 2018 22:14
Promises with thenable objects
function thenable(value) {
return {
then: function (onfulfill, onreject) {
onfulfill(value);
};
};
}
const promise = Promise.resolve(thenable('voila!'));
@idmontie
idmontie / Reiss User Stories.md
Created March 17, 2018 05:30
User stories, but focused on meeting Reiss desires

As a <role>, I want <something> so that <Reiss desire is met>.

  • Power – I can feel powerful and meet my goals.
  • Curiosity – I can gain understanding of the world around me.
  • Independence – I can make choices that are meaningful to me and explore possibilities about myself.
  • Status – I feel like I am an important person.
  • Social contact – I can connect with others.
  • Vengeance – I can compete against others.
  • Honor – I can feel reliable.
  • Idealism – I can help others and improve their situation.
@idmontie
idmontie / framebust.html
Last active March 17, 2018 20:34
Make sure you aren't iframed!
<!-- Crazy, but consistent method: -->
<style>
body { display: none; }
</style>
<script>
if (self === top) {
documents.getElementsByTagName("body")[0].style.display = 'block';
} else {
top.location = self.location;
@idmontie
idmontie / beep
Created March 29, 2018 08:58
Bash script to let you know when a command finishes
#!/bin/bash
# Add this file to your bash path
# Make sure to chmod 755 it
# Example useage:
# MY_COMMAND; beep
if [ "$?" = "0" ]; then
afplay /System/Library/Sounds/Submarine.aiff -v 8
else
@idmontie
idmontie / App.js
Last active April 6, 2018 22:30
Mouse Move Example
const centerX = Math.floor(window.innerWidth / 2);
const centerY = Math.floor(window.innerHeight / 2);
class App extends Component {
render() {
return (
<MousePosition>
{({ x, y }) => (
<Tween func={easeOutQuad} defaultStart={centerX} end={x}>
{({ current: cx }) => (
function linear(diff, start, change, duration) {
return change * (diff /= duration) + start;
}
class SimpleTween extends Component {
static defaultProps = { duration: 1000 }
constructor(props) {
super(props);
this.state = {
timeStart: +new Date(),
current: props.start,
};