Skip to content

Instantly share code, notes, and snippets.

@huytd
huytd / ffmpeg-compress-mp4
Created December 18, 2018 20:45 — forked from lukehedger/ffmpeg-compress-mp4
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@huytd
huytd / ripgrep-in-emacs.md
Created November 16, 2018 21:50 — forked from pesterhazy/ripgrep-in-emacs.md
Using ripgrep in Emacs using helm-ag (Spacemacs)

Why

Ripgrep is a fast search tool like grep. It's mostly a drop-in replacement for ag, also know as the Silver Searcher.

helm-ag is a fantastic package for Emacs that allows you to display search results in a buffer. You can also jump to locations of matches. Despite the name, helm-ag works with ripgrep (rg) as well as with ag.

How

@huytd
huytd / slim-redux.js
Created May 24, 2017 17:26 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@huytd
huytd / x11-get-clipboard-text.cpp
Created March 30, 2017 01:09 — forked from t-mat/x11-get-clipboard-text.cpp
X11: クリップボードからUTF-8テキストを取得する
// g++ -std=c++0x x11clipboard.cpp -lX11
// http://tools.suckless.org/sselp
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <string>
#include <climits>
std::string getClipboardText() {
std::string result;
Display* d = XOpenDisplay(nullptr);
@huytd
huytd / XClipboard.cpp
Created March 30, 2017 00:36 — forked from bluecube/XClipboard.cpp
Clipboard under X11
#include "Agui/Clipboard/XClipboard.hpp"
#include <X11/Xatom.h>
#include <stdio.h>
#include <sys/select.h>
#include <unistd.h>
#include <assert.h>
#include <algorithm>
#include <iostream>
// Most of the code here is adapted from the example at
@huytd
huytd / x11keylogger.c
Last active March 30, 2017 00:25 — forked from robertklep/gist:5124355
X11 keylogger
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <netdb.h>
#include <string.h>
#include <netinet/in.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
@huytd
huytd / package.json
Created September 8, 2016 20:25 — forked from dghuy/package.json
Webpack Babel React SCSS PostCSS
"dependencies": {
"autoprefixer": "^6.4.1",
"babel": "^6.5.2",
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"css-loader": "^0.25.0",
"node-sass": "^3.9.3",
"postcss-loader": "^0.13.0",

Secret Management with Vault

Problems

  • Cloud deployment problem: Where do we store our secrets (read: database username and password) and how to give them to the server when we deploy?
  • Secret sharing and auditing problem: If everybody in our team uses the same token, how can we audit when something wrong happend? Who is the last person logged in using the shared key?
  • Revocation problem: our ex-sysadmin have quitted, how we managed to remove his
@huytd
huytd / lldb_cheat_sheet.md
Created July 14, 2016 17:48 — forked from ryanchang/lldb_cheat_sheet.md
LLDB Cheat Sheet

LLDB Cheat Sheet

A complete gdb to lldb command map.

Print out

  • Print object
(lldb) po responseObject
(lldb) po [responseObject objectForKey@"state"]
  • p - Print primitive type
<link href='http://fonts.googleapis.com/css?family=Open+Sans:700' rel='stylesheet' type='text/css'>
<a id="view-code" href="http://codepen.io/virgilpana/pen/wBOBYo" target="_blank">VIEW CODE</a>
<div id="window">
<div id="header">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>