Skip to content

Instantly share code, notes, and snippets.

Avatar

Son Tran trandaison

View GitHub Profile
@trandaison
trandaison / redis_mac.md
Created May 17, 2021
Install Redis on MacOS
View redis_mac.md

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@trandaison
trandaison / pm2.md
Created May 17, 2021
PM2 deployment
View pm2.md

1. Preparing the server

Install git

sudo apt install git-all

Generate Server's SSH public key

ssh-keygen -t rsa -b 4096 -C "deploy"
cat ~/.ssh/id_rsa.pub
@trandaison
trandaison / pm2.md
Last active Feb 26, 2021
PM2 Guide
View pm2.md

Chuẩn bị server

Cài đặt git

sudo apt install git-all

Generate SSH key để phục vụ deploy

ssh-keygen -t rsa -b 4096 -C "server.ip"
@trandaison
trandaison / cw-dark-mode.vue
Last active Sep 25, 2019
Chatwork dark mode
View cw-dark-mode.vue
<template>
<div class="toggle-dark-theme">
Dark theme
<label class="switch">
<input type="checkbox" checked id="toggle-dark-theme">
<span class="slider round"></span>
</label>
</div>
</template>
View arrays.js
const generateArrays = (limit = 600, arraySize = 36, min = 1, max = 99) => {
let currentIndex = max - arraySize + 2;
const result = [];
while (result.length < limit) {
const initArray = [null];
const nextIndex = currentIndex + (arraySize - 1);
for (let i = currentIndex; i <= nextIndex; i++) {
initArray.push(i);
View .gitconfig
[user]
name = Son Tran
email = sontd.it@gmail.com
[alias]
s = status
ck = checkout
l1l = log --oneline
br = branch
@trandaison
trandaison / .gitconfig
Created Apr 4, 2019
.gitconfig aliases `~/.gitconfig`
View .gitconfig
[user]
name = Son Tran
email = sontd.it@gmail.com
[alias]
s = status
ck = checkout
l1l = log --oneline
br = branch
@trandaison
trandaison / script.js
Created Mar 18, 2019
Redmine hide sidebar
View script.js
var toggle = document.createElement('div');
var sidebar = document.getElementById('sidebar');
toggle.innerHTML = '>';
toggle.classList.add('toggle-sidebar');
toggle.classList.add('open');
toggle.addEventListener('click', function() {
sidebar.classList.toggle('hidden');
toggle.classList.toggle('open');
setTimeout(function() {
toggle.innerHTML = sidebar.classList.contains('hidden') ? '<' : '>';
@trandaison
trandaison / scripts.js
Created Dec 17, 2018
Redmine Toggle sidebar
View scripts.js
var button = document.createElement('div');
button.innerHTML = '>';
button.setAttribute('id', 'sidbar-collapse');
var sidebar = document.getElementById('sidebar');
button.onclick = () => {
sidebar.classList.toggle('collapse');
button.innerHTML = button.innerText == '>' ? '<' : '>';
};
sidebar.appendChild(button);
button.click();
@trandaison
trandaison / upload.js
Created Oct 7, 2018 — forked from virolea/upload.js
Tracking file upload progress using axios
View upload.js
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round( (progressEvent.loaded * 100) / progressEvent.total )
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])