トップ «前の日記(2013-10-28) 最新 次の日記(2013-10-30)» 編集

ヨタの日々

2001|08|09|10|11|12|
2002|01|02|03|04|05|06|07|08|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|12|
2024|01|02|03|

2013-10-29 :-(

_ 午前

0530 起床

0600 朝飯ったけどぐったりしてきたので仕事休みの連絡した

0620 寝る

_ 午後

1200 おひる。作っておいた弁当です

1400 寝る

_

1700 アニメ消化など

2100 飯。牛丼など

_ [艦これ]艦これ

大井さん改造

電ちゃん改造

3-2 に挑戦してみる。

ダメでした。道中で渦潮に巻き込まれたので戦闘せずに済んだのはよかったけど、ボス前ですらこの有り様。陣形は単横陣。やはり火力をカンストさせるくらいに改修しないとダメか。

腹いせに 4-1 行ったら普通にクリアできた。道中の潜水艦はろくにダメージ与えられなかったけど戦術的勝利なので問題なし。

_ [ruby]ASCII で書かれたファイルをバイナリへ変換して書き出す

# coding: utf-8

def conv(in_file_path, out_file_path)
  text = File.open(in_file_path).read()
  sp = text.split
  d = sp.map{|h| h.hex}
  File.open(out_file_path, "wb").write(d.pack("C*"))
end

def main(argv)
  in_file_path = argv[0]
  out_file_path = argv[1]
  conv(in_file_path, out_file_path)
end

main(ARGV)

こういうファイル

01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f

ruby は楽なんだけどな

_ [C]ASCII で書かれたファイルをバイナリへ変換して書き出す(C)

面倒くさすぎる

#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>

enum ST_ANALYZE
{
  ST_ANALYZE_HIGH,
  ST_ANALYZE_LOW,
  ST_ANALYZE_DELIM,
};

char hex(char c)
{
  char h = 0;

  if('0' <= c && c <= '9')
  {
    h = c - '0';
  }
  else if('a' <= c && c <= 'f')
  {
    h = (c - 'a') + 10;
  }
  else if('A' <= c && c <= 'F')
  {
    h = (c - 'A') + 10;
  }
  return h;
}

void conv(char* in_file_path, char* out_file_path)
{
  struct stat st;
  int result;
  int in_file_size;
  char* in_file_buf = NULL;
  char* out_file_buf = NULL;
  FILE* in_fp = NULL;
  FILE* out_fp = NULL;
  int read_bytes;
  int write_bytes;
  char hi;
  char lo;
  int i;
  int in_pos;
  int out_pos;
  int analy_st;

  result = stat(in_file_path, &st);
  if(result != 0)
  {
    perror("stat");
    goto ERROR;
  }

  in_file_size = st.st_size;

  in_file_buf = (char*)malloc(in_file_size);
  if(in_file_buf == NULL)
  {
    perror("malloc");
    goto ERROR;
  }

  out_file_buf = (char*)malloc(in_file_size);
  if(out_file_buf == NULL)
  {
    perror("malloc");
    goto ERROR;
  }

  in_fp = fopen(in_file_path, "rb");
  if(in_fp == NULL)
  {
    perror("fopen");
    goto ERROR;
  }

  read_bytes = fread(in_file_buf, 1, in_file_size, in_fp);
  if(read_bytes != in_file_size)
  {
    perror("fread");
    goto ERROR;
  }

  analy_st = ST_ANALYZE_HIGH;

  for(out_pos = 0, in_pos = 0; in_pos < in_file_size; in_pos++)
  {
    char c = in_file_buf[in_pos];

    switch(analy_st)
    {
    case ST_ANALYZE_HIGH:
      hi = hex(c);
      analy_st = ST_ANALYZE_LOW;
      break;
    case ST_ANALYZE_LOW:
      lo = hex(c);
      out_file_buf[out_pos] = (hi << 4) + lo;
      out_pos++;
      analy_st = ST_ANALYZE_DELIM;
      break;
    case ST_ANALYZE_DELIM:
      if(c == ' ' || c == '\n')
      {
        analy_st = ST_ANALYZE_HIGH;
      }
      break;
    default:
      break;
    }

  }

  out_fp = fopen(out_file_path, "wb");
  if(out_fp == NULL)
  {
    perror("fopen");
    goto ERROR;
  }

  write_bytes = fwrite(out_file_buf, 1, out_pos, out_fp);
  if(write_bytes != out_pos)
  {
    perror("fread");
    goto ERROR;
  }

ERROR:
  if(in_file_buf != NULL)
  {
    free(in_file_buf);
  }

  if(out_file_buf != NULL)
  {
    free(out_file_buf);
  }

  if(in_fp != NULL)
  {
    fclose(in_fp);
  }

  if(out_fp != NULL)
  {
    fclose(out_fp);
  }
}


int main(int ac, char** av)
{
  char* in_file_path;
  char* out_file_path;

  in_file_path = "asc2bin.txt";
  out_file_path = "asc2bin.bin";

  conv(in_file_path, out_file_path);  

  return 0;
}