Skip to content

Instantly share code, notes, and snippets.

@tarao
tarao / smart_ptr.hpp
Created July 24, 2010 12:54
An easy implementation of smart pointer
#ifndef GNN_PORT_SMART_PTR_HPP_INCLUDED
#define GNN_PORT_SMART_PTR_HPP_INCLUDED
/**
An easy implementation of "smart pointer"
The idea is just like shared_ptr in Boost C++ Library: it has a reference
counter indicating when to delete the raw pointer.
This file is a part of gnn C++ Library by L.INA.
@tarao
tarao / lambda.cpp
Created November 1, 2011 07:47
Lambda calculus with type inference in C++ template
namespace lambda {
////////////////////////////////////////////////
// Lambda term
namespace term {
template<char c> struct var {};
template<typename N, typename M> struct app {};
template<char v, typename M> struct abs {};
@tarao
tarao / auth-command.sh
Created November 19, 2012 01:40
auth-command - a tool for SSH authorized commands
#!/bin/sh -e
base=`basename "$0"`
auth_options=',no-port-forwarding,no-agent-forwarding'
lf='
'
duser=`id -run`
dport=22
dconfig_dir_rel=".ssh/$base/config"
@tarao
tarao / install-automount.sh
Last active October 13, 2015 08:27
sshfs wrapper
#!/bin/sh -e
sshmount_url='https://raw.github.com/gist/4167564/sshmount.sh'
sshumount_url='https://raw.github.com/gist/4167564/sshumount.sh'
sshmount='sshmount'
sshumount='sshumount'
bin="$HOME/bin"
verbose=0
error() {
@tarao
tarao / qemu.sh
Created November 29, 2012 13:42
Register start hook to libvirt
#!/bin/sh -e
# /etc/libvirt/hooks/qemu
guest="$1"
action="$2"
try=60
wait=1
lf='
'
app='virt-start-hook'
@tarao
tarao / notify-send.rb
Created November 29, 2012 15:23
Configure virtualized guest environment on laptop
#!/usr/bin/env ruby
require 'optparse'
require 'rubygems'
require 'dbus'
class Notification
BUS = 'org.freedesktop.Notifications'
SERVICE = '/org/freedesktop/Notifications'
INTERFACE = BUS
#!/usr/bin/env python
import sys
if len(sys.argv) > 1 and sys.argv[1] in ['on', 'off']:
import ibus
bus = ibus.Bus()
ic = ibus.InputContext(bus, bus.current_input_contxt())
getattr(ic, sys.argv[1].replace('on','en').replace('off','dis')+'able')()
else:
@tarao
tarao / trayapp.rb
Created December 8, 2012 15:06
trayapp - show tray icon with running something
#!/usr/bin/env ruby
require 'yaml'
require 'optparse'
require 'shellwords'
require 'logger'
require 'gtk2'
module Loggable
class Logger
def initialize(klass, *args)
@tarao
tarao / init-loader.el
Last active December 10, 2015 01:48 — forked from zqwell/init-loader.el
init-loader.el 修正版(elc優先読込み、load-path問題修正、windows/linux設定ファイル読込みPrefix追加、自動バイトコンパイル)
;;; -*- coding: utf-8; mode: emacs-lisp; -*-
;;; init-loader.el ---
;; Author: IMAKADO <ken.imakado@gmail.com>
;; Author's blog: http://d.hatena.ne.jp/IMAKADO (japanese)
;; Prefix: init-loader-
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)