Skip to content

Instantly share code, notes, and snippets.

Peponi peponi

Block or report user

Report or block peponi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@peponi
peponi / details.polyfill.js
Last active May 6, 2019
details element polyfill for IE11, supoorts elements inside summary
View details.polyfill.js
/**
* based on
* @url https://github.com/rstacruz/details-polyfill
* @todo https://www.sitepoint.com/fixing-the-details-element/
* @todo https://www.smashingmagazine.com/2014/11/complete-polyfill-html5-details-element/
*/
const detailsPolyfillEs6 = ({
CSS_CLASS = 'no-details',
CSS_STRING = false,
@peponi
peponi / is.js
Last active May 6, 2019
is.js - es6 - just browser detection, nothing elese
View is.js
// based on https://github.com/arasatasaygin/is.js/blob/master/is.js
// this is a cut off minimal version
const userAgent = (navigator && navigator.userAgent.toLowerCase()) || '';
const vendor = (navigator && navigator.vendor || '').toLowerCase();
// build a 'comparator' object for various comparison checks
const comparator = {
'<': (a, b) => a < b,
'<=': (a, b) => a <= b,
View crappyStore.js
const l = localStorage
const crappyStore = {
get: (key) => JSON.parse(l.getItem(key)),
set: (key, data) => l.setItem(key, JSON.stringify(data)),
rm: (key) => l.removeItem(key),
getKeysFor: (prefix) => {
const ret = []
for (let key in l) {
ret.push(key)
@peponi
peponi / store.js
Created Oct 2, 2018
simple one level immutable store object
View store.js
const store = {
storageIndex: undefined,
debug: false,
state: Object.freeze({
}),
setState(keyword, value) {
if (this.debug) console.log(`STATE: ${keyword}:`, value); // eslint-disable-line no-console
const newObject = Object.assign({}, this.state, { [keyword]: value });
this.state = Object.freeze(newObject);
if (this.storageIndex) localStorage.setItem(this.storageIndex, JSON.stringify(newObject));
@peponi
peponi / device_metrics.scss
Created Jan 19, 2016
lsit of constans for device metrics ios & android
View device_metrics.scss
/* GENERAL DEVICE CONSTANTS
##################################################################################################################### */
/*
* iOS
*/
// iOS metrics
$ios-status-bar-height: em-calc(20);
$ios-nav-bar-height: em-calc(44);
@peponi
peponi / gulp-task-to-create-git-tags.js
Created Jan 13, 2016
a simple gulp task to set & overwrite git tags on remote
View gulp-task-to-create-git-tags.js
// set a git tag & overwrite if already set
gulp.task('push-tag', function(cb) {
if(process.argv[3] !== '--tag' ) {
console.error('ERROR: no "--tag" parameter found');
} else if (process.argv[4] == undefined ) {
console.error('ERROR: no tag name found in parameter');
} else {
exec( 'git tag -d ' + process.argv[4] +
';git push origin :refs/tags/' + process.argv[4] +
@peponi
peponi / detect-orientation.js
Created Jan 13, 2016
A small helper, which detects orientation of viewport. Sets 'is-landscape' or 'is-portrait' to the html element.
View detect-orientation.js
'use strict';
(function(){
window.NIJS = window.NIJS || {};
NIJS.detection = NIJS.detection || {};
var html = document.getElementsByTagName('html')[0],
removeClass = function(str, className){
var classArr = str.split(' '),
@peponi
peponi / detect-android-stock-browser.js
Created Jan 13, 2016
detect android stock browser. Adds class "is-android-stock-browser" to the html element. You will need this only in rare cases. For example: text-rendering bug with webfonts in Android 4.x.
View detect-android-stock-browser.js
(function(){
/*
Use this only if really really necessary.
This plugin tries to detect android stock browser.
Place it in the head tag. And after Modernizr.
https://developer.chrome.com/multidevice/user-agent#webview_user_agent
*/
@peponi
peponi / detect-IE.js
Created Jan 13, 2016
detect any IE Browser. checks for ActiveXObject which is exclusively available on IE. Works for IE5 -11. Use only when feature detection won't give desired results.
View detect-IE.js
//place script in head and after modernizr.
(function(){
var html = document.getElementsByTagName('HTML')[0];
if("ActiveXObject" in window){
html.className += ' is-IE';
}
})()
You can’t perform that action at this time.