Skip to content

Instantly share code, notes, and snippets.

View tuanmai's full-sized avatar
🎯
Focusing

Tuan Mai tuanmai

🎯
Focusing
View GitHub Profile
@tuanmai
tuanmai / list.md
Created January 7, 2022 11:10 — forked from ih2502mk/list.md
Quantopian Lectures Saved
@tuanmai
tuanmai / Flexible Dockerized Phoenix Deployments.md
Created October 20, 2020 07:37 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

@tuanmai
tuanmai / gist:f524aff20b424bf9f5d735ef3951f5c8
Last active July 19, 2019 03:01 — forked from bessarabov/gist:674ea13c77fc8128f24b5e3f53b7f094
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Tuan Mai" --date=iso | perl -nalE 'if (/[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
import React, { PureComponent } from 'react';
import { View, Animated, Dimensions, Platform } from 'react-native';
import Interactable from 'react-native-interactable';
import { compose, mapProps } from 'recompose';
const { width } = Dimensions.get('window');
/* eslint-disable */
/*
* Origin state
$$('.file-header button').forEach(function(element){element.click()})
Type man tar for more information, but this command should do the trick:
tar -xvzf community_images.tar.gz
To explain a little further, tar collected all the files into one package, community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things:
f: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file.
z: tells tar to decompress the archive using gzip
x: tar can collect files or extract them. x does the latter.
v: makes tar talk a lot. Verbose output shows you all the files being extracted.
lsof -nP +c 15 | grep LISTEN
```
com.docker.slir 1676 tuanmai 19u IPv4 0x833f33a136ee0815 0t0 TCP *:10871 (LISTEN)
com.docker.slir 1676 tuanmai 21u IPv6 0x833f33a13723fb95 0t0 TCP [::1]:10871 (LISTEN)
com.docker.slir 1676 tuanmai 23u IPv4 0x833f33a13a3c8435 0t0 TCP *:32773 (LISTEN)
com.docker.slir 1676 tuanmai 25u IPv6 0x833f33a136b18b75 0t0 TCP [::1]:32773 (LISTEN)
com.docker.slir 1676 tuanmai 26u IPv4 0x833f33a136f55435 0t0 TCP *:5431 (LISTEN)
com.docker.slir 1676 tuanmai 27u IPv6 0x833f33a12d071615 0t0 TCP [::1]:5431 (LISTEN)
com.docker.slir 1676 tuanmai 29u IPv4 0x833f33a136bdea05 0t0 TCP *:3000 (LISTEN)
```
grep -A 5
-B, --before-context=NUM print NUM lines of leading context
-A, --after-context=NUM print NUM lines of trailing context
-C, --context=NUM print NUM lines of output context
@tuanmai
tuanmai / branch-fu.md
Created June 15, 2016 16:41 — forked from unbracketed/branch-fu.md
Moving commits between branches

Example: Moving up to a few commits to another branch

Branch A has commits (X,Y) that also need to be in Branch B. The cherry-pick operations should be done in the same chronological order that the commits appear in Branch A.

cherry-pick does support a range of commits, but if you have merge commits in that range, it gets really complicated

git checkout branch-B
git cherry-pick X
git cherry-pick Y
@tuanmai
tuanmai / nginx.conf
Created May 6, 2016 03:44 — forked from baskaran-md/nginx.conf
NginX allow POST on static pages.
# ...
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}