Skip to content

Instantly share code, notes, and snippets.

@hiiamyes
hiiamyes / basic.js
Last active August 29, 2015 14:03
template for expressjs
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('Hello World');
});
var server = app.listen(3000, function() {
console.log('Listening on port %d', server.address().port);
});
@hiiamyes
hiiamyes / read_photo_geolocation.js
Last active August 29, 2015 14:05
feteching geolocation info from EXIF of photo by nodejs
// author: yes
// 1. Use Picasa first to set geolocation for photos.
// 2. Use this file to read geolocation info in the exif.
var readline = require('readline');
var gm = require('gm');
var imageMagick = gm.subClass({
imageMagick: true
});
@hiiamyes
hiiamyes / index.html
Last active August 29, 2015 14:05
hellow_github_pages
---
---
<!doctype html>
<html>
<head>
</head>
<body>
hi i'm yes
<ul>
@hiiamyes
hiiamyes / app.js
Created August 26, 2014 17:11
exiftool + nodejs
var cp = require('child_process');
// show keywords of photo
cp.exec('exiftool -keywords photo.jpg', function(err, stdout, stderr) {
console.log(stdout);
}
http = require 'http'
querystring = require 'querystring'
postData = querystring.stringify
'__VIEWSTATE': '/wEPDwUKMTkxNTE3NzM4MA9kFgJmD2QWAgIDD2QWCAIBDw8WAh4EVGV4dAUM5pyD5ZOh55m75YWlZGQCAw8WAh8ABesGIDxkaXYgc3R5bGU9J2Rpc3BsYXk6IG5vbmU7Jz48YSBocmVmPSdSQS9SQV9pbmRleC5hc3B4JyB0YXJnZXQ9J19zZWxmJz48aW1nIHNyYz0naW1hZ2VzL3RvcHBpYy90ZXN0Mi5qcGcnIGFsdD0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJyB0aXRsZT0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJy8+PC9hPjwvZGl2PiA8ZGl2IHN0eWxlPSdkaXNwbGF5OiBub25lOyc+PGEgaHJlZj0nVkwvVkxfaW5kZXguYXNweCcgdGFyZ2V0PSdfc2VsZic+PGltZyBzcmM9J2ltYWdlcy90b3BwaWMvYi5qcGcnIGFsdD0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJyB0aXRsZT0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJy8+PC9hPjwvZGl2PiA8ZGl2IHN0eWxlPSdkaXNwbGF5OiBub25lOyc+PGEgaHJlZj0nUlQvUlRfMl9pbmRleC5hc3B4JyB0YXJnZXQ9J19zZWxmJz48aW1nIHNyYz0naW1hZ2VzL3RvcHBpYy90cmFpbDEuanBnJyBhbHQ9J+WPsOeBo+Wxseael+aCoOmBiue2sicgdGl0bGU9J+WPsOeBo+Wxseael+aCoOmBiue2sicvPjwvYT48L2Rpdj4gPGRpdiBzdHlsZT0nZGlzcGxheTogbm9uZTsnPjxhIGhyZWY9J0ZQL0ZQX2luZGV4LmFzcHgnIHRhcmdldD0nX3NlbGYnPjxpbWcgc3JjPSdpbWFnZXMvdG9wcGl
request = require 'request' # https://github.com/request/request
cheerio = require 'cheerio' # https://github.com/cheeriojs/cheerio
optionsLogin =
'method': 'POST'
'url': 'http://recreation.forest.gov.tw/index.aspx'
'followRedirect': false
'form':
'__VIEWSTATE': '/wEPDwUKMTkxNTE3NzM4MA9kFgJmD2QWAgIDD2QWCAIBDw8WAh4EVGV4dAUM5pyD5ZOh55m75YWlZGQCAw8WAh8ABesGIDxkaXYgc3R5bGU9J2Rpc3BsYXk6IG5vbmU7Jz48YSBocmVmPSdSQS9SQV9pbmRleC5hc3B4JyB0YXJnZXQ9J19zZWxmJz48aW1nIHNyYz0naW1hZ2VzL3RvcHBpYy90ZXN0Mi5qcGcnIGFsdD0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJyB0aXRsZT0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJy8+PC9hPjwvZGl2PiA8ZGl2IHN0eWxlPSdkaXNwbGF5OiBub25lOyc+PGEgaHJlZj0nVkwvVkxfaW5kZXguYXNweCcgdGFyZ2V0PSdfc2VsZic+PGltZyBzcmM9J2ltYWdlcy90b3BwaWMvYi5qcGcnIGFsdD0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJyB0aXRsZT0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJy8+PC9hPjwvZGl2PiA8ZGl2IHN0eWxlPSdkaXNwbGF5OiBub25lOyc+PGEgaHJlZj0nUlQvUlRfMl9pbmRleC5hc3B4JyB0YXJnZXQ9J19zZWxmJz48aW1nIHNyYz0naW1hZ2VzL3RvcHBpYy90cmFpbDEuanBnJyBhbHQ9J+WPsOeBo+Wxseael+aCoOmBiue2sicgdGl0bGU9J+WPsOeBo
request = require 'request' # https://github.com/request/request
cheerio = require 'cheerio' # https://github.com/cheeriojs/cheerio
optionsLogin =
'method': 'POST'
'url': 'http://recreation.forest.gov.tw/index.aspx'
'followRedirect': false
'form':
'__VIEWSTATE': '/wEPDwUKMTkxNTE3NzM4MA9kFgJmD2QWAgIDD2QWCAIBDw8WAh4EVGV4dAUM5pyD5ZOh55m75YWlZGQCAw8WAh8ABesGIDxkaXYgc3R5bGU9J2Rpc3BsYXk6IG5vbmU7Jz48YSBocmVmPSdSQS9SQV9pbmRleC5hc3B4JyB0YXJnZXQ9J19zZWxmJz48aW1nIHNyYz0naW1hZ2VzL3RvcHBpYy90ZXN0Mi5qcGcnIGFsdD0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJyB0aXRsZT0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJy8+PC9hPjwvZGl2PiA8ZGl2IHN0eWxlPSdkaXNwbGF5OiBub25lOyc+PGEgaHJlZj0nVkwvVkxfaW5kZXguYXNweCcgdGFyZ2V0PSdfc2VsZic+PGltZyBzcmM9J2ltYWdlcy90b3BwaWMvYi5qcGcnIGFsdD0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJyB0aXRsZT0n5Y+w54Gj5bGx5p6X5oKg6YGK57ayJy8+PC9hPjwvZGl2PiA8ZGl2IHN0eWxlPSdkaXNwbGF5OiBub25lOyc+PGEgaHJlZj0nUlQvUlRfMl9pbmRleC5hc3B4JyB0YXJnZXQ9J19zZWxmJz48aW1nIHNyYz0naW1hZ2VzL3RvcHBpYy90cmFpbDEuanBnJyBhbHQ9J+WPsOeBo+Wxseael+aCoOmBiue2sicgdGl0bGU9J+WPsOeBo
request = require 'request' # https://github.com/request/request
cheerio = require 'cheerio' # https://github.com/cheeriojs/cheerio
form =
'__VIEWSTATE': viewstate
'__EVENTVALIDATION': '/wEWBwK6/o7eDgK23+DHBQKP48TJBwKj360MAqmqibEJAuH354MMAu2LvqIIlo3AZ3cxBMksG9AnBmqNoeKydSOHjl33UiOdH319ygk='
'ctl00$ContentPlaceHolder1$ID_TextBox': '[email protected]'
'ctl00$ContentPlaceHolder1$Pass_TextBox': 'iamahutcrawler1'
'ctl00$ContentPlaceHolder1$btn_login': '登入'
request = require 'request' # https://github.com/request/request
cheerio = require 'cheerio' # https://github.com/cheeriojs/cheerio
async = require 'async'
async.waterfall([
(cb) ->
request 'http://recreation.forest.gov.tw/index.aspx', (err, res, body) ->
$ = cheerio.load body
# console.log 'open homepage: ' + res.statusCode
# console.log res.headers
@hiiamyes
hiiamyes / index.coffee
Last active August 29, 2015 14:22
D3.js - part 1
data = ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']
d3.select 'body'
.selectAll 'p'
.data data
.enter()
.append 'p'
.text (d) -> d