Skip to content

Instantly share code, notes, and snippets.

View dangh's full-sized avatar
🤖
I may be slow to respond.

Dang dangh

🤖
I may be slow to respond.
View GitHub Profile
@dangh
dangh / uuid.lua
Last active April 6, 2023 09:52 — forked from jrus/lua-uuid.lua
quick lua implementation of "random" UUID
local function uuid()
math.randomseed(os.time())
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return string.format('%x', v)
end)
end
@dangh
dangh / tftpd.fish
Created January 20, 2017 19:33
start OSX built-in TFTP server in fish shell
function tftpd
switch $argv
case start
sudo rm -rf /private/tftpboot
sudo ln -s (pwd) /private/tftpboot
sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist
case stop
sudo launchctl unload -w /System/Library/LaunchDaemons/tftp.plist
end
end
@dangh
dangh / ffmpeg_rotate_mp4.md
Last active January 20, 2017 19:50
Rotate MP4 file 90º clockwise
brew install ffmpeg
ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
@dangh
dangh / sublime_text_menu.bat
Created January 22, 2017 09:00
Open folders and files with Sublime Text 3 from Windows Explorer context menu
@echo off
echo Put this file in the same folder as sublime_text.exe
echo Need to run as administrator
SET AppKey=Sublime Text
SET AppTitle=Open with ^&Sublime Text
SET AppPath=%~dp0sublime_text.exe
SET AppIcon=%AppPath%,0
@dangh
dangh / hoc-component.jsx
Last active October 3, 2017 03:25
Recompose as HoC and render prop
import { compose, withState, withProps } from 'recompose'
function HoCComponent ({a, b, c, setA, setB}) {
return (
<div>
<span>A: {a}</span>
<button onClick={setA}>Update A</button>
<span>B: {b}</span>
<button onClick={setB}>Update B</button>
<span>C: {c}</span>
@dangh
dangh / replaceInputWithTextarea.js
Last active October 3, 2017 03:39
Replace <input/> tag with <textarea/> tag to preserve line-breaks.
/**
* Convert <input/> to <textarea/> to preserve line-breaks.
*/
function replaceInputWithTextarea(input) {
if (input.type !== 'text') return;
// Create textarea element.
const textarea = document.createElement('textarea');
// Copy all input attributes except `value`.
@dangh
dangh / env.cmd
Last active December 18, 2020 19:20
Setup command alias in Windows
@echo off
:: Setup bootstrap script
IF NOT [%1]==[--skip-setup] (
:: Allow (, ), ^, <, >, |, ... in the file name
:: See https://stackoverflow.com/a/36990712
SETLOCAL EnableDelayedExpansion
SET "EXECUTABLE_PATH=%~dpnx0"
ECHO AutoRun "!EXECUTABLE_PATH!"
@dangh
dangh / LuCI annotation.md
Last active June 19, 2018 07:28
LuCI annotation
@dangh
dangh / SketchSystems.spec
Last active August 24, 2018 07:11
channel spectrum
channel spectrum
ready
SELECT_AP -> ready
SCAN -> loading
loading
CANCEL_SCAN -> ready
SCAN_SUCCESS -> chart
SCAN_FAILURE -> error
chart
SELECT_AP -> ready
@dangh
dangh / build-zsh.sh
Last active October 18, 2018 06:19 — forked from nicoulaj/build-zsh.sh
Build Zsh from sources on Debian Wheezy
#!/bin/sh
# Build Zsh from sources on Debian Wheezy.
# From http://zsh.sourceforge.net/Arc/git.html and sources INSTALL file.
# Some packages may be missing
sudo apt-get install -y git-core gcc make autoconf yodl libncursesw5-dev texinfo
git clone git://git.code.sf.net/p/zsh/code zsh
cd zsh