Skip to content

Instantly share code, notes, and snippets.

View niceume's full-sized avatar

niceume

  • Tokyo
View GitHub Profile
@niceume
niceume / .cshrc
Last active April 8, 2021 22:20
.cshrc
#
# Written by niceume
# 2013 July. 11
#
# also refer to src/share/skel/dot.cshrc
# .cshrc - csh resource script, read at beginning of execution by each shell
# see also csh(1), environ(7).
@niceume
niceume / Q_q_string.rb
Last active August 29, 2015 14:13
Ruby %Q %q are used to create String
# When creating String, usually double quotations or single quotations are used.
# In double quotations, #{ var } can be used. \ should work.
# In single quotations, \ also should work.
"Hello, everyone"
'Hi, everyone'
"Hello, \" everyone"
'Hi, \' everyone'
greeting = "Good morning "

Install Java 8 in Linux Mint

Install JDK

Just download JDK, and extract.

Download appropriate JDK. (i586, amd64. This depends on your linux system. If you choose different one, the system cannot recognize the executable files.)

cd ~/Downloads
@niceume
niceume / TTestStat.java
Created January 15, 2015 22:30
Run ttest in Java by using Apache Math Library
// Put the commons-math3-3.4.1.jar file in the same directory of this code.
// Run :
// $ javac -cp commons-math3-3.4.1.jar TTESTStat.java
// $ java -cp .:commons-math3-3.4.1.jar TTESTStat
//
// When running "java", you have to be careful about "-cp option" having ".:" in its argument.
//
// "-cp" option clears previous CLASSPATH setting.
// When running javac, TTESTStat.java means a file on filesystem (Not a java class yet. Still just a file at this point).
// So ".:" is not required.
# This is a code for JRuby.
#
# Put the commons-math3-3.4.1.jar in the current code.
# Run
# $ jruby -J-cp commons-math3-3.4.1.jar TTESTStat.rb
#
require "java"
module ACMStat
@niceume
niceume / java_from_jruby.rb
Last active August 29, 2015 14:13
JRuby Tips : Accessing Java class from JRuby
# require "java" provides top-level functions like com, org, java, and javax.
require "java"
###############################
# Access Java class. (with package name (Ruby namespace))
###############################
java.lang.StringBuffer
# In JRuby, this class is recognized as
# Java::JavaLang::StringBuffer
# The begining Java:: means
@niceume
niceume / JRuby_and_Java_class_conversion.md
Created January 20, 2015 02:23
JRuby and Java class conversion.

JRuby and Java class conversion.

Intro

In JRuby, we can write Ruby code as if we are in real Ruby world. Moreover, From JRuby, most of the methods in Java class can be easily and seamlessly accessed!

One thing I have to keep in mind is that when we pass Ruby objects to Java method, how these objects are converted. And vice versa. (When Java objects are passed to Java methods, I don't have to take care about it. And also Ruby objects passed to Ruby methods.)

Most of the embedded Ruby libraries can be automatically converted to Java coresponding classes.

@niceume
niceume / Jruby_interface_abstract_class.md
Created January 20, 2015 02:25
Jruby : How to deal with java interface and abstract class

How to deal with java interface and abstract class

@niceume
niceume / HowToConverGoogleSpreadsheetToCSV.md
Last active August 29, 2015 14:13
How To Conver Google Spreadsheet To CSV

How To Conver Google Spreadsheet To CSV

-1. Make Google spreadsheet accessble from anyone.

  • Share button on the right above.
  • Set "Anyone with the link can view"

-2. (Re)Publish automatically

  • "File > publish to the Web"
@niceume
niceume / classinstance.rb
Created February 2, 2015 04:34
Ruby class instance explanation.
# Class (Class object, eigenclass ) also has its own instance variable(class instance variable).
# It can be accessed in static method.
# By the way, the difference in practice btw class variable and class instance is as follows,
# Class variable is shared by some related objects, say, its instances and inherited classes.
# Class instance variable is an instance variable of only class object.
# In code level, the difference is
# class variable can be written anywhere
# class instance variable can be written in class definition outside of method definitions or in static method definition.