Skip to content

Instantly share code, notes, and snippets.

@ryancat
ryancat / gist:da6423ef5246c96a61e6
Created December 5, 2014 07:42
how to move file in and out from hard drive with mac
# 用 root 身份做如下操作 (高危! 请切记自己在干什么)
sudo -s
cd /sbin
# 将系统自带的挂载程序改名
mv mount_ntfs mount_ntfs_orig
# 新建我们要的挂载脚本并编辑
vim mount_ntfs
#!/bin/sh
/sbin/mount_ntfs_orig -o rw,nobrowse "$@"
@ryancat
ryancat / gist:f67c3eab4a7e25858586
Created April 2, 2015 05:56
How to add folder in multiple folders
http://unix.stackexchange.com/questions/61907/how-do-i-create-a-directory-in-all-subdirectories
for dir in */; do mkdir -- "$dir/tmp1"; done
@ryancat
ryancat / gist:90679171d27eda64bbf2
Created April 2, 2015 15:20
How to change file name in multiple folders
http://unix.stackexchange.com/questions/102647/how-to-rename-multiple-files-in-single-command-or-script-in-unix
for file in aro_tty-mIF-*_opt
do
mv -i "${file}" "${file/-mIF-/-mImpFRA-}"
done
@ryancat
ryancat / gist:0a8f39b5f001f2f8f231
Created April 8, 2015 01:06
How to use two different versions in bower
http://www.danschnau.com/multiple-versions-of-a-package-in-bower/
"dependencies": {
"jquery-1.9.1": "jquery#1.9.1",
"jquery-1.8.1": "jquery#1.8.1"
}
@ryancat
ryancat / remove multiple git branch
Created March 1, 2016 21:40
remove multiple git branch
git branch | grep '3\.2' | xargs git branch -d
@ryancat
ryancat / gist:d4b1521f82a30b9a1354df1280daade9
Created July 10, 2017 15:23
Fix flow import style issue
GOAL:
Make flow understand *.css files and map them to an exported Object or whatever type you need... also to prevent this dreaded module not found error.
STEPS:
In your project folder, create a file helpers/CSSModule.js with following content:
//@flow
export default {};
@ryancat
ryancat / handleTouchMove.js
Created September 12, 2017 06:25
Mobile touch move detection
let touches = {
touchstart: Object.assign({}, {
x: -1,
y: -1
}),
touchmove: Object.assign({}, {
x: -1,
y: -1
})
}
@ryancat
ryancat / test_example.js
Last active March 12, 2018 19:51
webdriverjs tests locally and use sauce labs to run remotely
const {Builder, By, Key, until, remote} = require('selenium-webdriver');
const sauceUsername = process.env.SAUCELABS_USER,
sauceApiToken = process.env.SAUCELABS_APITOKEN;
(async function example() {
let driver = await new Builder()
.forBrowser('firefox')
.build();
@ryancat
ryancat / colorDiffUtil.js
Created May 9, 2018 06:07
Color difference in RGB and LAB
/**
* Compare color difference in RGB
* @param {Array} rgb1 First RGB color in array
* @param {Array} rgb2 Second RGB color in array
*/
export function deltaRgb (rgb1, rgb2) {
const [ r1, g1, b1 ] = rgb1,
[ r2, g2, b2 ] = rgb2,
drp2 = Math.pow(r1 - r2, 2),
dgp2 = Math.pow(g1 - g2, 2),