Skip to content

Instantly share code, notes, and snippets.

View dydx's full-sized avatar
🎯
Focusing

Josh Sandlin dydx

🎯
Focusing
View GitHub Profile
CreateUserEvent, id: 1, username: test, password: test
CreateAccountEvent, id: 1, user_id: 1, balance: 0
CreateUserEvent, id: 2, username: test2, password: test2
CreateAccountEvent, id: 2, user_id: 2, balance: 0
DepositEvent, account_id: 1, amount: 100
DepositEvent, account_id: 2, amount: 100
WithdrawEvent, account_id: 1, amount: 75
WithdrawEvent, account_id: 2, amount: 25
@dydx
dydx / robot.rb
Last active December 17, 2015 19:29
# robot thing - Josh Sandlin
def prompt(*args)
print(*args)
gets.chomp
end
name = prompt("What's your name? ")
age = prompt("How old are you? ")
@dydx
dydx / objects.js
Last active December 8, 2015 21:04
var billMurray = {
name: "Bill Murray",
age: 65,
movies: [
'Caddy Shack',
'Lost in Translation',
'Ghost Busters'
],
show: function () {
return `
// theory of tic tac toe win discovery
//
// | 2 | 7 | 6 |
// | 9 | 5 | 1 |
// | 4 | 3 | 8 |
//
// this forms a "magic square" where each
// row, column, or diagonal adds up to 15
//
// as players make moves, the values of
var result;
var max = 20;
function fizzbuzz (x) {
if (x % 15 === 0) {
return 'fizzbuzz';
} else if (x % 3 === 0) {
return 'fizz';
} else if (x % 5 === 0) {
return 'buzz';
// | a | b | c |
// | d | e | f |
// | g | h | i |
//
// sometimes either the player or the computer end up playing an undefined move, which
// is weird. I think it has something to do with the repeat handling. If a player or
// the computer mark a spot that has already been marked, the respective input functions
// recurse back and repeat the process, though it doesn't register with the main loop
// that a different input was sent.... sometimes. Sometimes it works, sometimes it doesn't
// The goal here is to write fizzbuzz in such a
// way that adding new rules is as easy as defining
// a new predicate containing a number to check and
// return result.
//
// I want the changes to be easily made, in a single
// place, outside of the hard logic of the code
//
// I also want it so that there is no need for a special
// case for multiple predicates matching, e.g. `fizzbuzz`
function sayHello(name) {
console.log(`Hello, ${name}`);
};
function areBothEven(a, b) {
return ((a % 2 == 0) && (b % 2 == 0))
}
function hotOrNot(temp) {
return (temp > 75) ? "hot" : "not"
// Josh Sandlin <josh@thenullbyte.org>
// Code for WDI-Fundamentls Exercises: 6.1.1, 6.2.1, 6.3.1
// Linted with the Standard JS Linter
var checkerboard = [
[null, null, null, null, null, null, null, null],
[null, null, null, null, null, null, null, null],
[null, null, null, null, null, null, null, null],
[null, null, null, null, null, null, null, null],
[null, null, null, null, null, null, null, null],
nat(z). %% zero
nat(Z) :- %% every number after zero is a successor
successor(Y, X), nat(Y).
successor(s(A), A).
%% A + 0 = A
natadd(A, z, A).
%% s(C) = A + S(B) if C = A + B
natadd(A, s(B), s(C)) :-
natadd(A, B, C).