Skip to content

Instantly share code, notes, and snippets.

View thstarshine's full-sized avatar
🏔️

starshine thstarshine

🏔️
  • Taipei, Taiwan
View GitHub Profile
@ryu1kn
ryu1kn / README.md
Last active March 18, 2024 14:19
Getting GCP access token from a service account key JSON file

Getting GCP access token from a service account key

Use your service account's key JSON file to get an access token to call Google APIs.

Good for seeing how things work, including the creation of JWT token.

To create a JWT token, you can replace create-jwt-token.sh script with tools like step.

If you just want to get an access token for a service account,

@phiberoptick
phiberoptick / pritunl-server-custom-ssl_manually
Last active April 20, 2024 21:51
Use custom SSL cert in Pritunl Server Community
Ignore all that craziness below. These can be set from the cli with the "pritunl" command.
The commands below can be used to get/set the values of the cert, key, port and if the :80 -> "app.server_port" redirect is active.
# Get current SSL server cert:
pritunl get app.server_cert
# Get current SSL server key:
pritunl get app.server_key
@majodev
majodev / Dockerfile
Created December 4, 2018 09:11
netdata daemonset on kubernetes
FROM netdata/netdata:latest
MAINTAINER YOUR_EMAIL
# add netdata user to root group (access volumne mounts from host)
RUN apk --no-cache add shadow
RUN usermod -a -G root netdata
ENTRYPOINT ["/usr/sbin/run.sh"]
@jonathanhle
jonathanhle / pritunl_mongo_audit_query.py
Last active May 16, 2023 09:32
pritunl mongodb query for user info
# Requires pymongo 3.6.0+
from datetime import datetime, timedelta
from pymongo import MongoClient
from bson.tz_util import FixedOffset
from bson.son import SON
from collections import OrderedDict
# Setup logger
import logging
@sturmenta
sturmenta / firestore2json.js
Last active October 28, 2022 19:03
firestore to json & json to firestore
const admin = require('firebase-admin');
const fs = require('fs');
const serviceAccount = require('../../../../../../Private/myschool-data_transfer-key.json');
admin.initializeApp({ credential: admin.credential.cert(serviceAccount) });
const schema = require('./schema').schema;
const firestore2json = (db, schema, current) => {
@luiseok
luiseok / jail.local
Last active September 20, 2023 07:16
Fail2ban MongoDB filter.d configuration file
#
# File Path : /etc/fail2ban/jail.local
#
# Please modify the port and logpath that you configured.
#
[mongo-auth]
enabled = true
filter = mongo-auth
@dain
dain / Directions for creating PEM files
Last active October 16, 2023 09:11
Create Java KeyStore from standard PEM encoded private key and certificate chain files
# To regenerate the test key and certificates
# Generate an RSA private key and convert it to PKCS8 wraped in PEM
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -out rsa.key
# Generate a certificate signing request with the private key
openssl req -new -key rsa.key -out rsa.csr
# Sign request with private key
openssl x509 -req -days 10000 -in rsa.csr -signkey rsa.key -out rsa.crt
@mustafaturan
mustafaturan / network-tweak.md
Last active February 29, 2024 15:08
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@JosiasSena
JosiasSena / DeCryptor.java
Last active September 12, 2023 12:40
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/