Skip to content

Instantly share code, notes, and snippets.

View androide-osorio's full-sized avatar

Andrés Osorio androide-osorio

View GitHub Profile
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@androide-osorio
androide-osorio / machine.js
Last active March 26, 2020 20:21
Generated by XState Viz: https://xstate.js.org/viz
/*
Null events and transient transitions
-----------------------------------------------
It is often useful to identify conditional branching in your machine as a state itself. A state that is designed to determine the next state does not need a specific event sent to trigger the transition. Instead, we can use the "null event" to trigger an immediate, transient transition.
The null event is identified with an event name of an empty string '', and is immediately sent to the state upon entry. We can setup multiple targets with conditionals, or fire off actions to set up a future state with this transient transitions.
*/
const ifAtFirstyouDontSuceed = Machine({
@androide-osorio
androide-osorio / proxies.js
Last active October 13, 2016 16:30
ES2015 Roadtrip to awesomeness - Proxies
/*
* Proxies
*/
/*
* Proxies allow to override the default behavior
* from an object's default operations.
*
* Proxies enable creation of objects with the full range of behaviors available to host objects.
* Can be used for interception, object virtualization, logging/profiling, etc.
*/
@androide-osorio
androide-osorio / generators.js
Created October 4, 2016 21:36
ES2015 roadtrip to awesomeness: Generators
/**
* ES2015 Generators
*/
// think of ES2015 generators as a new kind of function,
// which may be paused in the middle, one or many times,
// and resumed later, allowing other code to run during these
// periods of pause, and be passed different information
// each time it is started or paused, and respond accordingly
// to create a generator function,
@androide-osorio
androide-osorio / app.js
Last active September 9, 2016 20:16
ES2015 Roadtrip to awesomeness: Modules and SystemJS - this is a great way to quickly test an idea without having to use Webpack or Browserify. DO NOT USE FOR PRODUCTION CODE!!!
// with systemJS, you can import any npm module
// directly in the browser and use it as you see fit.
// just prepend the module name with 'npm:'
import { sum, kebabCase } from 'npm:lodash'
import { addTax } from './checkout';
const amount = 1500;
const myName = 'Androide Osorio';
console.log('Hi, my name is');
@androide-osorio
androide-osorio / .babelrc
Last active September 9, 2016 20:12
ES2015 Roadtrip to awesomeness: Modules - How to use ES2015 modules in a project using webpack. It also describes the syntax and rules of module exporting and importing.
{
"presets": [
["es2015", { "modules": false }]
]
}
@androide-osorio
androide-osorio / symbols.js
Last active September 9, 2016 15:53
ES2015 Roadtrip to awesomeness: Symbols
/**
______ _____ ___ ___ __ _____ _____ _ _
| ____| / ____| |__ \ / _ \ /_ | | ____| _ / ____| | | | |
| |__ | (___ ) | | | | | | | | |__ (_) | (___ _ _ _ __ ___ | |__ ___ | | ___
| __| \___ \ / / | | | | | | |___ \ \___ \ | | | | | '_ ` _ \ | '_ \ / _ \ | | / __|
| |____ ____) | / /_ | |_| | | | ___) | _ ____) | | |_| | | | | | | | | |_) | | (_) | | | \__ \
|______| |_____/ |____| \___/ |_| |____/ (_) |_____/ \__, | |_| |_| |_| |_.__/ \___/ |_| |___/
__/ |
|___/
*/
@androide-osorio
androide-osorio / sass-functions.scss
Created August 5, 2016 21:04
Useful SASS functions and mixins I keep using all the time build websites and applications
//-----------------------------------------------
// Utility functions
//-----------------------------------------------
// this file contains utility functions used
// throughout the entire SASS project
// @author Andrés Osorio
/// Remove the unit of a length
/// @param {Number} $number - Number to remove unit from
/// @return {Number} - Unitless number
@androide-osorio
androide-osorio / gh-pages-deploy.md
Created July 31, 2016 01:21 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@androide-osorio
androide-osorio / gulpfile.js
Created September 21, 2014 16:11
GulpJS workflow example
/*
Assets Tasks file with Gulp
Uses Gulp as build system. used mainly for watching changes
on the assets and process them to then copy the results into the
public directory
*/
//require gulp and gulp-load-plugins. We then call the gulp-load-plugins task
//to automatically load all installed gulp plugins
var gulp = require("gulp"),