Skip to content

Instantly share code, notes, and snippets.

(function() {
'use strict';
angular
.module('app.services')
.factory('$ionicPlatformManager', $ionicPlatformManager)
;
/* @ngInject */
@sharvit
sharvit / server.js
Created July 2, 2016 04:06
node.js micro service to run production angular app
(function() {
'use strict';
// use new relic if license key exists
if (typeof process.env.NEW_RELIC_LICENSE_KEY === 'string') {
require('newrelic');
}
var express = require('express'),
@sharvit
sharvit / init.coffee
Last active June 28, 2022 15:22
My atom editor settings. automatic update by http://atom.io/packages/sync-settings
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@sharvit
sharvit / webpack-stats-check.md
Created December 27, 2017 09:02
How to check webpack stats in foreman
  1. Get webpack stats into json file
NODE_ENV=production ./node_modules/.bin/webpack --config config/webpack.config.js --json > stats.json
  1. Upload your stats.json file to webpack-visualizer
@sharvit
sharvit / axios-test-error.diff
Last active January 11, 2018 09:07
error while running test on foreman axios branch
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 11): Error: expect(received).toEqual(expected)
Expected value to equal:
[{"payload": {"id": "operatingsystem", "search": "/hosts?search=os_title=~VAL~", "title": "OS Distribution", "url": "statistics/operatingsystem"}, "type": "STATISTICS_DATA_REQUEST"}, {"payload": {"id": "architecture", "search": "/hosts?search=facts.architecture=~VAL~", "title": "Architecture Distribution", "url": "statistics/architecture"}, "type": "STATISTICS_DATA_REQUEST"}, {"payload": {"data": [["centOS 7.1", 6]], "id": "operatingsystem", "search": "/hosts?search=os_title=~VAL~", "title": "OS Distribution", "url": "statistics/operatingsystem"}, "type": "STATISTICS_DATA_SUCCESS"}, {"payload": {"data": [["x86_64", 6]], "id": "architecture", "search": "/hosts?search=facts.architecture=~VAL~", "title": "Architecture Distribution", "url": "statistics/architecture"}, "type": "STATISTICS_DATA_SUCCESS"}]
Received:
+ Array []
Difference:
- Expected
@sharvit
sharvit / README.md
Last active January 15, 2018 09:04
Testing redux actions

Testing redux actions

Goals:

  1. Create a pure unit-testing

    • Do net allow the tests to get out from the file context
    • Mock all imports and treat them as simple inputs
    • Do not use store to test the actions
  2. Use snapshots

@sharvit
sharvit / layout_helper.rb
Created January 18, 2018 15:08
Breadcrumbs layout helper
def get_resource
instance_variable_get("@#{controller_name.singularize}")
end
def get_resource_label(resource)
resource.try(:to_label) || resource.try(:to_s) unless resource.new_record?
end
def get_resource_menu(resource)
label = get_resource_label(resource)
@sharvit
sharvit / README.md
Created February 21, 2018 08:07
Git commands

Cancel 1 last commit, and keep the changes:

git reset HEAD~1

Can replace the number 1 to cancel more than one commit at once:

git reset HEAD~5

Can cancel the commit and remove the changes (dangerous) :

@sharvit
sharvit / ToastNotifications.md
Last active March 8, 2018 14:32
Foreman toast-notifications readme

Toast Notifications

Types

['error', 'warning', 'success', 'info']
// deprecated-types
['notice']

Create notification from the server

@sharvit
sharvit / BreadcrumbBar.md
Last active April 26, 2018 10:14
BreadcrumbBar toturial

BreadcrumbBar

breadcrumb-bar-2

Breadcrumbs display a users location within an application hierarchy. They act as a resource to help users navigate more efficiently and provide additional context.

The Breadcrumb Switcher provides a shortcut for users to quickly navigate to parallel pages, rather than navigating back to the previous page and making a new selection.