Skip to content

Instantly share code, notes, and snippets.

View kg's full-sized avatar

Katelyn Gadd kg

View GitHub Profile
/* MultiFile - A JavaScript library to load multiple files from
tar archives and json_packed files (see http://gist.github.com/407595)
Example: Loading multiple images from a tarball.
MultiFile.load('images.tar', function(xhr) {
this.files.forEach(function(f) {
var e = document.createElement('div');
document.body.appendChild(e);
var p = document.createElement('p');
@kig
kig / gzip.js
Last active August 1, 2019 08:59
TarGZ = function(){};
// Load and parse archive, calls onload after loading all files.
TarGZ.load = function(url, onload, onstream, onerror) {
var o = new TarGZ();
o.onload = onload;
o.onerror = onerror;
o.onstream = onstream;
o.load(url);
return o;
@k0s
k0s / pbmoz.py
Created July 28, 2011 16:08 — forked from djmitche/pbmoz.py
stdin-to-pastebin script by @catlee
#!/usr/bin/env python
import urllib, sys
if len(sys.argv) == 2:
url = "http://%s.pastebin.mozilla.org" % sys.argv[1]
fmt = sys.argv[1]
else:
url = "http://pastebin.mozilla.org"
fmt = "None"
@kg
kg / StructCopyElimination.cs
Created March 20, 2012 14:34
JSIL Code Sample: Struct Copy Elimination
using System;
public static class Program {
public static CustomType ReturnArgument (CustomType arg) {
return arg;
}
public static void Main (string[] args) {
var a = new CustomType(1);
var b = new CustomType(2);
anonymous
anonymous / product.c
Created August 24, 2013 21:00
/*
My results:
Given COUNT floats, each float ranging from [1/MAG, MAG]:
Naive product overflows easily (depends on MAG and COUNT)
Divide & conquer product can still overflow
@jbevain
jbevain / roslyn-enumerable-of-t.diff
Last active August 29, 2015 13:58
Roslyn patch to add syntactic sugar to C# replacing IEnumerable<T> with T~
diff --git a/Src/Compilers/CSharp/Source/Binder/Binder_Symbols.cs b/Src/Compilers/CSharp/Source/Binder/Binder_Symbols.cs
index ce0a903..b34b498 100644
--- a/Src/Compilers/CSharp/Source/Binder/Binder_Symbols.cs
+++ b/Src/Compilers/CSharp/Source/Binder/Binder_Symbols.cs
@@ -379,6 +379,20 @@ namespace Microsoft.CodeAnalysis.CSharp
return new PointerTypeSymbol(elementType);
}
+ case SyntaxKind.EnumerableType:
+ {
@rygorous
rygorous / winrt_basic.cpp
Created April 7, 2014 18:11
WinRT basic D3D example, one file; all cube rendering/framework-y stuff removed, this just clears the screen every frame.
#include <wrl/client.h>
#include <d3d11_1.h>
#include <agile.h>
#include <ppl.h>
#include <ppltasks.h>
using namespace Microsoft::WRL;
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
@flibitijibibo
flibitijibibo / SpriteBatchTest.cs
Created July 26, 2014 16:16
SpriteBatch Stress Test
/* SpriteBatch Stress Test
* Written by Ethan "flibitijibibo" Lee
* http://www.flibitijibibo.com/
*
* Released under public domain.
* No warranty implied; use at your own risk.
*/
using System;
using System.Diagnostics;
@charlesnicholson
charlesnicholson / gist:5f066d9f0ea2f7b484ac
Last active December 3, 2021 20:08
compile-time string concatenation
#include <cstdio>
namespace detail {
template<unsigned count, template<unsigned...> class meta_functor, unsigned... indices>
struct apply_range {
typedef typename apply_range<count - 1, meta_functor, count - 1, indices...>::result result;
};
template<template<unsigned...> class meta_functor, unsigned... indices>
struct apply_range<0, meta_functor, indices...> {
@jibsen
jibsen / bytes.md
Last active December 20, 2023 10:02
Ramblings about uint8_t and undefined behavior

Introduction

The C standard only specifies minimum limits for the values of character types and standard integer types. This makes it possible to generate efficient code on diverse architectures, but can pose problematic if your code expects the limits to match your development platform, or if you have to do low-level things.

Before C99, the usual way to solve this was to use typedef to declare synonyms