Skip to content

Instantly share code, notes, and snippets.

View ryan2clw's full-sized avatar

Ryan Dines ryan2clw

  • Tampa, FL
View GitHub Profile
@ryan2clw
ryan2clw / Square.tsx
Last active August 24, 2019 22:32
Square for bingo game
import React from 'react';
import styled from 'styled-components';
import { Flex } from 'rebass';
const FlexHeight = styled(Flex)`
height: ${(props) => props.height};
min-width: 0;
height: 42px;
margin: 1px !important;
padding: 4px;
@ryan2clw
ryan2clw / BingoBoard.tsx
Last active August 24, 2019 22:34
The card of a bingo game
import React from 'react';
import { Flex } from 'rebass';
import styled from 'styled-components';
import Square from './Square';
import { ICard, IRow } from '../store/cards';
// Create a Title component that'll render an <h1> tag with some styles
const BingoHeader = styled.div`
width: 132%;
margin-left: -15%;
@ryan2clw
ryan2clw / App.css
Created August 18, 2019 19:14
Bingo css
.ticket-number {
margin: 1px;
color: black;
background: #defffd;
}
.called {
transition: all .5s ease-in-out;
background: #076461;
color:white;
}
@ryan2clw
ryan2clw / models.py
Created August 19, 2019 01:23
Added balls to model
# keep Card and Row models from before
class Ball(models.Model):
"""
The ball in a ball-blower. Represents a random number 1-75.
"""
num_value = models.CharField(max_length=3)
updated_at = models.DateTimeField(auto_now=True)
class MatchSmiley(models.Model):
""" Derived from card data, each column is a number on a specific card"""
@ryan2clw
ryan2clw / models.py
Created August 19, 2019 16:05
Models for bingo
"""
We have 4 models that interact with each other to form the game play.
The card and row tables will form the data for the bingo cards.
The match_smiley table is populated from the card/row tables, where each column is a certain number on the card,
so the row would be the group of numbers that make a smiley-face.
We'll decrement the 'left' property of match_smiley as balls are called that match.
"""
from django.db import models
# keep Card and Row models from before
@ryan2clw
ryan2clw / 0007_auto_some_date.py
Created August 19, 2019 16:24
data migration
# Generated by Django 2.2.4 on 2019-08-19 15:30
from django.db import migrations
def seed_database(apps, _):
""" Seed the ball numbers into the database """
balls = apps.get_model('play', 'Ball')
balls.objects.all().delete()
for i in range(1, 76):
data = {
@ryan2clw
ryan2clw / urls.py
Created August 20, 2019 12:59
Play bingo urls
""" urls for playing bingo """
from django.urls import path
from play.views import CardList, BallList, reset_balls
urlpatterns = [
path('cards/', CardList.as_view(), name='cards'),
path('balls/', BallList.as_view(), name='balls'),
path('reset_balls/', reset_balls, name='reset_balls')
]
@ryan2clw
ryan2clw / BingoPage.tsx
Last active August 23, 2019 17:40
Start of bingo page
import * as React from 'react'
import styled from 'styled-components';
import { connect } from 'react-redux';
// tslint:disable-next-line: no-submodule-imports
import 'bootstrap/dist/css/bootstrap.css';
import { Flex } from 'rebass';
import { Container, Row } from 'reactstrap';
import { IApplicationState, IConnectedReduxProps } from '../store/configureStore';
import { danger, clear } from '../store/messages';
@ryan2clw
ryan2clw / tslint.json
Last active August 23, 2019 17:43
tslint config
{
"defaultSeverity": "error",
"extends": [
"tslint-react"
],
"jsRules": {
},
"rules": {
"member-access": false,
"ordered-imports": false,
@ryan2clw
ryan2clw / serializers(Part4).py
Created August 25, 2019 03:07
remove excess data
(Keep the rest of BallSerializer)
def to_representation(self, instance):
""" Get rid of excess data, makes it easier to consume on the client """
ret = super().to_representation(instance)
ret.pop('updated_at')
ret.pop('is_played')
return ret