Skip to content

Instantly share code, notes, and snippets.

@richard1122
richard1122 / main.kt
Created July 19, 2020 14:53
origin engine parse/merge translation file script
import java.io.BufferedWriter
import java.io.File
import java.io.FileInputStream
import java.util.*
import kotlin.test.assertTrue
const val FOLDER_PATH = "c:/data"
const val CHINESE_FILE_PATH = "$FOLDER_PATH/chinese.txt"
const val CHINESE_FILE_TEST_PATH = "$FOLDER_PATH/chinese_temp.txt"
@richard1122
richard1122 / main.kt
Last active July 8, 2020 14:41
String construction
import java.io.File
import java.io.FileInputStream
import java.util.*
// Unique index for each Vertex
var currentIndex = 0
class Vertex(private val index: Int = ++currentIndex) {
var terminate = false
val edges = mutableMapOf<Char, Vertex>()
@richard1122
richard1122 / .vmoptions
Created July 12, 2019 06:08
idea vm options
# custom IntelliJ IDEA VM options
# from https://github.com/adben/config/blob/master/idea64.vmoptions
-ea
-server
-Xms2G
-Xmx4096M
-Xss16m
-XX:MaxMetaspaceSize=2G
-XX:MetaspaceSize=512m
-XX:ConcGCThreads=6
@richard1122
richard1122 / assertj-kotlin.postfixTemplates
Created January 29, 2019 04:24
custom intellij postfix template
.assertJ : AssertJ
ANY → org.assertj.core.api.Assertions.assertThat($expr$)
.isEqualTo: AssertJ And isEqualTo
ANY → org.assertj.core.api.Assertions.assertThat($expr$).isEqualTo($END$)
.isZero: AssertJ And isZero
ANY → org.assertj.core.api.Assertions.assertThat($expr$).isZero()
.isCloseTo: AssertJ And isCloseTo
ANY → org.assertj.core.api.Assertions.assertThat($expr$).isCloseTo($value#1$, Percentage.withPercentage(.1))$END$
.isTrue: AssertJ And isTrue
ANY → org.assertj.core.api.Assertions.assertThat($expr$).isTrue()
@richard1122
richard1122 / v2ex.css
Created November 19, 2018 05:14
stylish
#Main > .box tr > td:first-child {
width: 0;
}
@richard1122
richard1122 / idea.xml
Created May 17, 2018 09:27
intellij code style
<code_scheme name="Default" version="173">
<HTMLCodeStyleSettings>
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
</HTMLCodeStyleSettings>
<JSCodeStyleSettings>
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
<option name="FORCE_SEMICOLON_STYLE" value="true" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="FORCE_QUOTE_STYlE" value="true" />
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
@richard1122
richard1122 / TL.d.ts
Last active November 20, 2016 07:51
telegram typings
// A typings definition of some telegram data structure
// author: Richard He<richard9372@gmail.com>
// https://gist.github.com/richard1122/1eb54cd4e422aeb707718ab307decd34
// see more detail: https://core.telegram.org/bots/api
declare namespace TL {
export interface IResponse<T> {
ok:boolean
result:T
}
@richard1122
richard1122 / DPToPX.java
Last active August 29, 2015 14:23
Android snippet
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, mContext.getResources().getDisplayMetrics());
@richard1122
richard1122 / TransprentHTTPGzipedStreamReader.java
Last active August 29, 2015 14:19
Android HTTPURLConnection auto read gzip inputStream
public static String networkInputstreamtoString(InputStream is) throws IOException {
byte []sig = new byte[2];
final PushbackInputStream pb = new PushbackInputStream(is, sig.length);
pb.read(sig);
pb.unread(sig);
if (sig[0] == (byte) 0x1f && sig[1] == (byte) 0x8b) {
is = new GZIPInputStream(pb);
} else {
is = new BufferedInputStream(pb);
}
@richard1122
richard1122 / openmp_pi.cpp
Created January 2, 2015 17:11
OpenMP for PI calculation test
#include <iostream>
#include <omp.h>
#include <ctime>
using namespace std;
#define N 3000000000L
int main() {
omp_set_num_threads(8);