Skip to content

Instantly share code, notes, and snippets.

View Xayer's full-sized avatar
👨‍💻
Coding

Frederik Rabøl Xayer

👨‍💻
Coding
View GitHub Profile
@Xayer
Xayer / AdaptibleSpeedLGauge.py
Last active November 4, 2024 13:43
Pybricks algorithm for consistent train speed
# good introduction video to "Pybricks":
# https://www.youtube.com/watch?v=Jmh4NLxJ_8c
from pybricks.pupdevices import DCMotor, ColorDistanceSensor
from pybricks.hubs import CityHub
from pybricks.tools import StopWatch
from pybricks.parameters import Port, Color
# Initialize the motor and the sensor.
motor = DCMotor(Port.B)
sensor = ColorDistanceSensor(Port.A)
from pybricks.hubs import CityHub
from pybricks.pupdevices import DCMotor, Light, ColorDistanceSensor, PFMotor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
# Initialize the hub.
hub = CityHub()
trainMotor = DCMotor(Port.B, Direction.CLOCKWISE)
# Initialize the sensor.
{"name":"Debugging of new Widgets","widgets":[{"type":"TodoList","title":"Todo List","settings":{"todos":[]},"w":1,"h":2,"y":0,"x":0,"i":1637132303640,"guid":1637132303640,"moved":false},{"type":"PriceRunnerProductInfo","title":"PriceRunner Price","settings":{"country":"dk","productId":"5182343","name":"Canon EOS R"},"w":1,"h":1,"maxH":1,"y":3,"x":0,"i":1639685400928,"guid":1639685400928,"moved":false},{"type":"PriceRunnerProductInfo","title":"PriceRunner Price","settings":{"country":"dk","productId":"3200433833","name":"Sony A7 IV"},"w":1,"h":1,"maxH":1,"y":4,"x":0,"i":1639685407228,"guid":1639685407228,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"Stocks 📈"},"w":1,"h":1,"y":0,"x":1,"i":1639685490469,"guid":1639685490469,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"Weather 🌧"},"w":2,"h":1,"y":0,"x":4,"i":1639685553815,"guid":1639685553815,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"PriceRunner 📉"},"w":1,"h":1,"y":2,"x":0,"
{
"tankSize": 50,
"name": "Toyota Corolla T-Sport"
}
{"name":"Debugging of new Widgets","widgets":[{"type":"TodoList","title":"Todo List","settings":{"todos":[]},"w":1,"h":4,"y":0,"x":0,"i":1637132303640,"guid":1637132303640,"moved":false},{"type":"PriceRunnerProductInfo","title":"PriceRunner Price","settings":{"country":"dk","productId":"5182343","name":"Canon EOS R"},"w":1,"h":1,"maxH":1,"y":5,"x":0,"i":1639685400928,"guid":1639685400928,"moved":false},{"type":"PriceRunnerProductInfo","title":"PriceRunner Price","settings":{"country":"dk","productId":"3200433833","name":"Sony A7 IV"},"w":1,"h":1,"maxH":1,"y":6,"x":0,"i":1639685407228,"guid":1639685407228,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"Stocks 📈"},"w":1,"h":1,"y":0,"x":1,"i":1639685490469,"guid":1639685490469,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"Weather 🌧"},"w":2,"h":1,"y":0,"x":4,"i":1639685553815,"guid":1639685553815,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"PriceRunner 📉"},"w":1,"h":1,"y":4,"x":0,"
{"name":"Cardlay","widgets":[{"type":"RejseplanenDeparture","title":"Departure Board","settings":{"title":"Work","stationId":"461120000"},"w":2,"h":3,"y":0,"x":0,"i":6,"minH":2,"guid":1622718077849,"moved":false},{"type":"RejseplanenDeparture","title":"Departure Board","settings":{"title":"Home","stationId":"461097000"},"w":2,"h":3,"y":3,"x":0,"i":4,"minH":2,"guid":1622718140031,"moved":false},{"type":"TodoList","title":"Todo List","settings":{"todos":[]},"w":2,"h":5,"y":8,"x":0,"i":1625472114739,"guid":1625472114739,"moved":false},{"type":"Forecast","title":"Forecast","settings":{"city":"Holbaek","units":"metric"},"w":2,"h":3,"y":13,"x":0,"i":1625472279279,"guid":1625472279279,"moved":false},{"type":"Forecast","title":"Forecast","settings":{"city":"Odense","units":"metric"},"w":2,"h":3,"y":16,"x":0,"i":1626419010869,"minW":3,"minH":2,"guid":1626419010869,"moved":false},{"type":"Weather","title":"Weather","settings":{"city":"Odense","units":"metric"},"w":2,"h":1,"y":6,"x":0,"i":1638868326112,"minW":2,"minH":1
@Xayer
Xayer / strip-miner.js
Last active March 1, 2020 18:36
Minecraft Strip Miner
player.onChat("to me", function () {
agent.teleportToPlayer()
agent.turnRight();
})
function mineInFront () {
while(agent.detect(AgentDetection.Block, FORWARD)){
agent.destroy(FORWARD);
}
agent.move(FORWARD, 1)
agent.destroy(UP)
@Xayer
Xayer / builder.js
Created February 17, 2020 21:19
Minecraft tower builder
player.onChat("run", function (roofHeight) {
for (let index = 0; index <= 4; index++) {
builder.mark()
builder.move(FORWARD, roofHeight)
builder.raiseWall(POLISHED_ANDESITE, 5)
for (let index2 = 0; index2 < 2; index2++) {
builder.turn(RIGHT_TURN)
builder.move(FORWARD, 1)
}
builder.turn(RIGHT_TURN)
@Xayer
Xayer / FastLED test code.h
Last active February 5, 2020 18:08
FastLED test code.h
#include <FastLED.h>
#define LED_PIN 7
#define NUM_LEDS 300
#define FADE_AMOUNT 5
#define MAX_BRIGHTNESS 255
CRGB leds[NUM_LEDS];
void setup() {
@Xayer
Xayer / Minerbot
Last active February 16, 2020 20:52
Minerbot made in Minecraft MakeCode - Javascript code. Still need to figure out what to do, if the block you're destroying is sand or gravel, as it falls down.
function GoHomeWithLoot () {
LastMiningPosition = agent.getPosition()
agent.teleport(Home, WEST)
agent.dropAll(DOWN)
agent.teleport(LastMiningPosition, WEST)
player.say("start mining")
}
function CheckForGravel () {
while (blocks.testForBlock(GRASS, positions.add(
agent.getPosition(),