This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validator = require('validator'); | |
var hankaku = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '; | |
var zenkaku = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '; | |
var zenkakuToHankaku = function (word) { | |
for (var i = 0, n = zenkaku.length; i < n; i++) { | |
word = word.replace(new RegExp(zenkaku[i], 'gm'), hankaku[i]); | |
} | |
return word.replace(/^\s+|\s+$/g, ''); // trim head and tail white space | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var NotFoundError = module.exports.NotFoundError = function (message) { | |
this.name = 'NotFoundError: ' + message; | |
Error.call(this, message); | |
Error.captureStackTrace(this, arguments.callee); | |
}; | |
NotFoundError.prototype.__proto__ = Error.prototype; | |
var UnauthorizedError = module.exports.UnauthorizedError = function (message) { | |
this.name = 'UnauthorizedError: ' + message; | |
Error.call(this, message); | |
Error.captureStackTrace(this, arguments.callee); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server-side | |
app.get('/keyword/search', | |
function (req, res, next) { | |
var query = new RegExp('^' + req.query.q + '.*$', 'i'); | |
var result = []; | |
mongodb.keywords.find( | |
{ word: query }, [ 'word' ], { limit: 5 }, | |
function (err, keywords) { | |
keywords.forEach(function (k) { | |
result.push(k.word); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.youtalk; | |
import java.io.IOException; | |
import java.net.Socket; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.TimeUnit; | |
public class SocketAcceptor implements Callable { | |
public static final int INTERVAL_MS = 1000; | |
public static final int MAX_TRIAL = 100; | |
private final String host; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET = name | |
CXXFLAGS = -O2 -g -Wall | |
LIBS = -lboost_thread -lboost_filesystem ¥ | |
-I/usr/include/octave-`octave-config -v` ¥ | |
-L/usr/lib/octave-`octave-config -v` -loctave -lcruft ¥ | |
-I/usr/local/include -L/usr/local/lib -lode -ldrawstuff -lglut -l3ds | |
SRCS = $(shell ls *.cpp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.youtalk; | |
public enum NullRunnable implements Runnable { | |
INSTANCE; | |
@Override | |
public void run() {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET = name | |
SOURECE = $(shell ls eps/*.eps) | |
LATEX = platex | |
DVIPDFM = dvipdfmx | |
XDVI = xdvi | |
.SUFFIXES: .tex .dvi .pdf | |
$(TARGET).dvi: $(TARGET).aux $(SOURECE) | |
$(LATEX) $(TARGET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.youtalk; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.StringReader; | |
import java.io.UnsupportedEncodingException; | |
import java.net.HttpURLConnection; | |
import java.net.URL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
(function ping () { | |
request.get({ url: 'http://YourWebApp.herokuapp.com' }, function (err, res, body) { | |
if (!err && res.statusCode === 200) { | |
console.log('done'); | |
} | |
}); | |
})(); |
OlderNewer