Skip to content

Instantly share code, notes, and snippets.

@valerykalashnikov
valerykalashnikov / rails_projects_bootstrap
Last active August 29, 2015 14:14
Typical rails project installation
#!/bin/bash
# The output of all these installation steps is noisy. With this utility
# the progress report is nice and concise.
function install {
echo installing $1
shift
apt-get -y install "$@" >/dev/null 2>&1
}
@valerykalashnikov
valerykalashnikov / LocalStorageCache.js
Last active August 29, 2015 13:57
LocalStorageCache
var cache = (function() {
'use strict';
var TTL_POSTFIX = 'time2live';
var TTE_POSTFIX = 'time2expire';
function _hasLocalStorage() {
if (!window.localStorage) {
throw new Error('you have no localStorage');
}
}
function _removeCachedKey(key) {
var onFileSystemError = function onFileSystemError() {
alert('the was an error during access to filesystem');
};
var remove_file = function(entry) {
entry.remove(function() {
self.model.remove();
self.model.set('synced',false);
self.render();
}, onFileSystemError);
};
@valerykalashnikov
valerykalashnikov / phonegap_download_file_example.html
Last active January 4, 2016 13:39
Example how to download files via http using phonegap
<!DOCTYPE html>
<html>
<head>
<!-- Set the viewport to show the page at a scale of 1.0, and make it non-scalable -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<script src="cordova.js"></script>
</head>
<body>
@valerykalashnikov
valerykalashnikov / js_precommit_hook
Last active October 4, 2018 08:13
Precommit hook to prevent console.log, debugger and binding.pry
#!/bin/bash
#Precommit hook to prevent "debugger" and "console.log"
#Note: to enamble precommit on Windows machine don't forget add path to Git\bin and Git\cmd to PATH environment variable
count=0
for FILE in `git diff-index --name-status HEAD -- | cut -c3-` ; do
# Check if the file contains 'debugger' or 'console.log'
contains=`grep -e "debugger" -e "console\.log" -e "binding\.pry" $FILE`
if [ `grep -e "debugger" -e "console\.log" -e "binding\.pry" $FILE|wc -l` -ne 0 ]