Skip to content

Instantly share code, notes, and snippets.

View mladenp's full-sized avatar

Mladen Petrović mladenp

View GitHub Profile
@mladenp
mladenp / win-cmd-del-all-svn-files
Created August 5, 2016 14:28
Win cmd delete all .svn files
FOR /R FOLDERNAME %X IN (.svn) DO (RD /S /Q "%X" 2>nul)
@mladenp
mladenp / generate-hash-android-debug
Created July 28, 2016 20:52
Generate hash key for android debug
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
@mladenp
mladenp / JOSN_escapeSpecialChars
Created July 15, 2016 11:22
JSON parse escape special characters
function escapeSpecialChars(jsonString) {
return jsonString.replace(/\n/g, "\\n")
.replace(/\r/g, "\\r")
.replace(/\t/g, "\\t")
.replace(/\f/g, "\\f");
}
@mladenp
mladenp / ng-editableContent
Created June 3, 2016 10:00
Angular directive editable content
.directive('contenteditable', function () {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelController
link: function (scope, element, attrs, ngModel) {
if (!ngModel) return; // do nothing if no ng-model
// Specify how UI should be updated
ngModel.$render = function () {
element.html(ngModel.$viewValue || '');
@mladenp
mladenp / preventCircularJSON.js
Created March 7, 2016 14:48
Prevent Circular JSON
/**
* Traverses a javascript object, and deletes all circular values
* @param source object to remove circular references from
* @param censoredMessage optional: what to put instead of censored values
* @param censorTheseItems should be kept null, used in recursion
* @returns {undefined}
*/
function preventCircularJson(source, censoredMessage, censorTheseItems) {
//init recursive value if this is the first call
censorTheseItems = censorTheseItems || [source];
@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;
}
@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 / 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 / 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 / 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