Skip to content

Instantly share code, notes, and snippets.

View mcseptian's full-sized avatar
🏠
Working from home

Septian Adi mcseptian

🏠
Working from home
View GitHub Profile
@SangsooNam
SangsooNam / gh-pages-deploy.sh
Created January 6, 2019 23:11
Script to deploy a target directory to `gh-pages` branch.
#!/bin/bash
directory=_site
branch=gh-pages
build_command() {
jekyll build
}
echo -e "\033[0;32mDeleting old content...\033[0m"
rm -rf $directory
/* --------------------------------
Typography
-------------------------------- */
:root {
--font-primary: sans-serif;
--font-secondary: serif;
@renoirb
renoirb / extractcss.js
Last active January 20, 2020 10:19
Extract CSS for a given element
/**
* Based on work from krasimirtsonev
*
* http://krasimirtsonev.com/blog/article/csssteal-chrome-extension-that-extracts-css
*/
// helper function for transforming
// node.children to Array
function toArray (obj, ignoreFalsy) {
var arr = [], i;
const copyToClipboard = str => {
const el = document.createElement('textarea'); // Create a <textarea> element
el.value = str; // Set its value to the string that you want copied
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
el.style.position = 'absolute';
el.style.left = '-9999px'; // Move outside the screen to make it invisible
document.body.appendChild(el); // Append the <textarea> element to the HTML document
const selected =
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
? document.getSelection().getRangeAt(0) // Store selection if found
@victor-homyakov
victor-homyakov / detect-unused-css-selectors.js
Last active February 17, 2023 18:36
Detect unused CSS selectors. Show possible CSS duplicates. Monitor realtime CSS usage.
/* eslint-disable no-var,no-console */
// detect unused CSS selectors
(function() {
var parsedRules = parseCssRules();
console.log('Parsed CSS rules:', parsedRules);
detectDuplicateSelectors(parsedRules);
var selectorsToTrack = getSelectorsToTrack(parsedRules);
window.selectorStats = { unused: [], added: [], removed: [] };
console.log('Tracking style usage (inspect window.selectorStats for details)...');
@anthrotype
anthrotype / svg2glif.py
Created September 8, 2017 13:02
svg2glif: convert SVG paths to UFO glyphs
#!/usr/bin/env python
""" Convert SVG paths to UFO glyphs.
"""
# Author: Cosimo Lupo
# Email: cosimo@anthrotype.com
# License: Apache Software License 2.0
from __future__ import print_function, absolute_import
__requires__ = ["svg.path", "ufoLib", "FontTools"]
@guilhermejcgois
guilhermejcgois / getStyle.ts
Last active July 20, 2023 11:38
Get computed styles (in typescript)
// Gist adapted from: https://gist.github.com/cms/369133
export getStyle(el: Element, styleProp: string): string {
let value;
const defaultView = el.ownerDocument.defaultView;
// W3C standard way:
if (defaultView && defaultView.getComputedStyle) {
// sanitize property name to css notation (hypen separated words eg. font-Size)
styleProp = styleProp.replace(/([A-Z])/g, '-$1').toLowerCase();
return defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
} else if (el['currentStyle']) { // IE
@joelcardinal
joelcardinal / getCssData.js
Last active May 23, 2019 09:55
Lists pages stylesheet/inline CSS. Also reports CSS selectors used on page from stylesheet/inline and inline JS.
/*
TODO: add check for used Font Family, refactor
*/
(function getStyleSheetsCssData(){
var styleSheets = document.styleSheets,
data = {
cssData : {
allUsedSelectorText : []
},
jsData : []
@netsi1964
netsi1964 / ChromeGetUsedClassesAsCSS.js
Created December 1, 2016 10:56
Chrome developer toolbar util: Get CSS containing used CSS classes used below a specified selector
var allClasses = {}, css = '';
var startFrom = prompt('Where should I start?', '#application');
Array.prototype.forEach.call(document.querySelectorAll(startFrom+' *[class]'), function(element) {
Array.prototype.forEach.call(element.classList, function(className) {
if (!allClasses[className]) {
allClasses[className] = 0;
}
allClasses[className]++;
})
});
@thegitfather
thegitfather / vanilla-js-cheatsheet.md
Last active July 16, 2024 15:33
Vanilla JavaScript Quick Reference / Cheatsheet