Skip to content

Instantly share code, notes, and snippets.

Rasmus Bondesson raek

Block or report user

Report or block raek

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
@raek
raek / cowsay.py
Created Nov 30, 2018
cowsay widget for urwid
View cowsay.py
import urwid
import subprocess
class Cowsay(urwid.WidgetDecoration):
_LEFT = 2
_RIGHT = 2
_TOP = 1
_BOTTOM = 6
View rocketty.py
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
View hello_kitty_ledslinga.ino
#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 Jan 22, 2018
Regnbågseffekt
View ledsinga.ino
// 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 Oct 26, 2017
A-Star 32U4 NES Controller
View nes_controller.ino
#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
View pipe.h
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 Oct 5, 2016
YAML reformatting
View reformat_yaml.py
# 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 Sep 21, 2016
unused symbols and GCC
View all.c
#include <stdio.h>
int used(void)
{
printf("all used\n");
return 0;
}
int unused(void)
{
@raek
raek / puzzle5.c
Created Sep 8, 2016
Puzzle of the Week #5: C'ing is believing
View puzzle5.c
#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 Nov 8, 2015
Super advanced simulation
View simulate.py
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):
You can’t perform that action at this time.