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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
vim="vim $1 $2 $3" | |
osascript -e " | |
tell application \"iTerm\" | |
set myterm to (create window with default profile) | |
tell myterm | |
activate current session | |
launch session \"Default Session\" | |
tell the current session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stop and remove the container and run again: | |
docker stop mysql4 && docker rm mysql4 | |
docker run - name=mysql1 -e MYSQL_ROOT_HOST=% -p 3306:3306 -d mysql/mysql-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>'; | |
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '<password>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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) { |
Script to install docker and docker-compose for ubuntu 16.04
Docker version 18.03.0-ce, build 0520e24
docker-compose version 1.21.0, build 5920eb0
sudo apt-get update \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - \
&& sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
NewerOlder