Skip to content

Instantly share code, notes, and snippets.

@Nguyenanh
Nguyenanh / gcm-high-prio.sh
Created April 16, 2018 04:49 — forked from sebastianbenz/gcm-high-prio.sh
Send high priority GCM messages via curl (Android Doze mode & App Standby testing)
curl -X POST \
-H "Authorization: key= YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [
"YOUR-GCM-REGISTRATION-ID"
],
"data": {
"message": "Hello Message"
},
@Nguyenanh
Nguyenanh / CONCURRENCY.md
Created April 29, 2018 08:36 — forked from montanaflynn/CONCURRENCY.md
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.

@Nguyenanh
Nguyenanh / CONCURRENCY.md
Created April 29, 2018 08:36 — forked from montanaflynn/CONCURRENCY.md
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.

@Nguyenanh
Nguyenanh / CONCURRENCY.md
Created April 29, 2018 08:36 — forked from montanaflynn/CONCURRENCY.md
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.

@Nguyenanh
Nguyenanh / run phoenix on amazon linux.sh
Last active April 19, 2019 09:14 — forked from mike-north/run phoenix on amazon linux.sh
run phoenix on amazon linux
# app deps
sudo yum install git
# erlang deps
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel openssl-devel
# erlang
wget http://www.erlang.org/download/otp_src_19.2.tar.gz
tar -zxvf otp_src_19.2.tar.gz
##### Replace 'example' anywhere with the name of your app and '*ec2ip*' with your ec2 instance ip
##### Set up your instance and make sure it's security group has ssh, http, and https open inbound and outbound
##### Don't forget to chmod 400 cert.pem
##### .deliver/config
APP="example"
BUILD_HOST="*ec2ip*"
BUILD_USER="elixir_builder"
BUILD_AT="/home/$BUILD_USER/edeliver/$APP/builds"
@Nguyenanh
Nguyenanh / preload_association.rb
Last active December 23, 2019 01:38 — forked from ssnickolay/preload_association.rb
Preload with Rails 6+
def preload_association(records)
::ActiveRecord::Associations::Preloader.new.preload(
records,
@association_schema,
@preload_scope
).then(&:first).then do |preloader|
next unless @preload_scope
# The result of previous preload is memoized, ActiveRecord won't load this association again.
if preloader.is_a?(::ActiveRecord::Associations::Preloader::AlreadyLoaded)
owner = preloader.send(:owners).first
@Nguyenanh
Nguyenanh / mysql2-mojave.md
Created January 8, 2020 02:15 — forked from fernandoaleman/mysql2-mojave.md
Install mysql2 on MacOS Mojave

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

brew install openssl
@Nguyenanh
Nguyenanh / gist:3b2564f1cb3c932fe48187f8b4c1477c
Created May 12, 2020 05:53 — forked from jordandm/gist:1879573
yum install of libxml-devel and libxslt-devel on broken node
$ sudo yum install libxml2-devel
Loaded plugins: fastestmirror, priorities, security
Loading mirror speeds from cached hostfile
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package libxml2-devel.x86_64 0:2.7.6-4.11.amzn1 set to be updated
--> Processing Dependency: pkgconfig for package: libxml2-devel-2.7.6-4.11.amzn1.x86_64
@Nguyenanh
Nguyenanh / install-redis.sh
Created October 1, 2020 05:31 — forked from jpickwell/install-redis.sh
Installing Redis 5.0.0 on Amazon Linux
#!/bin/bash
###############################################
# To use:
# chmod +x install-redis.sh
# ./install-redis.sh
###############################################
version=5.0.0