Skip to content

Instantly share code, notes, and snippets.

Mark Corkery KramKroc

Block or report user

Report or block KramKroc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:f19a97e61feba64c4689d7d5e0984f98
2018-08-30 15:43:01.589 DEBUG 40617 --- [qtp773865813-26] o.e.j.s.HttpChannel : REQUEST for //169.254.172.199:53063/.~~spring-boot!~/restart on HttpChannelOverHttp@10c28298{r=1,c=false,a=IDLE,uri=//169.254.172.199:53063/.~~spring-boot!~/restart,age=1}
POST //169.254.172.199:53063/.~~spring-boot!~/restart HTTP/1.1
Content-Type: application/octet-stream
X-AUTH-TOKEN: mysecret
User-Agent: Java/1.8.0_60
Host: 169.254.172.199:53063
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 2344
@KramKroc
KramKroc / lux_quest_results_run.md
Last active May 10, 2018
Instructions on how to get Lux Quest results and run them in MineCraft
View lux_quest_results_run.md

Fetching the results

We've stored our entire Astro-Pi project including the results up on Github so these steps will detail how to pull them down onto your Pi.

First, create a folder to work with the code:

mkdir results
@KramKroc
KramKroc / result.csv
Created Jan 26, 2018
Example of file create using csv library
View result.csv
time lat long photo lux
2018-01-26-22-06-35 98 75 photoloc 199
2018-01-26-22-06-40 14 90 photoloc 211
2018-01-26-22-06-45 70 37 photoloc 59
2018-01-26-22-06-50 73 75 photoloc 82
2018-01-26-22-06-55 11 95 photoloc 219
2018-01-26-22-07-00 12 61 photoloc 145
2018-01-26-22-07-05 12 91 photoloc 274
2018-01-26-22-07-10 39 49 photoloc 72
2018-01-26-22-07-15 46 75 photoloc 199
@KramKroc
KramKroc / reading_from_csv.py
Created Jan 26, 2018
Short example showing how to read a csv file
View reading_from_csv.py
import csv
from time import sleep
with open('/home/pi/results.csv') as csvfile:
fieldnames = ['time', 'lat', 'long', 'photo', 'lux'] # Same fields we wrote to the file
reader = csv.DictReader(csvfile, fieldnames=fieldnames)
next(reader) # this lets us skip the header row
for row in reader:
print(row['lux']) # here we are just interested in the lux column
@KramKroc
KramKroc / writing_with_csv.py
Created Jan 26, 2018
Short example on how to use csv library to write to a file
View writing_with_csv.py
import csv
import datetime as dt
from random import randint
from time import sleep
time_format = "%Y-%m-%d-%H-%M-%S"
with open('/home/pi/results.csv', 'w') as csvfile: # open the file for writing
fieldnames = ['time', 'lat', 'long', 'photo', 'lux'] # the different elements we store in each row
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) # create writer with fields
@KramKroc
KramKroc / picameriapillowmean.py
Created Dec 10, 2017
Using the Pillow module to calculate average brightness of an image
View picameriapillowmean.py
import io
import time
import picamera
from PIL import Image
from PIL import ImageStat
stream = io.BytesIO()
with picamera.PiCamera() as camera:
camera.start_preview()
time.sleep(2)
@KramKroc
KramKroc / where_is_iss.py
Last active Nov 14, 2017
Get details on ISS
View where_is_iss.py
import ephem
import time
iss = ephem.readtle("ISS (ZARYA)",
"1 25544U 98067A 17317.62840120 .00004117 00000-0 69389-4 0 9994",
"2 25544 51.6432 13.3344 0004461 113.6331 45.1344 15.54138509 84996")
while True:
iss.compute(ephem.now())
print("Current position: %s, %s In darkness: %s" % (iss.sublat / ephem.degree, iss.sublong / ephem.degree, iss.eclipsed))
@KramKroc
KramKroc / mission_zero.py
Created Oct 14, 2017
Code for Mission Zero, displaying CoderDojo Banbridge logo
View mission_zero.py
from sense_hat import SenseHat
from time import sleep
sense = SenseHat()
sense.set_rotation(270)
sense.show_message("Hello from Coderdojo Banbridge!", 0.05)
r = (255,0,0)
g = (0,255,0)
@KramKroc
KramKroc / minecraft_rgbled.py
Created Dec 31, 2015
Control color of RGB LED based on what player is standing on
View minecraft_rgbled.py
from mcpi.minecraft import Minecraft
from time import sleep
from gpiozero import RGBLED
mc = Minecraft.create()
rgbled = RGBLED(26,19,13)
# block
grass = 2
ice = 9
@KramKroc
KramKroc / mibecraft_teleport.py
Created Dec 30, 2015
Teleport player using a button
View mibecraft_teleport.py
from mcpi.minecraft import Minecraft
from time import sleep
from gpiozero import LED, Button
mc = Minecraft.create()
led = LED(4)
button = Button(25)
start = mc.player.getTilePos()
while True:
You can’t perform that action at this time.