Skip to content

Instantly share code, notes, and snippets.

@beoran
beoran / proposal_go2_range_types.md
Last active March 15, 2019 07:07
Proposal for Go Range Types

Proposal: Go 2 Range Types

B.

Last updated: 15 march, 2019

Discussion at:

golang/go/issues/30428 (the proposal itself)

golang/go/issues/30613 (checked integer types)

@beoran
beoran / c99_ub_list.rst
Created October 12, 2018 10:00 — forked from Earnestly/c99_ub_list.rst
C99 List of Undefined Behavior (193 Cases)

C99 List of Undefined Behavior

From N1256: (See http://port70.net/~nsz/c/c99/n1256.html#J.2)

  • A "shall" or "shall not" requirement that appears outside of a constraint is violated (clause 4).
  • A nonempty source file does not end in a new-line character which is not immediately preceded by a backslash character or ends in a partial preprocessing token or comment (5.1.1.2).
  • Token concatenation produces a character sequence matching the syntax of a universal character name (5.1.1.2).
  • A program in a hosted environment does not define a function named main using one of the specified forms (5.1.2.2.1).
  • A character not in the basic source character set is encountered in a source file, except in an identifier, a character constant, a string literal, a header name, a comment, or a preprocessing token that is never converted to a token (5.2.1).
  • An identifier, comment, string literal, character constant, or header name contains an invalid multibyte character or does not
@beoran
beoran / nsteps.rb
Created November 16, 2012 18:55
nsteps the rubyway.
# this has only one side effect, it defines the nsteps fmethod
def nsteps(x, y)
if (x.even?)
return false if(y.odd?)
return x * 2 if(x == y)
return x * 2 - 1 if (x==(y-2))
return false
else
return false if(y.even?)
return x * 2 if(x == y)
@beoran
beoran / lua-5.2.0.diff
Created April 14, 2012 20:57
Diff for updating to lua 5.200
git diff
diff --git a/index.html b/index.html
index 399ee51..366aa4b 100644
--- a/index.html
+++ b/index.html
@@ -1490,7 +1490,7 @@ USE_OSGPLUGIN(<plugin2>)
</tr>
<tr>
<td id="lua-package">lua</td>
- <td id="lua-version">5.1.4</td>
@beoran
beoran / utilities.js
Created September 14, 2011 13:14
Dynamic object generation
function $id(id) {
return document.getElementById(id)
}
function $create(kind) {
return document.createElement(kind)
}
function $move(node, x, y) {
node.style.left = x.toString() + 'px'
@beoran
beoran / SDL_Main.cpp
Created July 19, 2011 22:00
Milkytracker CANOO
/*
* tracker/sdl/SDL_Main.cpp
*
* Copyright 2009 Peter Barth, Christopher O'Neill
*
* This file is part of Milkytracker.
*
* Milkytracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
#include <SDL.h>
#include <stdio.h>
int main(void) {
puts("Hello world!");
return 0;
}
cpu : $22
mem : $10
sound : $3
screen+touch : $30
pots : $5
sd : $3
PMIC : $5
HDMI : $4
battery : $5
wifi/bt : $9
*snes like
*Handheld with TV out.
*Wide screen. WQVGA or WVGA?
@beoran
beoran / end_of_blocks.rb
Created May 31, 2011 07:02
Clarify end of Ruby blocks
module Foo
class Bar
def initialize(a)
@a = a
end # def initialize
def frob
if @a
puts @a
else