CentOS7でMySQL完全アンインストールする

操作手順
#yum remove mysql mysql-server mysql-devel mysql-libs compat-mysql51 mysql-community-client mysql-community-libs mysql-community-server mysql-community-common mysql-community-release.noarch
#rm -rf /var/lib/mysql
#rm /etc/my.cnf
#rm -rf /var/lib/mysql/
#rm -rf /usr/lib64/mysql
#rm -rf /usr/lib/mysql
#rm -rf /usr/share/mysql
#rm –rf /usr/my.cnf
#rm -rf /root/.mysql_sercret
#chkconfig –del mysqld

#yum list installed mysql*

「PHP」アップロードされた画像の拡張子(jpg、png、gif)を判定する

phpコード:
function isImageFunc($fileName)
{
$file = fopen($fileName, “rb”);
$kdf = fread($file, 2);

fclose($file);
$strInfo = @unpack(“C2chars”, $kdf);
$typeCode = intval($strInfo[‘chars1’].$strInfo[‘chars2’]);
$fileType = ”;

if($typeCode == 255216 /*jpg*/ || $typeCode == 7173 /*gif*/ || $typeCode == 13780 /*png*/ || $typeCode == 8273 /*webp*/)
{
return $typeCode;
}
else
{
// echo ‘”jpg/jpeg/gif/png/webp画像をアップロードしてください’;
return false;
}
}

jqueryで最初ラジオボタンの値を取得

$(“input[type=radio][checked]”).eq(0).val()

CentOS7.3にphp-mcrypt5.4.16をインストールする

# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm

# sudo rpm -ivh epel-release-7-10.noarch.rpm
Preparing… ################################# [100%]
Updating / installing…
1:epel-release-7-10 warning: /etc/yum.repos.d/epel-testing.repo created as /etc/yum.repos.d/epel-testing.repo.rpmnew
warning: /etc/yum.repos.d/epel.repo created as /etc/yum.repos.d/epel.repo.rpmnew
################################# [100%]

 

# sudo yum install –enablerepo=epel php-mcrypt
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* epel: ftp.riken.jp
* remi-safe: mirrors.mediatemple.net
Resolving Dependencies
–> Running transaction check
—> Package php-mcrypt.x86_64 0:5.4.16-7.el7 will be installed
–> Processing Dependency: libmcrypt.so.4()(64bit) for package: php-mcrypt-5.4.16-7.el7.x86_64
–> Running transaction check
—> Package libmcrypt.x86_64 0:2.5.8-13.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php-mcrypt x86_64 5.4.16-7.el7 epel 20 k
Installing for dependencies:
libmcrypt x86_64 2.5.8-13.el7 epel 99 k

Transaction Summary
================================================================================
Install 1 Package (+1 Dependent package)

Total download size: 119 k
Installed size: 331 k
Is this ok [y/d/N]: y
Downloading packages:
(1/2): libmcrypt-2.5.8-13.el7.x86_64.rpm | 99 kB 00:00
(2/2): php-mcrypt-5.4.16-7.el7.x86_64.rpm | 20 kB 00:00
——————————————————————————–
Total 432 kB/s | 119 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : libmcrypt-2.5.8-13.el7.x86_64 1/2
Installing : php-mcrypt-5.4.16-7.el7.x86_64 2/2
Verifying : libmcrypt-2.5.8-13.el7.x86_64 1/2
Verifying : php-mcrypt-5.4.16-7.el7.x86_64 2/2

Installed:
php-mcrypt.x86_64 0:5.4.16-7.el7

Dependency Installed:
libmcrypt.x86_64 0:2.5.8-13.el7

php5.6をインストールするメモ

1.古いphpをアンインストール
$ sudo yum remove php-*

2.パッケージをインストール
$ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
$ rpm -ivh remi-release-6.rpm
phpをインストール
php v5.6
$ sudo yum install –enablerepo=remi-php56 php

「spring」 log4jの設定サンプルコード

サンプルコード

log4j.rootLogger = debug, stdout
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = %d %5p [%c] – %m%n

log4j.logger.org.apache.ibatis = DEBUG
log4j.logger.org.mybatis.spring = DEBUG
log4j.logger.org.mybatis.spring.SqlSessionUtils = WARN

「Spring MVC」HttpServletRequestでリクエストパラメータの取得方法

Javaコード
@RequestMapping(“/addUserInfo”)
public String addUserInfo(HttpServletRequest request) {
String userName = request.getParameter(“userName”);
String password = request.getParameter(“password”);
System.out.println(“ユーザ名:”+userName);
System.out.println(“パスワード:”+password);
return “/user/success”;
}

「java」ZipEntryでファイルを圧縮するコード

Javaコード
public static void zipDIR(String srcDir, String destZipFile) {
try {
FileOutputStream target = new FileOutputStream(destZipFile);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(target));
int BUFFER_SIZE = 1024;
byte buff[] = new byte[BUFFER_SIZE];
File dir = new File(srcDir);
if (!dir.isDirectory()) {
throw new IllegalArgumentException(srcDir+” はディレクトリではありません!”);
}
File files[] = dir.listFiles();
for (int i = 0; i < files.length; i++) {
FileInputStream fi = new FileInputStream(files[i]);
BufferedInputStream origin = new BufferedInputStream(fi);
ZipEntry entry = new ZipEntry(files[i].getName());
out.putNextEntry(entry);
int count;
while ((count = origin.read(buff)) != -1) {
out.write(buff, 0, count);
}
origin.close();
}
out.close();
} catch (IOException e) {
throw new MsgException(“”);
}
}

java.io.FileWriterで文字ファイルを書き込むサンプルコード

Javaコード
String str=”hello world!”;
FileWriter writer;
try {
writer = new FileWriter(“D:/demo.txt”);
writer.write(str);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}

java.io.OutputStream.FileOutputStreamのサンプルコード

Javaコード
File txt=new File(“D:/demotxt”);
if(!txt.exists()){
txt.createNewFile();
}
byte bytes[]=new byte[512];
bytes=str.getBytes();
int b=bytes.length;
FileOutputStream fos=new FileOutputStream(txt);
fos.write(bytes,0,b);
fos.write(bytes);
fos.close();