カテゴリー : システム

10分でコーディング、をコードゴルフで。

以前やったFizzBuzzが再燃したので、

10分でコーディング|プログラミングに自信があるやつこい!!

をjavaでやってみた。ただ、元ネタ自体がだいぶ古い話題で、こんな感じであちこちに派生してて

10分でコーディング|プログラミングに自信があるやつこい!! だって。|ゲンゾウ用ポストイット
[どうでもよいこと]10分コーディング | Ryuzee.com

いまさら10分で書いてもおもしろくないので、いかに少ない文字数でコードを書くか、いわゆるコードゴルフです。
# javaが久々すぎて10分で書けなかったのは内緒。

public class Cards
{
  public static void main(String[] args)
  {
    String[] deals = Cards.deal(5,"123456");

    for (int i = 0; i < deals.length; i++)
    {
      System.out.println("["+i+"] = [" + deals[i]+"]");
    }
  }
  private static String[] deal(int p, String d)
  {
    String[] c=new String[p];int i,k=d.length();for(i=0;i<p;i++)c[i]="";for(i=0;i>k-(k%p);i++)c[i%p]+=d.charAt(i);return c;
  }
}

dealメソッド内の純粋なロジックだけで、119文字。
もう無理ヽ(´~`;)ノ

「クラウドの利用者に保証されるべき6つの権利、ガートナーが提唱 – Publickey」についてのメモ。


クラウド・コンピューティングというのがよくあるバズワードで終わるのか、あるいは今度こそ何かしらの変革をもたらすものなのかはさておき、私の会社でも少しずつクラウド・サービスを展開しつつあります。

続きを読む

GAE/JでSerializableなクラスを永続化してみようとして落とし穴に落ちた。

表題の通りです。。

がっつり落とし穴に落ちまして、しばらく悩みました。
脱出方法は下記。

GAE/JでSerializableなクラスを永続化してみる(落とし穴注意) – やればできる子の日記

まず、Serializableなフィールドに@Persistentのアノテーションをつけるときに、defaultFetchGroup = “true”とする必要があります。

@Persistent(serialized = "true", defaultFetchGroup = "true")
public HashMap prop = new HashMap();

・・・だそうです。

ただ、これだけのためのエントリー。

Eclipse + GAE/J でローカル環境を起動しようとして落ちた。

・・・ので、復旧するためのメモ。

出てくるエラーはこんな感じ。

Exception thrown
Persistent class "Class jp.fs10.gae.NantokaKantoka does not seem to have been enhanced.  You may want to rerun the enhancer and check for errors in the output." has no table in the database, but the operation requires it. Please check the specification of the MetaData for this class.
org.datanucleus.store.exceptions.NoTableManagedException: Persistent class "Class jp.fs10.gae.NantokaKantoka does not seem to have been enhanced.  You may want to rerun the enhancer and check for errors in the output." has no table in the database, but the operation requires it. Please check the specification of the MetaData for this class.
 at org.datanucleus.store.appengine.DatastoreManager.getDatastoreClass(DatastoreManager.java:644)
 at org.datanucleus.store.appengine.query.DatastoreQuery.performExecute(DatastoreQuery.java:212)
 at org.datanucleus.store.appengine.query.JDOQLQuery.performExecute(JDOQLQuery.java:85)
 at org.datanucleus.store.query.Query.executeQuery(Query.java:1489)
 at org.datanucleus.store.query.Query.executeWithArray(Query.java:1371)
 at org.datanucleus.store.query.Query.execute(Query.java:1344)
 at org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:221)
...

データストア用のキャッシュがうにうにしてるようなので、それをクリアしてあげる。

Eclipseの[Project(P)]⇒[Clean(N)]([プロジェクト(P)]⇒[クリーン(N)])で回避。

Excel VBA 全シートに何かしたい

自分のためのコードサンプル集。

Sub 全シートに何かしたい()
' 【処理内容】
' Activebookの全Sheetに対して処理を行います。
'
' 作成日 : 2007/10/25
' 作成者 : t.shimoyama

 Dim ws As Worksheet

 Worksheets(1).Select ' 先頭シートを選択しておかないとアクティブシートからループしてしまう。。

 For Each ws In ActiveWorkbook.Sheets
  ws.Cells(3, 3).Value = "がふー。" ' やりたいこと
  ws.Cells(3, 5).Value = "どひゃー。" ' やりたいこと
  ws.Cells(7, 3).Value = "うりゃー。" ' やりたいこと
 Next

End Sub

TOP