Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>成語松 Idiomthon</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
@iamso1
iamso1 / configureStore.js
Last active May 3, 2016 15:34
解決 Actions must be plain objects. Use custom middleware for async actions 的問題
import { createStore, applyMiddleware} from 'redux';
import reducers from '../reducers';
import thunk from 'redux-thunk';
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
export default function(initialState){
const store = createStoreWithMiddleware(reducers, initialState);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextRootReducer = require('../reducers');
@iamso1
iamso1 / app.js
Last active April 19, 2017 13:26
koa route設定
const Koa = require('koa');
const app = new Koa();
const Router = require('koa-router');
//方法一
// 1. 想要用的route 先用變數存,
// 2. 一個一個加進route變數中.
// 3. app一次使用route變數
const router = Router();
@iamso1
iamso1 / DynamicGenComponent.swift
Last active June 8, 2017 17:28
swift學習之路01-疑難雜症
override func viewDidLoad() {
super.viewDidLoad()
for i in 0 ..< 12 {
let btnMyButton = UIButton.init(type: .system)
btnMyButton.frame=CGRect(x: 47 + (i % 4) * 60, y: 95 + (i/4) * 50, width: 20, height: 20)
btnMyButton.setTitle(String(i), for: .normal)
btnMyButton.backgroundColor = UIColor.black
view.addSubview(btnMyButton)
}
}
@iamso1
iamso1 / sample.js
Last active September 14, 2017 16:23
[Selenium WebDriver] solve NoSuchElementError
//排除前端頁面物件動態生成 造成後端爬蟲無法正確抓到內容的錯誤
driver.get('http://grbsearch.stpi.narl.org.tw/search/planDetail?id=2228&docId=35');
driver.wait(until.elementLocated(By.id('maincontent')),5000).then(()=>{
driver.getPageSource().then(body => {
const $ = cheerio.load(body);
console.log($('#maincontent'));
});
});
@iamso1
iamso1 / comparator.js
Created September 5, 2017 17:00
[Ramda] comparator
module.exports = _curry1(function comparator(pred) {
return function(a, b) {
return pred(a, b) ? -1 : pred(b, a) ? 1 : 0;
};
});
@iamso1
iamso1 / comparator.js
Last active September 5, 2017 17:02
[Ramda] comparator 之謎, 如何判斷兩個參數大小 ( 以0,1,-1表示)
module.exports = _curry1(function comparator(pred) {
return function(a, b) {
return pred(a, b) ? -1 : pred(b, a) ? 1 : 0;
};
});
@iamso1
iamso1 / note.md
Created September 14, 2017 16:47
[Quokka] 各種小密技
  1. 重新啟動quokka的即時運算 按F1 並輸入 Quokka.js start on current file 就可以重新執行當前檔案

  2. 計算程式執行時間

//在要計算的程式後面加上 /*?.*/ 就會顯示當下執行的時間
let num=Math.floor(Math.random()*100);/*?.*/