Skip to content

Instantly share code, notes, and snippets.

Avatar

Mischa Alff Mischa-Alff

View GitHub Profile
@Mischa-Alff
Mischa-Alff / autoexp.dat
Last active Mar 1, 2016
VS2010 SSO debug fix
View autoexp.dat
; AutoExp.Dat - templates for automatically expanding data
; Copyright(c) Microsoft Corporation. All Rights Reserved.
;---------------------------------------------------------------
;
; While debugging, Data Tips and items in the Watch and Variable
; windows are automatically expanded to show their most important
; elements. The expansion follows the format given by the rules
; in this file. You can add rules for your types or change the
; predefined rules.
;
View Ball.cpp
#include <SFML/Graphics.hpp>
#include "Ball.hpp"
Ball::Ball(int x, int y) : Entity(x, y, 10, 10, 4) {}
void Ball::checkCollision(int x, int y) {
;
}
@Mischa-Alff
Mischa-Alff / AABB.cpp
Last active Feb 24, 2017
Simple AABB implementation using SIMD instructions for x86-64
View AABB.cpp
#include <chrono>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <random>
struct AABB{int32_t left, top, right, bottom;};
extern "C" bool check_aabb(AABB *a, AABB *b);
extern "C" bool check_aabb_conventional(AABB *a, AABB *b);
View aabb.nasm
section .data
fmt: db "%#06x", 0xA, 0x0
align 16
aabb1:
.left: dd 1
.top: dd 1
.right: dd 1
.bottom: dd 1
align 16
aabb2:
View fps.cpp
std::chrono::high_resolution_clock::time_point start, end, timetoprint;
timetoprint = start = end = std::chrono::high_resolution_clock::now();
long long frame_count=0;
long double frametime_total=0.f;
while(!glfwWindowShouldClose(win)) {
end = std::chrono::high_resolution_clock::now();
long int frametime_us = (std::chrono::duration_cast<std::chrono::microseconds>(end-start).count());
float frametime_s = ft/1e6f;
View gameloop.py
Clock gameClock;
while gameIsRunning:
frameTime = gameClock.restart()
process_input()
update_physics(frameTime)
update_graphics(frameTime)
@Mischa-Alff
Mischa-Alff / bf.c
Last active Aug 29, 2015
Brainfuck interpreter in C.
View bf.c
char*c="code",*z="input",d['u0']={0};
main(r,i,k){char*p=d;int s['~']={k=r=0},*l=s;while(i=c[r++])k?i==91?++k:i==93?k?--k:--k:0:(i==93?*p?r=*l:l--:i==91?*p?*++l=r:++k:0,p+=i==62,p-=i==60,i==46?putchar(*p):0,*p-=i==45,i==44?*p=*z++:0,*p+=i==43);}
View gist:98470190e32553a44142
Program received signal SIGSEGV, Segmentation fault.
0x000000000041dab8 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x8c630000000008, __in_chrg=<optimized out>)
at /usr/include/c++/4.9.1/bits/shared_ptr_base.h:665
665 if (_M_pi != nullptr)
(gdb) bt
#0 0x000000000041dab8 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x8c630000000008, __in_chrg=<optimized out>)
at /usr/include/c++/4.9.1/bits/shared_ptr_base.h:665
#1 0x000000000041d57a in std::__shared_ptr<wind::Entity, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x8c630000000000, __in_chrg=<optimized out>)
at /usr/include/c++/4.9.1/bits/shared_ptr_base.h:914
#2 0x000000000041d594 in std::shared_ptr<wind::Entity>::~shared_ptr (this=0x8c630000000000, __in_chrg=<optimized out>)
View pow.cpp
/*
g++
std::pow: Times (min, max, avg): 27635604us, 28006757us, 27696884us
expanded: Times (min, max, avg): 1318329us, 1409901us, 1335821us
jplatte's... thing: Times (min, max, avg): 7105522us, 7219386us, 7135305us
g++ -O3
std::pow: Times (min, max, avg): 25542284us, 26192220us, 25633656us
expanded: Times (min, max, avg): 0us, 0us, 0us
View featherkit_simplex_tests.cpp
#include <chrono>
#include <iostream>
#include <fea/util/noise.hpp>
int main()
{
fea::Noise noise;
uint64_t min(-1), max(0), avg(0);
int steps = 10;