Skip to content

Instantly share code, notes, and snippets.

View chrismay's full-sized avatar

Chris May chrismay

  • Warwickshire, UK
View GitHub Profile
@chrismay
chrismay / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@chrismay
chrismay / random.sh
Created February 12, 2015 12:07
Convert dev/random to PRNG
$ sudo -i
# cd /dev
# rm random
# mknod /dev/random c 1 9
# cat /dev/random
@chrismay
chrismay / loop.html
Last active October 11, 2016 14:09
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<style type='text/css'>
</style>
@chrismay
chrismay / Hamilton.java
Last active October 22, 2017 19:25
An implementation of Hamilton's method for Smallest-Remainder rounding of percentages.
package chris.impl;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@chrismay
chrismay / LambdaLogger.js
Created June 21, 2018 09:40
A lambda to unpack the POST body (assumed to be JSON) and log it to cloudwatch
exports.handler = async (event, ctx, callback) => {
console.log({app:"unknown", env: "unknown", ...(JSON.parse(event.body))});
var response = {
"statusCode": 200,
"body": JSON.stringify({result:"ok"}),
"isBase64Encoded": false
};
callback(null,response);
};
@chrismay
chrismay / cold_observable_test.ts
Created August 1, 2018 11:23
Jasmine/Karma test of cold observables
it('delete me', async (done) => {
const addAll = nums => nums.reduce((a, b) => a + b, 0);
const o1 = Observable.of(1);
const o2 = Observable.of(2).delay(1000).shareReplay(1);
const o1p2 = Observable.forkJoin([o1, o2]).pipe(
map(addAll),
shareReplay(1));
@chrismay
chrismay / Hyper-settings.js
Last active August 10, 2018 07:11
Hyper seting
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: "canary",
if ($host.Name -eq 'ConsoleHost') {
Set-PSReadLineOption -EditMode Emacs
Set-PSReadlineOption -BellStyle None
}
# Ensure that Get-ChildItemColor is loaded
Import-Module Get-ChildItemColor
# Set l and ls alias to use the new Get-ChildItemColor cmdlets
Set-Alias ll Get-ChildItemColor -Option AllScope
Set-Alias ls Get-ChildItemColorFormatWide -Option AllScope
import { Instant } from '../types';
type NotificationType = 'po-approval' | 'program-activation';
interface NotificationSharedFields {
referenceId: string;
message: string;
seen: boolean;
createdAtUtc: Instant;
notificationType: NotificationType;
@chrismay
chrismay / anagrams.py
Created April 12, 2023 06:55
anagrams kata (pyspark)
from pyspark.sql import SparkSession
from pyspark.sql.types import StringType
from pyspark.sql.functions import col, udf, collect_list, size, length
spark = SparkSession.builder.getOrCreate()
def alpha_sort(word):
return "".join(sorted(word))