Skip to content

Instantly share code, notes, and snippets.

View mahish's full-sized avatar

Jiří Maha mahish

View GitHub Profile
@mahish
mahish / gist:0747ffec3bb39834f6546fc9ee4f4b9e
Created June 30, 2017 21:51 — forked from bradwestfall/gist:f5a010e96fb0c4d18556
Pull Instagram Images via JavaScript
@mahish
mahish / multiline-values.yaml
Created November 8, 2016 12:14 — forked from rjattrill/multiline-values.yaml
Break YAML over multiple lines
# Join multiple lines without new line
value: >
part 1
part 2
# Join with newline
value2: |
line 1
line 2
@mahish
mahish / dom-ready.js
Created October 25, 2016 08:15
DOM ready
// https://www.sitepoint.com/jquery-document-ready-plain-javascript/
var callback = function(){
// Handler when the DOM is fully loaded
};
if (
document.readyState === "complete" ||
(document.readyState !== "loading" && !document.documentElement.doScroll)
) {
callback();
@mahish
mahish / detect-os.js
Last active August 1, 2016 14:22
OS detection
// browser
var nAgt = navigator.userAgent;
// system
var os = unknown;
var clientStrings = [
{s:'Windows 10', r:/(Windows 10.0|Windows NT 10.0)/},
{s:'Windows 8.1', r:/(Windows 8.1|Windows NT 6.3)/},
{s:'Windows 8', r:/(Windows 8|Windows NT 6.2)/},
{s:'Windows 7', r:/(Windows 7|Windows NT 6.1)/},
@mahish
mahish / detect.js
Last active August 1, 2016 14:22
browser & os detect
/**
* JavaScript Client Detection
* (C) viazenetti GmbH (Christian Ludwig)
* http://jsfiddle.net/ChristianL/AVyND/
*/
(function (window) {
{
var unknown = '-';
// // screen
@mahish
mahish / detect-feature.js
Last active August 1, 2016 14:22
browser feature detection function
/**
* Gets the browser name or returns an empty string if unknown.
* This function also caches the result to provide for any
* future calls this function has.
* http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser#answer-31479176
*
* @returns {string}
*/
var browser = function() {
// Return cached result if avalible, else get result then cache it.
@mahish
mahish / _variables.scss
Last active May 30, 2016 20:30
easy breakpoint scaling of everything on website with one size change only
// Breakpoints
$screen-sm: 500px;
$screen-md: 768px;
$screen-lg: 1024px;
$screen-lg: 1500px;
// Font Sizes
$base-font-size: 1rem;
$base-font-sizes: (
null : 1rem,
@mahish
mahish / Default (OSX).sublime-keymap
Last active May 30, 2016 20:25
Sublime Text 3 settings
[
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} },
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
{
"keys": ["super+alt+shift+f"], // create your own key command combination here!
"command": "html_beautify", // command that executes html_beautify
"context": [{
// these options ensure that the command is executed in the right files/context
"key": "selector",
@mahish
mahish / svg2png.js
Created May 12, 2016 13:18 — forked from gustavohenke/svg2png.js
SVG to PNG
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
$(document).ready(function() {
// https://medium.com/@mariusc23/hide-header-on-scroll-down-show-on-scroll-up-67bbaae9a78c#.jim2ghyzy
// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('body > header').outerHeight();
$(window).scroll(function(event){