Skip to content

Instantly share code, notes, and snippets.

@opheliasdaisies
opheliasdaisies / game.py
Created February 4, 2020 04:21
tic-tac-toe
import tty, sys
from interface import Interface
class Game:
def __init__(self):
self.X = []
self.O = []
self.cursor_row = 0
self.cursor_column = 0
<div class="board">
<div class="row" ng-repeat="row in boards[0] track by $index">
<div class="cell-container" ng-repeat="cell in row track by $index">
<div class="cell {{cell}}"></div>
</div>
</div>
</div>
"use strict";
var lifeControllers = angular.module("lifeControllers", []);
lifeApp.controller("BoardCtrl", ["$scope", "$http", "$timeout",
function($scope, $http, $timeout){
$http.get("/random_board").success(function(data){
$scope.boards = data;
var loading = false;
configure do
set :root, File.dirname(__FILE__)
set :public_folder, "public/app"
end
get "/" do
File.read("public/app/index.html")
end
"use strict";
var lifeApp = angular.module("lifeApp", [
"ngRoute",
"lifeControllers"
]);
lifeApp.config(["$routeProvider",
function($routeProvider){
$routeProvider.
<!DOCTYPE html>
<html ng-app="lifeApp">
<head>
<title>The Game of Life</title>
<link href="/css/normalize.css" type="text/css" rel="stylesheet">
<link href="/css/app.css" type="text/css" rel="stylesheet">
<script src="lib/jquery/jquery-1.10.2.min.js"></script>
<script src="lib/angular/angular.min.js"></script>
<script src="lib/angular/angular-route.min.js"></script>
<script src="lib/angular/angular-resource.min.js"></script>
get "/random_board" do
board = Board.new(20,20)
board.starting_move!(board.randomize_start)
turns = []
turns << board.cell_states
50.times do
board.evaluate_all
board.tick!
turns << board.cell_states
end
What does the following code print to the console?
var person = {
name: "Joe Camel",
age: 42,
status: "dead"
}
console.log(typeof person);
ans: object
@opheliasdaisies
opheliasdaisies / closure.js
Last active January 4, 2016 02:19
example of a closure for blog post
function target(threat){
function attack(weapon){
return 'You attack a ' + threat + ' with a ' + weapon + '.';
}
return attack;
}
var targetZombie = target("zombie");
targetZombie("chainsaw");
@opheliasdaisies
opheliasdaisies / quiz2questions.js
Created January 21, 2014 21:13
questions for quiz 2
What does the following expression return?
4 > 1;
What does the following expression return?
"chatty" === "chatty";