Skip to content

Instantly share code, notes, and snippets.

View vermilion1's full-sized avatar

Vitalii Petrychuk vermilion1

View GitHub Profile
@vermilion1
vermilion1 / gist:4257182
Created December 11, 2012 09:00
CSS animation plugin
/*!
* CSS animation plugin
* Copyright 2012, Vitaliy Petrychuk
*/
;(function ($, _) {
// usage
// 1! register ($el - jQuery element)
// 2. setAnimationClass || onAnimationStart || onAnimationEnd
@vermilion1
vermilion1 / gist:4296485
Last active December 9, 2015 16:28
Log plugin
/*!
* Log plugin
* Copyright 2012, Vitaliy Petrychuk
*/
;(function(window) {
var log = function() {
if (window.debug_mode) {
var stack = (new Error).stack;
@vermilion1
vermilion1 / KeyBoardPlugin.java
Last active December 9, 2015 19:39
Cordova Android Keyboard Plugin
package com.LALALA;
import org.json.JSONArray;
import org.json.JSONException;
import android.content.Context;
import android.view.KeyEvent;
import android.view.inputmethod.InputMethodManager;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
@vermilion1
vermilion1 / .gitconfig
Last active December 10, 2015 08:09
dotfiles
[user]
name = Vitalii Petrychuk
email = vitaliy@petrychuk.com
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[color]
@vermilion1
vermilion1 / gist:5379524
Last active December 16, 2015 04:49
Substitute
/**
* Substitute {d} with passed arguments
* @example substitute('key is {0} and value is {1}', 'some_key', 'some_value');
* @param string {String} initial string
* @returns {String} modified string
*/
var substitute = function (string) {
if (!string) {
return '';
}
@vermilion1
vermilion1 / gist:5525972
Last active December 17, 2015 01:09
Override Marionette route to have ability to pass different controllers to the single router
Marionette.AppRouter.prototype.processAppRoutes = function(controller, appRoutes) {
var routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes
_.each(routeNames, function(route) {
var methodName = appRoutes[route];
var params = methodName.split('#');
var ctrl = controller;
var method;
if (params.length > 1) {
@vermilion1
vermilion1 / gist:7484817
Last active December 28, 2015 10:09
Print image
var makePrint = function (win, src) {
if (!src) {
win = window.open();
src = win;
}
var add = function () {
var img = win.document.createElement('img');
var style = win.document.createElement('style');
style.setAttribute('media', 'all');
style.innerHTML = '@page{size:auto;margin:0;}body{border:0;background:#fff;margin:0;padding:0;}img{max-width:100%;max-height:100%;margin:0;display:block;}';
@vermilion1
vermilion1 / gist:7583811
Created November 21, 2013 15:38
Print image
@page {
size: auto;
margin: 0;
}
@media screen, print {
html,
body {
height: 100%;
}
body {
/*global define */
/*jshint expr:true */
define([], function () {
'use strict';
var hasLocalStorageSupport = (function () {
var str = 'storage-test-' + Math.random();
try {
@vermilion1
vermilion1 / gist:af0a9acbcd24edcdc82c
Created August 21, 2014 17:38
Update search parameter
/**
* Update the param value of the passed URI.
* In case parameter wasn't found we have to add it.
* @param {string} uri - URI.
* @param {string} key - Parameter name.
* @param {string} value - Parameter value.
* @returns {string} Updated URI.
*/
var updateQueryStringParameter = function (uri, key, value) {
var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');