Skip to content

Instantly share code, notes, and snippets.

View mahish's full-sized avatar

Jiří Maha mahish

View GitHub Profile

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mahish
mahish / index.html
Created October 23, 2015 20:14 — forked from flesler/index.html
Anchor navigation powered by jquery.scrollTo
<!-- Include jQuery from somewhere, must use version 1.8 or above -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include latest jquery.scrollTo, currently 2.1.0, can download from https://github.com/flesler/jquery.scrollTo/releases -->
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.scrollto/2.1.0/jquery.scrollTo.min.js"></script>
<!-- Initialize the plugin, the contents of the script can be inlined here, of course -->
<script type="text/javascript" src="js/init.js"></script>
@mahish
mahish / Video cover
Created December 12, 2015 12:11
Set size of a video to fill a hero wrapper
// set size of the video to fill the hero wrapper
if (ratio >= vidratio) {
$(video).css({
minHeight: '',
height: '',
minWidth: windowwidth,
width: '100%'
});
} else {
$(video).css({
var gulp = require('gulp');
// css modules
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var cssnano = require('gulp-cssnano');
// js modules
var jsminify = require('gulp-uglify');
var jshint = require('gulp-jshint');
@mahish
mahish / Hypermiling.md
Last active December 14, 2015 13:18
publishing workflow base on https://micah.codes/
  • Blog articles written in Markdown
  • Source code pushed to Github repo
  • TravisCI checks out master and compiles site using NodeJS based static site generator, Metalsmith
  • Dist folder is automatically pushed to Amazon S3
  • Cloudflare CDN is instructed to clear cache and pull new assets forward
  • Static site is served to client over HTTPS using HTTP/2 from the nearest Cloudflare CDN
$(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){
@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() {
@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 / _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 / 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.