Skip to content

Instantly share code, notes, and snippets.

View marcopompili's full-sized avatar
🐌

Marco Pompili marcopompili

🐌
View GitHub Profile
@huxuan
huxuan / Makefile
Last active February 26, 2023 17:33
Hello World for LuaJIT FFI/C++ binding.
all: lib run
lib:
g++ -shared -fPIC -o libhello.so libhello.cpp hello.cpp
run:
luajit main.lua
clean:
rm *.so
@rundis
rundis / user.behaviors
Created December 29, 2015 22:26
Reload Namespace in Light Table
; add this to hook up your custom behavior
[:editor.clojure :lt.plugins.user/reload-ns]
@graphitemaster
graphitemaster / WORKING_AROUND_OFFSETOF_LIMITATIONS.MD
Last active February 29, 2024 08:49
Working around offsetof limitations in C++

Working around offsetof limitations in C++:

There is sometimes a situation in which one needs to get the relative offset of a structure field, common examples of this include serialization frameworks which aid to serialize objects, vertex attributes for rendering (D3D, GL.), etc.

The most common technique for getting this information is through the offsetof macro defined in stddef.h. Unfortunately using the macro in C++ comes with a new set of restrictions that prevent some (subjectively valid) uses of it.

@courtneyfaulkner
courtneyfaulkner / devices.c
Created December 11, 2013 22:20
List OpenCL platforms and devices
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
int main() {
@alandipert
alandipert / maptemplate.md
Created January 30, 2013 00:28
ClojureScript macros: kinda, sorta, not really.

ClojureScript macros: kinda, sorta, not really.

ClojureScript does not have a standalone macro system. To write ClojureScript macros, one must write them in Clojure and then refer to them in ClojureScript code. This situation is workable, but at a minimum it forces one to keep ClojureScript code and the macros it invokes in separate files. I miss the locality of regular Clojure macros, so I wrote something called maptemplate that gives me back some of what I miss. The technique may be useful in other scenarios.

Problem

Suppose you're wrapping functionality in another namespace or package so that you can have your own namespace of identically named but otherwise decorated functions:

ClojureScript:

def queryset(self, request):
if request.user.is_superuser:
return self.model.objects.all()
return self.model.objects.filter(user=request.user)
@yevgenko
yevgenko / .Xdefaults
Created August 24, 2011 02:58
URxvt settings with solarized theme
!-------------------------------------------------------------------------------
! Xft settings
!-------------------------------------------------------------------------------
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight
@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//