Skip to content

Instantly share code, notes, and snippets.

View FlandreDaisuki's full-sized avatar
🌈
世界にバグは不要です

Chun-Hao Lien FlandreDaisuki

🌈
世界にバグは不要です
View GitHub Profile
@FlandreDaisuki
FlandreDaisuki / gfile.md
Last active August 29, 2015 14:03
Gist Markdown Cheat Sheet

Header 1

Header 2

Header 3 ### (Hashes on right are optional)

Header 4

Header 5

Markdown plus h2 with a custom ID ## {#id-goes-here}

Link back to H2

This is a paragraph, which is text surrounded by whitespace. Paragraphs can be on one

package main
import (
"code.google.com/p/go-tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
a := strings.Split(s, " ")
res :=make(map[string]int)
// ==UserScript==
// @name FlandreFaveriteSubclub
// @namespace FlandreDaisuki
// @description 註冊字幕組
// @include http://share.dmhy.org/*
// @include https://share.dmhy.org/*
// @match http://share.dmhy.org/*
// @match https://share.dmhy.org/*
// @version 2015.09.28
// @grant none
@FlandreDaisuki
FlandreDaisuki / Huffman.js
Created May 13, 2015 04:07
Simple implement of Huffman tree encoding
var question = [9, 4, 7, 20, 8, 11, 3];
var q = question.map(function(e){
return {left:null, right:null, num:e}
})
// {}是一個有左右樹的結構,若節點左右皆為null為葉節點
for(var i = 0; i < question.length-1; i++) {
//迴圈 n-1 次
q.sort(function(a, b){return a.num-b.num});
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} root
* @return {TreeNode}
@FlandreDaisuki
FlandreDaisuki / FB.rainbow.CSSgradient.js
Last active August 29, 2015 14:23
paste on console and 🌈
function repImg( tar ) {
var div = document.createElement( 'div' );
div.style.height = tar.height + 'px';
div.style.width = tar.width + 'px';
div.style.display = 'inline-block';
div.style.backgroundColor = 'transparent';
// http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
var isFirefox = typeof InstallTrigger !== 'undefined';
// ==UserScript==
// @name Flanico
// @namespace FlandreDaisuki
// @description A HTML5 based niconico player
// @include http://www.nicovideo.jp/watch/*
// @match http://www.nicovideo.jp/watch/*
// @exclude
// @version 2015.07.14
// @grant none
// ==/UserScript==
#include <GL/glut.h>
#include <cstdio>
#include <cmath>
GLfloat rot = 0.0;
GLfloat PI = (GLfloat)3.14159265;
GLfloat seed_2 = 0.0;
enum EXAMPLE{ NORMAL, ROTATE, TRANSLATE, SCALE };
EXAMPLE mode = SCALE;
@FlandreDaisuki
FlandreDaisuki / ordered-fetch-promise.js
Created September 16, 2015 18:49
Thanks dannvix senpai
import fetch from "/Users/dannvix/node_modules/node-fetch";
import Promise from "/Users/dannvix/node_modules/promise";
const urls = [
"http://www.google.com",
"http://www.yahoo.com",
"http://www.microsoft.com",
];
(function fetchUrl(urlIdx) {