Skip to content

Instantly share code, notes, and snippets.

@fornext1119
fornext1119 / FizzBuzz.sql
Created April 3, 2012 03:47
SQL で FizzBuzz
with a as
(
select 0 as n from dual
union all
select 1 from dual
)
select
case
when mod(n, 3) = 0 and mod(n, 5) = 0 then 'FizzBuzz'
when mod(n, 3) = 0 then 'Fizz'
@fornext1119
fornext1119 / iTunes.vbs
Created April 3, 2012 04:36
VBScript で iTunes の曲一覧を取得する
Set iTunesApp = WScript.CreateObject("iTunes.Application")
For Each track In iTunesApp.LibraryPlaylist.Tracks
WScript.StdOut.Write track.Artist & ","
WScript.StdOut.Write track.Album & ","
WScript.StdOut.Write track.TrackNumber & ","
WScript.StdOut.Write track.Name & ","
WScript.StdOut.Write track.Composer & ","
WScript.StdOut.Write track.Duration & ","
WScript.StdOut.Write track.BitRate
WScript.StdOut.WriteLine
@fornext1119
fornext1119 / gist:2359458
Created April 11, 2012 13:56
Ruby で Excel のシート名一覧を出力
require 'win32ole'
excelApp = WIN32OLE.new('Excel.Application')
excelApp.Visible = 1
excelApp.DisplayAlerts = 0 #警告メッセージをOFF
#ブックを読み取り専用で開く
book = excelApp.WorkBooks.Open(ARGV[0], false, true)
book.WorkSheets.each do |sheet|
puts(sheet.Name)
@fornext1119
fornext1119 / gist:2359464
Created April 11, 2012 13:58
Java で Excel のシート名一覧を出力
import com.jacob.com.*;
import com.jacob.activeX.*;
public class Lesson001
{
public static void main(String[] args) {
ActiveXComponent excelApp = new ActiveXComponent("Excel.Application");
try {
excelApp.setProperty("Visible", new Variant(true));
excelApp.setProperty("DisplayAlerts", new Variant(false)); //警告メッセージをOFF
@fornext1119
fornext1119 / gist:2359417
Created April 11, 2012 13:50
VBScript で Excel のシート名一覧を出力
Dim excelApp: Set excelApp = CreateObject("Excel.Application")
excelApp.Visible = True
excelApp.DisplayAlerts = False '警告メッセージをOFF
'ブックを読み取り専用で開く
Dim book: Set book = excelApp.Workbooks.Open(WScript.Arguments(0), False, True)
For Each sheet In book.Sheets
WScript.Echo sheet.Name
Next
@fornext1119
fornext1119 / gist:2359426
Created April 11, 2012 13:52
JScript で Excel のシート名一覧を出力
var excelApp = WScript.CreateObject("Excel.Application");
excelApp.Visible = true;
excelApp.DisplayAlerts = false; //警告メッセージをOFF
//ブックを読み取り専用で開く
var book = excelApp.Workbooks.Open(WScript.Arguments(0), false, true);
for (var i=1;i<=book.Sheets.Count;i++)
{
WScript.Echo(book.Sheets(i).Name);
@fornext1119
fornext1119 / gist:2359439
Created April 11, 2012 13:53
Perl で Excel のシート名一覧を出力
use Win32::OLE;
Win32::OLE::CreateObject("Excel.Application", $excelApp); # || die; # "fail! : $!";
$excelApp->{Visible} = 1;
$excelApp->{DisplayAlerts} = 0; #警告メッセージをOFF
#ブックを読み取り専用で開く
$book = $excelApp->WorkBooks->Open($ARGV[0], 0, 1);
foreach $i (1..$book->WorkSheets->Count)
@fornext1119
fornext1119 / gist:2359444
Created April 11, 2012 13:54
PHP で Excel のシート名一覧を出力
<?php
// EXCELのインスタンス作成
$excelApp = new COM("Excel.Application"); # or die;
$excelApp->Visible = 1;
$excelApp->DisplayAlerts = 0; #警告メッセージをOFF
#ブックを読み取り専用で開く
$book = $excelApp->Workbooks->Open($argv[1], false, true);
foreach ($book->Worksheets as $sheet)
@fornext1119
fornext1119 / gist:2359460
Created April 11, 2012 13:57
C# で Excel のシート名一覧を出力
using System.Runtime.InteropServices;
using System.Reflection;
class Program
{
static void Main(string[] args)
{
//Excelファイルパス
try
{
// Excel操作用COMオブジェクトを生成する
@fornext1119
fornext1119 / gist:2866620
Created June 4, 2012 06:07
WindowsPowerShellでSQLを実行し結果をコンソール出力
[System.Reflection.Assembly]::LoadWithPartialName("System.Data")
$cs = "Provider=MSDAORA;User ID=xxxxx;Password=yyyyy;Data Source=zzzzz"
$oraCon = New-Object System.Data.OleDb.OleDbConnection($cs)
$oraCmd = New-Object System.Data.OleDb.OleDbCommand
$oraCon.Open()
$oraCmd.Connection = $oraCon
$oraCmd.CommandText = "SELECT * FROM wwwwww"
$oraReader = $oraCmd.ExecuteReader()
while ($oraReader.Read())
{