Skip to content

Instantly share code, notes, and snippets.

@akyao
akyao / generator.py
Created July 14, 2017 08:53
template + csv -> file...
# -*- coding: utf-8 -*-
import csv
import sys
tmpl_file = sys.argv[1]
csv_file = sys.argv[2]
ctx_header = []
cxt_list = []
@akyao
akyao / build.gradle
Last active August 21, 2016 08:25
Gradle マルチプロジェクト
apply plugin: 'eclipse'
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
maven {
url 'http://repo.spring.io/libs-release'
@akyao
akyao / scraping_lxml_sample.py
Created July 14, 2016 02:33
Python lxmlでのスクレイピングサンプル
# coding: utf-8
import lxml.html
import requests
# http://qiita.com/beatinaniwa/items/72b777e23ef2390e13f8
# これが文字化けで動かなかったのでエンコード追加
target_url = 'http://news.tv-asahi.co.jp/news_politics/articles/000041338.html'
find src/test/java/hoge -type f -name "*.java" -print0 | xargs -0 sed -i -e "s%@Ignore%//@Muscle%"
#find src/test/java/hoge -type f -name "*.java" -print0 | xargs -0 sed -i -e "s%//@Muscle%@Ignore%"
@akyao
akyao / killer.sh
Created April 8, 2016 08:52
子プロセスもろとも殺害するスクリプトサンプル
# get pgid from process group leader cmd
PGID=`ps -eo user,pid,pgid,cmd | grep vagrant | grep "[o]ya.sh" | awk '{ print $3 }'`
# get children pids from pgid
PIDS=`ps -eo user,pid,pgid | grep vagrant | grep " $PGID" | awk '{ print $2 }'`
# kill them all
for PID in $PIDS; do
echo $PID
kill -kill $PID
@akyao
akyao / Sample.java
Last active April 4, 2016 13:22
ファイル名と2行目のJavaファイル名が異なっている場合は出力する
/**
* SimulationItemStatus.java 2016/4/04
*
* Copyright (c) xxxxxxx
*/
@akyao
akyao / panda_hoge.ipynb
Created March 15, 2016 12:08
ipython-test
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akyao
akyao / SpreadSheet2InsertSql.js
Created January 26, 2016 10:25
SpreadSheet2InsertSql.js
function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var tblName = sheet.getRange("A1").getValue();
var allData = sheet.getDataRange().getValues();
var headers = allData[1];
var records = allData.slice(2);
var sql = toInsertSql(tblName, headers, records);
Browser.msgBox(sql);
}
@akyao
akyao / urlunzip.sh
Created October 19, 2015 08:44
unzip short-url
#!/bin/bash
# via http://stackoverflow.com/questions/3074288/get-url-after-redirect
# usage echo "http://bit.ly/xxxxx" | sh urlunzip.sh
# cat short_url_list.txt | sh urlunzip.sh
while read line
do
curl -s -i $line -L | egrep -A 10 '301 Moved Permanently|302 Found' | grep 'Location' | awk -F': ' '{print $2}' | tail -1
done
@akyao
akyao / measure_time.py
Last active August 29, 2015 14:22
コマンドの実行時間を測定するツール。(例:git clone時にdepth1指定をした場合のパフォーマンス向上効果)
# encoding: utf-8
from datetime import datetime
import time
import os
def measure(func):
time_start = datetime.now()
func()
time_stop = datetime.now()