Skip to content

Instantly share code, notes, and snippets.

@joehwang
joehwang / README.md
Last active July 19, 2021 09:15
安裝orcal client用來支援nodejs連接orcal
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@joehwang
joehwang / demo.html
Last active February 6, 2020 11:22
get the dpi and pixel_ratio in javascript and layout dot in canvas
<html>
<body>
<div id="box">
</div>
<img src="t.png" alt="" id="desc_img">
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="smallGrid" width="37.79" height="37.79" patternUnits="userSpaceOnUse">
@joehwang
joehwang / OpenWithSublimeText.bat
Created May 8, 2018 05:42 — forked from zouyangdev/OpenWithSublimeText.bat
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 10)
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
pause
@joehwang
joehwang / block.sublime-snippet
Last active February 27, 2018 16:45
sublime-snippet集合
<snippet>
<content><![CDATA[<%=${1:v}%>$0]]></content>
<tabTrigger>aa</tabTrigger>
<description>輸出$const_vw</description>
</snippet>
@joehwang
joehwang / .dockerignore
Created December 27, 2017 09:16 — forked from davidderus/.dockerignore
Docker + Rails + Puma + Postgres + Nginx
.git
.gitignore
/doc
.yardoc
coverage
jsdoc
/tmp
/log
Dockerfile
Dockerfile.prod
@joehwang
joehwang / Dockfile
Created December 26, 2017 10:14
ubuntu-rails5-docker
FROM ubuntu
# 維護者
MAINTAINER joehwang [email protected]
RUN sed -i 's/archive.ubuntu.com/free.nchc.org.tw/' /etc/apt/sources.list
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-utils -y \
build-essential libpq-dev ruby patch ruby-dev zlib1g-dev liblzma-dev curl libxss1 libappindicator1 \
libindicator7 gconf-service libasound2 libgconf-2-4 libnspr4 fonts-liberation libnss3 xdg-utils \
imagemagick libmysqlclient-dev locales tzdata
RUN locale-gen en_US.UTF-8
@joehwang
joehwang / js
Created May 31, 2017 17:02
轉換座標系
function oMousePos(target, evt) {
var rect = target.getBoundingClientRect();
console.log( Math.round(evt.clientX - rect.left))
return {
x: Math.round(evt.clientX - rect.left),
y: Math.round(evt.clientY - rect.top)
};
}
@joehwang
joehwang / Process.rb
Created March 29, 2017 10:32
ruby Process test
def log msg
printf "pid %5d %-10s %s\n", $$, Time.now, msg
end
tasks = (1..10).map { 2 + rand(5) }
limit = 2
processes = []
@joehwang
joehwang / supervisor.conf
Created March 29, 2017 09:19
supervisor設定
[unix_http_server]
file=/tmp/supervisor.sock ; UNIX socket 文件,supervisorctl 会使用
[supervisord]
childlogdir=/var/log/supervisor/
logfile=/tmp/supervisord.log
pidfile=/tmp/supervisord.pid
nodaemon=true ; 是否在前台启动,默认是 false,即以 daemon 的方式启动,docker要跑要設true避免進程結束,測試再設false
loglevel=debug ;什麼碗糕都會印出來
[rpcinterface:supervisor]