Skip to content

Instantly share code, notes, and snippets.

View XianYeeXing's full-sized avatar

XianYeeXing XianYeeXing

View GitHub Profile
@XianYeeXing
XianYeeXing / no-coflict-series.js
Created April 9, 2020 07:32
不斷地取出與上一次不重複的元素
/**
* EXAMPLE:
* const factory = require('no-coflict-series');
*
* const series = factory([1, 4, 3, 2, 7]);
*
* console.log( series.next() );
* console.log( series.next() );
* console.log( series.next() );
* console.log( series.next() );
const convertTimestampToDateStr = timestamp => {
let d = new Date(timestamp),
yyyy = d.getFullYear(),
mm = ('0' + (d.getMonth() + 1)).slice(-2),
dd = ('0' + d.getDate()).slice(-2),
hh = d.getHours(),
h = hh,
min = ('0' + d.getMinutes()).slice(-2),
ampm = 'AM';
/**
* USAGE:
* const scrollTo = require('../lib/animated-scroll-to');
* scrollTo(window.innerHeight, {speed: 1000, elemrnt: window});
*/
(function() {
'use strict';
// desiredOffset - page offset to scroll to
// speed - duration of the scroll per 1000px
/// 參看文件: https://felgo.com/doc/felgo-different-screen-sizes
/**
* Bg Manager
*
* PROPS
* =====
*
* speed {number}
*
@XianYeeXing
XianYeeXing / exampleDomStyeUpdate.js
Created March 29, 2019 11:05
Example of updating dom style
let _el = null;
const _getEl = sel => {
if(_el === null) {
_el = document.querySelector(sel);
}
return _el;
}
module.exports = opts => {
<script>
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.ProgressBar=a()}}(function(){var a;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(b,c,d){(function(){var b=this||Function("return this")(),e=function(){"use strict";function e(){}function f(a,b){var c;for(c in a)Object.hasOwnProperty.call(a,c)&&b(c)}function g(a,b){return f(b,function(c){a[c]=b[c]}),a}function h(a,b){f(b,function(c){"unde
/**
* EXAMPLE:
*
* /// HTML:
* <div.app-loading>
* <div.app-loading__backing>
* <img.app-loading__img src='https://media0.giphy.com/media/aFTt8wvDtqKCQ/giphy.gif?cid=3640f6095c35e19e7366515351ade54e'/>
* <div.app-loading__txts>
* <span.app-loading__txts__desp></span>
* <span.app-loading__txts__cnt></span>%
@XianYeeXing
XianYeeXing / svgToPng.js
Last active May 16, 2024 15:45
Convert SVG (data url) into PNG (data url) and scale it to the desired size.
/*
EXAMPLE
=======
svgToPng(
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgaGVpZ2h0PSczMDBweCcgd2lkdGg9JzMwMHB4JyAgZmlsbD0iIzAwMDAwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCA1LjU1NiAxMDAgODguODg5IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgNS41NTYgMTAwIDg4Ljg4OSIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PGc+PHBhdGggZD0iTTkwLDE2LjY2N1Y1LjU1Nkg1NS41NTZ2MTEuMTExSDQ0LjQ0NFY1LjU1NkgxMHYxMS4xMTFINy42NDFIMFY1MGg3LjY0MUgxMHYxMi4yMjNoMTEuMTExdjEwaDExLjExMXYxMi4yMjJoMTEuMTExdjEwDQoJCWgxMy4zMzN2LTEwaDExLjExVjcyLjIyM2gwLjk5NGgxMC4xMTd2LTEwSDkwVjUwaDIuMjgzSDEwMFYxNi42NjcgTTI0LjQ0NCwyOS4wMTZ2MTIuMDk2SDExLjExMVYyOS4wMTZWMTcuNzc4aDEzLjMzM1YyOS4wMTZ6Ij48L3BhdGg+PC9nPjwvc3ZnPg==',
65,
65
)
.then(console.log);