Skip to content

Instantly share code, notes, and snippets.

{
init: function(elevators, floors) {
var capacity = 4;
var step = Math.floor(floors.length / elevators.length)
var getClosestElevator = function(elevators, floor){
return elevators.reduce(function(closest, current){
var distance1 = Math.abs(closest.currentFloor()-floor.floorNum())
var distance2 = Math.abs(current.currentFloor()-floor.floorNum())
if(distance1 > distance2){
return current
sudo apt-get install rng-tools gpgv
This file has been truncated, but you can view the full file.
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
docker-machine create default
# this I think not needed because it was started on create?:
# docker-machine start default
eval $(docker-machine env default)
# create/start docker containers based on docker-compose config files
docker-compose up
@ajkovar
ajkovar / psql-issue.sh
Last active June 30, 2020 01:14
psql issue
#Received this error recently
psql
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/Cellar/postgresql@10/10.6_1/lib/libpq.5.10.dylib
Reason: image not found
Abort trap: 6
# Based on this post
#https://stackoverflow.com/questions/59006602/dyld-library-not-loaded-usr-local-opt-openssl-lib-libssl-1-0-0-dylib
# I hade to change homebrew's versino of openssl
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(200) NOT NULL
);
insert into users (name) values ('bob'), ('tom'), ('jane'), ('mary');
CREATE TABLE sales (
id SERIAL PRIMARY KEY,
user_id int references users(id),
Had to add line to pg_hba.conf:
You need to open file called /var/lib/pgsql/data/pg_hba.conf. Login as postgres user using su command:
$ su - postgres
$ vi /var/lib/pgsql/data/pg_hba.conf
Now append following line. Let us say you would like to give access to 192.168.1.0/24 network:
host all all 192.168.1.0 255.255.255.0 trust
@ajkovar
ajkovar / setting-up-wepack.md
Last active July 7, 2020 01:52
Steps for getting webpack/typescript/HtmlWebPackPlugin working to my liking

I spent some time today setting up a project using React, Typescript, and Webpack. There are various guides out there but none were quite to my liking. It took a little while to get everything working right so I decided to document my journey. Mostly I just did this for my own purposes but maybe it will be helpful to someone. I'll be breaking it down step by step with every error along the way documented. If you are looking for a quick get up and running guide and you don't care about any of the details, this is probably not the place for you. If you are here to resolve some issue you have had or maybe want some insight into how things work and why they need to be configured the way they are, this post might help you.

Why did I do this? For one thing, HtmlWebPackPlugin was not mentioned in many posts. I find that this plugin helps to cleanup the syntax of wiring everything together. Typescript's own website [rec

Ran into this while running nix-build (for buildling a haskell project:

"checking whether the C compiler works... no osx"

This fixed it:

xcode-select --install

This didn't seem to fix the problem. Also ran this:

@ajkovar
ajkovar / nix.md
Last active August 28, 2020 20:49

See what installable packages are currently available in the channel:

$ nix-env -qa

(-q is for query and -a for available) What is the channel?

It is also possible to see the status of available packages, i.e., whether they are installed into the user environment and/or present in the system:

nix-env -qas