Skip to content

Instantly share code, notes, and snippets.

View taybenlor's full-sized avatar

Ben Taylor taybenlor

View GitHub Profile
@taybenlor
taybenlor / background.js
Created March 27, 2023 08:15
A chrome extension for Cypress that forces the browser to emulate focus.
/**
* Force Focus
*
* This extension forces Emulation.setFocusEmulationEnabled
* which allows tests that are dependent on focus to work when
* the browser is not focused or when it is in headless mode
*/
chrome.tabs.onUpdated.addListener(function (tabId, info) {
console.log("Force focus opened new tab", tabId, info);
@taybenlor
taybenlor / write.rs
Created September 12, 2022 10:30
This program writes whatever you type into STDIN to the file specified in arg1.
use std::io::Read;
use std::{env, fs, io};
fn main() {
let filename = env::args().nth(1).expect("no filename provided");
let stdin = io::stdin();
let mut buf = String::new();
stdin
.lock()
@taybenlor
taybenlor / cat.rs
Last active September 12, 2022 10:36
print content in each args file to STDOUT
use std::{env, fs};
fn main() {
for filename in env::args().skip(1) {
let content = fs::read_to_string(filename).expect("unable to read file");
print!("{}", content);
}
}
@taybenlor
taybenlor / house.py
Created July 18, 2021 07:32
A way to do text adventures using modules.
"""
Each module can import the player module to get their name and their items.
Here we add boots to their items if they write "pickup boots".
"""
import main
import player
def enter():
#include <Mouse.h>
#define enc_dt 2
#define enc_clk 3
int responseDelay = 2; // response delay of the mouse, in ms
void setup() {
@taybenlor
taybenlor / Form Letter.md
Last active April 23, 2017 08:35
Form letter that I email to companies offering unpaid internships.

Subject: Unpaid Internships & Fair Work

Hi there,

I'm Ben Taylor, I don't represent anyone or anything, I'm simply a concerned Australian. Our country has long been known as a paradise for the working class. We give fair holidays and fair pay. We're a country that doesn't tip because we know the waitstaff are earning enough to support themselves.

I'm emailing you because your company is offering an unpaid internship. Under Australian law it's illegal to have an employee that works for free. In many cases unpaid internships are illegal.

It's absolutely in your right to offer an internship, you can pay them minimum wage if you like, but not paying is exploitative and discriminatory. Should a young person who is independent be forced to take a second job or live under severe financial stress just to get a chance in an industry? What about those who can't afford to do even that?

@taybenlor
taybenlor / gist:3684133
Created September 9, 2012 12:49
Heroku pros/cons

Pros

  • Very low effort to get running
  • Easily extensible to add very powerful features eg. I added memcache and caching to one of our apps and had it live within 30mins
  • Less downtime stress (if shit fails, you know heroku is dealing with it and you don't have to do much other than respond to customers)
  • Very little platform lockin (unlike Google App Engine)
  • Standing on shoulders of giants
  • Strong app segmentation = stability
  • Easy to price for clients
@taybenlor
taybenlor / CustomCollectionFlowLayout.h
Last active January 1, 2016 08:59 — forked from toblerpwn/CustomCollectionFlowLayout.h
Adds support for sections with no header.
//
// CustomCollectionFlowLayout.h
// evilapples
//
// http://stackoverflow.com/questions/13511733/how-to-make-supplementary-view-float-in-uicollectionview-as-section-headers-do-i
//
//
#import <UIKit/UIKit.h>

Autolayout lessons:

@taybenlor
taybenlor / colour.js
Created October 15, 2012 23:28
Colour Helpers in JS
/**
* A class to parse colour values. Updated by Ben to support colour conversions.
* @author Stoyan Stefanov <sstoo@gmail.com>
* @author Ben Taylor <taybenlor@gmail.com>
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
* @license Use it if you like it
*/
function Colour(colour_string)
{
this.ok = false;