Skip to content

Instantly share code, notes, and snippets.

View trandaison's full-sized avatar

Son Tran trandaison

View GitHub Profile
@trandaison
trandaison / cw-dark-mode.vue
Last active September 25, 2019 04:52
Chatwork dark mode
<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>
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);
[user]
name = Son Tran
email = [email protected]
[alias]
s = status
ck = checkout
l1l = log --oneline
br = branch
@trandaison
trandaison / .gitconfig
Created April 4, 2019 14:26
.gitconfig aliases `~/.gitconfig`
[user]
name = Son Tran
email = [email protected]
[alias]
s = status
ck = checkout
l1l = log --oneline
br = branch
@trandaison
trandaison / script.js
Created March 18, 2019 01:28
Redmine hide sidebar
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 December 17, 2018 01:03
Redmine Toggle sidebar
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 October 7, 2018 12:40 — forked from virolea/upload.js
Tracking file upload progress using axios
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])
@trandaison
trandaison / nginx-options-request.conf
Created October 6, 2018 03:33 — forked from james2doyle/nginx-options-request.conf
A Nginx conf for handling OPTIONS request for functions like window.fetch
server {
# ...
# handle OPTIONS requests from window.fetch
if ($request_method = OPTIONS ) {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, OPTIONS";
add_header Access-Control-Allow-Headers "Authorization,content-type";
add_header Access-Control-Allow-Credentials "true";
@trandaison
trandaison / default.conf
Created August 30, 2018 13:54
NGiNX Configuration for Vue-Router in HTML5 Mode
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
server_name you.server.com;
@trandaison
trandaison / geotool.js
Created June 15, 2018 04:06 — forked from Craftworks/geotool.js
測地系変換ライブラリ(WGS <=> TKY, degree <=> dms)
//------------------------------------------------------------------------------
// geotool.js - version 1.0.0
//
// Copyright (c) 2005 Craftworks Corp. All Right Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//