Skip to content

Instantly share code, notes, and snippets.

@rkpatel33
rkpatel33 / DocNav_PhoneInterview1.md
Last active August 29, 2015 14:14
DocNav Phone Screen Part 1

DocNav Phone Screen

Part 1

You're running a pool of servers where the servers are numbered sequentially starting from 1. Over time, any given server might explode, in which case its server number is made available for reuse. When a new server is launched, it should be given the lowest available number.

Write a function which, given the list of currently allocated server numbers, returns the number of the next server to allocate.

@rkpatel33
rkpatel33 / DocNav_PhoneInterview2.md
Last active June 13, 2022 23:12
DocNav Phone Screen Part 2

DocNav Phone Screen

Part 2

Server names consist of an alphabetic host type (e.g. "apibox") concatenated with the server number, with server numbers allocated as before (so "apibox1", "apibox2", etc. are valid hostnames).

Write a name tracking class with two operations, allocate(host_type) and deallocate(hostname). The former should reserve and return the next available hostname, while the latter should release that hostname back into the pool.

For example:

@rkpatel33
rkpatel33 / gotoproject.sh
Last active August 29, 2015 14:14
Vagrant box - setup venv and move to project directory
#!/bin/bash
# run $ chmod 755 gotoproject.sh to make executable
# Activate venv
source ~/venv/bin/activate
# cd to repo directory /vagrant
cd /vagrant
@rkpatel33
rkpatel33 / loadLibraries.js
Created February 8, 2017 20:36
Load various JS libraries for working from the console
var library_urls = [
'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js',
'https://raw.githubusercontent.com/jquery/jquery-simulate/master/jquery.simulate.js',
];
library_urls.forEach(function(url) {
var script = document.createElement('script');
script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);
setTimeout(function(){ console.log(url + " loaded"); }, 2000);
@rkpatel33
rkpatel33 / Paragraph properties.yaml
Created May 10, 2017 06:04
Shows how to set indentation, space between paragraphs and other paragraph properties. - Shared with Script Lab
name: Paragraph properties
description: 'Shows how to set indentation, space between paragraphs and other paragraph properties.'
host: WORD
api_set: {}
script:
content: |-
$("#indent").click(indent);
$("#spacing").click(spacing);
$("#space-after").click(spaceAfter);
$("#align").click(align);
@rkpatel33
rkpatel33 / .slate
Created May 24, 2017 19:58
Slate config file
# config defaultToCurrentScreen true
config checkDefaultsOnLoad true
# *****************************************************************************
# Screens resolutions
# *****************************************************************************
alias screen_macbookpro_2017 1440x900
alias screen_dell_4k 2560x1440
@rkpatel33
rkpatel33 / buttons.schema.json
Last active July 20, 2017 05:48
buttons.schema.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://gist.github.com/rkpatel33/d1b202c8c3e1cd1c02d2369fddea971c",
"type": "array",
"items": {
"type": "object",
"properties": {
"deep_link": {
"type": ["null", "string"]
},
@rkpatel33
rkpatel33 / .vimrc
Created August 13, 2017 21:31
.vimrc file
set nocompatible " be iMproved, required
filetype off " required
" Show line numbers
set number
" Set encoding
set encoding=utf-8
set ffs=unix
" Set 'nocompatible' to ward off unexpected things that your distro might
" have made, as well as sanely reset options when re-sourcing .vimrc
BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//Mac OS X 10.13.3//EN
N:;;;;
FN:Dummy VCard
ORG:Dummy VCard;
TEL;type=CELL;type=VOICE;type=pref:917-6470892
X-ABShowAs:COMPANY
UID:9270779c-d4a3-4c61-8096-5fdad75b0b99
X-ABUID:B5720A0A-66FF-48D4-91CC-70AA73B547AB:ABPerson
BEGIN:VCARD
VERSION:3.0
N:Doe;John;;;
FN:John Doe
ORG:Example.com Inc.;
TITLE:Imaginary test person
EMAIL;type=INTERNET;type=WORK;type=pref:[email protected]
TEL;type=WORK;type=pref:+1 617 555 1212
TEL;type=WORK:+1 (617) 555-1234
TEL;type=CELL:+1 781 555 1212