Skip to content

Instantly share code, notes, and snippets.

View ryan2clw's full-sized avatar

Ryan Dines ryan2clw

  • Tampa, FL
View GitHub Profile
{this.props.organizationId == "2728d56c-9676-4ce2-a188-77654991333e" ?
<Row style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}>
<Image
source={{ uri: apiDomain + this.props.logo }}
style={{
width: deviceWidth * 0.4,
@ryan2clw
ryan2clw / views(v4).py
Last active August 25, 2019 17:48
add balls biews
""" These are endpoints that get or create cards and rows """
from os import system
from random import randint
from django.http import JsonResponse
from django.utils import timezone
from rest_framework.decorators import api_view
from rest_framework import generics
from background_task import background
from background_task.models_completed import CompletedTask
from background_task.models import Task
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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;
}