This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
#ifdef _WIN32 | |
#include <windows.h> | |
void _sleep(unsigned int milliseconds) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def count_words | |
h = Hash.new(0) | |
self.downcase.gsub(/[[:punct:]]/, '').split.each { |w| h[w] += 1 } | |
return h | |
end | |
end | |
#print 'a b c d e a b a a b c d d e f'.count_words #=> {"a"=>4, "b"=>3, "c"=>2, "d"=>3, "e"=>2, "f"=>1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="ctrl clearfix"> | |
<a href="/m/main/mypage.jsp" class="btn btn-default pull-right">取消</a> | |
<a class="btn btn-primary pull-right" href="talk.jsp?Username=xxx">改傳訊息</a> | |
<a class="btn btn-warning pull-right" href="sticker.jsp?Username=xxx">改傳貼圖</a> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
====Detecting hime install==== | |
==>Hime binary found. | |
==>/usr/bin/hime: version 0.9.10 (git b745493), linked to /usr/lib/libgtk-x11-2.0.so.0 | |
==>/usr/share/doc/hime/ChangeLog: 0.9.10 | |
====Detecting OS/Distribution==== | |
Linux 3.19.3-3-ARCH #1 SMP PREEMPT Wed Apr 8 14:10:00 CEST 2015 x86_64 GNU/Linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
原文 | |
ループが書けなくなる(或いは再帰依存症)レベル10 | |
http://d.hatena.ne.jp/yuki_neko_nyan/20090217/1234850409 | |
level 0 | |
不會寫遞迴,也沒辦法用遞迴思考。只覺得用迴圈寫就好了。 | |
level 1 | |
開始學習遞迴,但只要一用遞迴思考就覺得煩。有時還會忘了寫終止條件。覺得實在太麻煩了還是想寫迴圈就好。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import request from 'superagent' | |
import { | |
SIGNUP_USER_STARTED, | |
SIGNUP_USER_COMPLETED, | |
SIGNUP_USER_FAILED | |
} from 'shared/constants/ActionTypes' | |
import { auth } from 'shared/actions/AuthActions' | |
export function submit (form) { | |
return async dispatch => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function auth (form) { | |
return new Promise((resolve, reject) => { | |
request | |
.post('/api/v1/login') | |
.set('Accept', 'application/json') | |
.auth(form.email, form.password) | |
.end(function (err, res) { | |
if (!err && res.body) { | |
resolve(res.body) | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function login (form) { | |
return async dispatch => { | |
dispatch({ type: AUTH_USER_STARTED }) | |
try { | |
const res = await auth(form) | |
if (res && res.token) { | |
setToken(res.token) | |
return dispatch({ | |
type: AUTH_USER_COMPLETED, | |
token: res.token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
/* C++ 14 */ | |
int main(void) { | |
auto add = [](auto x, auto y) {return x + y;}; | |
printf("%d", add(1,2)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// borrow from react-redux-starter-kit | |
// https://github.com/davezuko/react-redux-starter-kit | |
export function createConstants (...constants) { | |
return constants.reduce((acc, constant) => { | |
return Object.assign({}, acc, { [constant]: constant }) | |
}, {}) | |
} | |
export function createReducer (initialState, reducerMap) { |
OlderNewer