Skip to content

Instantly share code, notes, and snippets.

View ptgamr's full-sized avatar

Anh Trinh ptgamr

View GitHub Profile
@ptgamr
ptgamr / ffmpegExplained.sh
Created July 5, 2022 08:34
FFMPEG Explained
ffmpeg -re \
# -re (input)
# Read input at native frame rate. Mainly used to simulate a grab device, or live input stream (e.g. when reading from a file). Should not be used with actual grab devices or live input streams (where it can cause packet loss). By default ffmpeg attempts to read the input(s) as fast as possible. This option will slow down the reading of the input(s) to the native frame rate of the input(s). It is useful for real-time output (e.g. live streaming).
# (!) Turns out this will interrupt the stream by the audio input, making the output stream fps looks extremely low
-pix_fmt uyuv442 \
-framerate 30 \
-f avfoundation \
# Pixel format & Framerate for FFMPEG-device: https://www.ffmpeg.org/ffmpeg-devices.html#avfoundation
-i "0" \
# Use input "0" from avfoundation
@ptgamr
ptgamr / canvasArrowhead.js
Created January 19, 2022 20:48 — forked from jwir3/canvasArrowhead.js
Code to create an arrowhead on an html5 canvas
/**
* Draw an arrowhead on a line on an HTML5 canvas.
*
* Based almost entirely off of http://stackoverflow.com/a/36805543/281460 with some modifications
* for readability and ease of use.
*
* @param context The drawing context on which to put the arrowhead.
* @param from A point, specified as an object with 'x' and 'y' properties, where the arrow starts
* (not the arrowhead, the arrow itself).
* @param to A point, specified as an object with 'x' and 'y' properties, where the arrow ends
@ptgamr
ptgamr / app.transitions.js
Created December 15, 2020 01:58 — forked from jacobq/app.transitions.js
Modal Dialog Test
// Problem happens regardless of duration, but unless using
// the `.velocity-animating` CSS hack it is easier to see with longer durations.
const options = {duration: 1000, easing: 'easeInOutQuad'};
export default function(){
this.transition(
// this works
//this.use('fade')
// this has a glitch; can see second copy/ghost of modal in top left when closing
@ptgamr
ptgamr / clean-up-boot-partition-ubuntu.md
Created September 18, 2018 10:44 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@ptgamr
ptgamr / alacritty.yml
Created August 13, 2018 10:12
~/.config/alacritty/alacritty.yml
# Configuration for Alacritty, the GPU enhanced terminal emulator
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty it self.
env:
# TERM env customization. Default is xterm-256color
# Note: the default TERM value `xterm-256color` does not
# specify all features alacritty supports. This does pose
@ptgamr
ptgamr / Ubuntu-Compass-ruby[16.04]
Created March 24, 2018 10:36 — forked from AungMyoKyaw/Ubuntu-Compass-ruby[16.04]
Compass installation for ubuntu 16.04
[https://gist.github.com/stephou0104/233b5c99884f1d8c8b8b#file-ubuntu-compass-ruby]
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
@ptgamr
ptgamr / README.md
Created April 21, 2017 13:02 — forked from mik01aj/README.md
How to use Tether with React

Tether is a great library for positioning stuff (tooltips, modals, hints, etc) in your web app.

But, as I use React, it was pretty problematic for me, as Tether mutates the DOM and React breaks miserably when it sees mutated DOM. The solution is to have the tethered element outside the part of the DOM tree which is controlled by React (in this case, I use document.body).

That's why I created 2 helpers to use Tether with React.

The first one, TetheredElement is a plain JS helper to create a new element, attach it to some other one via Tether, and populate it with some React component.

The second one, TetherTarget is a React component and it uses TetheredElement to integrate it further with React, so that you can attach components to each other with Tether, without leaving the cozy React/JSX world and worrying about manual DOM operations. Just write:

@ptgamr
ptgamr / Sharded mongodb environment on localhost
Created May 6, 2016 12:26 — forked from joewagner/Sharded mongodb environment on localhost
Bash shell script that sets up a sharded mongodb cluster on a single machine. Handy for testing or development when a sharded deployment is required. Notice that this will remove everything in the data/config and data/shard directories. If you are using those for something else, you may want to edit this...
# clean everything up
echo "killing mongod and mongos"
killall mongod
killall mongos
echo "removing data files"
rm -rf data/config
rm -rf data/shard*
# For mac make sure rlimits are high enough to open all necessary connections
ulimit -n 2048
@ptgamr
ptgamr / ngram-search.sh
Created May 5, 2016 13:33 — forked from avar/ngram-search.sh
ElasticSearch fuzzy ngram powered search
export http_proxy=
export https_proxy=
curl -XDELETE 'http://localhost:9200/test/'
echo "Creating the mapping"
curl -XPUT 'http://localhost:9200/test/?pretty=1' -d '
{
"mappings" : {
"member" : {
@ptgamr
ptgamr / ember_examples.md
Created November 16, 2015 10:50 — forked from rwjblue/ember_examples.md
Ember Examples