Skip to content

Instantly share code, notes, and snippets.

Herwindo Artono winndo

View GitHub Profile
@winndo
winndo / load.js
Created Apr 18, 2019
Critical Path
View load.js
function loadStylesheet(src) {
if (document.createStylesheet) {
document.createStylesheet(src);
} else {
const linkTag = document.createElement('link');
linkTag.rel = "stylesheet";
linkTag.type = "text/css";
linkTag.href = src;
document.getElementsByTagName('head')[0].appendChild(linkTag);
}
@winndo
winndo / index.html
Created Feb 11, 2019
Responsive iFrame
View index.html
<!doctype html>
<html>
<head>
<title>Responsive iFrame</title>
<style>
.resp-iframe {}
.resp-iframe__container {
position: relative;
overflow: hidden;
padding-top: 56.25%; // video ratio 9 / 16 = 0.5625 ~ 56.25% change this according video ratio
@winndo
winndo / telephoneCheck.js
Created Sep 22, 2018
Javascript Telephone Number Validator
View telephoneCheck.js
function telephoneCheck(strPhoneNumber) {
let phonePattern = /^\d{10}$|^(1{1}[ ]?)?((\(\d{3}\) ?)|(\d{3}))[- ]?\d{3}[- ]\d{4}$/;
return phonePattern.test(strPhoneNumber);
}
// telephoneCheck("555-555-5555"); // --> true
@winndo
winndo / diagonal-stripe.css
Created Aug 11, 2018
a repeating gradient that make diagonal stripe
View diagonal-stripe.css
.diagonal-stripe {
background: repeating-linear-gradient(
45deg,
yellow 0px,
yellow 40px,
black 40px,
black 80px
);
}
@winndo
winndo / package.json
Created Aug 5, 2018
basic-webpack-scss
View package.json
{
"name": "basic-webpack-scss",
"version": "1.0.0",
"description": "Minimum Webpack SCSS for development",
"main": "",
"scripts": {
"build": "webpack --watch",
"start": "webpack-dev-server --open"
},
"author": "Herwindo Artono",
@winndo
winndo / package.json
Created Jul 29, 2018
Basic webpack config with scss support
View package.json
{
"name": "basic-webpack-config-windo",
"sideEffects": [
"*.css"
],
"version": "0.0.1",
"description": "",
"private": true,
"main": "index.js",
"scripts": {
View rethinkdb_restore.sh
# https://stackoverflow.com/questions/40505481/error-when-launching-rethinkdb-restore-no-such-file-or-director/51242048#51242048
python -mrethinkdb._restore #FILE
View addItem.js
/**
* addItem
* adding item into existing array by matching id
*/
function addItem(item, currentArrayOfItem) {
let exist = currentArrayOfItem.find(_item => _item.id === item.id);
if (exist) {
let index = currentArrayOfItem.indexOf(exist);
currentArrayOfItem.splice(index, 1, item); // reason: reactivity
} else {
@winndo
winndo / checkStringIsXML.js
Last active Jun 6, 2018
simple js function to check if a string is XML using Regular Expression
View checkStringIsXML.js
function checkStringIsXML(data) {
var matcher = new RegExp('<?xml');
return data.match(matcher) ? true : false;
}
View msNow.ts
/**
* msNow
* UNIX timestamp in javascript
*/
function msNow(): number {
return (new Date()).getTime();
}
You can’t perform that action at this time.