Skip to content

Instantly share code, notes, and snippets.

View abrahamhurtado's full-sized avatar
🤷‍♂️
¯\_(ツ)_/¯

Abraham Hurtado abrahamhurtado

🤷‍♂️
¯\_(ツ)_/¯
  • Nearsoft
  • Hemosillo, Sonora, MX.
View GitHub Profile
@toptensoftware
toptensoftware / getFileLinesSync.js
Last active March 27, 2021 07:20
Synchronously read a file line by line with NodeJS
let fs = require('fs');
let string_decoder = require('string_decoder');
// Synchronously read the content of a text file one line at a time
// Note, caller must complete the iteration for file to be closed
// ie: don't break out early from the loop calling this function
function* getFileLinesSync(filename, encoding)
{
let fd = fs.openSync(filename);
let buf = Buffer.allocUnsafe(32768);
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active March 14, 2026 03:25
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
@jwilson8767
jwilson8767 / install_WSL_docker.sh
Last active March 23, 2026 02:58
Docker Toolbox for Windows and Windows Subsystem for Linux (aka Bash on Windows)
#
# This script installs and configures WSL to work with Docker Toolbox for Windows.
# 1. Install WSL (check out [bowinstaller](https://github.com/xezpeleta/bowinstaller) for programmatic installation.
# 2. Run the contents of this script in Bash. (copy and paste works fine, no need to save)
#
sudo -sEH << 'EOM'
# Install the docker client and docker-compose
apt-get update && apt-get install -y curl ca-certificates
curl -sSL https://get.docker.com/ | sh
curl -L "https://github.com/docker/compose/releases/download/1.11.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
@strarsis
strarsis / docker-on-wsl-windows-10-home-docker-toolbox.md
Last active September 4, 2023 07:29
Notes about Docker on WSL (Windows 10 Home / Docker Toolbox) (Virtualbox instead Hyper-V)

Edit (September 2020):

@acdlite
acdlite / app.js
Last active April 20, 2026 19:56
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@Dr-Nikson
Dr-Nikson / 0-redux-auth.MD
Last active October 23, 2017 17:16
This is a redux-auth concept

This gist is about token-based authentication (who you are?) with redux

Currently it for clent-side apps only. Not for universall (isomorphic) apps. Will add it soon

0. Requirements

I'm using the promise middleware to dispatch actions like this:

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () =&gt; x) {
require("babel/register");
const dependencies = require('./src/dependencies');
var WebpackIsomorphicTools = require('webpack-isomorphic-tools');
var chokidar = require('chokidar');
var webpack = require('webpack');
var config = require('./config/webpack.config.dev');
var compiler = webpack(config);
var app = dependencies.expressApp;
var Mocha = require('mocha');

First of all, this is not my brilliant effort to get react-native working on Windows, it is the collation of work by others, particularly @mqli and @Bernd Wessels. I've just summarised what worked for me.

If you would prefer to read what I've plagerised, head over to mqli's great gist

Disclaimer

  • The below is tested with react-native-cli 0.1.5, react-native 0.12.0 on Windows 10, node 4.1.1, and Android (physical Nexus 6 and AVD with API v22)
  • I hope this will all be redundant in a few weeks. Please comment on stuff that is now fixed and I will update this to keep it relevant.
  • Sprinkle a bit of YMMV around

Keep this github issue handy, it’s the bucket for all Windows/Linux related tricks to get RN working.

@gaearon
gaearon / slim-redux.js
Last active March 26, 2026 21:25
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {