Skip to content

Instantly share code, notes, and snippets.

View mariojunior's full-sized avatar

Mario de Souza Junior mariojunior

View GitHub Profile
@mariojunior
mariojunior / gist:6175849
Created August 7, 2013 16:47
AngularJS Learned Lessons #2: Enabling HTTP Credentials (needed by Session IDs)
//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 August 7, 2013 16:36
AngularJS Learned Lessons #1: - Getting a Invalid Session State on response and trait it.
//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 December 15, 2015 15:29
How to create .iso files using Terminal on MacOS
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 December 14, 2015 17:29
Hd Externo usando NTFS com Mac OS 10.8 (Mountain Lion) (read/write)
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 June 13, 2012 14:14
Showing / Hidding hidden Files on MacOSX
#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 March 8, 2012 20:32
Magic line for BlazeDS null/NaN Number (Java/AS3) serialization
//On input class....
...
} else if ((value instanceOf Double) && (null == value)) {
return Double.NaN;
} else ...
//on output class...
...
} else if ((o instanceOf Double) && (null == o)) {