Skip to content

Instantly share code, notes, and snippets.

View backslash112's full-sized avatar
🎯
Focusing

Cun Yang backslash112

🎯
Focusing
View GitHub Profile
@backslash112
backslash112 / mongodbIndexExporter.js
Last active August 24, 2021 16:02 — forked from ytkang/mongodbIndexExporter.js
Mongodb Index exporter importer
/*
How to export
* mongo is mongoshell command
mongo dbname --quiet mongodbIndexExporter.js > index.js
*/
let collectionNames = db.getCollectionNames();
let index_data = {'collections': []};
for (let i in collectionNames) {
JFS_BASE=/Users/yujunz/JuiceFS
JFS_NAME=rogerz-s3-cn-east-1-qiniu
BUNDLE=TimeMachine.sparsebundle
VOLUME=/Volumes/TimeMachine

# Mount JuiceFS
juicefs mount --cache-dir $JUICEFS_BASE/cache --batch 10 --writeback --metacache --opencache $JFS_NAME $JFS_BASE/$JFS_NAME

# Create sparse bundle
function countDuplicate(arr) {
let map = new Map();
arr.forEach(num => {
if (map.get(num) > 0) {
// set(key, value)
map.set(num, map.get(num) + 1);
} else {
// set(key, value)
map.set(num, 1);
}
function decrypt(word) {
// string to char array
let chars = [];
for (let c of word) {
chars.push(c);
}
// step 3
let asciiValues = chars.map(c => c.charCodeAt(0));
console.log(asciiValues);
import java.util.*;
class Main {
public static void main(String[] args) {
System.out.println(modifyStr("").equals(""));
System.out.println(modifyStr("Automotive parts").equals("A6e p3s"));
System.out.println(modifyStr("Automotive par").equals("A6e p1r"));
System.out.println(modifyStr("Automotive pa").equals("A6e p0a"));
System.out.println(modifyStr("Automotive p").equals("A6e p0p"));
System.out.println(modifyStr("**Automotive p").equals("**A6e p0p"));
@backslash112
backslash112 / print-leetcode-question.js
Created July 10, 2018 21:24
Pring Leetcode question
document.getElementsByTagName('body')[0].innerHTML = document.querySelectorAll('.question-description__3U1T')[0].innerHTML;
var css = 'body {line-height:1.2} p { font-size: 11px; margin:0px; padding:0px } pre {font-size:8px; margin:0px; padding:2px 4px} code {font-size:8px}',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
// This is required for IE8 and below.
style.styleSheet.cssText = css;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@backslash112
backslash112 / docker-images.sh
Created May 16, 2018 14:34
Blog: Start a Remote MySQL Server with Docker quickly
docker images
@backslash112
backslash112 / alter-user-2.sql
Created May 16, 2018 14:33
Blog: Start a Remote MySQL Server with Docker quickly
ALTER USER 'root'@'localhost' IDENTIFIED BY '<password>';
@backslash112
backslash112 / connect.console
Created May 16, 2018 14:28
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed