Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Creates a HTTP response to be sent as the response.
*
* @param resource The socket connection stream
* @param array array(response_code, array(header_title => header_content), content)
* @return string
*/
protected function httpResponse($conn, array $response)
{
/* Function to calcuate the n first fibonacci numbers */
Frame *fib_frame = malloc(sizeof(Frame));
Frame_init(fib_frame);
uint32_t prevfr = Frame_allocVariable(fib_frame);
/* No continuations called here, so we can get away with not allocating space for return values */
uint32_t varsum = Frame_allocVariable(fib_frame);
uint32_t varn = Frame_allocVariable(fib_frame);
uint32_t vara = Frame_allocVariable(fib_frame);
uint32_t varb = Frame_allocVariable(fib_frame);
@m4rw3r
m4rw3r / gist:3070816
Created July 8, 2012 12:53
Test interpreter with function-pointers
#include <inttypes.h>
#include <stdio.h>
#define Util_StaticAssert_CONCAT_(a, b) a##b
#define Util_StaticAssert_CONCAT(a, b) Util_StaticAssert_CONCAT_(a, b)
#define Util_StaticAssert(e, msg) \
enum { Util_StaticAssert_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }
@m4rw3r
m4rw3r / battlestation.md
Last active June 18, 2023 11:05
Gaming desktop hardware

My hardware if anyone is interested:

Gaming Computer

  • CPU: Intel Core i9 13900K @ +2 TVB bins, no OC (6.0 GHz @ 1-2 core) for now
  • RAM: G.Skill 64 (2x32GB) DDR5 6400MT/s CL32 Trident Z5 RGB @ XMP for now
  • GPU: MSI GeForce RTX 4090 Suprim X @ 3 GHz & +1500 Mem
  • Motherboard: ASUS Maximus Z790 Apex
  • PSU: Corsair HX1200i 1200W
  • Case: Streacom BC1 Bench Table
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
#include <sys/mman.h>
typedef uint8_t Register;
#define Register_lowBits(r) (r & 0x7)
<?php
/**
* @ORM\Entity
*/
class User
{
/**
* @ORM\String
*/
#!/usr/bin/env php
<?php
$files = glob('Templates/*.tmpl');
$templates = array();
foreach($files as $file) {
$data = file_get_contents($file);
@m4rw3r
m4rw3r / Promise 0.1.js
Last active December 10, 2015 12:38
Minimalistic CommonJS Promises/A implementation fulfilling all the tests in https://github.com/domenic/promise-tests and also all tests in https://github.com/promises-aplus/promises-tests
(function() {
/**
* Defers the execution of func to the next tick.
*
* @param function
*/
var deferFunc = this.nextTick
? this.nextTick
: function(func) {
setTimeout(func, 0);
(function() {
var deferFunc = this.nextTick ? this.nextTick : this.setImmediate ? this.setImmediate : function(func) {
setTimeout(func, 0);
}, doResolve = function(default_action, next, callback, value) {
if ("function" != typeof callback) return next[default_action](value);
try {
var ret = callback(value);
ret && "function" == typeof ret.then ? ret.then(function(value) {
next.resolve(value);
}, function(reason) {
var map = function(args, mapFunc)
{
var d = new Deferred(),
length = args.length,
results = [],
resolved = 0;
var mapLoop = function(i) {
var arg = typeof args[i].then == 'function' ? args[i] : new Resolved(args[i]);