Skip to content

Instantly share code, notes, and snippets.

@peponi
peponi / is.js
Created Dec 3, 2018
is.js - es6
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';
}
})()
View frontend_editing
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<style>
.edit{width: 100px;margin-left:20px;}
input
{
You can’t perform that action at this time.