This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example_grammar = { | |
# A dragonfly grammar is basically a python dictionary of phrases to the actions they should trigger | |
# With some special syntax for words than can vary. See the up command below, where "[<n>]" in the key means "any number" | |
# Then it's possible to use that number in the action. "up:%(n)d" means press the up key n times | |
# where n was the number from before | |
"up [<n>]": Key("up:%(n)d"), | |
# This allows us to go up by an amount. E.g. saying "up two" will simulate pressing the up button two times | |
"down [<n>]": Key("down:%(n)d"), | |
"space": release + Key("space"), | |
# Saying space will release all other held keys, and simulate a space press |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import collections | |
fileImports = [] | |
def getImports(file): | |
with open(file) as file: | |
fileContents = file.readlines(); | |
# See if line contains import and the "." character - that (probably) means it's a relative import. | |
# Imports are not case sensitive on all platforms, so to aggregate them, we make them all lower case |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function boilWater(){ | |
const water = axios.get("https://somethingFromSomeApi.com/something").data.water | |
const potIdForWater = axios.get("https://somethingFromSomeOtherApi.com/adress").data.potId | |
const temperature = getTemperatureToBoilAt(); | |
const heatedWater = getHeatedWater(water, temperature) sendBoilingWaterToThePot(potIdForWater, heatedWater); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function boilWater(){ | |
const water = axios.get("https://somethingFromSomeApi.com/something").data.water | |
const potIdForWater = axios.get("https://somethingFromSomeOtherApi.com/adress").data.potId | |
const temperature = getTemperatureToBoilAt(); | |
const heatedWater = getHeatedWater(water, temperature) sendBoilingWaterToThePot(potIdForWater, heatedWater); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getTemperatureToBoilAt(){ | |
return "100 celcius"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getHeatedWater(water, temperature) { | |
// Convert the water to a number | |
const waterAsNumber = parseInt(water, 10); | |
// We spilled some.. | |
const remainingWater = waterAsNumber - 10; | |
// Make sure the temperature is in celcius | |
if (temperature.indexOf("celcius") == -1){ | |
throw new Error("No imperial units allowed!"); | |
} | |
return `Heated ${remainingWater} ml water to ${temperature}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendBoilingWaterToThePot(potId, heatedWater) { | |
axios.post(potId, { | |
water: heatedWater | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function waterBoiler(){ | |
const water: string = axios.get("https://somethingFromSomeApi.com/something").data.water | |
const potIdForWater: string = axios.get("https://somethingFromSomeOtherApi.com/adress").data.potId | |
const temperature: string = getTemperatureToBoilAt(); | |
const heatedWater: string = getHeatedWater(water, temperature) | |
sendBoilingWaterToThePot(potIdForWater, heatedWater); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Logo = () => <img src="/img/logo.png" /> |
OlderNewer