Skip to content

Instantly share code, notes, and snippets.

@keizie
keizie / grab_munpia.sh
Created July 23, 2021 17:54
grab_munpia.sh (euc-kr) 2011-03-26
#!/bin/sh
TARGET_URL="$1"
BASE_URL=$(dirname $TARGET_URL)
NEXT_URL="go first"
until [ -z "$NEXT_URL" ]
do
w3m -I cp949 -O cp949 -cols 72 -dump $TARGET_URL | awk 'BEGIN {sw=""} /\[목록보기\]/ {sw=""} {if (sw) print} /댓글 부분으로/ {sw="ok"}'
NEXT_URL=$(w3m -dump_source $TARGET_URL | grep -m 1 "윗글" | awk -F\' '{print $2}')
@keizie
keizie / umpv.sh
Created February 15, 2020 20:40
bash clone of python umpv from mpv package
#!/bin/bash
FIFO="/tmp/mpvpipe"
TARGET=$1
if [ "x--" = "x$TARGET" ]; then
TARGET=$2
fi
PID=$(fuser $FIFO 2> /dev/null)
@keizie
keizie / navermap-reversegeocode.js
Last active June 8, 2018 13:23
네이버 맵이 너무 웹페이지 출력에 맞춰져서 URL 호출만으로는 사용할 수 없는 바람에 만들어본 샘플
'use strict';
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('적당한URL', { waitUntil: 'networkidle2' });
await page.addScriptTag({
// 대량으로 호출해야 한다면 파일로 저장하고 path 옵션으로 추가하는 방식도 가능해보임
@keizie
keizie / img2txt.js
Created March 27, 2016 12:01
OCR via Google Vision API
var fs = require('fs');
var request = require('request');
var base64 = require('base64-stream');
var JSONStream = require('JSONStream');
var visionArgs = {key: fs.readFileSync('vision.key')};
var visionUrl = 'https://vision.googleapis.com/v1/images:annotate';
var reader = process.stdin.pipe(base64.encode());
var writer = request.post({
@keizie
keizie / generator.php
Created March 26, 2016 15:45
Running multiple generator simultaneously
<?php
$epoch = microtime(true);
function times(int $a) {
global $epoch;
$i = 0;
while (++$i <= $a) {
//sleep(1);
var_dump(microtime(true) - $epoch);
@keizie
keizie / vfio-bind.sh
Created July 6, 2015 22:06
vfio-bind that does not hang on trying to bind again
#!/bin/bash
modprobe vfio-pci
for dev in "$@"; do
if [ -e /sys/bus/pci/drivers/vfio-pci/$dev ]; then
continue
fi
vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
device=$(cat /sys/bus/pci/devices/$dev/device)
#!/usr/bin/python3
import os, re, logging
from glob import glob
from pipes import quote
from shutil import rmtree
SOURCES = ('/mnt/1.5T/,movie/','/mnt/1.5T/,tv/',)
LOGFILE = '/home/keizie/.brag/autounrar.log'
EXECUTE_RAR = 'unrar'
@keizie
keizie / tease.py
Last active December 20, 2015 14:19
http://zariski.wordpress.com/2013/08/02/%EC%98%A4%EB%8A%98%EC%9D%98-%EB%B8%8C%EB%A0%88%EC%9D%B8%ED%8B%B0%EC%A0%80/ 문제를 확인하기 위한 코드. 결과적으로 35개의 3으로 이루어진 목록은 나오지만 최종적으로 1만으로 이루어진 데까지는 가지 않는다.
# -*- coding:utf-8 -*-
from itertools import combinations
from pprint import pprint
bundle = [51,49,5]
candidates = [bundle]
loop = True
loop_count = 0
largest_member = []