Skip to content

Instantly share code, notes, and snippets.

View brudil's full-sized avatar
🦋
making things better

James Canning brudil

🦋
making things better
View GitHub Profile
declare module '*.svg' {
const value: string;
export = value;
}
@brudil
brudil / ConditionalWrap.tsx
Last active April 23, 2018 21:26 — forked from kitze/conditionalwrap.js
one-line React component for conditionally wrapping children
interface IProps {
condition: boolean;
wrap(wrapper: (children: any) => any): any;
children: any;
}
export const ConditionalWrap = ({ condition, wrap, children }: IProps) =>
condition ? wrap(children) : children;

How to draw

Our rend language consists of:

  • variable declarations
  • loop settings
  • statements

Variable declarations

Variables are single characters. They are defined as x=(expressions). Multiple varibles can be defined with a comma seperating them.

# squares
x=0;200 ms:x=rand(0,20);#white;r rand(0,%) rand(0,%) x x; #280canvas
# lines
x=0;80 ms:#blue;l abs(500*sin(x)),50,rand(0,%),800;#red;l %,500,rand(400,600),rand(0,%);x++;#280canvas
// 200 + sin(y/5)
{
"statements": [
{
"instruction": "ASSIGNMENT",
"var": "y",
"expression": {
"lhs": 200, // short hand for { "type": "number", value: 200 }
"operator": "+",
window.HYDROSTATE_34 = {"pageId":"14","contentAPIStore":{"14":{"id":14,"meta":{"type":"content.SectionContentPage","detailUrl":"http://falmer.sussexstudent.com/content-api/v2/pages/14/","htmlUrl":"http://falmer.sussexstudent.com/pages/event-trips-societies/","slug":"event-trips-societies","showInMenus":false,"seoTitle":"","searchDescription":"","firstPublishedAt":"2017-10-27T11:59:31.860415Z","parent":{"id":2,"meta":{"type":"wagtailcore.Page","detailUrl":"http://falmer.sussexstudent.com/content-api/v2/pages/2/","htmlUrl":"http://falmer.sussexstudent.com/pages/"},"title":"Website","slug":"home"}},"title":"Event trips for societies","body":[{"type":"section","value":{"heading":"Organising events","body":[{"type":"paragraph","value":"<p>Events and trips are two of the most rewarding and fun aspects of being in a club or society and can provide you and your members with some amazing experiences. </p><p>Events can range from hosting speakers on campus, to film showings, to fundraising gigs, to a themed cocktail ni
<div class="u-container-bleed-top"><div class="AdvertBar advert AdvertBar--mobile-home"><div class="AdvertBar__advert"><MSL:Advert Position="TopBanner" /></div></div><div class="Trail"><div class="Trail__row u-container-bleed-2"><div class=" Hydro" data-component="FreshersWeek2017Banner"><a class="FlexibleHero FlexibleHero--bleed FlexibleHero--link" style="background-color:#ff546a;height:350px;" href="/freshers" data-reactroot="" data-reactid="1" data-react-checksum="-139236805"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="4517" height="2825" viewBox="0 0 4517 2825" style="width:100%;height:100%;max-height:90vh;" preserveAspectRatio="xMidYMid slice" class="HeroSVG" data-reactid="2"><defs data-reactid="3"><path id="a" d="M1868.372 280.063c-5.639 0-11.262.424-16.826 1.235l-31.731-120.862h50.065c16.34 0 29.634 13.274 29.634 29.588 0 7.022 5.702 12.717 12.733 12.717 7.031 0 12.733-5.695 12.733-12.717 0-30.339-24.718-55.024-55.101-55.024h-66.57c-3.946 0-7.67 1.829-10.0
import { createGeneration, gs, needsArticle, useArticle } from 'generation-game';
const names = [
'Dave',
'Chris',
'Sally',
'Lucy',
];
const places = [

Contribute

API

https://github.com/urfonline/api

  • Get Docker ➡️ https://www.docker.com/ avalible for Windows and macOS.
  • In the terminal, inside the project directory
  • build the server with a: docker-compose -f dev.yml build <- this builds the server (downloading python, django, postgres in side a container, seperate from your system)
  • then to run the server: docker-compose -f dev.yml up
  • The api server is at http://localhost:8000/
@brudil
brudil / a_wagtail_image_graphql.py
Created April 12, 2017 22:49
Basic DjangoObjectType for Wagtail images
from graphene_django import DjangoObjectType
from wagtail.wagtailimages.models import Image, Filter
class WagtailImage(DjangoObjectType):
url = graphene.String(width=graphene.Int())
def resolve_url(self, args, context, info):
filter = Filter()
filter.spec = 'width-{}'.format(args.get('width'))
return self.get_rendition(filter).url