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 prettyDate(time) { | |
| var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")), | |
| diff = (((new Date()).getTime() - date.getTime()) / 1000), | |
| day_diff = Math.floor(diff / 86400); | |
| if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 ){ | |
| return; |
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 http = require("http"), | |
| url = require("url"), | |
| path = require("path"), | |
| fs = require("fs") | |
| port = process.argv[2] || 8888; | |
| http.createServer(function(request, response) { | |
| var uri = url.parse(request.url).pathname | |
| , filename = path.join(process.cwd(), uri); |
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 Pocket = require('./lib/pocket-auth.js'); | |
| var express = require('express'); | |
| var request = require('request'); | |
| var router = express.Router(); | |
| var auth = require('../../auth/auth.service'); | |
| var consumer_key = process.env.POCKET_KEY; | |
| var redirect_uri = process.env.DOMAIN + '/pocket/redirect'; | |
| var pocket = new Pocket({ |
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() { | |
| /** | |
| * @ngInject | |
| */ | |
| function ius($q, $ionicLoading, $cordovaFile, $translate, CLOUDINARY_CONFIGS) { | |
| var service = {}; |
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 ghost = require( 'ghost' ) | |
| function processBuffer( buffer, app ){ | |
| while( buffer.length ){ | |
| var request = buffer.pop() | |
| app( request[0], request[1] ) | |
| } | |
| } | |
| function makeGhostMiddleware( options ){ |
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 mongoose = require('mongoose'); | |
| var Schema = mongoose.Schema; | |
| //Database connection | |
| var uristring = 'mongodb://localhost/test'; | |
| var mongoOptions = { }; | |
| mongoose.connect(uristring, mongoOptions, function (err, res) { | |
| if (err) { | |
| console.log('Error when connecting to: ' + uristring + '. ' + err); |
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
| /** | |
| * This function assumes string as a argument and | |
| * replaces everything between "START" and "END" | |
| * with "START";var __REPLACED = console.log('replaced');"END" | |
| * @param input string | |
| * @author Georgi Naumov | |
| * gonaumov@gmail.com for contacts and | |
| * suggestions. | |
| */ | |
| function replaceString(input) { |
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
| <!doctype html> | |
| <html> | |
| <head> | |
| <style> | |
| /* container which maintains the ratio */ | |
| /* padding-bottom is the magic rule to set the aspect ration */ | |
| /* in this case below, this is a trick, to add padding bottom 50% but height 0 to compensate for the height created */ | |
| /* this will make the height of this container div always 50% of the width */ | |
| .container { |
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
| /** | |
| * Evaluate a basic mathematical expression | |
| * | |
| * This is my 2nd attempt at this problem. | |
| * For the 1st attempt, please look at the code | |
| * commented at the bottom. | |
| * | |
| * Did some research on how to tackle this problem, | |
| * came up to using Reverse Polish Notation. | |
| * |
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
| /* You are given an n x n array P[i,j] with i and j indices that range from 0 to n-1. There is a number in each location of P[i,j] that can be negative or positive. You start with the index pair [n-1, n-1] and are free to traverse any path(according to the following two rules) that ends at [0,0]. | |
| **Rule 1:** At any location [i,j] you can decrement either one of the indices or both. So from [i,j] you can go to [i-1, j] or [i,j-1] or [i-1,j-1]. However no index is allowed to go below 0(obviously). | |
| **Rule 2:** When an index reaches 0, it stays at 0. | |
| Again, there is a number stored at each location of P[i,j]. The value of a path is the sum of the P[i,j] values for the indices used by the path. | |
| Present a recursive solution that solves for the greatest possible value path among all such paths. In other words find **Best(i, j)** which is the value of the best**(maximum sum)** path from location (i,j) to (0,0). |
OlderNewer