Skip to content

Instantly share code, notes, and snippets.

View masaru-b-cl's full-sized avatar

TAKANO Sho / @masaru_b_cl masaru-b-cl

View GitHub Profile
@masaru-b-cl
masaru-b-cl / git-now
Last active January 24, 2024 02:22 — forked from mzp/git-now
#!/bin/sh
PREFIX="from now"
MESSAGE="[${PREFIX}] `date +\"%Y/%m/%d %T\"`"
MAIN_BRANCH=${1:-master} # デフォルトは 'master'、第1引数で上書き可能
shift # 引数リストからメインブランチ名を除外
get_amend() {
if [ -z `git log --pretty=oneline --no-color -1 | cut -d " " -f 2- | grep "^\[${PREFIX}]"` ]
@masaru-b-cl
masaru-b-cl / substringByShiftJISBytesCount.java
Created January 25, 2013 00:40
文字列をShiftJISとして扱って先頭から指定したバイト数分切り出す。最後の文字がマルチバイト文字だった場合、切り落とす。
protected String substringByShiftJISBytesCount(String source, int bytesCount)
throws UnsupportedEncodingException {
if (source == null) return source;
byte[] bytes = source.getBytes("MS932");
if (bytes.length < bytesCount) return source;
String result = new String(bytes, 0, bytesCount, "MS932");
String last = result.substring(result.length() -1);
String lazt = new String(last.getBytes("MS932"), "MS932");
if (!last.equals(lazt)) {
result = result.substring(0, result.length()-1);

Original blog entry is The Pragmatics of TDD

#The Pragmatics of TDD

#TDDの実例

So my last blog: The Startup Trap raised quite a ruckus. Amidst the various shouts of agreement and support, there was also a group who vehemently disagreed. I'm not going to summarize all their disagreements here, since I've already used up my quota of curse words for the month. But one of those disagreements struck me as something I should address.

前回のblog「スタートアップの罠」は物議を醸した。様々な同意や補助といった叫び声のど真ん中に、激しく異議を唱えるグループがいた。その意見をまとめることはしないけど、思いつく限りの汚い言葉を全部使いきっちゃったよ。でも、言及する価値があると思われる、とても面白い意見がひとつあった。

:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 25 2018 03:02:16)
macOS version
適用済パッチ: 1-1633
Compiled by travis@Traviss-Mac-913.local
Huge 版 with MacVim GUI. 機能の一覧 有効(+)/無効(-)
+acl +cmdline_info +extra_search +jumplist +mouse +odbeditor +signs +timers -X11
+arabic +comments +farsi +kaoriya +mouseshape +packages +smartindent +title -xfontset
+autocmd +conceal +file_in_path +keymap +mouse_dec +path_extra +startuptime +toolbar +xim
-autoservername +cryptv +find_in_path +lambda -mouse_gpm +perl/dyn +statusline +transparency -xpm
@masaru-b-cl
masaru-b-cl / pgco-alias.sh
Created May 22, 2019 08:25
pecoを使ってgit checkoutするやつ
alias pgco='git branch -a --sort=-authordate | cut -b 3- | perl -pe '\''s#^remotes/origin/###'\'' | perl -nlE '\''say if !$c{$_}++'\'' | grep -v -- "->" | peco | xargs git checkout'
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, serif;
background-color: white;
color: #24292e;
}
table {
width: auto;
border-collapse: collapse;
border-spacing: 0;
border-width: 1px;
@masaru-b-cl
masaru-b-cl / pvim.bat
Created April 3, 2018 05:52
pvim (ルートディレクトリ) で指定したディレクトリ配下のファイルをpecoで絞り込んでgvimで開くbatファイル
@echo off
set ROOT_DIR=.
if "%1" neq "" (
set ROOT_DIR=%1
if "%1" equ "~" (
set ROOT_DIR=%USERPROFILE%
)
)
@masaru-b-cl
masaru-b-cl / file0.txt
Last active August 31, 2017 07:26
Visual Studio Codeタスクのdotnetコマンド出力を文字化けしないようにする ref: http://qiita.com/masaru_b_cl/items/705b75d256b11cb82feb
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"windows": { // Windows固有の設定
"command": "cmd", // cmd.exeを実行
"args": [ "/C", "chcp 65001 && dotnet"] // /Cオプションで第二引数のコマンドを実行
}, // chcp 65001 の後に && で続けてdotnetを実行するよう指定
"tasks": [
<Query Kind="Statements" />
File.ReadAllLines(@"path\to\ppap.txt")
.Select(line => line.Length)
.ToList()
.ForEach(Console.WriteLine);
@masaru-b-cl
masaru-b-cl / type-swich-in-range.cs
Last active February 20, 2017 07:44
値の範囲で型スイッチによる分岐 in C#
int a = ...;
switch (a)
{
case int _ when a < 10: return "low";
case int _ when 90 < a: return "high";
default: return "middle";
}