This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A sample to send a trap data. | |
// Ref. | |
// http://jis.hatenablog.com/entry/2013/09/05/134001 | |
// https://www.qoosky.net/techs/f8c35bb5d7 | |
import java.net.DatagramPacket; | |
import java.net.DatagramSocket; | |
import java.net.InetAddress; | |
public class SnmpTrapClient { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class testByte { | |
public static void main(String[] args) { | |
byte byteData = (byte) 0xC7; // 11000111 | |
// If there is no "(byte)", 0xC7 is looked as int. | |
System.out.println(byteData); // -57 | |
int intData = 0xC7; // 00000000 00000000 00000000 11000111 | |
System.out.println(intData); // 199 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Win32::Clipboard; | |
my $clip = Win32::Clipboard(); | |
my $text = $clip->GetText(); | |
$text =~ s/^/> /mg; | |
$clip->Empty(); | |
$clip->Set($text); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [課題] | |
// 5 = -0.00003*X^4 + 0.0034*X^3 - 0.1257*X^2 + 1.6351*X + 0.000000000003 のXを求める。 | |
// いろいろ方法はありそうだが、メジャーな数値計算法である、ニュートン法で試してみた。 | |
// 具体的には、f(X) = -0.00003*X^4 + 0.0034*X^3 - 0.1257*X^2 + 1.6351*X + 0.000000000003 - 5 として、 | |
// f(X) = 0 となる解Xを、ニュートン法、つまり、X[n+1] = X[n] - f(X)/f'(X) をもとに、繰り返し計算を行った。 | |
public class Newton { | |
public static void main(String[] args) { | |
double x = 1; // 出発値 | |
double new_x; | |
double EPS = 1.0e-5; // 許容誤差 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
# {}は、(無名)ハッシュを生成し、かつ、そのリファレンス(アドレス)となる。 | |
my $ref_hash = {"a" => "A", "b" => "B", "c" => "C"}; | |
print($ref_hash->{"a"} . "\n"); # "A" | |
# つまり、以下と同様。上のように書いた方がカッコいいか。 | |
my %hash = ("a" => "A", "b" => "B", "c" => "C"); | |
print((\%hash)->{"a"} . "\n"); # "A" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>現在時刻</title> | |
<script language="JavaScript"> | |
function getCurrentTime() { | |
var dayArray = new Array("日","月","火","水","木","金","土"); | |
var dateObj = new Date(); | |
var year = dateObj.getYear() + 1900; | |
var heisei = year - 1988; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package staticFieldTest; | |
public abstract class Base { | |
public static int staticCounter = 0; | |
public int NonStaticCounter = 0; | |
public void countUp(){ | |
staticCounter++; | |
NonStaticCounter++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.UnsupportedEncodingException; | |
public class getBytesSample { | |
public static void main(String[] args) { | |
// Tested on Windows7. | |
String str = "あいう"; | |
try { | |
byte[] bytesSJIS = str.getBytes("Windows-31J"); | |
byte[] bytesUTF8 = str.getBytes("UTF-8"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package innerClassTest; | |
public class ExternalClass { | |
String str = "external"; | |
class InnerClass { | |
String str = "inner"; | |
} | |
InnerClass createInner(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Archive::Zip; | |
use File::Basename; | |
use Getopt::Long; | |
my $DEF_OF_ARC = '(\.zip$)|(\.jar$)|(\.war$)|(\.ear$)|(\.sar$)'; | |
my $deleteArchiveFile; | |
GetOptions( |