Skip to content

Instantly share code, notes, and snippets.

View ww24's full-sized avatar
🏢
≡GO

Takenori Nakagawa ww24

🏢
≡GO
View GitHub Profile
@ww24
ww24 / remove.js
Last active August 29, 2015 14:02
.lightgray 要素の前に半角空白を挿入し、 .lightgray 要素を削除する。
/**
* コピペ防止対策☆
*/
var fakes = [].slice.call(document.getElementsByClassName("lightgray")), fake;
while (fake = fakes.shift()) {
fake.parentNode.insertBefore(document.createTextNode(" "), fake);
fake.parentNode.removeChild(fake);
}
@ww24
ww24 / snowflake.js
Created April 29, 2014 06:17
コッホ雪片
/**
* コッホ雪片
*/
// 設定
/*==========================*/
// 初期座標
var a = {x: 10, y: 580};
var b = {x: 1990, y: 580};
// 描画サイズ
@ww24
ww24 / download.js
Created April 26, 2014 17:24
任意のファイルの自動ダウンロード
function download(url, filename) {
var a = document.createElement("a");
a.href = url;
a.download = filename || url.split("/").slice(-1)[0];
a.click();
}
@ww24
ww24 / logistic_map.R
Last active August 29, 2015 14:00
ロジスティック写像の分岐図
# ロジスティック写像
# 周期倍加分岐図
require(compiler)
# 設定
x0 <- 0.1
aR <- 29000:40000 / 10000
tR <- 1900:2000
@ww24
ww24 / example.js
Created February 6, 2014 05:51
V8 で行番号を取得する。
// test1
console.log(getLineNumber());
// test2
var test = (function test() {
console.log(getLineNumber());
return test;
})();
var obj = {
@ww24
ww24 / GA.coffee
Last active August 29, 2015 13:55
###
GeneticAlgorithm Class
###
Gene = require "./Gene"
class GA
# 個体数, 評価関数
constructor: (@population, @gene_size) ->
@genes = (new Gene(null, @gene_size) for x in [0...population])
@ww24
ww24 / game.c
Created January 16, 2014 08:21
Number Guessing Game
#include <windows.h>
#include <assert.h>
#define EXITIF(COND) if (COND) { assert(!(COND)); exit(EXIT_FAILURE); }
void server(short port)
{
WSADATA wsaData;
int sock, newsock, sinlen, r, result, num;
u_long ulnum;
struct sockaddr_in sinme, sinhim;
@ww24
ww24 / shuffle.c
Last active January 2, 2016 11:09
あらゆる型の配列をシャッフルする関数
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// 配列シャッフル
void shuffle(void*, size_t, size_t);
// funcs
char _a(void) {return 'A';}
char _b(void) {return 'B';}
@ww24
ww24 / sse.html
Created January 2, 2014 15:59
WebSocket と Server-Sent Events を試す。
<!DOCTYPE html>
<html>
<head>
<title>WebSocket</title>
</head>
<body>
<h1>Hello</h1>
<script>
var event_src = new EventSource("http://localhost:3000/");
event_src.onopen = function (e) {
@ww24
ww24 / Slide-Page.markdown
Last active January 1, 2016 19:39
A Pen by Take.