Skip to content

Instantly share code, notes, and snippets.

package main
import (
"bytes"
"flag"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
@GreenLightning
GreenLightning / Keyboard Input Handling.txt
Created March 18, 2017 12:21
Keyboard Input Handling
Keyboard Input Handling
Keyboards are used in two different ways: As a way to enter text or as an array of buttons each of which has a different function. An input API should therefore provide you two kinds of information: which text was entered and what buttons were pressed.
For text I would actually prefer a string, because the most common thing to do is to append it to some form of buffer. If the input API gave you an UTF-32 char, you would have to convert it into UTF-8 before appending it to the buffer.
For the other kind of information - what buttons are pressed - the API should give you a "key position id". Note that I am avoiding the words scan code or virtual key code. The "key position id" treats keys more like buttons and it totally ignores what label is on each key. One important difference between keyboards is that US keyboards have 104 keys, while European keyboards have 105 keys (I don't know about other parts of the world). This is a difference that would need to be encoded in the "key posi
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<string> split(const string& line) {
vector<string> result;
string::size_type i = 0;
@GreenLightning
GreenLightning / 57827385.lua
Created June 21, 2015 20:01
TIS-100 SCATTER PLOT VIEWER SPECIFICATION
-- For anyone who liked the SCATTER PLOT VIEWER puzzle included in some of the early
-- access builds of TIS-100...
-- INSTALLATION: Copy everything in this file. Open TIS-100. Go to the SPECIFICATION
-- EDITOR. Click on IMPORT SPECIFICATION FROM CLIPBOARD. Done!
-- The function get_name() should return a single string that is the name of the puzzle.
--
function get_name()
return "SCATTER PLOT VIEWER"
@GreenLightning
GreenLightning / 19392494.lua
Created June 16, 2015 19:00
TIS-100 PRIME DETECTOR SPECIFICATION
-- For anyone who liked the PRIME DETECTOR puzzle included in some of the early access
-- builds of TIS-100...
-- INSTALLATION: Copy everything in this file. Open TIS-100. Go to the SPECIFICATION
-- EDITOR. Click on IMPORT SPECIFICATION FROM CLIPBOARD. Done!
-- The function get_name() should return a single string that is the name of the puzzle.
--
function get_name()
return "PRIME DETECTOR"
@GreenLightning
GreenLightning / Simon Says
Created November 11, 2013 20:17
Simon Says
int led[] = {4, 5, 6, 7};
int taster[] = {8, 9, 10, 11};
int zufallszahl[100] // Semikolon
int durchlauf = 0;
int tasterstatus[4] // Semikolon
void setup()
{
for (int x = 0; x < 4; x++); // Das Semikolon trennt die Schleife von dem Codeblock
{