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 / remove-duplicate.js
Created September 5, 2017 12:06
MONGODB: remove duplicates
var duplicates = [];
db.staff.aggregate([
{ $match: {
id: { "$exists": true } // discard selection criteria
}},
{ $group: {
_id: { id: "$id"}, // can be grouped on multiple properties
dups: { "$addToSet": "$_id" },
count: { "$sum": 1 }
@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 / controllers.application\.js
Last active September 29, 2020 22:57
Ember playground
import Controller from '@ember/controller';
import EmberObject, { computed, action } from '@ember/object';
let Person = EmberObject.extend({
// these will be supplied by `create`
firstName: null,
lastName: null,
address: {
road: 'Northland',
@ptgamr
ptgamr / flow-uploader.js
Last active September 17, 2019 13:38
Flowjs, ResumableJs NodeJS backend
'use strict';
const fs = Promise.promisifyAll(require('fs'));
const path = require('path');
const crypto = require('crypto');
const CronJob = require('cron').CronJob;
module.exports = class FlowUploader {
constructor(tempDir, uploadDir, maxFileSize, fileParameterName) {
this.tempDir = tempDir || './tmp';
@ptgamr
ptgamr / comments-box-initial-template.hbs
Last active August 28, 2019 04:14
Ember training gist
<div class="ui comments">
<h3 class="ui dividing header">Comments</h3>
<div class="comment">
<a class="avatar">
<img src="https://api.adorable.io/avatars/100/oldmonk@adorable.png">
</a>
<div class="content">
<a class="author">Matt</a>
<div class="metadata">
<span class="date">Today at 5:42PM</span>
3290  sudo sh ~/Downloads/cuda_10.0.130_410.48_linux.run              
3291  tail -f /var/log/nvidia-installer.log                              
3292  lsmod | grep nouveau                       
3293  tail -f /var/log/nvidia-installer.log                                              
3294  nvidia-detector            
3295  lsmod | grep nouveau                                       
3296  sudo sh ~/Downloads/cuda_10.0.130_410.48_linux.run


@ptgamr
ptgamr / Reddit thread.md
Created December 7, 2018 22:20
Slow Vim on Mac

https://www.reddit.com/r/vim/comments/7fqpny/slow_vim_scrolling_and_cursor_moving_in_iterm_and/

i guys, I'm desperate :c Just bought my new MacBook pro 2017 and was very happy with it for a while until I decided to configure my vim. On Linux vim works just fine, scrolling is always ok even with a much faster cursor speed than I have now on mac. But lately I spent a WHOLE day trying to figure out what's wrong with scrolling speed on mac. It drives me insane. Both terminal and iterm are extremely slow at rendering and even moving the cursor around without scrolling at all is laggy!

I think I tried almost all the possible suggestions including

setting ttyfast and lazyredraw

speeding up my key repeat to 1(scroll is faster but even more laggy)
@ptgamr
ptgamr / react-native-deployments.md
Last active November 20, 2018 21:59
Environment configurations for React Native App

Intro

If you ever need a mobile application, you probably have an API endpoint to talk to. And if you're doing it right, you should have different environment for your API, usually it'll be: dev, staging, production.

The problem: How do we do the testing for our app?

We dont' want to perform test againts the production API. We need a way to teach our app to talk to different API environment. But what is the switch?

The naive way: