Skip to content

Instantly share code, notes, and snippets.

Avatar
⛑️

Huy huytd

⛑️
View GitHub Profile
View for-in.js
const array = [5,3,3,6,2,3,4,67,7,2,2];
for (let i in array) {
debug({ i: i, value: array[i] });
}
View slack-style-join-left-message-run.js
// Run it online at:
// https://algorithm-pad.now.sh/?gist=https://gist.githubusercontent.com/huytd/7ed3521bc1bbe4b5086d176fda85fec8/raw/6019ff8e19ec8278ac55a21b3cbf43ef54ff1882/slack-style-join-left-message-run.js
const Join = 1;
const Leave = -1;
const JoinedAndLeft = 2;
const Rejoined = -2;
const toStatus = n => {
switch (n) {
case Join: return 'joined';
View same-schema-detect.js
const root = {
val: 1,
left: {
val: 2,
left: null,
right: null
},
right: {
val: 3,
left: null,
View Material-High-Constrast.tmTheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Mattia Astorino</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>name</key>
<string>Material-Theme</string>
@huytd
huytd / keybinding.json
Last active Mar 5, 2020
Sublime Monokai Filter Machine Theme
View keybinding.json
[
{"keys": ["ctrl+v"], "command": "expand_selection", "args": {"to": "scope"} },
{ "keys": ["super+shift+k"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+;"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },
]
View kiwi-theme.el
;;; kiwi-theme.el --- Theme
;; Copyright (C) 2016 ,
;; Author:
;; Version: 0.1
;; Package-Requires: ((emacs "24"))
;; Created with ThemeCreator, https://github.com/mswift42/themecreator.
@huytd
huytd / inefficient-db.coffee
Created Jan 23, 2020
A very inefficient file-based database. For prototyping only.
View inefficient-db.coffee
fs = require "fs"
###
A very inefficient file-based database. For prototyping only.
Usage:
db = new DB()
# Insert new row
@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 / k2pdfopt-params
Created Aug 20, 2019
k2pdfopt param for iPhone X
View k2pdfopt-params
k2pdfopt -om 0.15 -w 800 -h 1732 <file-name>
You can’t perform that action at this time.