Skip to content

Instantly share code, notes, and snippets.

View crossjs's full-sized avatar
🎯
Focusing

李文富 crossjs

🎯
Focusing
View GitHub Profile
@crossjs
crossjs / .editorconfig
Last active August 29, 2015 13:56
.editorconfig
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@crossjs
crossjs / XMLHttpRequest
Created December 22, 2014 10:40
upload base64 encoded files with xmlhttprequest
var dataURI = 'data:image/jpeg;base64,<...>==';
var blob = dataURItoBlob(dataURI);
var objURL = window.URL.createObjectURL(blob);
var image = new Image();
image.src = objURL;
window.URL.revokeObjectURL(objURL);
var formData = new FormData();
@crossjs
crossjs / conditional-comment
Last active August 29, 2015 14:14
conditional-comment
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
<!--[if IE]> 所有的IE可识别 <![endif]-->
<!--[if IE 6]> 仅IE6可识别 <![endif]-->
<!--[if lt IE 6]> IE6以下版本可识别 <![endif]-->
<!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
<!--[if IE 7]> 仅IE7可识别 <![endif]-->
<!--[if lt IE 7]> IE7以下版本可识别 <![endif]-->
<!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->
<!--[if IE 8]> 仅IE8可识别 <![endif]-->
<!--[if IE 9]> 仅IE9可识别 <![endif]-->
@crossjs
crossjs / git submodule foreach git pull
Created April 9, 2015 08:50
git submodule foreach git pull
git submodule foreach git pull
@crossjs
crossjs / WebStorage.js
Created December 9, 2015 16:12 — forked from heyimalex/WebStorage.js
localStorage sync with redux
export default class WebStorage {
constructor(key, storageArea = window.localStorage) {
this.key = key;
this.storageArea = storageArea;
}
load(defaultValue) {
const serialized = this.storageArea.getItem(this.key);
return serialized === null ? defaultValue : this.deserialize(serialized);
}
atom.settings
@crossjs
crossjs / gist:fdbbedd25b8d55fc589c
Created March 11, 2016 05:31 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@crossjs
crossjs / .bash_profile
Created March 14, 2016 14:02
.bash_profile
alias fuck='eval $(thefuck $(fc -ln -1)); history -r'
alias rn="react-native"
alias ni="npm install -r https://registry.npm.taobao.org"
@crossjs
crossjs / what-forces-layout.md
Created December 30, 2016 14:25 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@crossjs
crossjs / is360
Created January 25, 2017 09:44
is360
var is360 = function(){
try {
if(/UBrowser/i.test(navigator.userAgent)){
return '';
}
if (typeof window.scrollMaxX !== 'undefined') {
return '';
}