Skip to content

Instantly share code, notes, and snippets.

View gist:29f43bf7d242afd653979b418f69eeb2
node -v # => v8.1.1
node --harmony -e "r=require,h=r('http');h.createServer((q,s)=>{q.pipe(h.request({...q,...r('url').parse(q.url)},a=>{s.writeHead(a.statusCode,a.headers);a.pipe(s)}))}).listen(8081)"
@nash716
nash716 / gist:1498004
Created Dec 19, 2011
index_pickup.html
View gist:1498004
<script type="text/javascript">
var socket;
$(document).ready(function() {
socket = new io.Socket();
socket.connect();
// 接続成功
socket.on('connect', function() {
$('#select').show();
$('#status').text('サーバーと接続成功!');
});
@nash716
nash716 / gist:1497990
Created Dec 19, 2011
background_pickup.html
View gist:1497990
<html><head>
<script>
var url = 'http://localhost:12000/#receive';
var type;
chrome.tabs.onUpdated.addListener(function(id, info, tab) { // タブが更新されたときに呼ばれる
if (tab.url.match(url)) {
// 命令部分だけを取り出す
type = JSON.parse(tab.url.substring(url.length + 1)).type;
chrome.tabs.getAllInWindow(null, function(tabs) {
for (var i=0; i<tabs.length; i++) {
View gist:1497809
http://localhost:12000/#receive
↓ { type: 'aaa' } という情報を受信
URLが http://localhost:12000/#receive/{type:'aaa'} となったのち、http://localhost:12000/#receive に戻る
View gist:1497669
<html><head>
<meta charset="utf-8">
<style type="text/css">
html {
height: 100%;
width: 100%;
display: table;
}
body {
height: 100%;
@nash716
nash716 / gist:1497542
Created Dec 19, 2011
background.html
View gist:1497542
<html><head>
<script>
var url = 'http://localhost:12000/#receive';
var type;
chrome.tabs.onUpdated.addListener(function(id, info, tab) { // タブが更新されたときに呼ばれる
if (tab.url.match(url)) {
// 命令部分だけを取り出す
type = JSON.parse(tab.url.substring(url.length + 1)).type;
chrome.tabs.getAllInWindow(null, function(tabs) {
for (var i=0; i<tabs.length; i++) {
View gist:1497527
var io = require('socket.io');
var express = require('express');
var app = express.createServer();
app.configure(function(){
app.use(express.static(__dirname));
app.use(express.logger());
app.use(app.router);
});
You can’t perform that action at this time.