Skip to content

Instantly share code, notes, and snippets.

View charandas's full-sized avatar

Charandas charandas

View GitHub Profile
@charandas
charandas / .tmux.conf
Last active December 25, 2015 12:49
tmux.conf using the new tmux copy-pipe command
# Start tmux shells with right hooks
set-option -g default-command "reattach-to-user-namespace -l zsh"
# vi keys
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "/usr/local/bin/reattach-to-user-namespace pbcopy"
angular.module('stateMock',[]);
angular.module('stateMock').service("$state", function($q){
this.expectedTransitions = [];
this.transitionTo = function(stateName){
if(this.expectedTransitions.length > 0){
var expectedState = this.expectedTransitions.shift();
if(expectedState !== stateName){
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
}
}else{
@charandas
charandas / routes.js
Created June 7, 2014 16:49
ui-router root controller in config
app.config(function($stateProvider, BaseSettingsService, PrintSettingsService) {
$stateProvider
// All app states loaded in index.html
.state('app', {
abstract: true,
templateUrl: 'views/app.html',
controller: 'AppCtrl',
resolve: {
baseSettings: settings: function(BaseSettingsService) {
@charandas
charandas / modal-instance.js
Last active August 29, 2015 14:02
Modal instance controller that can support almost any modal view
var ModalInstanceCtrl = function ($scope, $modalInstance, heading, messages, size, extraParams) {
extraParams = extraParams || {};
$scope.heading = heading;
$scope.messages = messages;
$scope.size = size;
angular.extend($scope, extraParams);
$scope.ok = function () {
@charandas
charandas / modal-service.js
Last active August 29, 2015 14:02
Wrapper around angular-foundation $modal service
angular.module('services').factory('ModalService',
function ($modal, $timeout) {
/**
* Provides a thin wrapper around a $modalInstance to help
* navigate around double-dismiss cases.
* @param the $modalInstance to wrap
* @constructor
*/
function Modal(instance) {
this.instance = instance;
@charandas
charandas / use-modal-wrapper.js
Created June 7, 2014 17:34
Using the $modal wrapper
// This modal will automatically close after the short timeout (i.e. 15 secs)
var modal = ModalService.open({
templateUrl: 'views/core/purchase/notifications/processing-timeout.html',
size: 'medium',
timeout: 15000
});
modal.instance.result.then(function() {
// No additional actions for dismiss
}, function() {
$scope.resetApp();
@charandas
charandas / using-modal-wrapper-2.js
Created June 7, 2014 17:46
Using $modal wrapper with extraParams
var notification =
{
title: 'We\'re sorry - we are unable to read your info!',
messages: [
{ text: 'Please see a representative.', className: 'lead' },
{ text: 'This screen will automatically timeout in 30 seconds.' },
{ text: 'Thank you for visiting.' }
]
}
@charandas
charandas / app.js
Last active August 29, 2015 14:02
root controller routes
define([
'angularUiRouter',
'core/modules/states/a',
'core/modules/states/b',
'core/controllers/home',
'core/controllers/logs',
'core/services/settings'
], function() {
@charandas
charandas / a.js
Last active August 29, 2015 14:02
Module A States
define([
'angularUiRouter',
'core/controllers/a'
], function() {
'use strict';
angular.module('core.states.a', [
@charandas
charandas / appSpec.js
Last active August 29, 2015 14:02
Tests for app states module
define([
'angularMocks',
'core/modules/states/app'
], function () {
'use strict';
describe('core.states.app spec', function () {
var $rootScope, $state, $injector, settingsShimService;