Skip to content

Instantly share code, notes, and snippets.

View mladenp's full-sized avatar

Mladen Petrović mladenp

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / launch_sublime_from_terminal.markdown
Created November 1, 2016 14:19 — forked from artero/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@mladenp
mladenp / install-brew-manual
Created November 1, 2016 14:55
install homebrew manually
sudo chown -R `whoami`:staff /usr/local
cd ~/src
git clone git://github.com/mxcl/homebrew.git
cd homebrew
git archive --format=tar HEAD|(cd /usr/local;tar xf -)
@mladenp
mladenp / webpack.config.js
Created November 5, 2016 00:34
webpack config basic starter
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@mladenp
mladenp / .bash_profile
Created November 7, 2016 09:57 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@mladenp
mladenp / webpack.config.js
Created November 8, 2016 10:20
react - webpack hot reload dev server
var webpack = require('webpack');
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'./src/index.js'
],
module: {
loaders: [{