Skip to content

Instantly share code, notes, and snippets.

View raek's full-sized avatar

Rasmus Bondesson raek

View GitHub Profile
import urwid as u
with open('text.txt', 'rt') as f:
text_lines = f.read().split('\n')
def unhandled_input(key):
pass #body.keypress(key)
def send_line(line):
pass
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN A2
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
@raek
raek / ledsinga.ino
Last active January 22, 2018 20:55
Regnbågseffekt
// Installation:
// * Install the "Adafruit NeoPixel" from the Arduino library manager.
//
// This is a modified example of the "standtest" example included in the library. Changes:
// * Set led strip pin to pin 11
// * Set number of leds to 30
// * made the loop() body only run the rainbow code
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
@raek
raek / nes_controller.ino
Last active October 26, 2017 19:00
A-Star 32U4 NES Controller
#include <Keyboard.h>
const int vccPin = 2; // red
const int gndPin = 3; // black
const int shiftPin = 4; // yellow
const int latchPin = 5; // green
const int dataPin = 6; // blue
char buttonToKey[8] = {
'f', // A
@raek
raek / pipe.h
Created February 7, 2017 22:15
struct input_t;
bool input_accept(struct input_t *input, reg_t *value);
void input_decline(struct input_t *input);
struct output_t;
bool output_offer(struct output_t *output, reg_t value);
void output_abstain(struct output_t *output);
@raek
raek / reformat_yaml.py
Created October 5, 2016 21:02
YAML reformatting
# to install yaml:
# sudo pip install pyyaml
import argparse
import yaml
import sys
parser = argparse.ArgumentParser(description="normalize YAML formatting")
parser.add_argument("--mode", help="how to pretty-print innermost nodes",
@raek
raek / all.c
Created September 21, 2016 12:55
unused symbols and GCC
#include <stdio.h>
int used(void)
{
printf("all used\n");
return 0;
}
int unused(void)
{
@raek
raek / puzzle5.c
Created September 8, 2016 08:58
Puzzle of the Week #5: C'ing is believing
#include <stdio.h>
/* Run like this:
* gcc -Wall -Wextra puzzle5.c && ./a.out
*/
/* TODO: remove these weird unused functions */
long int g(long int x) {
return x;
}
@raek
raek / simulate.py
Created November 8, 2015 20:01
Super advanced simulation
import pygame
import sys
assert sys.version_info.major == 2, "This is a Python 2 program"
def draw(surface, width, height, time):
surface.fill((0, 255, 0))
for i in range(256):
#include <AStar32U4Prime.h>
const char key = '.';
Pushbutton buttonD(0);
void setup() {
Keyboard.begin();
}
void loop() {
if (buttonD.getSingleDebouncedPress()) { Keyboard.press(key); }