Skip to content

Instantly share code, notes, and snippets.

@scottdomes
scottdomes / App.js
Last active December 20, 2016 00:39
import React, { Component } from 'react'
import './App.css'
import ListItem from './ListItem'
function arrayGenerator(length) {
return Array.apply(null, { length: length }).map(Number.call, Number)
}
class App extends Component {
constructor(props) {
@scottdomes
scottdomes / game.js
Last active April 11, 2016 20:10
Node betting game
var color = require('colors');
var fs = require('fs');
var player1 = {
cash: 50,
wins: 0
};
var player2 = {
cash: 50,
wins: 0
};
var net = require('net');
var server = net.createServer(function(socket) {
var date = printTime();
socket.end(date);
});
function zeroFill(i) {
return (i < 10 ? '0' : '') + i;
}
def determine_free_bottles (investment)
process_purchase(investment)
begin
find_bottles(@caps, @empty_bottles)
end while @empty_bottles > 1 || @caps > 3
print_result
end
@scottdomes
scottdomes / max.rb
Last active March 1, 2016 19:35 — forked from davidvandusen/max.rb
# Find the maximum
def maximum(arr)
arr.inject { |x, max| x > max ? x : max }
end
# expect it to return 42 below
result = maximum([2, 42, 22, 02])
puts "max of 2, 42, 22, 02 is: #{result}"
# expect it to return nil when empty array is passed in
scottdomes@scottdomes-ThinkPad:~/WebDev/RubyTest$ pry
[1] pry(main)> def say_hi(name)
[1] pry(main)*
[1] pry(main)* "Hi, #{name}."
[1] pry(main)* end
=> nil
[2] pry(main)> say_hi("Scott")
=> "Hi, Scott."
[3] pry(main)> Time.now
=> 2016-03-01 11:00:06 -0800