Skip to content

Instantly share code, notes, and snippets.

View taisyo7333's full-sized avatar

Daisuke Inoue taisyo7333

View GitHub Profile
@taisyo7333
taisyo7333 / Code3-161.rb
Last active January 24, 2016 09:31
Ruby Exception object
# encoding: SJIS
begin
1/0
rescue ZeroDivisionError => e
p e.backtrace
end
@taisyo7333
taisyo7333 / Code3-159.rb
Created January 24, 2016 09:20
Ruby Exception sample
# encoding: SJIS
1/0 rescue p 1
@taisyo7333
taisyo7333 / Code3-158.rb
Created January 24, 2016 09:18
Ruby Exception
# encoding: SJIS
begin # run
p 1
rescue # Do not run , because of no-execption occurs.
p 0
else # run , because of no-execption occurs.
p 2
ensure # run always at last.
p 3
@taisyo7333
taisyo7333 / Code3-160.rb
Last active January 24, 2016 09:16
Ruby Exception rescue
# encoding: SJIS
def foo
-1 / 0
rescue
p 1
end
foo
# => 1
@taisyo7333
taisyo7333 / output.log
Created November 8, 2015 12:35
半角空白で区切られた単語を単語ごとに分割して配列に格納する方法。(再帰版)
This
is
a
pen
@taisyo7333
taisyo7333 / ParseInt.cs
Created November 7, 2015 01:24
[C#] 整数で構成される文字列をint型に変換する.(Parseを使用せずにLINQを使用してみる)
using System;
using System.Linq;
namespace ParseInt
{
class Program
{
static void Main(string[] args)
{
// Success
@taisyo7333
taisyo7333 / Get-FolderHierarchy.ps1
Created September 10, 2015 15:26
Powershell Recursive
<#
.SYNOPSIS
.DESCRIPTION
.PARAMETER base_path
.PARAMETER max_depth
.PARAMETER depth
.EXAMPLE
Get-FolderHierarchy "C:\Windows"
.EXAMPLE
@taisyo7333
taisyo7333 / Call_XmlValid.cs
Created September 4, 2015 12:34
C# XML Schema 検証
public bool XmlValidTest( string path_xml , string path_schema )
{
using (XmlTester tester = new XmlTester())
{
if( tester.Test(path_schema, path_xml) )
{
return true;
}
}
return false;
@taisyo7333
taisyo7333 / LinqToXml.cs
Last active September 2, 2015 08:39
Get a value of attribute by C# LINQ to XML .
XElement po = XElement.Load(path_xml);
// <Substrates>
// <Substrate SubstrateType = "Strip" SubstrateId = "@@@">
var elems = po.Elements().Descendants()
.Where(node => node.Name.LocalName == "Substrate"
&& (string)node.Attribute("SubstrateType") == "Strip"
&& node.Attribute("SubstrateId") != null
)
.Select(elem => elem.Attribute("SubstrateId").Value);
@taisyo7333
taisyo7333 / Wrote-ErrorLog.ps1
Created August 28, 2015 03:50
powershell : tee error
function Write-ErrorLog {
param( $file_name , $message )
Write-Error $message 2>&1 | Tee-Object -FilePath $file_name -Append
}