Skip to content

Instantly share code, notes, and snippets.

View spectras's full-sized avatar

Julien Hartmann spectras

View GitHub Profile
// clang --target=wasm32 -nostdlib -Os -Wl,--no-entry -Wl,--export-all add.cpp -o add.wasm
extern "C" int add(int x, int y)
{
return x + y;
}
using Sandbox.Game.EntityComponents;
using Sandbox.ModAPI.Ingame;
using Sandbox.ModAPI.Interfaces;
using SpaceEngineers.Game.ModAPI.Ingame;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System;
using VRage.Collections;
@spectras
spectras / ember-register.js
Created August 30, 2017 21:23
Generate an entry point suitable for using Ember.js with rollup
#!/usr/bin/env node
"use strict";
/* Copyright (C) 2017 Julien Hartmann, juli1.hartmann@gmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@spectras
spectras / syncthing_id.py
Created September 23, 2016 16:25
Compute syncthing device ID from its certificate
#!/usr/bin/env python
import base64
import hashlib
import subprocess
import sys
B32ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'
def luhn_checksum(data, alphabet=B32ALPHABET):
n = len(alphabet)
@spectras
spectras / application.controller.js
Last active November 26, 2015 11:22
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
# http://stackoverflow.com/questions/33601864
products = {
'Cat1': {
'Prod1': {
'comment': 'ABC',
'indicator': 'Flat',
'pricelow': '10',
'priceaverage': '20',
'pricehigh': '30'},
@spectras
spectras / marty.py
Created October 12, 2015 19:07
Template function pattern
#!/usr/bin/env python
# See http://stackoverflow.com/questions/32885753/
class BaseRequestProcessor(object):
# Template class.
# The request processor gets some query, parses it into a request, executes it
# then saves the result and writes some logging info.
def get_query(self):
raise NotImplementedError()
@spectras
spectras / runners.py
Created June 20, 2015 14:03
Adding additional paths to Django's test runner
from django.conf import settings
from django.test.runner import DiscoverRunner
import os
# You'll need to adjust those
SUBPATHS = ('myproject/apps', 'myproject/libs')
ROOT = dirname(dirname(dirname(os.path.abspath(__file__))))
class TestRunner(DiscoverRunner):
""" Adds submodules from not-importable folders to the test suite.
@spectras
spectras / server_cursor_query.py
Created June 2, 2015 12:58
Server cursor query with Django
# Based on http://thebuild.com/blog/2010/12/13/very-large-result-sets-in-django-using-postgresql/
# Allows a queryset.
# Does not support defer(), annotate(), select_related() or prefetch_related()
import django
from django.db import connection, transaction
assert django.VERSION[0:2] == (1, 8), "only tested on Django 1.8, make sure to test on your version"