Skip to content

Instantly share code, notes, and snippets.

@toagit
toagit / findString.bat
Created June 16, 2015 04:00
変数内の文字列を検索するコマンドのサンプル
echo off
set hoge="aaatestxxx"
@echo %hoge% | find "test" > NUL
echo %errorlevel%
if errorlevel 1 (
echo error!!
) else (
echo OK!
)
@toagit
toagit / DelayedExpansion.bat
Created June 16, 2015 05:12
遅延環境変数使用可能オプション
rem 遅延環境変数使用可能オプション
@setlocal EnableDelayedExpansion
rem 変数
set hoge=xxx
echo !hoge!
@toagit
toagit / searchFile.bat
Created June 18, 2015 03:44
任意のファイルを探すコマンド
set KEYWORD="hoge"
for /R %USERPROFILE%\Documents %%f in (*%KEYWORD%*.txt) do (
echo %%f
)
@toagit
toagit / GetSysout.java
Last active August 29, 2015 14:24
標準出力の取得
PrintStream source = System.out;
ByteArrayOutputStream out = new ByteArrayOutputStream();
System.setOut(new PrintStream(out));
// version < java7
assertEquals("expect" + System.getProperty("line.separator"),out.toString());
// version >= java7
assertEquals("expect" + System.lineSeparator,out.toString());
@toagit
toagit / xlsFileMarge.vbs
Last active August 29, 2022 09:54
複数のExcelファイルを1ファイルにまとめるVBScript
Option Explicit
Const msoFileDialogFolderPicker = 4
Const EXTENSION = ".xlsx"
Call MargeSheet
'Excelファイルマージ
Sub MargeSheet()
Dim scriptPath
@toagit
toagit / CreateFolder.vbs
Last active December 15, 2015 01:21
階層フォルダを作成するVBスクリプト
Option Explicit
CreateFolder
Private Sub CreateFolder()
Dim path
' path = "C:\CreTest\a\b\c"
path = InputBox("作成するフォルダを入力してください。",,Replace(WScript.ScriptFullName,WScript.ScriptName,""))
Dim objExcel
@toagit
toagit / ActivateA1.vbs
Last active December 22, 2020 20:01
指定したファイルの全てのシートについてA1セルをActiveにするスクリプト
Option Explicit
'/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
'指定したエクセルファイルの全てのシートのセルをA1セルへ移動するスクリプト
'エクセルの指定はダイアログ、D&Dをサポート
'/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Call ActivateA1
Private Sub ActivateA1()
@toagit
toagit / SampleMain.java
Created July 9, 2015 03:52
javaの実行可能クラスの雛形。CLIからの呼び出し用。
/**
* 実行可能クラス雛形
*/
public class SampleMain() {
private boolean readyToRun = false;
private String sampleValue = "";
/**
* コンストラクタ
@toagit
toagit / AbstractMainTester.java
Last active April 3, 2017 09:35
mainメソッドのJUnitサンプル。System.Exitのコードの確認。標準出力(System.out、System.Err)の取得。
/**
* mainメソッド実装クラスをテストする基底クラス。
*/
public abstract class AbstractMainTester {
private static final String ARGS_DELIMITER = " ";
protected static final String LINE_SEPARATOR = System.getProperty("line.separator");
private static final PrintStream stdOut = System.out;
private static final PrintStream stdErr = System.err;
private static final SecurityManager securityManager = System.getSecurityManager();
@toagit
toagit / build.xml
Last active October 4, 2016 12:24
ant build sample. contain javac, javadoc, zip.
<?xml version="1.0" encoding="Windows-31J"?>
<project name="builSample" default="main" basedir=".">
<property name="path.lib" location="./lib"/>
<property name="path.out" location="./dest"/>
<property name="path.bin" location="${path.out}/bin"/>
<property name="path.src" location="./src"/>
<property name="path.test" location="./srctest"/>
<property name="path.doc" location="${path.out}/javadoc"/>
<property name="compiler" value="JAVA_HOME\bin\javac"/>