Skip to content

Instantly share code, notes, and snippets.

View matsumotius's full-sized avatar

Matsumoto Akihiro matsumotius

View GitHub Profile
@matsumotius
matsumotius / phonegapCamera.js
Created May 18, 2011 23:11
phonegap - camera
function getPicture(){
navigator.camera.getPicture(function(data){
// success handler
alert('success');
}, function(){
// error handler
alert('error');
}, {
// options
quality: 50
@matsumotius
matsumotius / time_t_sample.c
Created July 18, 2011 09:18
time_t sample
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t now;
struct tm *ts;
int year;
char buf[80];
// Get the current time
@matsumotius
matsumotius / hello.js
Created October 13, 2011 09:51
express server
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;
};
@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 / 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());
});
});
!!! 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!!!
var tests = {
'フォローを削除できる' : function(test) {
var searching_user = user_dao.find({ email : 'a@example.com' }, [], {});
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(){
@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)
@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;