Skip to content

Instantly share code, notes, and snippets.

View rvbsanjose's full-sized avatar

Richard Van Breemen rvbsanjose

View GitHub Profile
const lengthLongestPath = input => {
return input.split('\n').reduce((os, path) => {
const idx = path.lastIndexOf('\t') + 1;
idx <= os.filePath.length && os.filePath.splice(idx);
os.filePath.push(path.slice(idx));
if (path.lastIndexOf('.') >= 0) {
const length = os.filePath.join('/').length;
os.longest = length > os.longest ? length : os.longest;
@rvbsanjose
rvbsanjose / printCombinations.js
Created May 22, 2020 23:58
Print combinations
const printCombinations = (list, k, prefix = '') => {
if (!k) {
return console.log(prefix);
}
for (let i = 0; i < list.length; i++) {
printCombinations(list, k - 1, `${prefix}${list[i]}`);
}
};
// actions - streams
function makeStreamSettingsPayload(opts) {
return {
id: 'UPDATE_CONFIG',
payload: {
action: 'updateviewconfig',
userviewconfig: opts.streamSettings
}
};
@rvbsanjose
rvbsanjose / loneSurvivor.js
Created March 12, 2015 02:41
POPSUGAR JavaScript
var loneSurvivor = function () {
// create a list of players
var players = [];
for (var i = 1; i <= 100; i++) {
players.push(i);
}
// how many to step over
var step = 0;
var iterations = 0;
language: node_js
node_js:
- '0.10'
- '0.11'
before_script:
- npm install -g bower grunt-cli
- bower install
services: mongodb
notifications:
slack: hr22-23:cj7Wc706h8pEu4BGApvLCuJc
@rvbsanjose
rvbsanjose / message.controller.spec.js
Last active August 29, 2015 14:14
message.controller.spec.js
'use strict';
describe('Controller: MessageCtrl', function () {
var scope;
var state;
var messageService;
// load controller views
var views = [
set nocompatible
set nobackup
set shell=$HOME/.oh-my-zsh
syntax on
set incsearch
set hlsearch
set ignorecase
set smartcase
set guifont=Monaco:h13
set background=dark
var J500px = function () {
this.ajaxLoader = 'images/ajax-loader.gif';
this.categories = ['Travel', 'Popular', 'sports', 'Journal']; // look into 500px doc to get a full list of categories
};
J500px.prototype = {
// Displays the AJAX loader
displayLoader: function () {
var $loader = $('<div id="ajax-loader">');
var $imgLoader = $('<img>');
===================================================
// In case you didn't know, there is a Math object
// with all sorts of cool methods attached to it
// Let's take a look at Math.max();
// Call Math.max with an array of numbers
// i.e. Math.max(1,5,75,4,11);
Math.max(1, 2, 3, 4);
// Now declare a variable allNums that references a
// Using the JavaScript language, have the function LetterCount(str) take the str parameter being passed and return the first word with the greatest number of repeated letters. For example: "Today, is the greatest day ever!" should return greatest because it has 2 e's (and 2 t's) and it comes before ever which also has 2 e's. If there are no words with repeating letters return -1. Words will be separated by spaces.
// Input = "Hello apple pie" Output = Hello
// Input = "No words" Output = -1
function LetterCount( str ) {
var words = str.split( ' ' );
var longest = 0;
var longest_word;
for ( var i = 0; i < words.length; i++ ) {