Skip to content

Instantly share code, notes, and snippets.

View mladenp's full-sized avatar

Mladen Petrović mladenp

View GitHub Profile
@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');
@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 / 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 / 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 / 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 / 0_reuse_code.js
Created October 13, 2015 00:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mladenp
mladenp / generate-hash-4-debug
Created October 20, 2015 13:35
Android key hashes get
// Windows - inside c:\openssl\bin
keytool -exportcert -alias androiddebugkey -keystore debug.keystore | ".\openssl.exe" sha1 -binary | ".\openssl.exe" base64
@mladenp
mladenp / cordova-dir-ls
Created December 7, 2015 22:28
cordova list all dirs
function listDir(path){
window.resolveLocalFileSystemURL(path,
function (fileSystem) {
var reader = fileSystem.createReader();
reader.readEntries(
function (entries) {
console.log(entries);
},
function (err) {
console.log(err);
@mladenp
mladenp / list-pckg-get-apk
Created January 4, 2016 11:05
List android packages and get APK path
adb shell pm list packages
adb shell pm path com.example.app
@mladenp
mladenp / console.save.2.file.js
Last active March 3, 2016 10:21
Console.save File Download
// Console.save
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}