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.lang.reflect.Constructor; | |
import java.lang.reflect.Field; | |
import java.math.BigInteger; | |
import org.bouncycastle.crypto.DataLengthException; | |
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; | |
import org.bouncycastle.jcajce.provider.asymmetric.rsa.BCRSAPrivateCrtKey; | |
public class RSATest { |
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 static void compressZipfile(String sourceDir, OutputStream os) throws IOException { | |
ZipOutputStream zos = new ZipOutputStream(os); | |
compressDirectoryToZipfile(sourceDir, sourceDir, zos); | |
IOUtils.closeQuietly(zos); | |
} | |
private static void compressDirectoryToZipfile(String rootDir, String sourceDir, ZipOutputStream out) throws IOException, FileNotFoundException { | |
File[] fileList = new File(sourceDir).listFiles(); | |
if (fileList.length == 0) { // empty directory / empty folder | |
ZipEntry entry = new ZipEntry(sourceDir.replace(rootDir, "") + "/"); |
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 com.test; | |
import com.test.schema.ContactType; | |
import org.apache.kafka.clients.consumer.ConsumerConfig; | |
import org.apache.kafka.clients.consumer.ConsumerRecord; | |
import org.apache.spark.SparkConf; | |
import org.apache.spark.api.java.JavaPairRDD; | |
import org.apache.spark.api.java.function.*; | |
import org.apache.spark.streaming.Durations; | |
import org.apache.spark.streaming.api.java.JavaDStream; |
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 codecs | |
filename = 'input.csv' | |
# fr = open(filename) | |
fr = codecs.open(filename,"r","shift_jis") | |
lines = fr.readlines() | |
lines.sort() | |
dict = {} |
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 UIKit | |
import Foundation | |
import XCPlayground | |
XCPSetExecutionShouldContinueIndefinitely() | |
class RemoteAPI { | |
func getData(completionHandler: ((NSArray!, NSError!) -> Void)!) -> Void { | |
let url: NSURL = NSURL(string: "http://itunes.apple.com/search?term=Turistforeningen&media=software") | |
let ses = NSURLSession.sharedSession() |
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
create table t1 (num int, color varchar(10)); | |
insert into t1 values (1,'red'), (1,'black'), (2,'red'), (2,'yellow'), (2,'green'); | |
select num, | |
substr( xmlserialize( xmlagg( xmltext( concat( ', ', color ) ) ) as varchar( 1024 ) ), 3 ) | |
from t1 | |
group by num; | |
--OR without space after comma |
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 static String toHankakuNum(String text) { | |
StringBuilder res = new StringBuilder(); | |
final String listZens = "0123456789.-"; | |
final String listHans = "0123456789.-"; | |
for (int textIdx = 0; textIdx < text.length(); textIdx++) { | |
char ch = text.charAt(textIdx); | |
int listIdx = listZens.indexOf(ch); | |
if (listIdx >= 0) { | |
res.append(listHans.charAt(listIdx)); |
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
<?php | |
$salt = genrandom(40); | |
$seed = genrandom(29, "0123456789"); | |
echo "\tConfigure::write('Security.salt', '$salt');\n"; | |
echo "\tConfigure::write('Security.cipherSeed', '$seed');\n"; | |
function genrandom($len, $salt = null) { | |
if (empty($salt)) { |
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 static org.junit.Assert.assertFalse; | |
import java.io.UnsupportedEncodingException; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import org.apache.commons.logging.Log; | |
import org.apache.commons.logging.LogFactory; | |
import org.junit.Test; |