Skip to content

Instantly share code, notes, and snippets.

View todesking's full-sized avatar
💀

todesking todesking

💀
View GitHub Profile
@todesking
todesking / syn_region.vim
Last active September 27, 2020 09:22
syntax-region's odd behavior
syntax clear
syntax match expr_name /\K\k*/ nextgroup=B
syntax region outer
\ start=/(/ end=/)/
\ contains=inner
syntax region inner
\ start=/(/ end=/)/
@todesking
todesking / xor.cpp
Created August 31, 2019 09:08
given M and N, calc M xor M+1 xor ... xor N
// vim: shiftwidth=2 expandtab foldmethod=marker
// include {{{
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <map>
#include <queue>
@todesking
todesking / bash.patch
Created September 25, 2014 15:03
This patch introduces very cool feature and no more vulnerability!!!
diff --git a/variables.c b/variables.c
index 92a5a10..b485dab 100644
--- a/variables.c
+++ b/variables.c
@@ -347,39 +347,6 @@ initialize_shell_variables (env, privmode)
temp_var = (SHELL_VAR *)NULL;
- /* If exported function, define it now. Don't import functions from
- the environment in privileged mode. */
function jvm() {
local cmd="$1"
local java_root="/Library/Java/JavaVirtualMachines/"
case "$cmd" in
list )
find "$java_root" -maxdepth 1 | grep 'jdk.*\.jdk' | gsed 's/.*jdk\(.*\)\.jdk$/\1/' ;;
use )
local version="$2"
local home="$java_root/jdk${version}.jdk/Contents/Home/"
if [ -d "$home" ]; then
@todesking
todesking / application_helper.rb
Created February 27, 2014 17:20
Write Rails helper method with any template engine
module ApplicationHelper
def self.define_with_template(helper_name, template_type, template, locals = [])
compiled = Tilt[template_type].new(nil) { template }
define_method(helper_name) do|*args, &block|
compiled.render(self, Hash[*locals.zip(args).flatten], &block).html_safe
end
end
define_with_template :render_user_name, :slim, <<-SLIM, [:user_name]
.user
@todesking
todesking / tss.rb
Created June 23, 2013 08:16
rspec itss
def itss(name, &block)
describe name do
it { subject.instance_eval(name).instance_eval(&block) }
end
end
describe A do
subject { A.new }
itss('name.length') { should == 4 }
end

入門Puppet感想

2012-05-09 達人出版会版

具体例はあっても仕組みやそうする理由の説明に乏しく、わかりにくかった。

manifest

具体的に裏で何が起こっているかに対する説明がないため、システムにmanifestを適用したとき何が起こるのかわからなくてこわい。 manifestに定義されてるリソースを列挙→依存関係でソート→順番に適用、だと想像しているが。

@todesking
todesking / active_sti.rb
Created February 1, 2013 11:22
Customizable STI rule for ActiveRecord
# usage:
# class User < AR::Base
# extend ActiveSTI
# define_sti_rule do|record|
# if record['parent']
# ChildUser
# else
# RootUser
# end
# end
@todesking
todesking / .bash_profile
Created January 25, 2013 13:45
my .bash_profile
[ -s ~/.rvm/scripts/rvm ] && source ~/.rvm/scripts/rvm
source ~/scripts/vendor/git-completion/git-completion.bash
source ~/scripts/vendor/git-completion/git-prompt.sh
if [ "Darwin" = "$(uname)" ]; then
alias sed=gsed
export EDITOR=vim
fi
@todesking
todesking / cap_task_server_list.rb
Created January 10, 2013 10:54
cap、定義されてるサーバ一覧表示するタスク
task :server_list do
roles.each do|name, role|
role.each do|server|
puts "%10s %13s %s" % [name, server, server.options.inspect]
end
end
end