Skip to content

Instantly share code, notes, and snippets.

var tddjs = tddjs || {};
(function(global) {
global.ajax = {};
var ajax = global.ajax;
/**
* Define ajax.create()
*/
var i, l;
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Ajax integration text</title>
</head>
<body onload="startSuccessfullGetTest()">
<h1>Ajax Integration Test</h1>
<div id="output"></div>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript" src="successful_get_test.js"></script>
function startSuccessfullGetTest() {
var output = document.getElementById('output');
if (!output) {
return;
}
function log(text) {
if (output && typeof output.innerHTML !== 'undefined') {
output.innerHTML = text;
} else {
<h1>Remote page</h1>
<p>
Hello, I am an HTML fragment and I was fetched using <code>XMLHttpRequest</code>
</p>
@cou929
cou929 / jquery_plugin_boilerplate.js
Created July 1, 2012 10:26
Template of jQuery Plugin
!function($) {
var namespace = 'plugin_name';
$.fn[namespace] = function(options) {
var elements = this,
settings = $.extend({
'param': 'default value'
}, options);
elements.each(function() {
@cou929
cou929 / cookietest.js
Created July 14, 2012 17:23
set test cookie and return beacon gif
var http = require('http');
var imgdata = [
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01,
0x00, 0x80, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x21, 0xf9, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b
];
var imgbuf = new Buffer(imgdata);
@cou929
cou929 / notation_checker.py
Created September 17, 2012 01:03
文章の表記ゆれをなんとなくチェックする
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import MeCab
import sys
mecab = MeCab.Tagger('-Ochasen')
result = {}
linenum = 0
@cou929
cou929 / crawl_urls_with_cookie.js
Created November 20, 2012 09:13
url のリストをうけとって順番にアクセス. 各リクエスト時の cookie を表示する
@cou929
cou929 / twit_streaming_to_td_sample.js
Created November 21, 2012 17:05
Twitter Streaming API を td へ流し込む
/*jslint indent: 4*/
/*jslint node: true */
'use strict';
var Twitter = require('ntwitter'),
logger = require('fluent-logger');
logger.configure('td.test_db', {host: 'localhost', port: 24224});
var twit = new Twitter({
consumer_key: 'XXX',
@cou929
cou929 / locale.py
Created November 24, 2012 03:51
locale で 'ValueError: unknown locale: UTF-8' というエラーがでた
def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
# 略
import os
lookup = os.environ.get
for variable in envvars:
localename = lookup(variable,None)
if localename:
if variable == 'LANGUAGE':