python と java について、vim の mode line を設定する

tab で 4 space 入れる方法。

#!/usr/bin/env python
# -*- encoding:utf-8 -*-
# vim:tabstop=4:shiftwidth=4:expandtab

print('aaa')
/* vim:set ts=4 sw=4 et ws is nowrap ft=java fenc=utf-8 ff=dos: */
class JSample13_1{
  public static void main(String args[]){
    char c;
    int num;

    num = 20;
    c = num >= 0 ? '正' : '負';
    System.out.print(num + "は");
    System.out.println(c);

    num = -4;
    c = num >= 0 ? '正' : '負';
    System.out.print(num + "は");
    System.out.println(c);
  }
}

vim.wikia.com

Javaのutf-8とかunicodeへのファイル変換

utf-8 => unicode にファイルをエンコードする。

$ cat JSample3_1.java
class JSample3_1{
  public static void main(String args[]){
    System.out.println("こんにちは");
    System.out.println("お元気ですか");
  }
}
$ native2ascii -encoding UTF-8 JSample3_1.java JSample3_2.java
$ cat JSample3_2.java
class JSample3_1{
  public static void main(String args[]){
    System.out.println("\u3053\u3093\u306b\u3061\u306f");
    System.out.println("\u304a\u5143\u6c17\u3067\u3059\u304b");
  }
}
$ javac JSample3_2.java
$ java JSample3_1
こんにちは
お元気ですか

$ native2ascii -reverse JSample3_2.java JSample3_3.java
$ cat JSample3_3.java
class JSample3_1{
  public static void main(String args[]){
    System.out.println("こんにちは");
    System.out.println("お元気ですか");
  }
}

FMとかFFMとかの論文

レコメンドエンジンで使えそうな論文。

参考までに。FM の実装

github.com

"SLIM: Sparse Linear Methods for Top-N Recommender Systems"を読んだ | takuti.me

www.analyticsvidhya.com

レコメンドシステムで、Explicit と Implicit とは(レコメンド例のSlide)

レビューとかでユーザが明示的に評価したら、Explicit。
PVとかCVとかのlogで評価を判断するのがImplicit。らしい。

There are two ways to gather the data. The first method is to ask for explicit ratings from a user, typically on a concrete rating scale (such as rating a movie from one to five stars). The second is to gather data implicitly as the user is in the domain of the system - that is, to log the actions of a user on the site.

Recommendation Systems :: General Collaborative Filtering Algorithm Ideas

www.slideshare.net

cassandra を tarball でインストール

MySQLも同様だけど、yumではなく、tarballからもインストールできるので勉強として。

実行

## cassandraがyum installされている場合
sudo yum remove cassandra
ls /var/lib/cassandra/*
rm -rf /var/lib/cassandra/*

## tarをインストール

mkdir /usr/local/cassandra
mkdir /var/lib/cassandra/
cd /usr/local/cassandra

curl -O http://ftp.jaist.ac.jp/pub/apache/cassandra/3.11.2/apache-cassandra-3.11.2-bin.tar.gz
tar -xvf apache-cassandra-3.11.2-bin.tar.gz

chmod 777 /var/lib/cassandra/

$ vim ~/.bash_profile
$ source ~/.bash_profile

vi /etc/init.d/cassandra
chkconfig --add cassandra
chkconfig --list cassandra

$ cassandra -v
$ cassandra -f
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
if [ -d "/usr/local/cassandra/apache-cassandra-3.11.2" ]; then
    export PATH="/usr/local/cassandra/apache-cassandra-3.11.2/bin:$PATH"
fi

export PATH
  • /etc/init.d/cassandra
#!/bin/sh
# chkconfig: 345 99 1
# description: cassandra
# processname: cassandra

CASSANDRA_BIN=/usr/local/cassandra/apache-cassandra-3.11.2/bin/cassandra
CASSANDRA_PID=/var/run/cassandra.pid

case "$1" in
  start)
     $CASSANDRA_BIN -p $CASSANDRA_PID
     echo "Running Cassandra"
     ;;
  stop)
     kill `cat $CASSANDRA_PID`
     rm -f $CASSANDRA_PID
     echo "Stopped Cassandra"
     ;;
  *)
     echo "Usage: $0 {start|stop}"
     exit 1
esac
exit 0