Skip to content

Instantly share code, notes, and snippets.

View mladenp's full-sized avatar

Mladen Petrović mladenp

View GitHub Profile
@mladenp
mladenp / ng-filter_limit_lenght
Created September 8, 2015 09:44
Angular Filter - Limit string length
.filter('cut', function(){
return function (value, wordwise, max, tail) {
if (!value) return '';
max = parseInt(max, 10);
if (!max) return value;
if (value.length <= max) return value;
value = value.substr(0, max);
if (wordwise) {
@mladenp
mladenp / android-keystore-cert
Created May 8, 2015 10:21
Get Android Keystore Certificate
Linux:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Windows:
keytool -list -v -keystore %USERPROFILE%/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
@mladenp
mladenp / SQLite-wrapper
Created November 27, 2014 13:25
SQLite wrapper for phonegap
.factory('DB', function ($q, $http, DB_CONFIG) {
var self = this;
self.db = null;
/*self.db_open = function () {
self.db = window.sqlitePlugin.openDatabase({name: DB_CONFIG.name, bgType: 1});
};*/
self.db_open =function(){
var def = $q.defer();
@mladenp
mladenp / leverage-cache
Created June 29, 2014 00:11
Leverage browser cache .htaccess
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
@mladenp
mladenp / wp-class2body
Created May 30, 2014 11:49
Add class to body of WP
// category id in body and post class
function category_id_class($classes) {
global $post;
foreach((get_the_category($post->ID)) as $category)
$classes [] = 'cat-' . $category->cat_ID . '-id';
return $classes;
}
add_filter('post_class', 'category_id_class');
add_filter('body_class', 'category_id_class');