Skip to content

Instantly share code, notes, and snippets.

@kanonji
kanonji / test.sh
Last active August 15, 2016 11:26
Test that command substitution invokes a subshell.
#!/bin/sh
echo "\$ echo \$(pwd)"
echo $(pwd) #Current directory not changed.
echo "\$ \$(cd ..)"
$(cd ..)
echo "\$ echo \$(pwd)"
echo $(pwd) #Current directory not changed.
@kanonji
kanonji / Publisher.cs
Created May 10, 2016 15:49
Get an event when tags edited on Tag Manager.
using UnityEditor;
using UnityEditorInternal;
namespace Kanonji.TagManagerEvent
{
public delegate void OnTagsChangedHandler(string[] tags);
public class Publisher
{
public static event OnTagsChangedHandler OnTagsChanged;
@kanonji
kanonji / ConstMapTrait.php
Created October 16, 2014 10:40
Const map trait
<?php
trait ConstMapTrait{
private static $const_map = [];
public static function const_map($prefix = 0){
if(! isset(self::$const_map[$prefix])){
if(0 === $prefix){
self::$const_map[$prefix] = (new \ReflectionClass(get_called_class()))->getConstants();
} else {
self::const_map();
$list = self::$const_map[0];
var tag_helpers = {
relative_path: function(basePath) { // I want basePath in this scope.
var pathDepth = basePath.split('/').length -2;
var path = new Array(pathDepth + 1).join('../');
return path;
}
};
module.exports = {
get: function(basePath, file_extension, options, callback){
@kanonji
kanonji / 20131002_mongo_aggregate_query_log.md
Last active December 24, 2015 11:29
mongo mongodb aggregate aggregation

Aggregation Frameworkのクエリーログをなんとかして得る方法

方法1(多分無理)

db.system.profile.find();

Profiling Levelsの設定次第ですが、スロークエリーがdb.system.profileに格納されているので、ここから探す。 ただ、明らかにスロークエリーなはずのaggregate()で発行したクエリーが、何故かここから見つけられなかったので、もしかしたらAggregation Frameworkのクエリーはここには入らないのかもしれない。

@kanonji
kanonji / 20130702_packages-for-build.md
Created July 2, 2013 14:57
python rubyなどをビルドする時に必要になるパッケージまとめたい。python rubyなどの公式ドキュメントでまとまってる情報源を見つけるのが理想。
bzip2: tar.bz2の展開に必要
gcc
make
libdb-dev: _bsddbモジュール(python3には無い)に必要
libreadline-dev: _curses、_curses_panel、readlineモジュールに必要
libsqlite3-dev: _sqlite3モジュールに必要
libssl-dev: _sslモジュールに必要(zlibモジュールに必要なzlib1g-devも依存関係でインストールされる)
tk-dev: _tkinterモジュールに必要
libbz2-dev: bz2モジュールに必要
@kanonji
kanonji / 20130702_mongo_memo.md
Last active June 23, 2018 13:22
最近mongodbを使っていてのメモ
@kanonji
kanonji / common_used_perl_module.pl
Last active December 18, 2015 00:19
良く使うPerlモジュール
use feature qw/say/;
use Encode;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); #http://memememomo.hatenablog.com/entry/20100422/1271894685
use XML::Simple;
use Tie::IxHash; #http://blog.dealforest.net/2009/09/xml-parse-in-order/
use Path::Class;
use HTML::TreeBuilder::XPath; #http://blog.64p.org/entry/20100607/1275878274
use HTML::Selector::XPath 'selector_to_xpath';
@kanonji
kanonji / .mpdconf
Last active December 17, 2015 22:19
mpd 0.16.3 on serversman
port "6600"
playlist_directory "~/.mpd/playlists"
music_directory "~/.mpd/music"
db_file "~/.mpd/mpd.db"
log_file "~/.mpd/mpd.log"
pid_file "~/.mpd/pid"
state_file "~/.mpd/state"
#bind_to_address "127.0.0.1" #does not work
bind_to_address "0.0.0.0"
#bind_to_address "any" #does not work
#!/usr/bin/perl
use strict;
use warnings;
use Archive::Zip;
use Encode;
if (@ARGV == 0) {
die "usage: $0 ZIPFILE\n";
}