Skip to content

Instantly share code, notes, and snippets.

View lrlna's full-sized avatar

Iryna Shestak lrlna

View GitHub Profile
@lrlna
lrlna / sort.rb
Created August 6, 2014 00:14 — forked from aspyct/sort.rb
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end

Keybase proof

I hereby claim:

  • I am ishestak on github.
  • I am irina (https://keybase.io/irina) on keybase.
  • I have a public key whose fingerprint is 5EBC 83B1 F568 57CF 0869 646C CBE8 5651 05E0 BEDE

To claim this, I am signing this object:

@lrlna
lrlna / gist:74c2d18e6b7c152f7398
Last active August 29, 2015 14:18
node things to look at for learning purposes.
@lrlna
lrlna / gist:06c25c7bb7096d50a1b5
Last active January 29, 2016 17:04
npm cli: ALL THE THINGS -- resources
@lrlna
lrlna / monads.md
Created July 30, 2015 20:34
intro to monads
# define a construct
data Maybe a = Just a | Nothing

#define martist
martist :: Maybe String
martist = Just "Varen"

#define mtrack
mtrack :: Maybe String
@lrlna
lrlna / clithings.md
Last active September 8, 2015 04:45

###Building Interactive npm Command Line Modules -- all the things.

Here you are coding away, when you realize you're in desperate need of a quick shell script to get your project cleaned up. You're standing at a fork in the road: Bash or Node? You choose the road less travelled by (for some reason) -- Node. I congratulate you on this decision. You've written it, you may have published it, and it certainly works. But what now? Is this all a command line module Node is good for: a project clean up and some data manipulation?

Let's take it a step further. Let's make a command line module that's more than just your compiling script. I am, of course, talking about making it more interactive.

In this talk I want to take you on an adventure that will require cunning, bravery, and maybe some magic. We will walk through obtaining and parsing data, using Node's process functions, and finally improving your module's user experience.

in package.json
  • `"preferGlobal": true
  • `"bin": { "nameOfModule": "entryFile.js" }
  • in entryFile.js --> #! /usr/bin/env node on top
  • npm link
Alright, that's a mouthful. Let's break it down.
1. We will be looking at cellular automata. A cellular automata is a set of units governed with very simple rules. These units make up a complex system, or model.
2. We can train cellular automata to genetically evolve, making themselves better overtime. We can make them adhere to a set of rules that would make the system reach a certain outcome at the end of N generations. We can even use these concepts in the wild.
3. We will be doing it all with JavaScript.
it('fails with invalid command', function (done) {
yargs('marsupial -w 10')
.command('marsupial', 'wombat burrows', function (yargs, argv) {
console.log(argv)
return argv
})
.demand(1, ['w', 'b'])
.strict()
.fail(function (msg) {
msg.should.equal('Missing required argument: b')
irina@aniri-Satellite-L350 ~/developer/yargs $ npm test

> yargs@3.32.0 pretest /home/irina/developer/yargs
> standard


> yargs@3.32.0 test /home/irina/developer/yargs
> nyc --cache mocha --require ./test/before.js --timeout=4000 --check-leaks