Skip to content

Instantly share code, notes, and snippets.

View DanCouper's full-sized avatar

Dan Couper DanCouper

  • Strive Gaming
  • Newcastle, UK
  • 01:01 (UTC +01:00)
  • X @DanCouper
View GitHub Profile
body {
background-color: #c9c9c9;
background-size: cover;
}
#cal {
width: 400px;
margin: 0 auto;
background-color: #1e7145;
height: 620px;
@DanCouper
DanCouper / index.html
Created November 16, 2016 15:53
Tic Tac Toe
<div class='container-fluid text-center'>
<h1>Tic Tac Toe</h1>
<div class='container'>
<div class='tic'>
<div class='area'>
<div class="row1">
<div class='box one' value='1'></div>
<div class='box two' value='2'></div>
<div class='box three' value='3'></div>
@DanCouper
DanCouper / functional_data_extraction.md
Last active December 16, 2016 16:20
Method of extracting complex nested data from an object using functional-style methods

This was an explanation I gave to someone on Reddit (original question now deleted, thread here) regarding their frustrations extracting data using functional-style techniques (they were doing the twelfth functional programming exercise here).

The Data

var movieLists = [
	{
		name: "Instant Queue",
		videos : [
			{
@DanCouper
DanCouper / sumAllPrimes.js
Last active January 16, 2017 09:51
Sum all primes up to given number (max 104729)
// First 10,000 primes:
const primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201,

By Mark Damon Hughes [email protected]

The original Rogue algorithm is pretty nifty. Any time you need a random dungeon, give this a try:

  1. Divide the map into a grid (Rogue uses 3x3, but any size will work).
  2. Give each grid a flag indicating if it's "connected" or not, and an array of which grid numbers it's connected to.
  3. Pick a random room to start with, and mark it "connected".
  4. While there are unconnected neighbor rooms, connect to one of them, make that the current room, mark it "connected", and repeat.
  5. While there are unconnected rooms, try to connect them to a random connected neighbor (if a room has no connected neighbors yet, just keep cycling, you'll fill out to it eventually).
  6. All rooms are now connected at least once.
@DanCouper
DanCouper / dice.ex
Last active February 13, 2017 23:42
Exploratory investigation of methods of creating dice rolls (first spike)
defmodule Dice do
@moduledoc """
Fragile function that turns a string into a list of rolls - _e.g._
> Dice.roll("2d6")
[4, 3]
> Dice.roll("d12")
[11]
"""
@DanCouper
DanCouper / reduce.md
Last active February 28, 2017 16:20
Explanation of how reduce works

So you have an array and you want to add it up. Here:

var arr = [1,2,3]
var accumulator = 0
for (var i = 0; i < arr.length; i++) {
  accumulator = accumulator + arr[i]
}
return accumulator
<!--FCC Tic Tac Toe-->
<header></header>
<main>
<button onclick='gameData.reset()'>New Game</button>
<section id='gameOverall'>
<div id='gameCentral' class='gameCentralDefault'></div>
</section>
</main>
@DanCouper
DanCouper / calculator-using-shunting-yard-algorithm.markdown
Created May 8, 2017 13:27
Calculator using Shunting Yard Algorithm
@DanCouper
DanCouper / index.html
Created May 23, 2017 20:34
React Calculator
<!--
Nothing here, the app will render on the Body.
Sorry.
-->