Skip to content

Instantly share code, notes, and snippets.

View fancyboynet's full-sized avatar
😎

Fancy fancyboynet

😎
View GitHub Profile
@fancyboynet
fancyboynet / isPortrait.js
Created November 28, 2019 06:27
判断手机是否竖屏
export function isPortrait () {
if (!/ios|iphone|ipad|Macintosh/i.test(window.navigator.userAgent)) { // iphone 只会保留竖屏的宽高
return window.screen.width < window.screen.height
}
return (window.orientation === 180 || window.orientation === 0)
}
@fancyboynet
fancyboynet / gist:1c9f76ab850a7f5afc19bd91b5716a77
Created September 18, 2019 09:30
解决virtualbox安装centos7无法联网的问题
sudo dhclient -v
@fancyboynet
fancyboynet / c.bash
Created November 5, 2018 09:15
Export files listed by git diff between two commits.
git diff --name-only HEAD^ | xargs tar -zcvf update.zip
@fancyboynet
fancyboynet / post-merge
Created September 18, 2018 06:06 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@fancyboynet
fancyboynet / demo.js
Created August 22, 2018 07:12
Automatically bind methods to their class instance
class AutoBindMethod {
constructor () {
Object.getOwnPropertyNames(this.constructor.prototype).forEach(m => {
this[m] = this[m].bind(this)
})
}
}
class Demo extends AutoBindMethod {
constructor () {
@fancyboynet
fancyboynet / cmd.md
Last active April 10, 2018 07:19
cmd常用命令

删除指定进程

taskkill /pid {pid} /f

获取指定端口进程pid

netstat -ano | findstr :8090
yum install redis
systemctl start reids
redis-cli ping
brew upgrade
brew install redis
brew services start reids
redis-cli ping // will output 'PONG'
@fancyboynet
fancyboynet / gist:ae5e1543d26361a756820e93c6fe8dc0
Last active July 26, 2016 06:50 — forked from mfenniak/gist:2978805
An extension of Flask that adds file hashes to static file URLs built by url_for("static"...)
import os.path
import contextlib
import hashlib
from flask import Flask
from flask.helpers import safe_join
# Injects an "h" parameter on the URLs of static files that contains a hash of
# the file. This allows the use of aggressive cache settings on static files,
# while ensuring that content changes are reflected immediately due to the
# changed URLs. Hashes are cached in-memory and only checked for updates when
@fancyboynet
fancyboynet / demo.css
Last active October 26, 2015 10:35
移动端用css控制容器高度为多行文本高度
div{
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3; /*3行高*/
-webkit-box-orient: vertical;
}