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 / serializers.py
Last active August 25, 2019 01:14
Serialize card and row data
"""
Form the JSON that we need
"""
from random import sample
from rest_framework import serializers
from play.models import Row, Card
def card_data(card):
""" populates card with 5 rows of random data """
b_column = sample(range(1, 16), k=5)
@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 / 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 / cards.tsx
Last active August 24, 2019 22:30
Card action and reducer
import { actionTypes } from './actionTypes';
import { action as act } from 'typesafe-actions'
import { getCards } from '../webservices/bingoService';
import { Reducer, AnyAction } from 'redux'
import { Dispatch } from 'react';
import { danger, clear } from './messages';
/* Card Interface */
export interface ICardArray {
@ryan2clw
ryan2clw / BingoPage(Part3).tsx
Last active August 24, 2019 22:26
Main page for python bingo
import * as React from 'react'
import styled from 'styled-components';
import { connect } from 'react-redux';
import { Flex } from 'rebass';
import { Container, Row, Spinner } from 'reactstrap';
import { IApplication, IConnectedReduxProps } from '../store/configureStore';
import BingoBoard from './BingoBoard';
import { requestNumbers } from '../store/cards';
import './styles/App.css';
import './styles/bootstrap.css';
@ryan2clw
ryan2clw / bingoService.tsx
Last active August 24, 2019 00:10
Call the bingo backend with AJAX request
import { handleResponse } from '../store/events';
export const getCards = async () => {
const requestOptions = {
method: 'GET'
};
const uri = "http://localhost:8000/cards";
return fetch(uri, requestOptions)
.then(handleResponse)
.then(cards => cards);
@ryan2clw
ryan2clw / actionTypes.tsx
Last active August 23, 2019 23:56
Events for bingo game aka actionTypes
enum actionTypes {
/* Messaging system */
ALERT_SUCCESS = 'ALERT_SUCCESS',
ALERT_DANGER = 'ALERT_DANGER',
ALERT_CLEAR = 'ALERT_CLEAR',
/* Bingo cards */
CARD_REQUEST = 'CARD_REQUEST',
CARD_SUCCESS = 'CARD_SUCCESS',
CARD_FAILURE = 'CARD_FAILURE',
}