Skip to content

Instantly share code, notes, and snippets.

View matsumotius's full-sized avatar

Matsumoto Akihiro matsumotius

View GitHub Profile
@matsumotius
matsumotius / gyapin_test.rb
Created January 29, 2012 15:19
gyapin test
def gyapin(image, source, alt, title)
host = "http://pinterest.com/pin/create/bookmarklet/"
url = host + "?media=" + image +
"&url=" + source +
"&alt=" + alt +
"&title=" + title + "&is_video=false"
system "google-chrome \"#{url}\""
end
gyapin("http://cache.gyazo.com/99ba9338b392dc5750492cfc1f0c4f94.png",
@matsumotius
matsumotius / timer.js
Created January 25, 2012 00:20
timer
var timer = function(sec, internal, finished) {
var limit = parseInt(sec);
var count = 0;
var counter = setInterval(function(){
count++;
if(count < limit) {
if(typeof internal == "function") internal(count, limit);
} else {
if(typeof finished == "function") finished(count, limit);
clearInterval(counter);
@matsumotius
matsumotius / 8queen.rb
Created January 8, 2012 05:07
8queen
def eight_queen(n = 8, m = 8)
run(n, m, [])
end
def run(kinds, len, a)
return unless can_set_queen?(a)
if len == 0 then
puts a.join(',')
else
kinds.times { |i|
@matsumotius
matsumotius / Twitter.java
Created December 6, 2011 06:56
twitter
import java.net.*;
import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.io.*;
public class Twitter extends DefaultHandler {
public Boolean is_tweet = false;
@matsumotius
matsumotius / login.rb
Created November 15, 2011 04:43
kicchiiii
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
agent.follow_meta_refresh = true
page = agent.get('https://vu8.sfc.keio.ac.jp/sfc-sfs/')
form = page.forms.first
form['u_login'] = ARGV[0]
form.add_field!("u_pass", ARGV[1])
agent.submit(form)
var tests = {
'フォローを削除できる' : function(test) {
var searching_user = user_dao.find({ email : '[email protected]' }, [], {});
searching_user.on('end', function(users){
var searching_node = node_dao.find({ value : 'a' }, [], {});
searching_node.on('end', function(nodes){
var inserting_node = user_dao.add_node(users[0]._id, { node_id : nodes[0]._id });
inserting_node.on('end', function(){
var remove_node = user_dao.remove_node(users[0]._id, nodes[0]._id);
remove_node.on('end', function(){
!!! 5
html(lang='ja')
head
title hello
script(type = 'text/javascript', src = '/socket.io/socket.io.js')
script(type = 'text/javascript', src = '/jquery-1.6.2.min.js')
script(type = 'text/javascript', src = '/hello.js')
body
div hello!!!
@matsumotius
matsumotius / hello.js
Created October 21, 2011 16:18
client
$(function(){
var socket = io.connect('http://localhost/');
socket.on('hello', function(message){
$('body').append('<p>'+message+'</p>');
});
$('body').append('<button id="send">全員に送る</button>');
$('#send').click(function(e){
socket.emit('message', 'hello!! '+new Date().toLocaleString());
});
});
@matsumotius
matsumotius / hello.js
Created October 21, 2011 09:38
say hello
var express = require('express');
var app = module.exports = express.createServer();
var store = new (require('connect').session.MemoryStore)();
app.configure(function(){
app.set('views', __dirname + '/view');
app.set('view options', { layout : false, filename : __dirname + '/view/index.jade' });
app.set('view engine', 'jade');
app.use(express.static(__dirname + '/static'));
app.use(express.bodyParser());
app.use(express.cookieParser());
@matsumotius
matsumotius / linked_list.c
Created October 20, 2011 14:22
linked list
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
struct node {
int value;
struct node *next;
};