Skip to content

Instantly share code, notes, and snippets.

View esouthren's full-sized avatar

Eilidh Southren esouthren

  • London
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: white;
}
</style>
</head>
<body>
@esouthren
esouthren / github_transposit.js
Created April 25, 2019 13:17
Transposit GitHub Connector Example
(params) => {
let tree = api.run("this.list_commits", {owner: params.owner, repo: params.repo});
var commit_count = tree.length;
var random_commit = tree[Math.floor(Math.random() * commit_count)];
return random_commit;
}
(params) => {
// use our data connection to get a list of all repository commits
let commits = api.run("this.list_commits", {owner: params.owner, repo: params.repo});
// select a random commit from the list
var commit_count = commits.length;
var random_commit = commits[Math.floor(Math.random() * commit_count)];
return random_commit;
SELECT * FROM github.list_commits
WHERE owner=@owner
AND repo=@repo
<script>
const transposit = new Transposit.Transposit(
"eilidhsouthren",
"git_a_commit",
"https://api.transposit.com",
);
</script>
transposit.runOperation('get_a_commit', {owner: user, repo: repo}).then((response) => {
if (response.status !== "SUCCESS") {
console.log(response);
throw response;
}
transposit.runOperation('get_a_commit', {owner: user, repo: repo}).then((response) => {
if (response.status !== "SUCCESS") {
console.log(response);
throw response;
}
@esouthren
esouthren / index.js
Created May 7, 2020 12:09
Hacking with Amazon Alexa
/*
* Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
@esouthren
esouthren / hofstadter_sentences
Created January 10, 2021 16:29
Hofstadter's Sentences
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Metamagical Themas, Douglas R Hofstadter
# Self-Referential Sentences: a follow up
#
# The noted logician Raphael Robinson submitted a playful puzzle
# in the self documenting genre. Readers are asked to complete
# the following sentence:
#
# "In this sentence, the number of occurrences of 0 is _, of 1
void main() {
void runTestCases(Function scoringFunction) {
print(scoringFunction(1, 1) == 'Player 1: fifteen, Player 2: fifteen'
? 'passes'
: 'fail: output = ${scoringFunction(1, 1)}');
print(scoringFunction(3, 0) == 'Player 1: forty, Player 2: love'
? 'passes'
: 'fail: output = ${scoringFunction(3, 0)}');
print(scoringFunction(4, 4) == 'Deuce'
? 'passes'