Skip to content

Instantly share code, notes, and snippets.

View vothanhkiet's full-sized avatar
🎯
99% of ideas are worth nothing without good execution.

Kiệt Thành Võ vothanhkiet

🎯
99% of ideas are worth nothing without good execution.
View GitHub Profile
@vothanhkiet
vothanhkiet / terminal
Created July 11, 2019 09:26 — forked from FreddyPoly/terminal
[REACT NATIVE] Get SHA1
Debug SHA1 (root of project)
keytool -J-Duser.language=en -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Release SHA1 (/android/app/)
keytool -J-Duser.language=en -list -v -keystore mystore.keystore
@vothanhkiet
vothanhkiet / imgOrientation.js
Created May 29, 2019 00:43 — forked from thachnuida/imgOrientation.js
Angularjs Directive to rotate image base on EXIF orientation value
/* global EXIF */
'use strict';
// Require library: https://github.com/jseidelin/exif-js
// Require Jquery (If not have jquery you must handle DOM by native js code)
/**
@description this directive auto rotate image by css base on image orientation value
Check the example of image orientation here:
https://github.com/recurser/exif-orientation-examples
@example
@vothanhkiet
vothanhkiet / difference.js
Created January 4, 2019 02:22 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@vothanhkiet
vothanhkiet / gpg-import-and-export-instructions.md
Created November 18, 2018 02:20 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@vothanhkiet
vothanhkiet / flash-android-rom-with-heimdall-on-mac.md
Created November 15, 2018 09:28 — forked from kevinpapst/flash-android-rom-with-heimdall-on-mac.md
Flash a new Android ROM on Mac with ADB and Heimdall

Installing an Android ROM with your Mac via Heimdall and bash

Because every time I want to flash a new ROM, I forgot how I did it the last time.

This is how I re-flashed my unbranded Samsung Galaxy S4 (german black edition) with a stock ROM (because Cyanogenmod crashed my phone all the time). The correct Stock ROM for my Galaxy S4 is: I9505XXUHOJ2_I9505OXAHOJ2_I9505XXUHOJ2

Software you need

  • adb
  • heimdall (brew cask install heimdall-suite)
@vothanhkiet
vothanhkiet / blog.md
Created September 28, 2018 01:26 — forked from JacobBennett/blog.md
Sharing Laravel Cookies across subdomains

I recently ran into a problem where I had a suite of applications hosted on a set of subdomains that all needed to be able to share a single cookie. Any cookies other than the shared cookie needed to stay specific to their subdomain, but this one shared cookie needed to be accessible to any of them. I also wanted to accomplish this using Laravel's Cookie facade.

The Problem

To accomplish this, there were two issues to solve.

  1. All cookies created by the Laravel framework are encrypted by default. (link)
  2. I needed to figure out how to set a domain on the shared cookie that was different than the domain it was being set from.

Setting Non-Encrypted Cookies

In Laravel 5.1, a feature was added which allows you to add a list of cookie names that should not be encrypted to the EncryptCookies Middleware under the $except array. Check out [the docs](http://laravel.com/docs/5.1/responses#attaching-cookies

@vothanhkiet
vothanhkiet / simple-promise-retry.js
Created September 20, 2018 12:27 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@vothanhkiet
vothanhkiet / uploader.go
Created September 19, 2018 12:46 — forked from taylorhughes/uploader.go
A lightly modified excerpt from Cluster's streaming media upload server, which encodes video on the fly as it is uploaded.
func EncodeStreamingVideo(streamingFile io.Reader, request ShouldCanceler) (*os.File, error) {
outputFilename := generateFilename("mp4")
// Actually start the command.
cmd := exec.Command("ffmpeg",
// Read input from stdin.
"-i", "-",
// ... environment-specific ffmpeg options ...
"-y", outputFilename)
@vothanhkiet
vothanhkiet / Controller.php
Created May 25, 2018 09:32 — forked from milon/Controller.php
Delete Modal Popup with Laravel, Bootstrap and jQuery
public function index(){
$categoryList = Category::all();
return view('category.list')->with('categoryList', $categoryList);
}
@vothanhkiet
vothanhkiet / LC_CTYPE.txt
Created February 2, 2018 04:44 — forked from thanksdanny/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8