Skip to content

Instantly share code, notes, and snippets.

View ArataKagan's full-sized avatar

Arata Kagan ArataKagan

  • Los Angeles, CA
View GitHub Profile
var longestCommonPrefix = function(strs) {
var common = "";
var index = 0;
if(strs.length == 0 || strs == "null"){
return common;
}
// split the first string of strs
var string = strs[0].split("");
const commands = require('./commands.js');
//prompt the user for input
process.stdout.write('prompt > ');
// the stdin 'data' event triggers after a user types in a line
process.stdin.on('data', (userInput) => {
userInput = userInput.toString().trim();
commands.evaluateCmd(userInput);
});
@ArataKagan
ArataKagan / basic-shell-commands.js
Last active January 8, 2022 12:54
Basic Shell Command Implementation with Node.js
//import fs library
const fs = require('fs');
//write out data
function done(output) {
process.stdout.write(output);
process.stdout.write('\nprompt > ');
}
// where we will store our commands
@ArataKagan
ArataKagan / psql-library.sql
Created October 15, 2018 21:42
psql library result
library=# SELECT * FROM books;
id | title | author
------+------------------------------------------+---------------------
1259 | Eloquent Ruby | Russell A. Olson
1593 | JavaScript: The Good Parts | Douglas Crockford
8982 | Designing Object-Oriented Software | Rebecca Wirfs-Brock
7265 | Practical Object-Oriented Design in Ruby | Sandi Metz