This file contains 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
BaseBallGame.prototype.pitch = function(toHitting, toBunt, score) { | |
var strike_prob = 0.6; | |
var goro_prob = 0.3; | |
var swing_miss_prob = 0.2; | |
var hit_prob = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 4]; | |
var strike = Math.random() > strike_prob; | |
var base = hit_prob[parseInt(Math.random() * 10, 10)]; | |
var isHit = false; | |
var isGoro = Math.random() < goro_prob; | |
var isSwingMiss = false; |
This file contains 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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
ex.py | |
expand pattern and return sequence. | |
Kosei Moriyama <[email protected]> |
This file contains 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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
wiki2rst.py | |
convert bitbucket style wiki notation to ReStructured Text (ReST) | |
Kosei Moriyama <[email protected]> |
This file contains 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
#! /bin/sh | |
# postfix and dovecot setup script (instead of sendmail) | |
# based on http://centossrv.com/postfix.shtml | |
echo "### install postfix via yum if not exist" | |
if [ ! -e /etc/postfix/main.cf ] | |
then | |
sudo yum -y install postfix | |
else |
This file contains 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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
tcget.py | |
Kosei Moriyama <[email protected]> | |
''' | |
import BeautifulSoup |
This file contains 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
#! /usr/bin/ruby | |
posterous_mailto = '[email protected]' | |
## get stdin | |
is_head = true | |
header = '' | |
body = '' | |
while line = gets |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import smtplib | |
import sys | |
import os | |
from email.MIMEText import MIMEText | |
from email.Utils import formatdate | |
from email.Header import Header | |
from optparse import OptionParser |
This file contains 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
#include <stdio.h> | |
#include <errno.h> | |
#include <sys/types.h> | |
#include <sys/uio.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#include <string.h> | |
void set_fl(int fd, int flags); |
This file contains 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
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Mocha Tests</title> | |
<link rel="stylesheet" href="https://raw.github.com/visionmedia/mocha/master/mocha.css" /> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script src="https://raw.github.com/LearnBoost/expect.js/d2440da086bf8dc38c6085641f23b968a0f48b29/expect.js"></script> | |
<script src="https://raw.github.com/visionmedia/mocha/master/mocha.js"></script> | |
<script src="ajax.js"></script> | |
<script>mocha.setup('bdd')</script> |
This file contains 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
(function() { | |
describe('Mocha itself on client-side', function() { | |
it('should works well!', function() { | |
expect(5).to.be.a('number'); | |
}); | |
}); | |
if (!Object.create) { | |
Object.create = function (o) { | |
if (arguments.length > 1) { |