Skip to content

Instantly share code, notes, and snippets.

set cursorline
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@FATESAIKOU
FATESAIKOU / doubleimg
Last active November 9, 2017 11:31
Doubleimg
#!/usr/bin/env bash
#
# oh... double img... use https://github.com/nagadomi/waifu2x
# author: FATESAIKOU 2017/09/20
# $1 = source file
# $2 = noise level(from 0 to 3)
IFS=$'\n'
waifu2x_home=***Your path to waifu2x home***
src=$(readlink -f $1)
@FATESAIKOU
FATESAIKOU / wtf.c
Created December 11, 2017 16:08
hmm... deadlock
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <pthread.h>
#define MAX_CHILD 4096
@FATESAIKOU
FATESAIKOU / read.c
Last active January 8, 2018 11:49
Sample Read
#include <stdio.h>
int main() {
int MAX_LEN = 1024;
char buf[MAX_LEN];
printf("<Start Reading>\n");
while (fgets(buf, MAX_LEN - 1, stdin) != NULL) {
printf("%s", buf);
}
import requests
import urllib
import json
from bs4 import BeautifulSoup as Soup
def doRequest(url):
return requests.get(url)
def searchComic(pattern):
import requests
import urllib
import json
import re
from bs4 import BeautifulSoup as Soup
def doRequest(url):
return requests.get(url)
from selenium import webdriver
# 開啟 chrome 瀏覽器
driver = webdriver.Chrome()
# 前往 google 首頁 https://google.com.tw
driver.get("https://google.com.tw")
# 截圖並儲存為 google_homepage.png
driver.save_screenshot("google_homepage.png")
#!/usr/bin/env bash
sudo apt-get install -y unzip xvfb libxi6 libgconf-2-4
sudo apt-get update && sudo apt-get install chromium-browser chromedriver
# APT 上找不到就得去 chromedriver 官網找到正確的版本安裝。
# 通常版本號會與 chromium-browser --product-version 相同,
# 但也有可能唯獨最後面的小版本號不同(依然能使用),所以請
# 人工確認 XXXXXX 當中的版號。
# wget https://chromedriver.storage.googleapis.com/XXXXXX/chromedriver_linux64.zip
FROM ubuntu:18.04
# 安裝必要套件跟瀏覽器
RUN apt-get update && \
apt-get install -y apt-utils ssh && \
apt-get install -y python3 python3-pip && \
apt-get install -y chromium-browser udev chromium-chromedriver
RUN pip3 install selenium
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://google.com.tw")
driver.save_screenshot("google_homepage.png")
driver.close()