Skip to content

Instantly share code, notes, and snippets.

View fogonthedowns's full-sized avatar
👋

JZ fogonthedowns

👋
View GitHub Profile
class Node
attr_accessor :next, :value
def initialize(value)
@value = value
end
end
class LinkedList
attr_accessor :tail, :head
@fogonthedowns
fogonthedowns / card.rb
Last active April 6, 2017 23:55
Card game
module ScoreRound
SCORES = {"2"=>2, "3"=>3, "4"=>4, "5"=>5, "6"=>6, "7"=>7, "8"=>8, "9"=>9, "10"=>10, "J"=>11, "Q"=>12, "K"=>13, "A"=>14}
def high_card(hand)
hand.max_by do |card|
p card.rank
SCORES[card.rank]
end
end
end
@fogonthedowns
fogonthedowns / coinbase.rb
Created April 6, 2017 18:00
Build a market
# Imagine I wish to buy 5 btc. Iterate over order_book ask price and amounts. fullfill order, return lowest possible cost
order_book = {asks:[{price:2, amount:1, id:'id'},{price:2, amount:4, id:'id'}], bids:{}}
user_amount = 5
# 1000 btc for $2.5/each
def get_asks(order_book, user_amount)
asks = order_book[:asks]
returned_value = []
@fogonthedowns
fogonthedowns / minesweeper.rb
Created April 5, 2017 02:46
counts neighbors in a 2D array
require 'matrix'
width = 6
height = 5
number_of_mines = 25
def generate_board(width, height, number_of_mines)
two_d_array = Array.new(height) {Array.new(width, 0)}
height_index_max = height
width_index_max = width
placed_mines = 0
@fogonthedowns
fogonthedowns / cut command
Created February 21, 2017 22:50
cut columns from csv
# removes the second column ( I think the index is it )
cut -f 1,3- jz.tsv > x.tsv
@fogonthedowns
fogonthedowns / index.ios.js
Last active January 16, 2017 17:25
node-craigslist node module
import React, { Component } from 'react';
import { AppRegistry, Text, TextInput, View, TouchableHighlight } from 'react-native';
import craigslist from 'node-craigslist'
// The following line, substituted for the import statement above produces the same result:
// var craigslist = require('node-craigslist')
var client = new craigslist.Client({
city : 'seattle'
});
@fogonthedowns
fogonthedowns / backup.sh
Created December 7, 2016 18:53
back up cmd
sudo -u postgres /usr/bin/pg_dump whiteboard_api | gzip -c > /tmp/whiteboard_pre_RDAT-121.dump.gz
<html>
<title>Data Science</title>
<head>
<link href='https://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
<style>
.home {
display: -webkit-box;
@fogonthedowns
fogonthedowns / payload.json
Last active November 18, 2016 21:48
raw payload
{
"screening": "7.1",
"date": 1476908234241,
"uid": "UID-16-0003",
"linkage_matrix": [[2, 3, 0.06571365, 2],
[0, 10, 0.07951425, 2],
[5, 6, 0.09405724, 2],
[11, 13, 0.10182075, 3],
[1, 12, 0.12900146, 3],
[14, 15, 0.13498948, 5],
@fogonthedowns
fogonthedowns / api_post_example.json
Last active October 21, 2016 21:36
hitpicker api
{
"screening": 8,
"date": 1476908234241,
"uid": "UID-16-0003",
"linkage_matrix": [[2, 3, 0.06571365, 2],
[0, 10, 0.07951425, 2],
[5, 6, 0.09405724, 2],
[11, 13, 0.10182075, 3],
[1, 12, 0.12900146, 3],
[14, 15, 0.13498948, 5],