Skip to content

Instantly share code, notes, and snippets.

@kanonji
kanonji / 20130702_mongo_memo.md
Last active June 23, 2018 13:22
最近mongodbを使っていてのメモ
@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 / 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のクエリーはここには入らないのかもしれない。

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 / 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];
@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 / 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 / callee.sh
Last active August 15, 2016 11:52
Test to share variables within two script.
#!/bin/sh
echo " #${0} begin"
echo " echo \$WORKING_DIR"
echo " ${WORKING_DIR}"
echo " #${0} end"
@kanonji
kanonji / .gitignore
Last active February 20, 2017 01:18
Destroying session with session_regenerate_id(true)
/session
<?php
class SimpleDelegate {
protected $callbacks = [];
public function add(Closure $callback, $key = null){
$key = $key?: spl_object_hash($callback);
$this->callbacks[$key] = $callback;
}