Skip to content

Instantly share code, notes, and snippets.

View sonnyit's full-sized avatar
🌴
((sun))

sonny sonnyit

🌴
((sun))
  • VNG, Vietnam
  • Ho Chi Minh, Vietnam
View GitHub Profile

Manage Multiple Claude Code Accounts

Run two Claude Code accounts simultaneously on macOS without re-authenticating by using separate configuration directories.

Steps

  1. Create Separate Config Directories
    mkdir ~/.claude-account1
    mkdir ~/.claude-account2
@sonnyit
sonnyit / getRedirectUrl.java
Created September 30, 2022 12:24 — forked from kanzmrsw/getRedirectUrl.java
get redirect url from url
public class Test extends Activity {
...
public String getRedirectUrl(String url) {
URL urlTmp = null;
String redUrl = null;
HttpURLConnection connection = null;
try {
urlTmp = new URL(url);
@sonnyit
sonnyit / README.md
Created April 6, 2022 13:00 — forked from luciferous/README.md
Rate Limiter in Javascript

How to use

Let's say you want to limit some event to 5 occurrences every 20 seconds, you would set up the RateLimit like so:

var limit = new RateLimit(20); // Initialize a 20 second ticklog

// For events that we initiate...
if (limit.count('myevent_id') <= 5)) {

// Do some stuff

#!/bin/bash
RED='\033[0;31m';
NC='\033[0m'; # No Color
GREEN='\033[0;32m';
YELLOW='\033[1;33m';
CWD=`pwd`;
delay_after_message=3;
### download elasticsearch-[version].tar.gz from website
tar xvzf elasticsearch-[version].tar.gz
### download coccoc Tokenizer
```
git clone https://github.com/coccoc/coccoc-tokenizer.git
cd coccoc-tokenizer
mkdir build
cd build
```
@sonnyit
sonnyit / NlpUtils.java
Last active August 13, 2021 03:27 — forked from behitek/NlpUtils.java
Chuẩn hóa cách gõ dấu câu về kiểu gõ cũ (Python + Java version)
package utils;
import java.util.*;
public class NlpUtils {
static Map<String, String> dictChar;
static Character[][] vowelTable = {
{'a', 'à', 'á', 'ả', 'ã', 'ạ'},
{'ă', 'ằ', 'ắ', 'ẳ', 'ẵ', 'ặ'},
@sonnyit
sonnyit / nonAccentVietnamese.js
Created July 23, 2021 05:06 — forked from jarvisluong/nonAccentVietnamese.js
Converting standard Vietnamese Characters to non-accent ones. Example: hải -> hai
function nonAccentVietnamese(str) {
str = str.toLowerCase();
// We can also use this instead of from line 11 to line 17
// str = str.replace(/\u00E0|\u00E1|\u1EA1|\u1EA3|\u00E3|\u00E2|\u1EA7|\u1EA5|\u1EAD|\u1EA9|\u1EAB|\u0103|\u1EB1|\u1EAF|\u1EB7|\u1EB3|\u1EB5/g, "a");
// str = str.replace(/\u00E8|\u00E9|\u1EB9|\u1EBB|\u1EBD|\u00EA|\u1EC1|\u1EBF|\u1EC7|\u1EC3|\u1EC5/g, "e");
// str = str.replace(/\u00EC|\u00ED|\u1ECB|\u1EC9|\u0129/g, "i");
// str = str.replace(/\u00F2|\u00F3|\u1ECD|\u1ECF|\u00F5|\u00F4|\u1ED3|\u1ED1|\u1ED9|\u1ED5|\u1ED7|\u01A1|\u1EDD|\u1EDB|\u1EE3|\u1EDF|\u1EE1/g, "o");
// str = str.replace(/\u00F9|\u00FA|\u1EE5|\u1EE7|\u0169|\u01B0|\u1EEB|\u1EE9|\u1EF1|\u1EED|\u1EEF/g, "u");
// str = str.replace(/\u1EF3|\u00FD|\u1EF5|\u1EF7|\u1EF9/g, "y");
// str = str.replace(/\u0111/g, "d");
@sonnyit
sonnyit / KeyEventSimulator.js
Created July 11, 2021 03:08 — forked from GlauberF/KeyEventSimulator.js
A function for simulating key event in JavaScript. You just have to choose what key and keyboard event you want to simulate.
/**
* Simulate a key event.
* @param {Number} keyCode The keyCode of the key to simulate
* @param {String} type (optional) The type of event : down, up or press. The default is down
* @param {Object} modifiers (optional) An object which contains modifiers keys { ctrlKey: true, altKey: false, ...}
*/
function simulateKey (keyCode, type, modifiers) {
var evtName = (typeof(type) === "string") ? "key" + type : "keydown";
var modifier = (typeof(modifiers) === "object") ? modifier : {};
@sonnyit
sonnyit / README.md
Created March 21, 2021 18:21 — forked from noamtamim/README.md
Markdown with PlantUML

How to use PlantUML with Markdown

PlantUML is a really awesome way to create diagrams by writing code instead of drawing and dragging visual elements. Markdown is a really nice documentation tool.

Here's how I combine the two, to create docs with embedded diagrams.

Step 0: Setup

Get the command-line PlantUML from the download page or your relevant package manager.

@sonnyit
sonnyit / Documentation.md
Created August 3, 2020 12:56 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs