Skip to content

Instantly share code, notes, and snippets.

@tngan
tngan / phx-1.4-upgrade.md
Created December 16, 2019 11:25 — forked from chrismccord/phx-1.4-upgrade.md
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@tngan
tngan / gist:1ab61415063d4c078c215f6909801bc8
Created November 26, 2019 05:51 — forked from meule/gist:777d9a8a42e2c99a3386
Smooth animation of changing Leaflet marker's position on setLatLng
// just include d3js and add animaDur in ms to marker's option
L.SVG.prototype._setPath = function(layer,path){
if(layer.options.animaDur)
d3.select(layer._path).transition().duration(layer.options.animaDur).ease('linear').attr('d',path)
else
layer._path.setAttribute('d', path);
}
@tngan
tngan / frontend-ws-connection.ts
Created May 2, 2019 15:01 — forked from jsdevtom/frontend-ws-connection.ts
kubernetes-ingress websockets with nodejs
export const ws = webSocket<WebsocketMessage>(`wss://${location.hostname}:${location.protocol === 'https:' ? 443 : 80}/ws/`);
export const wsObserver = ws
.pipe(
retryWhen(errors =>
errors.pipe(
delay(1000)
)
)
);
@tngan
tngan / erlang_string.ex
Last active September 8, 2018 09:49
my-elixir-playground
# output is "test"
:string.trim "test "
@tngan
tngan / stream_csv.ex
Created November 9, 2017 07:21 — forked from avdgaag/stream_csv.ex
Streaming CSV straight out of the database to the client using Elixir, Phoenix, Ecto and PostgreSQL.
def index(conn, _params) do
conn = conn
|> put_resp_content_type("text/csv")
|> put_resp_header("content-disposition", "attachment; filename=export.csv")
|> send_cunked(200)
Repo.transaction fn ->
Ecto.Adapters.SQL.stream(Repo, "COPY expensive_report TO STDOUT CSV HEADER")
|> Stream.map(&(chunk(conn, &1.rows)))
|> Stream.run
@tngan
tngan / .vimrc
Last active December 6, 2016 06:48
my .vimrc
set nocompatible " be iMproved, required
filetype off " required
let mapleader = "\<Space>"
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
" Plugin 'VundleVim/Vundle.vim'
@tngan
tngan / README.md
Last active December 5, 2016 02:18
.setup vim

https://github.com/junegunn/vim-plug

# install neovim in mac osx
brew install neovim/neovim/neovim
# install python interface
pip install neovim
pip3 install neovim # for vim-plug
# install vim-plug
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
@tngan
tngan / README.md
Last active October 14, 2016 08:56
Install ROS indigo in sierra

Ref: here

$ brew update
$ brew install cmake
$ brew tap ros/deps
$ brew tap osrf/simulation  # Gazebo, sdformat, and ogre
$ brew tap homebrew/versions # VTK5
$ brew tap homebrew/science  # others
@tngan
tngan / tmux-cheatsheet.markdown
Created June 22, 2016 11:15 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@tngan
tngan / command.md
Last active March 23, 2016 09:53
Useful ros command

Launch the environment

roslaunch hector_quadrotor_demo outdoor_flight_gazebo.launch

Mount the joystick

roslaunch hector_quadrotor_teleop logitech_gamepad.launch

Configure the joystick

roscd hector_quadrotor_teleop/launch