Skip to content

Instantly share code, notes, and snippets.

View chez14's full-sized avatar

Chris Qiang chez14

View GitHub Profile
@chez14
chez14 / keymap.txt
Created July 27, 2021 17:45
Mozc Japanese Input Keymap (Ctrl+Shift to Switch Kana Type, Shift + Tab to turn on/off IME)
status key command
Composition Backspace Backspace
Composition Ctrl a MoveCursorToBeginning
Composition Ctrl Backspace Backspace
Composition Ctrl d MoveCursorRight
Composition Ctrl Down MoveCursorToEnd
Composition Ctrl e MoveCursorToBeginning
Composition Ctrl Enter Commit
Composition Ctrl f MoveCursorToEnd
Composition Ctrl g Delete
@chez14
chez14 / proton.sh
Created November 1, 2020 10:50
Proton script to run non-Steam Apps on Linux. Supposedly you have to install Steam first (requires Steam account). Then put this to `/usr/bin/proton.sh` and add required file permissions.
#!/bin/bash
# Credits: https://pastebin.com/NJxfe8Ex
PROTON_VERSION="5.0"
PROTON_DIR=$HOME/.steam/steam/steamapps/common/Proton\ $PROTON_VERSION
RUNNING="$1"
if [ ! -f "$PROTON_DIR/proton" ] ; then
echo "Proton version $PROTON_VERSION not found!";
@chez14
chez14 / signing-gpg-keys.md
Created March 13, 2020 08:15 — forked from F21/signing-gpg-keys.md
Signing someone's GPG key

This is a quick guide of the commands we use to sign someone's GPG key in a virtual key signing party.

Note: The steps cover only the technical aspects of signing someone's key. Before signing someone's key, you must verify their identity. This is usually done by showing government-issued ID and confirming the key's fingerprint

The commands will work for both GPG and GPG2.

I use Julian's key for the examples. His key id is 2AD3FAE3. You should substitute with the appropriate key id when running the commands.

Signing the key

  1. List the keys currently in your keyring: gpg --list-keys.

Keybase proof

I hereby claim:

  • I am chez14 on github.
  • I am chez14 (https://keybase.io/chez14) on keybase.
  • I have a public key whose fingerprint is 0217 9AF8 338A B2BE 900A B709 7C5E 71E1 AAD7 4D83

To claim this, I am signing this object:

@chez14
chez14 / random.md
Created May 19, 2018 16:37 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@chez14
chez14 / Test.java
Last active March 31, 2018 06:02
Testing Thread
public class Test {
public void test() {
Thread saver = new Thread(() -> {
try {
td.save(location);
} catch (IOException ex) {
Logger.getLogger(frmMain.class.getName())
.log(Level.SEVERE, null, ex);
}
});

ES2K15 this

const benda = {
    a: function() {
        this.v_a = 1;

        let x = {
            count_va: () =>{ // notice here, we're using () => {...}
 return this.v_a;
@chez14
chez14 / Pool.java
Last active October 18, 2017 11:41
GANTENG
import java.util.Random;
public class Pool
{
public static boolean validity(int min, int max){
Random rd = new Random();
int lottery1 = rd.nextInt(max-min)+min;
int lottery2 = rd.nextInt(max-min)+min;
int lottery3 = rd.nextInt(max-min)+min;
System.out.println(lottery1);
System.out.println(lottery2);
@chez14
chez14 / Kambing.java
Created August 17, 2017 12:53
Mana yang paling cepat?
public class Kambing {
public static void main(String[] args){
int[] hive = {1,2,3,4,5,6,7,8,9,0};
int needle = 8;
/*
Ada 3 buah method yang bisa digunakan, dan sama-sama jalan semua.
tapi mana yang lebih cepet dari 3-3nya ini?
@chez14
chez14 / encrypt_openssl.txt
Created June 4, 2017 15:04 — forked from crazybyte/encrypt_openssl.txt
File encryption using OpenSSL
For symmetic encryption, you can use the following:
To encrypt:
openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt
To decrypt:
openssl aes-256-cbc -salt -a -d -in encrypted.txt -out plaintext.txt
For Asymmetric encryption you must first generate your private key and extract the public key.