Skip to content

Instantly share code, notes, and snippets.

View dsadhanala's full-sized avatar
💭
I may be slow to respond.

Durga Prasad Sadhanala dsadhanala

💭
I may be slow to respond.
  • Google
View GitHub Profile
@dsadhanala
dsadhanala / Jade: list iteration on a object
Last active August 29, 2015 14:10
Jade Snippet: Navigation iterator
//- compile and see the output online at below URL
http://jade-lang.com/
//- navigation data
-var navLinks = { 'Home': 'home.html', 'About': 'about.html', 'Services': 'services.html', 'Contact': 'contact.html'};
//- set default selected item (useful for adding active state for current page navigation link in each page)
- var activeLink = 'Home';
nav(role="navigation" aria-label="Primary")
@dsadhanala
dsadhanala / markup.html
Last active October 5, 2015 01:55
Flex box Sample
<div class="flex-row">
<div class="flex-col"></div>
<div class="flex-col"></div>
<div class="flex-col"></div>
<div class="flex-col"></div>
<div class="flex-col"></div>
<div class="flex-col"></div>
<div class="flex-col"></div>
<div class="flex-col"></div>
<div class="flex-col"></div>
@dsadhanala
dsadhanala / Jade: Table iteration
Last active August 9, 2016 19:20
Jade Snippet: Table iterator
//- compile and see the output online at below URL
http://jade-lang.com/
//- table data
- var tableData = [['R1 Col1', 'R1 Col2', 'R1 Col3'], ['R2 Col1', 'R2 Col2', 'R2 Col3'], ['R3 Col1', 'R3 Col2', 'R3 Col3'], ['R4 Col1', 'R4 Col2', 'R4 Col3'], ['R5 Col1', 'R5 Col2', 'R5 Col3']]
//- table markup
table.table
//- table head
tr.t-head
//- compile and see the output online at below URL
http://jade-lang.com/
-var menu = [{link_icon: 'icon sample1', link_text: 'Link1', link_url : 'link1.html'},{link_icon: 'icon sample2', link_text: 'Link2', link_url : 'link2.html'}, {link_icon: 'icon sample3', link_text: 'Link2', link_url : 'link2.html'}];
- var menuactive = "";
//- add page level variable "page.mpMenuSelected"
- var mpMenuSelected = "Link1";
@dsadhanala
dsadhanala / basicHTML-setup
Last active February 9, 2018 19:43
setup browser env in node with basicHTML
// setup browser env
const { Document, HTMLElement } = require('basichtml');
global.window = global;
global.document = new Document();
global.customElements = document.customElements;
global.HTMLElement = HTMLElement;
// mock missing api
document.importNode = (node, deep) => node.cloneNode(deep);
global.requestAnimationFrame = (callback) => setTimeout(callback, 0);
@dsadhanala
dsadhanala / JSDOM-setup
Created February 9, 2018 19:45
setup browser env in node with JSDOM
// setup browser env
const jsdom = require("jsdom@11.5.1");
const { JSDOM } = jsdom;
const doc = new JSDOM(`<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>`);
global.window = doc.window;
global.document = window.document;
// mock missing api
document.importNode = (node, deep) => node.cloneNode(deep);
global.requestAnimationFrame = (callback) => setTimeout(callback, 0);
@dsadhanala
dsadhanala / webpack-config.js
Last active March 20, 2018 03:49
webpack 4.x chunks config
const path = require('path');
const lodash = require('lodash');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const pkg = require(path.join(process.cwd(), 'package.json'));
const ENV = process.env.NODE_ENV || 'development';
const isProd = (ENV === 'production');
@dsadhanala
dsadhanala / index.html
Last active April 17, 2018 02:33
Simple component example and comparison using `baseui-wc-base-component`
<p>Click on each header element to see number of clicks updated
<header-text-base text="Rendered with base-custom-element"></header-text-base>
<header-text-lit text="Rendered with lit-html"></header-text-lit>
<header-text-hyper text="Rendered with hyper-html"></header-text-hyper>
@dsadhanala
dsadhanala / index.js
Last active December 16, 2018 05:09
Auto deploy dist folder to gh-pages
#!/usr/bin/env node
/**
* automated gh-pages deployment
*/
const path = require('path');
const shell = require('shelljs');
const { which, echo, exit, exec, cd, mkdir, rm } = shell;
const distRoot = 'dist';
@dsadhanala
dsadhanala / image from blob
Created August 12, 2019 10:17
Image blob to console
const image = new Image();
image.src = URL.createObjectURL(imageElement);
console.info('imageElement', image.src);