Skip to content

Instantly share code, notes, and snippets.

View vmi's full-sized avatar
😣
I may be slow to respond.

Motonori IWAMURO vmi

😣
I may be slow to respond.
View GitHub Profile
@vmi
vmi / test.rb
Created January 20, 2022 08:32
number format 3-digits with comma (ruby)
# https://stackoverflow.com/questions/6458990/how-to-format-a-number-1000-as-1-000
n = 1234567890
puts n.to_s.gsub(/(\d)(?=\d{3}+(?!\d))/, "\\1,")
@vmi
vmi / Main.java
Last active August 30, 2021 09:27
Script Engine Test
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class Main {
public static void main(String[] args) throws ScriptException {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
System.out.println(engine.toString());
# https://unix.stackexchange.com/a/31955
sed -i -e '$a\' file
@vmi
vmi / WriteCSV.rb
Last active September 10, 2019 03:20
Snippet of writing Excel CSV (ja) by Ruby.
#!/usr/bin/ruby
require 'csv'
BOM = "\u{FEFF}"
CSV.open(filename, "w", encoding: Encoding::UTF_8) do |csv|
csv << [ BOM + header1, header2, ... ]
csv << [ cell1_1, cell1_2, ... ]
end
@vmi
vmi / ReadCSV.rb
Last active September 10, 2019 04:16
Snippet of reading Excel CSV (ja) by Ruby.
#!/usr/bin/ruby
require 'csv'
### Anothor implementation:
# Encoding.default_internal = Encoding::UTF_8
# CSV.foreach(filename, encoding: Encoding::CP932) do |row| ...
CSV.foreach(filename, encoding: "CP932:UTF-8") do |row|
end
@vmi
vmi / bundle-install.sh
Last active August 9, 2017 01:06
bundle install
#!/bin/bash
ruby=$(which ruby)
shebang=""
if [ "$ruby" != "/usr/bin/ruby" ]; then
shebang="--shebang=$ruby"
fi
set -x
bundle install --binstubs=vendor/bin --path=vendor/bundle $shebang
@vmi
vmi / checkstyle.xml
Created June 8, 2017 10:10
How to configure aliasList of SuppressWarningsHolder in checkstyle.xml
<module name="SuppressWarningsHolder">
<property name="aliasList" value="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck=javadoc,com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck=javadoc,com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck=javadoc"/>
</module>
@vmi
vmi / open_new_mail.rb
Created September 15, 2016 08:30
Outlookメール作成覚え書き
require 'win32ole'
# 参考
# - Using Automation to Send a Microsoft Outlook Message
# https://support.microsoft.com/en-us/kb/161088
# - Office の開発 > Office クライアント > Outlook
# https://msdn.microsoft.com/ja-jp/library/office/fp161224.aspx
outlook = WIN32OLE.connect("Outlook.Application")
mail = outlook.CreateItem(0)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://localhost" />
<title>popup</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
package firefoxtest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverCommandProcessor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirefoxTest {