This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # To Calculate time from timestamp in ruby | |
| [9] pry(main)> Time.now | |
| => 2016-02-23 12:40:56 +0530 | |
| [10] pry(main)> Time.now.to_i | |
| => 1456211463 | |
| [11] pry(main)> Time.at(1456211463) | |
| => 2016-02-23 12:41:03 +0530 | |
| [12] pry(main)> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery Proxy Function | |
| EXAMPLE 1 | |
| $('#myElement').click(function() { | |
| // In this function, "this" is our DOM element. | |
| $(this).addClass('aNewClass'); | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CONQUER YOUR FEARS AND ACHIEVE SUCCESS | |
| Namaste, | |
| 1. Control your thoughts. It's possible to think about anything you choose. The best way to stress yourself is to think about stressful things. You're not more effective when you're afraid. You're less. That doesn't mean you should bury your head in the sand, but put yourself in a frame of mind that makes you most able to deal with the situation. | |
| 2. Consider the worst. Take a moment to consider the worst likely outcome. Can you handle it? Can you maneuver in a way that makes the worst outcome manageable? If you know you can handle the worst, there's no reason to be afraid. | |
| Be prepared for the worst and you'll find it rarely occurs. | |
| 3. Breathe. Focus on your breath and slow your mind. Your mind will take reality and run wild with it. Focusing on your breath will calm your mind, and reality remains. When stress is at your doorstep, just stop and breathe. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var person1 = { | |
| _name: "Nicholas", | |
| get name() { | |
| console.log("Reading name"); | |
| return this._name; | |
| }, | |
| set name(value) { | |
| console.log("Setting name to %s", value); | |
| this._name = value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isScrolledIntoView(elem) | |
| { | |
| var docViewTop = $(window).scrollTop(); | |
| var docViewBottom = docViewTop + $(window).height(); | |
| var elemTop = $(elem).offset().top; | |
| return ((elemTop <= docViewBottom) && (elemTop >= docViewTop)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //------------------------- | |
| // Map Example | |
| searches = _.map(response.data, (search) -> | |
| search.isFavorite = (Math.round(Math.random() * 10)) % 2 is 0 | |
| search | |
| ) | |
| //------------------------- | |
| // Array for each example | |
| favoriteSearchIds = _.forEach(data, function(obj){ | |
| console.log(obj.webSearchId) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @$scope.searchesDefinition.toggleFavorite = (row) => | |
| wait = if @$scope.selectedTab is @tabs.favorites then @MAX_DELAY else @MIN_DELAY | |
| debounce = _.debounce( => | |
| data = { UserID: @User.id, WebSearchId: row.searchId, IsFavorite: !row.isFavorite } | |
| @SearchHelper.setFavoriteStatus data, (err, response) => | |
| if err | |
| row.isFavorite = !row.isFavorite | |
| else | |
| @$scope.searches = _.clone(@filterSearches @$scope.searches) | |
| @$scope.searches = @_defaultSortSearches(@$scope.searches) /// Need to check for use case accordingly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sorted.sort(function(s1, s2){ | |
| return [ ((s1.isFavorite === s2.isFavorite) ? 0 : s1.isFavorite ? -1 : 1), new Date(s2.date) - new Date(s1.date)] | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| angular.module('Page').service('Browser', class Browser { | |
| constructor() { | |
| const ua = navigator.userAgent; | |
| const device = {}; | |
| device.android = (ua.match(/Android/i) || ua.match(/JellyBean/i)); | |
| device.androidTab = (device.android && !ua.match(/Mobile/ig)); | |
| device.iPad = (ua.match(/iPad/i)); | |
| device.iPhone = (ua.match(/iPhone/i) || ua.match(/iPod/i)); |