Skip to content

Instantly share code, notes, and snippets.

View GeeWee's full-sized avatar

Gustav Wengel GeeWee

View GitHub Profile
@GeeWee
GeeWee / dragonfly_grammar.py
Created November 24, 2017 12:50
Example of a dragonfly Grammar
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
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
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);
}
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);
}
function getTemperatureToBoilAt(){
return "100 celcius";
}
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}`;
function sendBoilingWaterToThePot(potId, heatedWater) {
axios.post(potId, {
water: heatedWater
});
}
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);
}
// button.jsx
import styled from 'styled-components';
export default styled.button`
display: block;
margin: 0;
padding: 0;
border: 0;
background: #34495f;
color: #fff;
const Logo = () => <img src="/img/logo.png" />