Skip to content

Instantly share code, notes, and snippets.

View cameronbourke's full-sized avatar

Cameron Bourke cameronbourke

  • Sydney, Australia
View GitHub Profile
@cameronbourke
cameronbourke / frugal-atronomer.md
Created March 2, 2021 04:53
The Frugal Astronomer

The Frugal Astronomer

🤔 The Problem

You are known as one of the most distinguished astronomers in the country, capturing images sky for decades on end. In the mail, arrives an invite to an art exhibition in New York. You've been invited to star in an exhibition! However, you are only allowed to submit one photo. What to show? You could show a photo of a single planet, but that's been done before. Then, you have an idea! What about two planets that are close to each other? You quickly realise that in order to have the highest resolution photo possible, you will need to find the closest pair of planets in your collection. The problem is, you've captured billions of planets over the years, and don't have time to compare every pair of planets! Lucky for you, you remember that lying around are the (x, y) co-ordinates for the positions of each and every planet in the night sky. You've heard talk around the town, that a technique called divide and conquer might be able to help!

We need to design an algorithm

#! /bin/bash
decimal=243881281
function dec2ip {
local v=$1
local i1=$((v>>24 & 255))
local i2=$((v>>16 & 255))
local i3=$((v>>8 & 255))
local i4=$((v & 255))
@cameronbourke
cameronbourke / .inputrc
Last active December 14, 2020 21:02
Simple Input RC
# Controls what happens when Readline wants to ring the terminal bell.
set bell-style none
# When pressing up or down arrows,
# show only history entries that match what was already typed.
"\ep":history-search-backward
"\en":history-search-forward
"\C-x\C-r": re-read-init-file
# Turn on case insensitivity for tab-completion.
@cameronbourke
cameronbourke / .block
Created May 16, 2019 01:43
fresh block
license: mit
@cameronbourke
cameronbourke / .block
Created May 16, 2019 01:43
fresh block
license: mit
@cameronbourke
cameronbourke / cwnd-sim.js
Created May 1, 2019 13:42
Simulating a simple network with two nodes A and B, with a buffer on the outbound link from A to B.
// Constants
// -----------------------------------------------
const DATA_PACKET_SIZE = 500 + 20 + 20;
const ACK_PACKET_SIZE = 0;
const BITS_TO_BYTE = 8;
const TOCK_MS = 1;
const LINK_RATE_BPS = 2 * Math.pow(10, 6);
const LINK_DELAY_MS = 50;
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "AppDelegate.h"
import React from 'react';
import ReactDOM from 'react-dom';
import Perf from 'react-addons-perf';
import { range } from 'ramda';
window.Perf = Perf;
Perf.start();
class Foo extends React.Component {