Skip to content

Instantly share code, notes, and snippets.

Huy Tr. huytd

Block or report user

Report or block huytd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View customize.material-dark-theme.md

;; Automatically generated
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(anzu-cons-mode-line-p nil)
View org-journal-list.el
(defun read-journal (path)
(with-temp-buffer
(insert-file-contents (concat "~/notes/journal/" path))
(split-string (buffer-string) "\n" t)))
(defun read-first-three-lines (list)
(cond ((>= (length list) 4) (subseq list 1 3))
((>= (length list) 1) (nthcdr 1 list))
(t list)))
@huytd
huytd / 2019.tmux.conf
Created Sep 27, 2019
My 2019 Tmux Config
View 2019.tmux.conf
# set -g default-terminal "xterm"
# set-option -ga terminal-overrides ",xterm:Tc"
set -g default-terminal "xterm-256color"
set -ga terminal-overrides ",*256col*:Tc"
set -g prefix C-x
unbind-key C-x
bind-key C-2 send-prefix
bind \ split-window -h -c '#{pane_current_path}'
View jquery-multiple-css-changes.md

Setting multiple CSS properties at once with jQuery doesn't batch

There's a trick that was suggested in a few articles on the internet, that whenever you should modify a lot of CSS properties, you should batch them in one call:

  // instead of this
  $('body').css('backgound-color', '#F00');
  $('body').css('width', 100);
  $('body').css('height', 300);
@huytd
huytd / .gitconfig
Created Aug 4, 2016
Use neovim as diff tool
View .gitconfig
[merge]
tool = vimdiff
[mergetool]
prompt = true
[mergetool "vimdiff"]
cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'
[difftool]
prompt = false
[diff]
tool = vimdiff
@huytd
huytd / k2pdfopt-params
Created Aug 20, 2019
k2pdfopt param for iPhone X
View k2pdfopt-params
k2pdfopt -om 0.15 -w 800 -h 1732 <file-name>
@huytd
huytd / d3-text-measure.js
Created May 6, 2016
Measure text size in pixels with D3.js
View d3-text-measure.js
function textSize(text) {
if (!d3) return;
var container = d3.select('body').append('svg');
container.append('text').attr({ x: -99999, y: -99999 }).text(text);
var size = container.node().getBBox();
container.remove();
return { width: size.width, height: size.height };
}
// Usage: textSize("This is a very long text");
@huytd
huytd / android_game.java
Last active Aug 12, 2019
Simple game engine using Canvas for Android - using for quick prototype or simple games
View android_game.java
package com.gamarist.momoney;
import android.os.Bundle;
import android.R.integer;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@huytd
huytd / vscode-espresso-custom.json
Created Jul 14, 2019
vscode-espresso-custom.json
View vscode-espresso-custom.json
"workbench.colorCustomizations": {
"sideBar.background": "#fafafa",
"activityBar.background": "#fafafa",
"statusBar.background": "#fafafa",
"tab.inactiveBackground": "#fafafa",
"tab.border": "#fafafa",
"editorGroupHeader.tabsBackground": "#fafafa",
"editorLineNumber.foreground": "#dddddd",
"editorCursor.foreground": "#6ab04c",
"diffEditor.removedTextBackground": "#F8E5E1",
View .tmux.conf
set -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
set -g prefix C-x
unbind-key C-x
bind-key C-2 send-prefix
bind \ split-window -h -c '#{pane_current_path}'
bind / split-window -v -c '#{pane_current_path}'
# Copy-paste integration
You can’t perform that action at this time.