This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type # First we must describe the words we use | |
| Name = distinct string # Names are special words | |
| Node = ref object # Nodes simply reference ... | |
| nodes: seq[Node] # ... other nodes. | |
| name: Name # They can be distinguished by their Name | |
| proc `<->`(a: var Node, b: Node) {.inline.} = | |
| a.nodes = a.nodes & b | |
| b.nodes = b.nodes & a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Unholy Image Generator</title> | |
| </head> | |
| <body> | |
| <img id="base_image" style="display: none;"> | |
| <img id="ghost_image" style="display: none;"> | |
| <canvas id="canvas" width="800" height="800" style="border:1px solid black;"></canvas> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Gambling Checker | |
| from random import randint | |
| roll = lambda x, y: [randint(1, y) for _ in range(x)] | |
| wins = lambda a, b: sum(map(lambda x: x[0] > x[1], zip(a,b))) | |
| rate = lambda a, b, s: "A d" + str(a) + " beats a d" + str(b) + " about " + str((wins(roll(s, a), roll(s,b))/float(s))*100) + " of the time" | |
| print(rate(20, 12, 1000000)) | |
| print(rate(20, 10, 1000000)) | |
| print(rate(20, 8, 1000000)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import strutils as str | |
| ## Game "rules" | |
| # The types in this game | |
| type | |
| # Types for the player | |
| Pos = tuple[x: int, y: int] | |
| Stats = tuple[hp: int, ap: int] | |
| Class = tuple[name: string, atk: int, def: int, mov: int, mag: int] | |
| Player = tuple[pos: Pos, stat: Stats, class: Class] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/tclsh | |
| # Open & read file | |
| set a [open $argv] | |
| set lines [split [read $a] "\n"] | |
| close $a; | |
| # Loop through lines | |
| foreach line $lines { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GRID_X = 20 | |
| GRID_Y = 20 | |
| CELL = 30 | |
| FOCAL = 2 | |
| points = {{5, 5, 5}, {5, 5, -5}, {5, -5, 5}, {5, -5, -5}, {-5, 5, 5}, {-5, 5, -5}, {-5, -5, 5}, {-5, -5, -5}} | |
| function ortho_transform(p) | |
| x, y, z = unpack(p) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| turtles-own [ beacon brightest ] | |
| ; Setup function | |
| to setup | |
| clear-all | |
| create-turtles num-turtles [ | |
| set color white | |
| set beacon -1 | |
| repeat 30 [ walk-random ] | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| const PORT = 8080; | |
| function handler(request, response){ | |
| response.end('Requested path: ' + request.url); | |
| } | |
| var server = http.createServer(handler); | |
| server.listen(PORT, function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* A small home-grown version of jQuery from https://gist.github.com/jacksarick/960528f69edf3cb9262183c26130b8f6*/ | |
| function Tag(x) { | |
| if (x[0] == "#") { | |
| this.$ = document.getElementById(x.slice(1)); | |
| } | |
| if (x[0] == ".") { | |
| this.$ = document.getElementsByClassName(x.slice(1))[0]; | |
| } | |
| this.style = function(a, v) { this.$.style[a] = v; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Basic CSS stylesheet from https://gist.github.com/jacksarick/9fab0439a0b5a043cf461f616195cd84 */ | |
| body { | |
| margin: 0 auto; | |
| max-width: 50em; | |
| line-height: 1.5; | |
| padding: 4em 1em; | |
| color: #555; | |
| font-family: "Helvetica", "Arial", sans-serif; | |
| margin-top: 1em; |
NewerOlder