Skip to content

Instantly share code, notes, and snippets.

@mariojunior
mariojunior / gist:6175849
Created Aug 7, 2013
AngularJS Learned Lessons #2: Enabling HTTP Credentials (needed by Session IDs)
View gist:6175849
//On config definition...
angular.module("moduleName").config(
function ($routeProvider, $httpProvider) {
//HERE THE IMPORTANT MAGIC LINE!
$httpProvider.defaults.withCredentials = true;
//If you don't set the line above, all $http will dispatch request without session_id to backend
//and the backend will not reconize the user session, giving your a big head pain! Believe on me.
//Question & Answer: http://stackoverflow.com/questions/17064791/http-doesnt-send-cookie-in-requests
@mariojunior
mariojunior / gist:6175736
Created Aug 7, 2013
AngularJS Learned Lessons #1: - Getting a Invalid Session State on response and trait it.
View gist:6175736
//Intercepting a Invalid Session status using an Interceptor:
//Following the sample described in http://docs.angularjs.org/api/ng.$http (see "Response inteceptors" paragraph)
//At error function handler:
function (response) {
//if the user's session is invalid, then the status code is zero.
if (response.status == 0) {
//Session Invalid! So, you can do anything... typically, you can dispatch a custom event to be handled by some controller
//and manipulate your models ou routing state.
$rootScope.$emit('redirect_event');
return;
@mariojunior
mariojunior / creating-iso-files-on-terminal
Last active Dec 15, 2015
How to create .iso files using Terminal on MacOS
View creating-iso-files-on-terminal
First: Discovery where your Volume disk running:
-- sudo df -k /Volumes/*
Second: umount your Volume disk without remove the disk:
-- sudo umount /dev/disk3 ('dev/disk3' may be different, you must replace it according previous command)
Third: Create an ISO file mirroring the disc on specified path:
--- dd if=/dev/disk3/ of=PATH_TO_ISO_FILE.iso bs=2048 (remember about the 'dev/disk3' argument)
Wait some several minutes. You can open the Finder on your destiny ISO file to monitoring the growing of file, but sometimes the file size take some minutes to show the real size. Keep calm, take a coffee and relax. :)
@mariojunior
mariojunior / NTFS on MacOS 10.7 or later.
Last active Dec 14, 2015
Hd Externo usando NTFS com Mac OS 10.8 (Mountain Lion) (read/write)
View NTFS on MacOS 10.7 or later.
Passo 1:
Baixe o NTFS-3G e instale-o
(http://sourceforge.net/projects/catacombae/files/NTFS-3G%20for%20Mac%20OS%20X/2010.10.2/ntfs-3g-2010.10.2-macosx.dmg/download)
Ao instala-lo, o MacFUSE será instalado junto (verifique se no Preference System tem dois novos items: MacFUSE e NTFS-3G).
Passo 2:
Baixe o fuse_wai-1.1pkg e instale-o
https://github.com/bfleischer/fuse_wait/downloads
@mariojunior
mariojunior / gist:2924325
Created Jun 13, 2012
Showing / Hidding hidden Files on MacOSX
View gist:2924325
#To show your hidden files on Finder, use this script:
#To Show:
defaults write com.apple.finder AppleShowAllFiles -bool true
killall -TERM Finder
#To Hide them:
defaults write com.apple.finder AppleShowAllFiles -bool false
killall -TERM Finder
@mariojunior
mariojunior / gist:2003261
Created Mar 8, 2012
Magic line for BlazeDS null/NaN Number (Java/AS3) serialization
View gist:2003261
//On input class....
...
} else if ((value instanceOf Double) && (null == value)) {
return Double.NaN;
} else ...
//on output class...
...
} else if ((o instanceOf Double) && (null == o)) {