Skip to content

Instantly share code, notes, and snippets.

View MehulATL's full-sized avatar

Mehul Patel MehulATL

View GitHub Profile
@MehulATL
MehulATL / .gitconfig
Created October 22, 2014 19:35
git config
[user]
name = Mehul Patel
email = [email protected]
[color]
ui = true
[alias]
co = checkout
ci = commit
st = status
br = branch
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 localhost.com
127.0.0.1 api.localhost
@MehulATL
MehulATL / safeApply.js
Created November 6, 2014 23:00
safeApply()
var safeApply = function (fn) {
var phase = $rootScope.$root.$$phase;
if (phase === '$apply' || phase === '$digest') {
if (fn && typeof fn === 'function') {
fn();
}
} else {
$rootScope.$apply(fn);
}
};
@MehulATL
MehulATL / nav-clear.js
Created November 7, 2014 22:04
programatic version of ionic's nav-clear directive
var unregisterListener = $rootScope.$on('$stateChangeStart', function() {
$ionicViewService.nextViewOptions({
disableBack: true
});
unregisterListener();
});
$window.setTimeout(unregisterListener, 300);
$state.go('someState');
@MehulATL
MehulATL / pn.js
Created November 20, 2014 04:36
pn abstraction
angular.module('keychain.services.pn', [])
.factory('PN', function($rootScope, $q, PubNub, User) {
return {
publish: function(channel, body) {
console.log('Publishing to', channel);
var dfd = $q.defer();
var rect;
var map;
var info;
var bounds = {};
var showNewRect = function(e) {
// var nw = rect.getBounds().getNorthWest();
var ne = rect.getBounds().getNorthEast();
var sw = rect.getBounds().getSouthWest();
var BackButtonCtrl = function ($scope, $log, $state, $ionicHistory, $ionicViewSwitcher) {
var ctrl = this;
/**
* Checks to see if there is a view to navigate back to
* if we have no current back view.
*
* @param {string} state The current view state
* @return {boolean} If there is a view we should navigate back to
@MehulATL
MehulATL / cards.css
Created May 12, 2015 19:57
ionic cards css
.card, .list-inset {
overflow: hidden;
margin: 20px 10px;
border-radius: 2px;
background-color: #fff; }
.card {
padding-top: 1px;
padding-bottom: 1px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
<?xml version="1.0" encoding="UTF-8"?>
<!-- Dracula Theme v0.7.6
#
# https://github.com/zenorocha/dracula-theme
#
# Copyright 2015, All rights reserved
#
# Code licensed under the MIT license
# http://zenorocha.mit-license.org
@MehulATL
MehulATL / app.js
Created June 29, 2015 23:18
declare view title in ui.router state declaration
.run(function($rootScope, $injector, $state, $stateParams) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
$rootScope.$title = function() {
if (angular.isFunction($state.current.title)) {
return $injector.invoke($state.current.title, $rootScope, {
$scope: $rootScope,
$currentState: $state.current
});