Skip to content

Instantly share code, notes, and snippets.

View almost's full-sized avatar

Thomas Parslow almost

View GitHub Profile
"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 / glacier.py
Created August 21, 2012 17:59
Amazon Glacier from Python. There's now a branch for this, see here: https://github.com/almost/boto/tree/glacier
# Thomas Parslow http://almostobsolete.net
# Just a work in progress and adapted to what I need right now.
# It does uploads (via a file-like object that you write to) and
# I've started on downloads. Needs the development version of Boto from Github.
#
# Example:
#
# glacierconn = GlacierConnection(AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY)
# writer = GlacierWriter(glacierconn, GLACIER_VAULT)
# writer.write(somedata)
// @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<*>
};
@almost
almost / generators-webserver.coffee
Created July 21, 2013 10:48
CoffeesScript generator based webserver
// Translated from https://github.com/maccman/mach/blob/150c06a0991674b1cb122bb9b1b0e801c52a72ac/prototypes/generators.js
// Uses my fork of CoffeeScript with the yield statement added at https://github.com/almost/coffee-script
mach = require('mach')
app = mach.stack()
Q = require('q')
sleep = (millis, answer) ->
deferredResult = Q.defer()
setTimeout((->
deferredResult.resolve(answer)
@almost
almost / notebook.sh
Last active April 16, 2018 09:33 — forked from yangj1e/notebook.sh
Deploy Jupyter Notebook server
#!/usr/bin/env bash
cd ~
wget http://repo.continuum.io/archive/Anaconda3-4.1.0-Linux-x86_64.sh
bash Anaconda3-4.1.0-Linux-x86_64.sh -b
echo 'PATH="/home/ubuntu/anaconda2/bin:$PATH"' >> .bashrc
. .bashrc
jupyter notebook --generate-config
@almost
almost / MyCustomView.m
Last active April 15, 2018 05:47
Examples from Custom iOS Views in React Native on almostobsolete.net
#import "MyCustomView.h"
@implementation MyCustomView
{
UIColor *squareColor;
}
- (void)setIsRed:(BOOL)isRed
{
squareColor= (isRed) ? [UIColor redColor] : [UIColor greenColor];
@almost
almost / models.coffee
Created November 26, 2011 20:02
The beginnings of a declarative model syntax for CoffeeScript.
# The beginnings of a declarative model syntax for CoffeeScript.
# SEE: http://almostobsolete.net/declarative-models-in-coffeescript.html
# Thomas Parslow
# Email: tom@almostobsolete.net
# Twitter: @almostobsolete
# The top part is the setup, see below that for the demo
# To see this run right away try copy pasting it into the 'Try
# CoffeeScript' box at http://jashkenas.github.com/coffee-script/
@almost
almost / codegolf.md
Last active August 21, 2017 01:00
Problems from last night's Code Golf at Async.JS

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)

UPDATE: The 1 can be either LEFT aligned (as shown) or RIGHT aligned, either will be accepted
###
# #
# #
# #
###
#
#
@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