Skip to content

Instantly share code, notes, and snippets.

View mazgi's full-sized avatar

Hidenori Matsuki mazgi

View GitHub Profile
@mazgi
mazgi / gist:3168836
Created July 24, 2012 08:32
zshでログ抽出してみる
$ zcat dir/orig.gz | while read line
do
r=
echo $line
vared -p "write?(Y/n)" r
if [ -z "${r}" -o "${r}" = 'y' -o "${r}" = 'Y' ]; then
echo $line >> /tmp/extracted.log
echo "writed."
fi
done
@mazgi
mazgi / zusaar_users_to_csv.rb
Created August 14, 2012 04:57
https://gist.github.com/2787140 とほぼ一緒。あとで整理する
#!/usr/bin/env ruby
require 'pp'
require 'optparse'
require 'net/http'
require 'json'
Version=0.5
class User
attr_accessor :atnd_name, :is_regular
@mazgi
mazgi / get_dist.capistrano.rb
Created September 1, 2012 08:23
capでディストリビューション判別
distribution={}
task :get_dist do
run "test -f /etc/redhat-release && cat /etc/redhat-release || true" do |channel, stream, data|
if data
release = data.split ' '
distribution[:type] = release[0].to_sym
distribution[:version] = release[2].to_f
end
end
run "test -f /etc/debian_version && cat /etc/debian_version || true" do |channel, stream, data|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
static const long MiB = 1024 * 1024;
int
@mazgi
mazgi / Android.mk
Last active December 14, 2015 07:08
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SQLite3Driver4AndroidSDK
LOCAL_SRC_FILES := SQLite3Driver4AndroidSDK.cpp
LOCAL_SRC_FILES += ../../../ThirdParty/sqlite3/sqlite-amalgamation.current/sqlite3.c
LOCAL_SRC_FILES += ../../../common/SQLiteDriverCPP.cpp
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../ThirdParty/sqlite3/sqlite-amalgamation.current
@mazgi
mazgi / file0.txt
Created March 8, 2013 23:54
GNU ParallelでAndroid NDKの全バージョンを一括ダウンロード ref: http://qiita.com/items/b10bf0ff3da2045d19ab
[mazgi@Mac] $ parallel -j4 --eta curl -sLI {} \| head -1 \| grep -qi \'200 ok\' \&\& curl -LOR {} ::: http://dl.google.com/android/ndk/android-ndk-r{1..8}{"",{b-d}}-darwin-x86.tar.bz2
Computers / CPU cores / Max jobs to run
1:local / 8 / 4
Computer:jobs running/jobs completed/%of started jobs/Average seconds to complete
ETA % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 47.8M 100 47.8M 0 0 3057k 0 0:00:16 0:00:16 --:--:-- 2395k
ETA: 1 % Total % Received % Xferd Average Speed Time Time Time Current
@mazgi
mazgi / main.cpp
Created March 15, 2013 09:27
c++で型取得してみる
#include <iostream>
#include <cxxabi.h>
template<class T>
void func(const T& t)
{
int status;
std::cout << "["
<< t << "]["
<< typeid(t).name() << "]["
@mazgi
mazgi / Gemfile
Last active December 17, 2015 13:29 — forked from nebiros/Gemfile
for Rack app with unicorn
group :production do
gem "unicorn"
end
@mazgi
mazgi / config.ru
Last active December 17, 2015 14:39 — forked from tobert/config.ru
for gollum
$: << 'lib'
require 'rubygems'
require 'gollum'
require 'gollum/app'
use Rack::ShowExceptions
Precious::App.set(:gollum_path, Dir.pwd)
Precious::App.set(:wiki_options, {})
@mazgi
mazgi / nginx
Created May 22, 2013 09:20
nginx init script for debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon