Skip to content

Instantly share code, notes, and snippets.

View smspillaz's full-sized avatar
💥
mindblown

Sam Spilsbury smspillaz

💥
mindblown
View GitHub Profile
@smspillaz
smspillaz / gist:e393e46b41ed40e0c239
Created July 25, 2014 13:45
Iterator Invalidation in C++
#include <boost/container/stable_vector.hpp>
#include <boost/timer/timer.hpp>
#include <vector>
#include <cstring>
#include <sys/time.h>
#include <iostream>
#include <cstdlib>
template <typename Container>
void randomize (Container &container)
@smspillaz
smspillaz / designer.html
Created August 12, 2014 03:49
designer
<link rel="import" href="../core-pages/core-pages.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@smspillaz
smspillaz / serialization
Created January 16, 2015 13:55
Coverage Serialization
static unsigned int COVERAGE_STATISTICS_CACHE_MAGIC = 0xC0432463;
static GjsCoverageCacheHeader *
create_coverage_statistics_cache(GjsCoverage *coverage)
{
GjsCoveragePrivate *priv = (GjsCoveragePrivate *) gjs_coverage_get_instance_private(coverage);
gsize allocation_len = calculate_coverage_statistics_cache_len(file_statistics_array);
void *allocation = g_malloc(allocation_len);
void *allocation_index = allocation;
@parameterized.expand(_KNOWN_STYLES)
def test_suggest_correction_docstring(self, style):
"""Correct slplling errors inside docstring."""
def get_replacement():
self._spellcheck_lint("{s}{e}\n\"\"\"splelling mistake\"\"\")\n",
style)
exception = self.assertRaises(LinterFailure, get_replacement)
self.assertEqual(replacement(exception),
(2,
game_map = list()
for i in range(0, 28):
sub = []
for j in range(0, 36):
sub.append(False)
game_map.append(sub)
for i in range(0, 28):
|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|
00 |@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|
01 |@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|
02 |@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|
03 |@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|@@|
04 |@@|..|..|..|..|..|..|..|..|..|..|..|..|@@|@@|..|..|..|..|..|..|..|..|..|..|..|..|@@|
05 |@@|..|@@|@@|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|@@|@@|..|@@|
06 |@@|..|@@|@@|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|@@|@@|..|@@|
07 |@@|..|@@|@@|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|..|@@|@@|@@|@@|@@|..|@@|@@|@@|@@|..|@@|
08 |@@|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|..|@@|
@smspillaz
smspillaz / gist:5329830
Created April 7, 2013 09:51
clang error
smspillaz@interpol:~/Source/Compiz/dev/dev/merges/compiz/proposed/compiz.fix_1024304/build$ clang++ -std=c++11 test.cpp -o test.out
In file included from test.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/memory:64:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/allocator.h:48:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7/bits/c++allocator.h:34:
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/ext/new_allocator.h:110:23: error:
allocating an object of abstract class type 'Foo'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/alloc_traits.h:256:8: note:
https://gist.github.com/smspillaz/18d703c0ac3d9ea9bc59
typedef struct _ChangeDebugModeData
{
guint flags;
gboolean enabled;
} ChangeDebugModeData;
typedef void (*LockAction) (JSContext *context,
gpointer user_data);
static void
@smspillaz
smspillaz / gist:8138673
Created December 26, 2013 21:03
G_FILE_CREATE_REPLACE_DESTINATION
static void
test_coverage_data_file_is_overwritten_completely(gpointer fixture_data,
gconstpointer user_data)
{
GjsDebugCoverageToSingleOutputFileFixture *fixture = (GjsDebugCoverageToSingleOutputFileFixture *) fixture_data;
/* Write the string "existing contents" about one hundred times to the file
* and check that the new file does not contain any string matching it */
const gchar *existing_contents = "existing_contents\n";
guint i = 0;