-
Locate the path to the interpreter for the language you are writing in with the
which
command.which node which python which bash which ruby
-
Add that path as an interpreter directive (using
#!
) on the first line of your script. For example ifwhich node
returned/usr/local/bin/node
, the first line of your script should be:
This file contains 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
#!/usr/bin/env node | |
const fs = require('fs'); | |
const path = require('path'); | |
const from = JSON.parse(fs.readFileSync(path.resolve(process.argv[2])).toString()); | |
const to = path.resolve(process.argv[3]); | |
const jsonPath = process.argv[4].split('.'); | |
function getValueFromPaths(paths, object) { |
This file contains 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
0xdA52ef28f5ff83f45439Aca6bf664F4edc581bAF |
This file contains 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
const net = require('net'); | |
const PORT = 6000; | |
const server = net.createServer((connection) => { | |
console.log('created server'); | |
connection.on('data', (data) => { | |
connection.write('pong\n'); | |
}); | |
connection.pipe(connection); |
This file contains 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
set autoindent | |
set indentexpr=off | |
set expandtab | |
set tabstop=4 | |
set sw=4 | |
set textwidth=80 | |
set nohls | |
set noshowmatch | |
syntax enable |
This file contains 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
'use strict'; | |
/** | |
* Run through promises sequentially. Useful when breaking 1000s records into manageable chunks | |
*/ | |
function processFile (filename) { | |
return new Promise((superResolve, superReject) => { |
This file contains 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
const flatten = (...args) => { | |
let result = []; | |
args.forEach(arg => { | |
if (Array.isArray(arg)) { | |
arg.forEach(element => { | |
if (Array.isArray(element)) { | |
result = result.concat(flatten(element)); | |
} else { | |
result.push(element); | |
} |
This file contains 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 countLetters (string) { | |
let letters = {}; | |
for (let i = 0; i < string.length; i++) { | |
letters[string[i]] = letters[string[i]] + 1 || 1; | |
} | |
return letters; | |
} |
This file contains 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
let seating = (people) => { | |
let result = []; | |
(function permutations (left, right) { | |
let current; | |
let before | |
let after; |
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
- Stores data elements based on an sequential, most commonly 0 based, index.
- Based on tuples from set theory.