Skip to content

Instantly share code, notes, and snippets.

View MehulATL's full-sized avatar

Mehul Patel MehulATL

View GitHub Profile
@MehulATL
MehulATL / .bash_profile
Last active January 3, 2016 02:09
Bash profile
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "git:("${ref#refs/heads/}$(num_git_commits_ahead)")"
}
function num_git_commits_ahead {
num=$(git status 2> /dev/null \
| grep "Your branch is ahead of" \
| awk '{split($0,a," "); print a[9];}' 2> /dev/null) || return
if [[ "$num" != "" ]]; then
// temp fix for iOS8 beta, add it after the reference to cordova.js
if (navigator.userAgent === undefined) {
navigator.__defineGetter__('userAgent', function() {
return("Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit");
});
}
.filter('timeago', function () {
/*
* time: the time
* local: compared to what time? default: now
* raw: wheter you want in a format of "5 minutes ago", or "5 minutes"
*/
// parse string date to milliseconds
// Note: months are 0-based
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query
@MehulATL
MehulATL / Preferences.sublime-settings
Created September 23, 2014 19:52
Preferences.sublime-settings
{
"color_scheme": "Packages/Dracula Color Scheme/Dracula.tmTheme",
"file_exclude_patterns":
[
".DS_Store",
".tags*",
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
@MehulATL
MehulATL / Dracula.tmTheme
Created September 23, 2014 20:08
modified Dracula color scheme to match Glacier theme for Sublime Text 3
<!-- Dracula Theme v0.7.0
#
# https://github.com/zenorocha/dracula-theme
#
# Copyright 2013, All rights reserved
#
# Code licensed under the MIT license
# http://zenorocha.mit-license.org
#
# @author Zeno Rocha <hi@zenorocha.com>
@MehulATL
MehulATL / .jshintrc
Created October 8, 2014 00:00
angular .jshintrc
{
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
"browser": true, // Standard browser globals e.g. `window`, `document`.
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
"curly": false, // Require {} for every new block or scope.
"eqeqeq": true, // Require triple equals i.e. `===`.
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef": true, // Prohibit variable use before definition.
@MehulATL
MehulATL / app.js
Created October 8, 2014 06:11
cordova push notifications
var pushNotification = window.plugins.pushNotification;
window.onNotificationAPN = onNotificationAPN;
pushNotification.register(
tokenHandler,
errorHandler, {
"badge":"true",
"sound":"true",
"alert":"true",
"ecb":"onNotificationAPN"
@MehulATL
MehulATL / currency.directive.js
Last active August 29, 2015 14:07
currencyMask directive for input fields
angular.module('currencyMask', [])
.directive('currencyMask', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ngModelController) {
// Run formatting on keyup
var numberWithCommas = function(value, addExtraZero) {
@MehulATL
MehulATL / subl
Last active August 29, 2015 14:08
subl
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl