Skip to content

Instantly share code, notes, and snippets.

View fanweixiao's full-sized avatar
🦖
hacking on @yomorun

C.C. fanweixiao

🦖
hacking on @yomorun
View GitHub Profile
/*
A neuron is basically the sum of its synapses.
Along with a trigger threshold, that's all we need to calculate
whether or not it will trigger at any given moment:
*/
const neuron = ({ synapses = [], threshold = 1 } = {}) => ({
synapses,
threshold
});
@fanweixiao
fanweixiao / kibana-dashboard.json
Created June 29, 2016 06:55 — forked from orweinberger/kibana-dashboard.json
Extract Gmail messages and insert into Elasticsearch
[
{
"_id": "Gmail-Dashboard",
"_type": "dashboard",
"_source": {
"title": "Gmail Dashboard",
"hits": 0,
"description": "",
"panelsJSON": "[{\"col\":1,\"id\":\"Top-10-Worst-senders\",\"row\":4,\"size_x\":2,\"size_y\":5,\"type\":\"visualization\"},{\"col\":3,\"id\":\"Emails-Date-Histogram\",\"row\":1,\"size_x\":10,\"size_y\":3,\"type\":\"visualization\"},{\"col\":3,\"id\":\"Top-10-Senders\",\"row\":4,\"size_x\":2,\"size_y\":5,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Total-Messages\",\"row\":1,\"size_x\":2,\"size_y\":3,\"type\":\"visualization\"},{\"col\":10,\"id\":\"Day-Of-Week\",\"row\":4,\"size_x\":3,\"size_y\":5,\"type\":\"visualization\"},{\"id\":\"Hour-Of-Day\",\"type\":\"visualization\",\"size_x\":5,\"size_y\":5,\"col\":5,\"row\":4}]",
"version": 1,
@fanweixiao
fanweixiao / icare_fetcher.sh
Created April 11, 2016 10:57
icarenewlife fether
#!/bin/bash
url=$1
echo "Parsing: $url"
id=$(curl -s $url | ggrep -Po '\/\Khttp\:\/\/.*'| cut -c52-69)
echo "id=$id"
img_url="http://www.icarenewlife.com/articles/image/default/"$id"jpg"
mp3_url="http://www.icarenewlife.com/share/audio/"$id"mp3"
@fanweixiao
fanweixiao / gist:04259bc2a3948d194d92
Created August 24, 2015 09:24
git ssh over socks5 proxy
Host bitbucket.org
Hostname bitbucket.org
Port 22
User git
ProxyCommand nc -x localhost:7070 %h %p
var util = require('util');
var events = require('events');
var redis = require('redis');
var RedisQueueConsumer = function (port, host) {
events.EventEmitter.call(this);
this.port = port || 6379;
this.host = host || '127.0.0.1';
};
@fanweixiao
fanweixiao / gulpfile.js
Last active October 30, 2015 03:50 — forked from elrrrrrrr/gulpfile.js
var gulp = require('gulp');
var gulpif = require('gulp-if');
var sprite = require('css-sprite').stream;
var base = require('gulp-base64');
// generate sprite.png and _sprite.scss
gulp.task('sprites', function () {
return gulp.src('img/*.png')
.pipe(sprite({
name: 'tx.png',
@fanweixiao
fanweixiao / cayley_antigfw
Last active August 29, 2015 14:05
Anti-GFW when using `cayley http`
if [ `builtin type -p gsed` ]; then
gsed -i 's/fonts.googleapis.com/fonts.useso.com/g' templates/head.tmpl
gsed -i 's/ajax.googleapis.com/ajax.useso.com/g' templates/head.tmpl
gsed -i 's/fonts.googleapis.com/fonts.useso.com/g' static/third_party/flatly/bootstrap.min.css
else
sed -i 's/fonts.googleapis.com/fonts.useso.com/g' templates/head.tmpl
sed -i 's/ajax.googleapis.com/ajax.useso.com/g' templates/head.tmpl
sed -i 's/fonts.googleapis.com/fonts.useso.com/g' static/third_party/flatly/bootstrap.min.css
fi
<?xml version="1.0"?>
<root>
<item>
<name>Switch Input Source</name>
<appendix>Use the right Option key to select the next input source</appendix>
<identifier>private.switch_input_source_with_right_option</identifier>
<autogen>--KeyToKey-- KeyCode::OPTION_R, KeyCode::SPACE, ModifierFlag::OPTION_L</autogen>
</item>
<item>
@fanweixiao
fanweixiao / hosts
Created July 1, 2014 17:27
dropbox hosts file
108.160.166.62 dropbox.com
108.160.166.62 www.dropbox.com
108.160.166.140 client-lb.dropbox.com
107.20.134.222 dl.dropbox.com
107.20.134.222 dl-web.dropbox.com
23.21.206.219 forums.dropbox.com
108.160.165.211 notify0.dropbox.com
108.160.165.211 notify1.dropbox.com
108.160.165.211 notify2.dropbox.com
108.160.165.211 notify3.dropbox.com
@fanweixiao
fanweixiao / gist:9533725
Last active August 29, 2015 13:57
/Interface/Search/getAllIndex json response
{ "data" : { "all" : [ { "area" : "0",
"areaName" : "全国",
"key" : "taylor swift",
"period" : "20110101|20140311",
"ratio" : { "agv_m" : "6064",
"agv_w" : "7079",
"qoq_m" : "-17",
"qoq_w" : "32",
"yoy_m" : "-44",
"yoy_w" : "-30"