Skip to content

Instantly share code, notes, and snippets.

View mosra's full-sized avatar

Vladimír Vondruš mosra

View GitHub Profile
@mosra
mosra / beer.b
Created May 26, 2011 19:04
Brainfuck interpreter
;; 99 bottles of beer on the wall
;; warning: alcohol destroys brain cells! (not as much as brainfuck)
;; written by Keymaker
++++[>+++++<-]>+++
[
[>+>+<<-]
>++++++[<+>-]+++++++++[<++++++++++>-]
>[<+>-]<-
@mosra
mosra / elastic.html
Created August 30, 2011 20:24
Percentage / fixed size combination in HTML tables
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<body>
<style type="text/css">
.special:after {
content: "";
display: block;
width: 100px;
height: 0px;
}
@mosra
mosra / scrollarea.html
Created August 31, 2011 18:55
Flexible height scroll area
<html>
<body>
<style>
.scrollable {
height: 100%;
overflow: auto;
}
html, body {
min-height: 100%;
margin: 0px;
@mosra
mosra / fullheight.html
Created September 6, 2011 18:34
Nested table layouts with enabled elasticity
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- kate: indent-width 1 -->
<!--
State:
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- FF, Webkit, Opera: OK
- IE8, IE9: takes height: 100% as 100% viewport height, thus enabling
unnecessary scrollbar.
(no doctype)
@mosra
mosra / Bourne.cpp
Created November 21, 2011 22:26
Bourne, a JSON parser library
#include "Bourne.h"
#define forever for(;;)
using namespace std;
namespace Bourne {
void AbstractValue::ignorespace(istream& in) {
while(isspace(in.peek()))
@mosra
mosra / Big.h
Created December 27, 2011 16:00
#ifndef BigFoot_Big_h
#define BigFoot_Big_h
#include <string>
#include <algorithm>
#include "TypeTraits.h"
#include "BigPrivate.h"
/** @brief BigFoot, aribitrary length integer library */
@mosra
mosra / benchmark.cpp
Created January 16, 2012 23:21
Tipsify benchmark
queue<unsigned int> cache;
unordered_set<unsigned int> map;
size_t misses = 0;
size_t maxSize = 24;
for(unsigned int index: builder.indices()) {
if(map.find(index) != map.end()) continue;
/* Not in cache */
++misses;
@mosra
mosra / gist:2629906
Created May 7, 2012 19:42
Attribute-less vertex shader
#version 330
uniform mat4 transformationMatrix;
uniform mat4 projectionMatrix;
out vec2 texCoord;
const vec2 data[4] = vec2[](
vec2(-1.0, 1.0),
vec2(-1.0, -1.0),
void RigidBodyGroup::physicsStep(GLfloat timeDelta) {
for(RigidBody* body: bodies) {
/* Compute force at current position */
body->force = _gravity;
body->physicsStep();
GLfloat accelerationHalfTimeDelta = (body->force/(body->_mass*2))*timeDelta;
/* New position */
body->transformation()[3].setXyz(body->transformation()[3].xyz() + (body->velocity + accelerationHalfTimeDelta)*timeDelta);
@mosra
mosra / README.md
Last active April 11, 2023 03:16
Most Obscure Features of C++