Skip to content

Instantly share code, notes, and snippets.

View H2CO3's full-sized avatar
🦀

Árpád Goretity  H2CO3

🦀
View GitHub Profile
#include <memory>
#include <cstdio>
static void foo(std::unique_ptr<int> p)
{
printf("%d\n", *p);
}
int main()
{
let SDL = dynld("sdl2");
var timers = {};
let timerWithEvent = fn (dt, callback) {
let tmr = SDL::StartTimer(dt);
timers[tmr] = callback;
};
@H2CO3
H2CO3 / Ubuntu-Macbook-Setup.md
Created April 27, 2015 18:43
Ubuntu Retina MacBook Pro mid-2014 UI and general Setup

Set up Wi-Fi:

sudo apt-get install bcmwl-kernel-source
sudo modprobe wl

in the file /etc/modules, add the line

wl

in order to start up the wireless service upon reboot.

@H2CO3
H2CO3 / pong.spn
Created April 24, 2015 13:11
Pong in Sparkling, in 40 minutes
let SDL = dynld("sdl2");
let w = SDL::OpenWindow("Pong", 640, 480);
var paddle = {
"x": 0,
"y": 0,
"w": 100,
"h": 40
};
@H2CO3
H2CO3 / SDL2_gfx_gradients.diff
Created April 6, 2015 11:05
Adding gradient drawing primitives to SDL2_gfx
Index: SDL2_gfxPrimitives.c
===================================================================
--- SDL2_gfxPrimitives.c (revision 29)
+++ SDL2_gfxPrimitives.c (working copy)
@@ -3788,3 +3788,288 @@
/* Draw polygon */
return filledPolygonRGBA(renderer, px, py, 4, r, g, b, a);
}
+
+/////// Gradient Drawing //////
@H2CO3
H2CO3 / RubyQuiz7.cpp
Created January 14, 2015 12:01
My solution to RubyQuiz #7 in C++. http://rubyquiz.com/quiz7.html
#include <vector>
#include <array>
#include <unordered_map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <utility>
#include <memory>
#include <functional>
@H2CO3
H2CO3 / SpnMap.hpp
Created January 13, 2015 18:20
SpnHashMap, rewritten in C++
//
// SpnMap: Sparkling's hash table, in C++
// Created by Arpad Goretity on 13/01/2015
//
#include <vector>
#include <utility>
#include <cstdint>
#include <climits>
#include <cassert>
@H2CO3
H2CO3 / sparkling-eval.el
Created December 21, 2014 01:08
Sparkling inline evaluation
;; C-c C-e
(defun sparkling-eval-replace-expr (start end)
"Evaluate the contents of the selected region (or the region between START and END) as an expression and replace it with the result."
(interactive "r")
(call-process "spn" nil t nil "-e" (delete-and-extract-region start end))
)
;; C-c C-r
(defun sparkling-eval-replace-stmt (start end)
"Evaluate the contents of the selected region (or the region between START and END) as statements and replace it with the result."
@H2CO3
H2CO3 / README.txt
Created November 24, 2014 08:08
[BUGFIX] – Sparkling parser crashes
This is a diff for Sparkling @ commit 665e00d51dae99493958fb2e25fe5d56ffb66a15
Fixes some crashes in the parser caused by infinite recursion upon encountering certain types of malformed Sparkling source.
Bugs found using `zzuf`, a fuzzing tool.
This is a patch and not a proper commit because I'm rewriting the parser in the meantime, and I don't want to deal with conflicts. They will be undone anyway – this patch is just a temporary (but nonehteless important) bugfix.
@H2CO3
H2CO3 / js2betterjs.js
Last active August 29, 2015 14:10
I just read in the description of Google's Closure compiler that it "compiles JavaScript to better JavaScript".
// This is how H2CO3 writes a JavaScript to better JavaScript compiler
function compile(source) {
return ""; // no JavaScript is definitely better than some JavaScript
}
// Usage example
var exampleSource = "window.alert('foo');";
eval(compile(exampleSource)); // extra advantage: no more annoying alert windows!