Skip to content

Instantly share code, notes, and snippets.

@ChitaGideon
ChitaGideon / gist:356e063f1e413d6424ad
Last active August 29, 2015 14:18
find all route path in krakenjs
app.on 'middleware:after:router',(eventargs)->
routes = []
app._router.stack.forEach (route)->
getPath = (route)->
route.path ||route.route?.path || route.regexp.toString().match(/[\/\w]+/g)[1..-4].join("")
recurPath = (route,head,arr)->
routeStr = getPath(route)
if route.handle?.stack
route.handle.stack.forEach (subRoute)->
recurPath(subRoute,head+routeStr,arr)
@ChitaGideon
ChitaGideon / gist:0bc7818a9dcfd4acf50e
Created October 15, 2015 08:55
react-native upload file using XMLHttpRequest
_upload() {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://posttestserver.com/post.php');
xhr.onload = () => {
this.setState({isUploading: false});
if (xhr.status !== 200) {
AlertIOS.alert(
'Upload failed',
'Expected HTTP 200 OK response, got ' + xhr.status
);
@ChitaGideon
ChitaGideon / validation.php
Created December 20, 2016 07:44 — forked from chareice/validation.php
Localization Validation Message For Chineses With Laravel 5
<?php
use Symfony\Component\Yaml\Yaml;
return Yaml::parse(file_get_contents(base_path().'/resources/lang/zh_cn/validation.yml'));