Skip to content

Instantly share code, notes, and snippets.

View hpcslag's full-sized avatar
🙀
Probability^C. not A and not B

MacTaylor hpcslag

🙀
Probability^C. not A and not B
  • Industrial Technology Research Institute.
  • Taiwan, Kaohsiung
View GitHub Profile
@hpcslag
hpcslag / microphone.js
Created December 26, 2014 14:55
Need use localhost, don't use file:///
// success callback when requesting audio input stream
function gotStream(stream) {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
var analyser = audioContext.createAnalyser();//x
// Create an AudioNode from the stream.
var mediaStreamSource = audioContext.createMediaStreamSource( stream );
// Connect it to the destination to hear yourself (or any other node for processing!)
@hpcslag
hpcslag / index.ejs
Last active August 29, 2015 14:16
WebRTC_Stream
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
<script type="text/javascript" src="./socket.io/socket.io.js" ></script>
<script>
var socket = io('http://localhost');
socket.on('connect',function(){
console.log("Hello World");
@hpcslag
hpcslag / mongodb.js
Created April 9, 2015 14:10
Mongodb用法
/*
* This is Official API Note, use mongojs!
*/
var mongojs = require('mongojs');
var db = mongojs('test',['table']); //test 是db的名稱,不需要create. table是集合的名稱
/**
* Search All(Find())
* @class
@hpcslag
hpcslag / bigpipe.php
Created October 10, 2015 13:54 — forked from LeoOnTheEarth/bigpipe.php
Bigpipe Demo
<?php set_time_limit(0); ?>
<!DOCTYPE html>
<html lang="zh-tw">
<head>
<meta charset="utf-8" />
<title>BigPipe Demo</title>
</head>
<body id="main">
<div>
Hello world
@hpcslag
hpcslag / gist:069e230fa8e23fe0ae933daf4cde086c
Last active April 9, 2016 05:17
比賽表,兩筆資料從一張表搜尋(國家),一張表的兩筆資料,參照替換成第二張表的參考
SELECT G.Home, G.Away,
C1.CountryName, C2.CountryName
FROM Game G
JOIN Country C1 ON C1.CountryID = G.Home
JOIN Country C2 ON C2.CountryID = G.Away;
--http://stackoverflow.com/questions/4267929/whats-the-best-way-to-join-on-the-same-table-twice
@hpcslag
hpcslag / semantic-layout.html
Created May 31, 2016 14:06 — forked from thomd/semantic-layout.html
Standard HTML5 Semantic Layout
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Title</title>
<link href="stylesheets/main.css" rel="stylesheet" />
</head>
<body>
<header>
<hgroup>
@hpcslag
hpcslag / Gauß.js
Created July 30, 2016 11:10
一個加總,各表自述
function sum(number) {
return (1 + number) * number / 2;
}
sum(1000);
@hpcslag
hpcslag / Install Cloud9 on local or remote computer, server, or raspberry pi This gist will help you install Cloud9 on your local or remote computer, server, or even your raspberry pi. Many people are having issues at the time of this Gist's creation.
Complete installation process:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y python-software-properties python make build-essential g++ curl libssl-dev apache2-utils git libxml2-dev
sudo apt-get update
sudo apt-get upgrade
cd ~
mkdir git
cd ~/git
@hpcslag
hpcslag / Decoder.java
Created November 8, 2017 04:04
Put byte arrays to hex string decoder.
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for ( int j = 0; j < bytes.length; j++ ) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
@hpcslag
hpcslag / guessNumber.m
Created November 19, 2017 04:17
Matlab homework 1
function guessNumber(m,n)
%call guessNumber(m,n) to play the game
%example:
%guessNumber(1,10) to play the game in range 1 to 10
%
r = randperm(n);
ans = r(m);
range_x = m;
range_y = n;