Skip to content

Instantly share code, notes, and snippets.

View sunb0002's full-sized avatar

sunb0002 sunb0002

  • Singapore
View GitHub Profile
@sunb0002
sunb0002 / Keystore
Last active October 29, 2018 04:17
## Generate a keypair
openssl req -x509 -newkey rsa:2048 -sha256 -keyout example.key -out example.crt -subj "/CN=example.com" -days 3650
## Create PFX keystore with this keypair
openssl pkcs12 -inkey example.key -in example.crt -export -out keystore.pkcs12
## Convert PFX keystore into Java JKS keystore
keytool -importkeystore -srckeystore keys.pkcs12 -srcstoretype pkcs12 -destkeystore keystore.jks
## Other often used
@sunb0002
sunb0002 / Show SSL cert chain with cmd
Last active October 6, 2018 02:58
Show SSL cert chain with cmd
openssl s_client -showcerts -connect www.domain.com:443
// "p" is price/revenue array
// return the maximum revnue by cutting a rod with length "n"
cutrod (int[] p, n) {
if (n==0) return 0;
max=Integer.MIN_VALUE;
for (i = 1 to n) {
// Code detail -- https://blog.teamtreehouse.com/getting-started-speech-synthesis-api
// Demo -- https://codepen.io/matt-west/pen/wGzuJ
function sayit(text, voice) {
var msg = new SpeechSynthesisUtterance();
msg.text = text;
msg.voice = voice
speechSynthesis.speak(msg);
javadoc ./com/sb/MyEnum.java -cp . -d testdir -author
ls *finanti*.sql | grep -E -v "^(1B|1C)" | xargs -I {} echo "-f {}" | xargs
// xargs supports parallel execution.
let rm = angular.element(document.body).injector().get("RM");
rm.email = "my.email@hotmail.com"
angular.element(document.body).injector().get('MyDataService').getRmEmail();
ssh -F ssh/config -N -L 1622:db-server-host:1622 jump-host-ssh-alias
sqlplus "user/pwd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=localhost)(Port=1622))(CONNECT_DATA=(SERVICE_NAME=THE_DB_SCHEMA)))"
const usage = () => console.log(`
Usage:
node decoder.js <file-path>
The script will decode any base64-encoded value for each line,
and create x.decoded.xml under the same folder.
`);
if (process.argv.length < 3) {
usage();
process.exit(0);