27th
ダンボー
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
namespace Dgst
{
class Program
{
static int Main(string[] args)
{
// parse arguments
var format = "hex";
var algorithm = "SHA256";
var files = new List<string>();
foreach (var arg in args)
if (arg.StartsWith("-") && (arg != "-"))
switch (arg)
{
case "-hex":
case "-binary":
format = arg.Substring(1);
break;
case "-sha1":
case "-sha256":
case "-sha384":
case "-sha512":
case "-ripemd160":
algorithm = arg.Substring(1).ToUpper();
break;
default:
Console.Error.WriteLine("unknown option '{0}'", arg);
ShowHelp();
return 1;
}
else
files.Add(arg);
// start processing
var exitCode = 0;
var hasher = GetHasher(algorithm);
Debug.Assert(hasher != null, "unexpected algorithm");
// digest stdin
if (files.Count < 1)
{
var hash = hasher.ComputeHash(Console.OpenStandardInput());
if (format == "binary")
using (var w = new BinaryWriter(Console.OpenStandardOutput()))
w.Write(hash);
else
{
foreach (var b in hash)
Console.Write(b.ToString("x2"));
Console.WriteLine();
}
}
// digest files
foreach (var path in files)
{
byte[] hash = null;
// input part
try
{
using (var f = File.OpenRead(path))
hash = hasher.ComputeHash(f);
}
catch (FileNotFoundException)
{
exitCode++;
Console.Error.WriteLine("{0}: no such file or directory", path);
}
catch (Exception e)
{
exitCode++;
Console.Error.WriteLine("{0}: {1}", path, e.Message);
}
if (hash == null)
break;
// output part
if (format == "binary")
using (var w = new BinaryWriter(Console.OpenStandardOutput()))
w.Write(hash);
else
{
Console.Write("{0}({1})= ", algorithm, path);
foreach (var b in hash)
Console.Write(b.ToString("x2"));
Console.WriteLine();
}
}
return exitCode;
}
static HashAlgorithm GetHasher(string name)
{
switch (name.ToUpper())
{
case "SHA1":
return new SHA1Managed();
case "SHA256":
return new SHA256Managed();
case "SHA384":
return new SHA384Managed();
case "SHA512":
return new SHA512Managed();
case "RIPEMD160":
return new RIPEMD160Managed();
default:
return null;
}
}
static void ShowHelp()
{
Console.Error.WriteLine("Usage: dgst [OPTION]... FILE...");
Console.Error.WriteLine();
Console.Error.WriteLine("options are");
Console.Error.WriteLine("-hex output as hex dump (default)");
Console.Error.WriteLine("-binary output in binary form");
Console.Error.WriteLine("-sha1 to use the sha1 message digest algorithm");
Console.Error.WriteLine("-sha256 to use the sha256 message digest algorithm (default)");
Console.Error.WriteLine("-sha384 to use the sha384 message digest algorithm");
Console.Error.WriteLine("-sha512 to use the sha512 message digest algorithm");
Console.Error.WriteLine("-ripemd160 to use the ripemd160 message digest algorithm");
}
}
}
#!/bin/sh # install and set up Finance::Quote::YahooJapan in the standard Ubuntu environment sudo aptitude install libssl-dev perl-doc cpan -i Finance::Quote cd $(dirname $(perldoc -l Finance::Quote))/Quote sudo wget 'http://github.com/LiosK/Finance--Quote--YahooJapan/raw/master/lib/Finance/Quote/YahooJapan.pm' sudo vim -c ':/Default modules/|echo "add YahooJapan to the default module list"' ../Quote.pm
draw.cvp <- function(units, margins,
names = NULL, fixed.costs = NULL) {
if (length(units) < 1) { return(NULL) }
x.lab <- cumsum(c(0, units))
library(grid)
grid.newpage()
vp <- viewport(width=0.8, height=0.8,
xscale=c(0, sum(units)), yscale=c(0, max(margins)))
pushViewport(vp)
grid.xaxis(x.lab)
grid.yaxis()
grid.rect(x=head(x.lab, -1), y=0, width=units, height=margins,
just=c("left", "bottom"), default.units="native",
gp=gpar(fill=rainbow(length(units))))
if (!is.null(names)) {
grid.text(names, x=unit(head(x.lab, -1) + units / 2, "native"),
y=unit(margins, "native") + unit(1, "char"))
}
if (!is.null(fixed.costs)) {
gp <- gpar(lwd=3)
grid.move.to(x=x.lab[1], y=fixed.costs[1], default.units="native")
for (i in 1:length(units)) {
grid.line.to(x=x.lab[i],
y=fixed.costs[i], default.units="native", gp=gp)
grid.line.to(x=x.lab[i + 1],
y=fixed.costs[i], default.units="native", gp=gp)
}
}
popViewport()
return(vp)
}
dat <- read.csv("data.csv")
draw.cvp(dat$units, dat$margin, dat$product, dat$fixed)
get.quotes <- function(symbol) {
url <- paste("http://k-db.com/site/jikeiretsu.aspx?download=csv&c=", symbol, sep="")
read.csv(url, skip=1)
};
!Account
N資産:流動資産:現金
^
!Type:Cash
D03/15/2010
Mてんぷらそば
L費用:食費
T-800
^
!Type:Cash
D03/15/2010
Mラーメン
S費用:食費
Eラーメン
$-600
S費用:食費
E餃子
$-300
S費用:食費
E割引
$100
^
!Account
N負債:クレジットカード
^
!Type:Cash
D03/15/2010
MAmazon.co.jp
L費用:コンピュータ
T-7500
^
!Type:Cash
D03/15/2010
MAmazon.co.jp
L費用:書籍
T-1500
^
!Account
N収益:給与
^
!Type:Cash
D03/10/2010
M給与振込
L資産:流動資産:普通預金
T-200000
^
!Account
N費用:医療費
^
!Type:Cash
D03/20/2010
M通院
L資産:流動資産:現金
T2000
^
root = Left(WScript.ScriptFullName, 3)
Set sh = CreateObject("WScript.Shell")
sh.Environment("Process")("HOME") = root & "home"
cmd = root & "apps\Vim\gvim.exe"
For Each arg In WScript.Arguments
cmd = cmd & " """ & arg & """"
Next
sh.Run cmd
root = Left(WScript.ScriptFullName, 3)
cmd = root & "apps\KeePass\KeePass.exe " & root & "home\KeePass.kdbx"
If WScript.Arguments.Count > 0 Then
cmd = cmd & " -preselect:""" & WScript.Arguments(0) & """"
End If
CreateObject("WScript.Shell").Run cmd
Transaction
- date
- ctime
- mtime
- history
- user (and any instances of Category)
- effects (list of Effect)
- commodity
Effect
- account (and any instances of Category)
- value (value evaluated in the transaction’s commodity) stub
- quantity (number or amount in the effect’s commodity) stub
- commodity
Category
- parent
Account extends Category
User extends Category
Center extends Category