Skip to content

Instantly share code, notes, and snippets.

@pinzolo
pinzolo / TwiceUnderscoreConverter.cs
Created September 7, 2012 10:17
アンダースコアをアンダースコア2つにエスケープするコンバータ
using System;
using System.Globalization;
using System.Windows.Data;
namespace MktSys.Gui.Converters
{
/// <summary>
/// アンダースコアを2つにしてエスケープするためのコンバータ
/// </summary>
/// <remarks>Label や MenuItem のアクセスキー対策</remarks>
@pinzolo
pinzolo / AddMagicComment.vim
Created September 19, 2012 23:09
保存時にマジックコメントがなければ挿入する.vimrc設定
" マジックコメント自動追加関数
function! AddMagicComment()
let pos = getpos('.')
let line_index = 1
let magic_comment = '# coding: utf-8'
if &filetype == 'ruby'
let line = getline(line_index)
if line[0:1] == '#!'
let line_index = 2
endif
@pinzolo
pinzolo / define_method_with_variable_arguments.rb
Created October 15, 2012 12:45
define_methodで可変長引数のメソッドを定義する
class Test
def self.method_missing(name, *args)
klass = class << self; self end
klass.class_eval do
define_method(name) do |*params|
p params
end
end
__send__(name, *args)
end
@pinzolo
pinzolo / alias_class_method_on_module_included.rb
Created October 29, 2012 03:15
include 時にクラスメソッドの alias を定義する
module Foo
def self.included(base)
class << base
alias_method :baz, :bar
end
end
end
class Bar
def self.bar
@pinzolo
pinzolo / define_method_with_arguments_having_default_value.rb
Created October 29, 2012 03:30
define_methodでデフォルト値のある引数を持つメソッドを定義する
class Test
def self.method_missing(name, *args)
klass = class << self; self end
klass.class_eval do
define_method(name) do |a = 1, b = 2|
puts "a: #{a}, b: #{b}"
end
end
if args.length > 1
__send__(name, args[0], args[1])
@pinzolo
pinzolo / DefaultForcusOnWindowShown.xaml
Last active December 18, 2015 08:29
[WPF]ウィンドウ表示時にデフォルトフォーカスを与える
<!-- Windowにて FocusManager.FocusedElement を設定する -->
<Window x:Class="MktSys.Gui.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Set default focus on Window shown" Height="525" Width="300"
FocusManager.FocusedElement="{Binding ElementName=TextBox}">
<Grid>
<TextBox Name="TextBox" HorizontalAlignment="Left" Height="25" Margin="0" TextWrapping="Wrap" VerticalAlignment="Top"/>
</Grid>
</Window>
@pinzolo
pinzolo / popup_and_disable.html
Created June 13, 2013 02:53
子画面を開き特定のボタンを非活性にする。子画面が閉じられたらボタンを活性化させる。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>親画面</title>
<style>
input {
width: 120px;
}
</style>
@pinzolo
pinzolo / pom.xml
Last active December 19, 2015 09:09
mvn package での生成物の名称を固定化する
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jp.mkt_sys.maven.tips</groupId>
<artifactId>some_app</artifactId>
<version>1.0.0</version>
<build>
<finalName>some_app</finalName>
<plugins>
<!-- some plugin settings -->
@pinzolo
pinzolo / pom.xml
Last active December 19, 2015 09:09
ソースの対象バージョンを固定化する
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jp.mkt_sys.maven.tips</groupId>
<artifactId>some_app</artifactId>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
@pinzolo
pinzolo / pom.xml
Last active December 19, 2015 09:09
java -jar にて実行可能な jar ファイルを作成するための pom.xml 設定
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jp.mkt_sys.maven.tips</groupId>
<artifactId>some_app</artifactId>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>