Skip to content

Instantly share code, notes, and snippets.

View ArvinH's full-sized avatar
🏠
Working from home

Huang Shuo-Han ArvinH

🏠
Working from home
View GitHub Profile
package org.sample.pubsub
import com.redis._
import akka.actor.ActorSystem
import akka.actor.Actor._
import akka.actor.Props
object Sub {
val actorSystem = ActorSystem("PubSubActorSystem")
println("starting subscription service...")
var GEO_LOCATION = {
watchID: null,
callback: null
};
GEO_LOCATION.mySpot = function(position){
var lat = (position.coords) ? new String(position.coords.latitude) : position.x;
var lon = (position.coords) ? new String(position.coords.longitude) : position.y;
return GEO_LOCATION.callback(lat, lon);
}
// fork from https://gist.github.com/takien/4077195
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
if(url[2] !== undefined) {
ID = url[2].split(/[^0-9a-z_\-]/i);
ID = ID[0];
}
else {
ID = url.toString();
@ArvinH
ArvinH / README.md
Last active August 20, 2016 12:59
Pokemon WeaknessesGraph

(Shamelessly taken here)

Come up with this idea, but found @filipekiss has already made a great version two years ago, I upgrade to D3v4 layout (with v3 linear radial)

same rule with orginal version:

click a type name and it will show you that type weaknesses. Clicking a second type will make the graph behave for dual types.

[Yellow line] Takes Double Damage [Blue line] Takes Half Damage

@ArvinH
ArvinH / README.md
Last active October 15, 2016 09:40

Time timer by d3.js v4

simply input minutes and you can see how many time remains through visual block

@ArvinH
ArvinH / MessengerGenericMessageAPI.js
Last active January 21, 2017 10:47
Messenger GenericMessage API usage
exports.sendNewsMessagePromise = (id, res) => {
const resData = res.extractorData.data[0].group;
const newResults = resData.map(function(item) {
return {
title: item.titleText[0].text,
buttons: [{
type: "web_url",
url: item.titleLink[0].href,
title: '看詳情',
}]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
const fs = require('fs');
const axios = require('axios');
const xml2js = require('xml2js-es6-promise');
let weatherData;
const extraDataMap = (status, data) => {
return {
status: status,
time: data.$.time,