Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Parslow almost

View GitHub Profile
View triangles.py
round = 500.0;
def setup():
size(1000, 1000)
def xy(i):
global round
dist = float(i * 2);
angle = (i/((float(round)+500)))*360
x = cos(angle)*dist;
View tree-iterator.js
class Tree {
constructor(value, left, right) {
this.left = left;
this.value = value;
this.right = right;
}
}
View crawler-solution.js
"use strict";
const url = require("url");
const rp = require("request-promise-native");
const getHrefs = require("get-hrefs");
const MAX_CONCURRENT = 10;
const MAX_COUNT = 2000;
const ALLOW_DOMAINS = new Set(["almostobsolete.net", "tomparslow.co.uk"]);
const START_URLS = ["http://almostobsolete.net/"];
@almost
almost / crawler.js
Last active November 22, 2018 09:30
View crawler.js
// Solution https://gist.github.com/almost/9ee99b1a3e7fa240c596be3820c0b6b0
"use strict";
const url = require('url');
const rp = require("request-promise-native");
const getHrefs = require("get-hrefs");
const MAX_CONCURRENT = 3;
const MAX_COUNT = 5;
View WithDimensions.js
// @flow
import React, { Component } from "react";
import { Dimensions } from "react-native";
type DimensionsState = { window: { width: number, height: number } };
type Props = {
children: (dimensions: DimensionsState) => React.Element<*>
};
View gist:ef7eceac380209961ae6681c5c95282d
UPDATE: The 1 can be either LEFT aligned (as shown) or RIGHT aligned, either will be accepted
###
# #
# #
# #
###
#
#
@almost
almost / codegolf.md
Last active August 21, 2017 01:00
Problems from last night's Code Golf at Async.JS
View codegolf.md

Yes? No?

Make a function (named 'play') that takes a boolean (true or false) and returns the string 'y' (for true) or 'n' (for false)

To the power of JavaScript

Make a function that takes a number between 1 and 30 and returns 2 raised to the power of that number. (you can use ES2015 but nothing beyond that)

@almost
almost / learning-timetable.md
Created July 2, 2016 16:43
My plan for the next 2 weeks of solid learning. I doubt I'll stick to it exactly but it gives me a framework to start with
View learning-timetable.md
@almost
almost / gifextract.py
Last active June 17, 2019 14:26 — forked from BigglesZX/gifextract.py
Extract frames from an animated GIF and return them from a generator, correctly handling palettes and frame update modes
View gifextract.py
import os
from PIL import Image
# Based on https://gist.github.com/BigglesZX/4016539 (but adapted to be a
# generator that yields frames instead of a function that saves out frames)
'''
I searched high and low for solutions to the "extract animated GIF frames in Python"
problem, and after much trial and error came up with the following solution based
on several partial examples around the web (mostly Stack Overflow).
@almost
almost / proposal.md
Last active September 12, 2019 09:07
Reactive 2016 Lightning Talk Proposal: Get Flow
View proposal.md

This is a proposal for a lightning talk at the Reactive 2016 conference.

NOTE: If you like this, star the Gist - the amount of stars decides whether it makes the cut! You could also Retweet if you want :)

Get Flow

Type checking JavaScript with Flow

JavaScript is a dynamic language, and there's nothing wrong with that. It allows quick iteration and lowers barriers. However, sometimes some compile-time type checking is just what you need to keep your code in line and give yourself the confidence to build bigger and faster. Flow gives the best of both worlds. You can have normal JavaScript but you can also add types where they're helpful, and it adds zero cost at runtime. In this talk I'll show Flow as it applies to a Redux & React codebase.