Skip to content

Instantly share code, notes, and snippets.

View alex-alex2006hw's full-sized avatar

alex-alex2006hw

View GitHub Profile
@alex-alex2006hw
alex-alex2006hw / gist:8b35983b068a17263295146ce71faaf9
Created June 8, 2018 19:49 — forked from ivan-loh/gist:ee0d96c3795e59244063
Node.JS ( & pm2 ) Process Memory Limit
# Plain Ol' Node
node --max-old-space-size=1024 app.js # increase to 1gb
node --max-old-space-size=2048 app.js # increase to 2gb
node --max-old-space-size=3072 app.js # increase to 3gb
node --max-old-space-size=4096 app.js # increase to 4gb
node --max-old-space-size=5120 app.js # increase to 5gb
node --max-old-space-size=6144 app.js # increase to 6gb
# For pm2
pm2 start app.js --node-args="--max-old-space-size=1024" # increase to 1gb
@alex-alex2006hw
alex-alex2006hw / LICENSE
Created April 23, 2018 22:30 — forked from ourmaninamsterdam/LICENSE
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@alex-alex2006hw
alex-alex2006hw / README.md
Created November 20, 2017 11:59 — forked from joyrexus/README.md
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@alex-alex2006hw
alex-alex2006hw / README.md
Created November 20, 2017 11:59 — forked from joyrexus/README.md
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@alex-alex2006hw
alex-alex2006hw / GunMiddleware.js
Created May 11, 2017 07:13 — forked from devel-pa/GunMiddleware.js
Redux middleware for GunDB. Low perfomance. Supports arrays.
/**
* Created by Paul on 10/7/2016.
* GunDB v0.3
* inspired by https://github.com/pgte/pouch-redux-middleware
* TODO: issue: stores duplicates in an object path.docs for removing redundant operations
* - can be implemented with redux history, but same lot of data
* - checking with gun, don't know how, yet
* - another method is eventually to store timestamps (updated_at) in redux and only that in path.docs
* TODO: issue: not quite async as it should be in certain areas
*/
@alex-alex2006hw
alex-alex2006hw / AvcEncoder.java
Created May 7, 2017 08:02 — forked from wobbals/AvcEncoder.java
MediaCodec encoder sample
package com.opentok.media.avc;
import java.io.IOException;
import java.nio.ByteBuffer;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
public class AvcEncoder {
@alex-alex2006hw
alex-alex2006hw / js-crypto-libraries.md
Created January 10, 2017 03:04 — forked from jo/js-crypto-libraries.md
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

I start with a list and plan to create a comparison table.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

@alex-alex2006hw
alex-alex2006hw / better-nodejs-require-paths.md
Created October 7, 2016 22:36 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

# this script is used to partition and mount a 'local' disk on AWS EC2 after provisioning
#
TARGETDISK='docker'
RAWDISK=`(lsblk -P | grep ${TARGETDISK} | awk '{ print $1}' | uniq | awk -F= '{print $2}' | sed 's/\"//')`
DISK="/dev/mapper/$RAWDISK"
MOUNTDIR='/scratch'
SWAPFILE="$MOUNTDIR/swapfile02"
NOTMOUNTED=`(mount | grep $DISK | wc -l)`
DISKSIZE=`lsblk -b --output SIZE -n -d $DISK`
SWAPSIZE=`r=$((($DISKSIZE)/2000000000)) ; printf %d.%d ${r%??} ${r#${r%??}} | awk '{print int($1+0.5)}'`
@alex-alex2006hw
alex-alex2006hw / Enhance.js
Created May 16, 2016 01:49 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {