Skip to content

Instantly share code, notes, and snippets.

@hiiamyes
hiiamyes / crawler.js
Last active September 17, 2017 19:19
npm-trail-crawler-v2
// get wayPoints
for (let i = 0; i < trails.length; i++) {
// 選主路線
await select(page, `${baseId}_climblinemain`, trails[i].value);
await page.waitForSelector(`a[title='${trails[i].name}']`);
const trail = trails[i];
for (let j = 0; j < trail.subTrails.length; j++) {
const subTrail = trail.subTrails[j];
// 選次路線
await select(page, `${baseId}climbline`, subTrail.value);
@hiiamyes
hiiamyes / crawler.js
Last active September 16, 2017 14:31
npm-trail-crawler-v1
const puppeteer = require("puppeteer");
const fs = require("fs");
const moment = require("moment");
const _ = require("lodash");
const baseId = "#ContentPlaceHolder1_";
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
@hiiamyes
hiiamyes / photo-management.sh
Created September 5, 2017 01:18
copy all files with a certain extension from all subdirectories
# https://stackoverflow.com/questions/15617016/cp-copy-all-files-with-a-certain-extension-from-all-subdirectories
find . -name \*.xls -exec cp {} newDir \;
@hiiamyes
hiiamyes / script.sh
Created August 30, 2017 06:45
Find and kill port in use on osx
# Error: listen EADDRINUSE 0.0.0.0:3003
# [ref](https://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac)
lsof -t -i tcp:3003 | xargs kill
@hiiamyes
hiiamyes / crawler.js
Last active August 23, 2017 18:41
Use puppeteer to crawl out verification image
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(
"https://npm.cpami.gov.tw/apply_1_2.aspx?unit=e6dd4652-2d37-4346-8f5d-6e538353e0c2"
);
await page.click("input[id='chk[]0']");
@hiiamyes
hiiamyes / my-vscode-snippet.json
Created August 19, 2017 13:05
VSCode custom snippet
{
"cx": {
"prefix": "cx",
"body": "className={cx('$1')}"
}
}
@hiiamyes
hiiamyes / .gitconfig
Last active September 14, 2017 02:02
My git alias
[user]
name = yes
[alias]
acn = !git add . && git commit -n
fdr = !git fetch origin develop:develop && git rebase -i develop
bmd = !git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d // branch merged delete
gp = !git push origin HEAD // push current branch
@hiiamyes
hiiamyes / app.go
Last active July 13, 2017 18:19
My first go code!
package main
import (
"context"
"log"
cdp "github.com/knq/chromedp"
)
func main() {
@hiiamyes
hiiamyes / package.json
Created July 12, 2017 16:03 — forked from tpai/package.json
A web crawler sample based on nightwatch.
{
"name": "nightwatch_webcrawler",
"description": "A web crawler sample based on nightwatch.",
"version": "0.0.1",
"author": {
"name": "tonypai",
"email": "[email protected]"
},
"homepage": "http://github.com/tpai",
"dependencies": {
@hiiamyes
hiiamyes / Dockerfile
Created July 12, 2017 15:33 — forked from kenfehling/Dockerfile
Docker: Ubuntu 16.04 with Node 6.10.2, Selenium Standalone, Chrome Headless
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
apt-transport-https \
openjdk-8-jre-headless \
curl \
xz-utils \
unzip \
bzip2 \