Skip to content

Instantly share code, notes, and snippets.

tuchida

Block or report user

Report or block tuchida

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View applynew.js
class MyClass {
constructor(a, b, c) {
this.sum_ = a + b + c;
}
sum() {
return this.sum_;
}
}
console.log(new MyClass(2, 3, 4).sum());
@tuchida
tuchida / delaunay.js
Created Feb 20, 2015
delaunay.js ES6Ver
View delaunay.js
// ref. http://qiita.com/edo_m18/items/7b3c70ed97bac52b2203
(require => {
require("babel/polyfill");
function Point(x, y) {
this.x = x;
this.y = y;
}
Object.assign(Point.prototype, {
@tuchida
tuchida / cjs.html
Created Jul 16, 2014
jsとcssを1ファイルに
View cjs.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="test.cjs">
</head>
<body>
<script src="test.cjs"></script>
</body>
</html>
@tuchida
tuchida / searchtools.js.diff
Created May 16, 2014
Sphinxの全文検索を複合語に強くする
View searchtools.js.diff
diff --git a/_build/html/_static/searchtools.js b/_build/html/_static/searchtools.js
index 3499624..6843d3b 100644
--- a/_build/html/_static/searchtools.js
+++ b/_build/html/_static/searchtools.js
@@ -81,7 +81,22 @@ var Search = {
},
setIndex : function(index) {
+ function objToSortArray(terms) {
+ var res = [];
@tuchida
tuchida / E4X.java
Created Mar 26, 2014
E4X in Nashorn
View E4X.java
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class E4X {
public static void main(String[] args) {
System.out.println("E4X: " + System.getProperty("nashorn.lexer.xmlliterals"));
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
try {
View comment.js
macro <<EOS {
case { $_ } => {
var comments = #{$_}[0].token.leadingComments;
var text = '';
if (comments) {
text = comments.map(function(c) {
return c.type === 'Block' ? c.value.replace(/^(\r\n|\n|\r)/, '').replace(/(\r\n|\n|\r)$/, '') : c.value;
}).join('\r\n');
}
return [makeValue(text, #{here})];
@tuchida
tuchida / app.js
Created Jan 10, 2014
Server-Sent Eventsテスト
View app.js
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.type('text/html');
res.send('<script>' +
'new EventSource(\'/event/a\').addEventListener(\'message\',function(event) {' +
'document.body.appendChild(document.createElement(\'div\')).textContent = event.data;' +
'});' +
'</script>');
@tuchida
tuchida / visitor.js
Created Jul 22, 2013
Nashorn Parser
View visitor.js
function parse(str) {
var ir = Packages.jdk.nashorn.internal.ir;
var runtime = Packages.jdk.nashorn.internal.runtime;
var parser = Packages.jdk.nashorn.internal.parser;
var context = runtime.Context.getContext();
var source = new runtime.Source('test', str);
var node = new parser.Parser(context.getEnv(), source, new runtime.Context.ThrowErrorManager(), true).parse();
var lexContext = new ir.LexicalContext();
@tuchida
tuchida / goto.js
Last active Dec 20, 2015
Rhino GOTO
View goto.js
function traverseFn(node, fn) {
var parents = [];
(function f(node) {
fn(node, parents);
parents.push(node);
for (var c in Iterator(node)) {
f(c);
}
parents.pop();
})(node);
View brainfuck.js
macro bf {
case : { $body ... } => {
(function() {
var env = {
p: 0,
b: [],
buf: new Buffer(1)
};
bf_tokenizer[env]($body ...);
})();
You can’t perform that action at this time.