Skip to content

Instantly share code, notes, and snippets.

@dinhnv
dinhnv / learn.md
Created May 25, 2022 03:28 — forked from rylev/learn.md
How to Learn Rust

Learning Rust

The following is a list of resources for learning Rust as well as tips and tricks for learning the language faster.

Warning

Rust is not C or C++ so the way your accustomed to do things in those languages might not work in Rust. The best way to learn Rust is to embrace its best practices and see where that takes you.

The generally recommended path is to start by reading the books, and doing small coding exercises until the rules around borrow checking become intuitive. Once this happens, then you can expand to more real world projects. If you find yourself struggling hard with the borrow checker, seek help. It very well could be that you're trying to solve your problem in a way that goes against how Rust wants you to work.

@dinhnv
dinhnv / useful_funcs
Created February 4, 2021 04:52
Helpful shell functions
#!/usr/bin/env bash
set -e
DC="${DC:-exec}"
APP_NAME="${APP_NAME:-hello}"
# If we're running in CI we need to disable TTY allocation for docker-compose
# commands that enable it by default, such as exec and run.
TTY=""
@dinhnv
dinhnv / resolve-docker-host-ip.sh
Created November 19, 2020 05:03
resolve ip for host.docker.internal DNS entry
# How to use:
# add to Dockerfile, otherwise add to entrypoint script. For example:
# RUN mkdir -p /bin/docker-entrypoint/ \
# && cp /tmp/scripts/docker-entrypoint/* /bin/docker-entrypoint/ \
# && chmod +x -R /bin/docker-entrypoint/ \
# ;
# ENTRYPOINT ["/bin/docker-entrypoint/resolve-docker-host-ip.sh", ...]
set -e
# brew install ffmpeg
# brew install youtube-dl
# F12, copy cookies header which starts 'cookie:...' by copying as cURL of any request
youtube-dl https://www.facebook.com/{video url} --add-header 'cookie:...' -f bestvideo+bestaudio/best
@dinhnv
dinhnv / helpful-docker-commands.sh
Created September 10, 2020 03:26 — forked from garystafford/helpful-docker-commands.sh
My list of helpful docker commands
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# exec into container
@dinhnv
dinhnv / start-stop-example.sh
Created July 15, 2018 13:38 — forked from alobato/start-stop-example.sh
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar
@dinhnv
dinhnv / miscellaneous.md
Created October 14, 2017 12:55
miscellaneous tips
  • Disable youtube ads:
document.cookie="VISITOR_INFO1_LIVE=oKckVSqvaGw; path=/; domain=.youtube.com";window.location.reload();

IDE Shortcuts

Intellij Idea Shortcuts

Linux: Cmd -> Ctrl

  • Navigation
Ctrl     + B                : Jump to Definition
@dinhnv
dinhnv / install_phantomjs.sh
Last active August 28, 2016 11:34
Use for CI remote call
#!/usr/bin/env bash
#
# script install phantomjs for ci automatically build & test
# \curl -sSL https://gist.githubusercontent.com/dinhnv/6eee21ad7677aa93ad7be3385c0b031c/raw/install_phantomjs.sh | bash -s
set -euo pipefail
IFS=$'\n\t'
# workaround for gitlab cache
WORK_DIR=`pwd`
@dinhnv
dinhnv / install_latest_docker_compose.sh
Last active February 25, 2019 01:57 — forked from luislobo/install_latest_docker_compose.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"