Skip to content

Instantly share code, notes, and snippets.

@cyio
cyio / ListView to FlatList.diff
Created August 11, 2017 06:41
Migrating from ListView to FlatList in React Native. Raw
diff --git a/app/containers/Search.js b/app/containers/Search.js
index 6a742f5..d75a738 100644
--- a/app/containers/Search.js
+++ b/app/containers/Search.js
@@ -7,6 +7,7 @@ import {
Dimensions,
TouchableOpacity,
ListView,
+ FlatList,
ScrollView
@cyio
cyio / bixin-auto-login.user.js
Created August 10, 2017 09:19
币信自动登陆
// ==UserScript==
// @name Bixin Auto Login
// @version 0.1
// @author Oaker
// @description 币信自动登陆
// @grant none
// @match https://bixin.com/auth/login/?next=https%3A//bixin.com/platform/vendor/hashex/
// ==/UserScript==
$('#login-acct').click()
@cyio
cyio / bind.js
Last active March 14, 2017 10:11
实现 bind 方法,用于不支持ES5的浏览器
// Credit to Douglas Crockford for this bind method​
if (!Function.prototype.bind) { // 如果不存在 bind 方法
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") { // bind 方法的调用对象只能是函数,如果不是则抛出异常
// closest thing possible to the ECMAScript 5 internal IsCallable function​
throw new TypeError ("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call (arguments, 1), // 浅复制 bind 的参数,从第 2 个开始到结束 http://stackoverflow.com/a/26618338/5657916
fToBind = this,
blockquote {
font-style: normal;
}
@cyio
cyio / BatchExportRowsToCSV.vba
Last active November 26, 2016 08:02
excel batch export rows to csv vba
Sub BatchExportRowsToCSV()
Dim Filename, Pathname As String
Dim wb As Workbook
Pathname = ActiveWorkbook.Path & "\source\"
Filename = Dir(Pathname & "*.xlsm")
Do While Filename <> ""
Set wb = Workbooks.Open(Pathname & Filename)
ExcelRowsToCSV wb
git init --bare $HOME/.dotfiles
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
echo "alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'" >> $HOME/.zshrc
@cyio
cyio / tmp.js
Created September 22, 2016 09:42
快速创建成员为0-9的数组,等价的两种方式
// 快速创建成员为0-9的数组,等价的两种方式
// let arr = []
// arr.length = 10
let arr = new Array(10) // 参数为个位数,表示长度,否则表示成员
//let arr = new Array(0, 1, 2)
for (let i=0; i<arr.length; i++) {
arr[i] = i
@cyio
cyio / tmp.js
Created September 22, 2016 06:53
// JS不能实现成员不可变数组
const a = 1
const arr = [a]
console.log(arr)
arr[0] = 2 // 赋值时替换了常量a
console.log(arr)
@cyio
cyio / localStorage.js
Last active September 20, 2016 10:56 — forked from anhang/localStorage.js
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}
/*
css reset
*/
html{
-webkit-tap-highlight-color: rgba(0,0,0,0);/*去掉触摸遮盖层*/
-webkit-user-modify: read-write-plaintext-only;
-webkit-user-select: none;/*禁止用户选择文字*/
}