Skip to content

Instantly share code, notes, and snippets.

View lackneets's full-sized avatar
🤗
Sorry I am super busy. I may respond in weeks or months

Lackneets Chang (小耀博士) lackneets

🤗
Sorry I am super busy. I may respond in weeks or months
  • TAROBO Investment Advisors Ltd.
  • Taipei, Taiwan
View GitHub Profile
@lackneets
lackneets / tasks.js
Created February 5, 2021 07:03
Promise One by One
(() => {
var p1 = (val) => new Promise((resolve, reject) => {
console.log('sent process 1')
setTimeout((val) => {
console.log('done1')
resolve(val)
}, 100, 'one');
});
var p2 = (val) => new Promise((resolve, reject) => {
console.log('sent process 2')
<!--[if IE]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-sham.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-sham.min.js"></script>
<script src="https://wzrd.in/standalone/es7-shim@latest"></script>
<![endif]-->
@lackneets
lackneets / shuffle-2.js
Last active May 21, 2019 08:01
混淆數值
function shuffle(obj, key){
if(['order', 'type', 'sector_1_id', 'sector_2_id', 'id'].includes(key)){
return obj
}
if(['name'].includes(key)){
return '明天無限美好'
}
if(['sub_funds', 'score_rating_intervals'].includes(key)){
return []
}
@lackneets
lackneets / cloudSettings
Last active May 11, 2021 05:53
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-05-11T05:53:17.745Z","extensionVersion":"v3.4.3"}
// Add to application.js
$("body").bind("ajaxSend", function(elm, xhr, s){
if (s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
}
});
// OR
@lackneets
lackneets / gasoline.json
Created December 20, 2017 05:22
2017/12/20 汽油歷史價格
[
["2017/12/18",26.3,27.8,29.8,24.1,0,0,16.893,11.978,0,0,0,0],
["2017/12/13",0,0,0,0,0,37.7,0,0,0,0,0,0],
["2017/12/11",26.1,27.6,29.6,23.9,0,0,16.693,11.778,0,0,0,0],
["2017/12/06",0,0,0,0,0,0,0,0,12.812,13.993,0,0],
["2017/12/04",0,0,0,24.1,0,0,16.893,11.978,0,0,0,0],
["2017/11/29",0,0,0,0,0,38.6,0,0,0,0,0,0],
["2017/11/27",26.2,27.7,29.7,24.0,0,0,16.793,11.878,0,0,0,0],
["2017/11/22",0,0,0,0,0,38.0,0,0,0,0,0,0],
["2017/11/20",26.1,27.6,29.6,23.9,0,0,16.693,11.778,0,0,0,0],
@lackneets
lackneets / getScrollbarWidth.js
Created November 10, 2016 07:43
from bootstrap modal
function getScrollbarWidth(){
var scrollDiv = document.createElement('div');
scrollDiv.style.position = 'absolute';
scrollDiv.style.top = '-9999px';
scrollDiv.style.width = '50px';
scrollDiv.style.height = '50px';
scrollDiv.style.overflow= 'scroll';
document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
@lackneets
lackneets / radar-chart.js
Last active January 15, 2020 13:09
ChartJS Radar Chart Example
var ctx = document.getElementById('radar-chart').getContext('2d');
var data = {
labels : ["January","February","March","April","May"],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
data : [65,59,90,81,56]
},
{
@lackneets
lackneets / poke.js
Created October 28, 2016 03:24
Facebook auto poke all
// https://www.facebook.com/pokes/?notif_t=poke
setInterval(function(){
var cancel = document.querySelector('a[autofocus][action=cancel]');
cancel && cancel.click();
var poke = document.querySelector('a[ajaxify*="/pokes/inline/"]:not(.saving)');
poke && poke.click();
}, 1000);
@lackneets
lackneets / iframe-responsive-beta.js
Created October 20, 2016 06:40
iframe-responsive-beta.js
/*
iFrameResponsive.js
by Lackneets Chang < [email protected] >
*/
(function(){
// Polyfill
// http://javascript.boxsheep.com/polyfills/Array-prototype-forEach/
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (fn, arg) {