Skip to content

Instantly share code, notes, and snippets.

View rayyee's full-sized avatar
🌴
On vacation

Ray Yee rayyee

🌴
On vacation
View GitHub Profile
@rayyee
rayyee / media-query.css
Created July 9, 2020 12:34 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@rayyee
rayyee / git_statistics.md
Last active November 22, 2019 10:21
line statistics with git
Summary statistics
git shortlog -s --since=2019-11-01 HEAD --no-merges -n
Particular statistics
function gcode() {
  git log --shortstat --since="$1" --author="$2" --no-merges | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6; ratio=deleted/inserted} END {printf "Commit stats:\n- Files changed (total)..  %s\n- Lines added (total)....  %s\n- Lines deleted (total)..  %s\n- Total lines (delta)....  %s\n- Add./Del. ratio (1:n)..  1 : %s\n", files, inserted, deleted, delta, ratio }' -
}
@rayyee
rayyee / problems-like-sqlite-in-pyenv.md
Created November 7, 2019 04:33
problems like not found sqlite moudle when pyenv installed

ERROR "No module named '_sqlite3'"

reinstall python to fix it

LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/sqlite/lib" \
CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/sqlite/include" \
pyenv install -v 3.5.5

if you installed brew on your os

@rayyee
rayyee / page-break-table.css
Last active November 1, 2019 05:57
friendly print options with css
@media print
{
table { page-break-inside:auto; }
tr { page-break-inside:avoid; page-break-after:auto; }
}
@rayyee
rayyee / mysql8_caching_sha2_password.md
Last active October 23, 2019 05:57
mysql8 caching_sha2_password
~> mysql -uroot -p
mysql> use mysql;
mysql> select user, host, plugin, authentication_string from user;
mysql> alter user 'user'@'user.host' identified with mysql_native_password by 'your_password';
mysql> exit;
@rayyee
rayyee / npm-dedupe.md
Last active August 13, 2019 12:41
Flatten Your Npm Dependencies With Dedupe

Flatten Your Npm Dependencies With Dedupe

安装依赖

$ npm install

由这2个文件package-lock.json and npm-shrinkwrap驱动安装,shrinkwrap.json优先。
如果2个文件都没有,install会附加dedupe。

去重依赖

$ npm dedupe

拆封依赖关系
@rayyee
rayyee / A Nuxt.js VPS production deployment.md
Created February 15, 2019 02:57 — forked from DreaMinder/A Nuxt.js VPS production deployment.md
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger then a landing page.

UPD: This manual now compatible with nuxt@2.3. For older versions deployment, see revision history.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

HTML

<div contenteditable data-placeholder="My Placeholder String"></div>

CSS

Simple solution
@rayyee
rayyee / hz.js
Created November 14, 2018 14:30
改良HZRecorder.js的采样压缩
(function (window) {
//兼容
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
//**blob to dataURL**
var blobToDataURL = function (blob, callback) {
var a = new FileReader();
a.onload = function (e) { callback(e.target.result); }
a.readAsDataURL(blob);