Skip to content

Instantly share code, notes, and snippets.

console.log("timer with node.js");
var now = new Date()
console.log(now);
var alarm = function(name){
var now = new Date()
console.log(now);
console.log(name);
console.log("alarm!, alarm!, alarm!, alarm!");
@seungjin
seungjin / picture_frame.html
Created October 23, 2010 04:12
javascript based picture frame web ui
<html>
<head>
<style>
/* Base styles*/
* {
margin: 0;
padding: 0;
}
body {
@seungjin
seungjin / notice or popup
Created November 19, 2010 18:27
notice or popup. server can push msg into function. so browser can get notice or push msg from server
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>MessageBox</title>
<link rel="stylesheet" type="text/css" href="ext-all.css" />
<script type="text/javascript" src="ext-base.js"></script>
<script type="text/javascript" src="ext-all.js"></script>
<style type="text/css">
#msg-div {
position:absolute;
var d = new Date();
var curr_hour = d.getHours();
var curr_min = d.getMinutes();
var curr_sec = d.getSeconds();
now = curr_hour.toString() + ":" + curr_min.toString() + ":" + curr_sec.toString();
notice.msg("time",now);
@seungjin
seungjin / localStorage and sessionStorage test
Created November 21, 2010 20:38
localStorage and sessionStorage test
<html>
<head>
</head>
<body>
<pre>
localStorage:
used for long-term storage. This data persists after the window is closed and is shared across all browser windows.
localStorage.setItem(key,value);
localStorage.getItem(key);
localStorage.clear();
var faye = require('./lib/faye-node');
var http = require('http');
var client = new faye.Client('http://localhost:9000/faye');
client.publish("/a","asdasdasdasd");
@seungjin
seungjin / gist:761304
Created December 31, 2010 20:13
get instance from eucalyptus/Amazon instance
$this_version = '2010.12.28.001'
$resource_url = 'http://169.254.169.254/latest/meta-data/'
$instance_info_hash = Hash.new
def vmInfo()
def a(address)
url = URI.parse(address)
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
res.body.split().map { |i| lambda{ if i[-1,1] != "/" then $instance_info_hash[(address+i)[40..-1]] = "" else lambda{a(address+i)}.call end}.call}
#!/usr/bin/env ruby
require 'net/http'
$this_version = '2011.01.04.001'
$resource_url = 'http://169.254.169.254/latest/meta-data/'
$instance_info_hash = Hash.new
def vmInfo()
@seungjin
seungjin / rc.local
Created January 6, 2011 17:23
atmo rc.local file
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
# load pci hotplug for dynamic disk attach in KVM (for EBS)
depmod -a
modprobe acpiphp
@seungjin
seungjin / gist:770970
Created January 8, 2011 16:39
ruby request to http or https
def reportToInstanceService(arg)
instance_service_url = JSON.parse(arg)['atmosphere']['instance_service_url']
token = JSON.parse(arg)['atmosphere']['token']
userid = JSON.parse(arg)['atmosphere']['userid']
res = Net::HTTP.post_form(URI.parse(instance_service_url), {'token'=> token, 'userid'=>userid,'vminfo'=>$instance_info_json})
end
def reportToInstanceServiceSSL(arg)
instance_service_url = JSON.parse(arg)['atmosphere']['instance_service_url']
token = JSON.parse(arg)['atmosphere']['token']