Skip to content

Instantly share code, notes, and snippets.

@richard1122
richard1122 / main.kt
Created Jul 19, 2020
origin engine parse/merge translation file script
View main.kt
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 Jul 8, 2020
String construction
View main.kt
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 Jul 12, 2019
idea vm options
View .vmoptions
# 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 Jan 29, 2019
custom intellij postfix template
View assertj-kotlin.postfixTemplates
.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()
View v2ex.css
#Main > .box tr > td:first-child {
width: 0;
}
@richard1122
richard1122 / idea.xml
Created May 17, 2018
intellij code style
View idea.xml
<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 Nov 20, 2016
telegram typings
View TL.d.ts
// 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 Aug 29, 2015
Android snippet
View DPToPX.java
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, mContext.getResources().getDisplayMetrics());
@richard1122
richard1122 / TransprentHTTPGzipedStreamReader.java
Last active Aug 29, 2015
Android HTTPURLConnection auto read gzip inputStream
View TransprentHTTPGzipedStreamReader.java
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 Jan 2, 2015
OpenMP for PI calculation test
View openmp_pi.cpp
#include <iostream>
#include <omp.h>
#include <ctime>
using namespace std;
#define N 3000000000L
int main() {
omp_set_num_threads(8);
You can’t perform that action at this time.