Skip to content

Instantly share code, notes, and snippets.

Stuart Carnie stuartcarnie

Block or report user

Report or block stuartcarnie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
stuartcarnie / goto.go
Created Oct 24, 2017
GOTO vs lots of returns
View goto.go
func (a Shards) CreateIterator(ctx context.Context, measurement string, opt query.IteratorOptions) (query.Iterator, error) {
var err error
itrs := make([]query.Iterator, 0, len(a))
for _, sh := range a {
var itr query.Iterator
itr, err = sh.CreateIterator(ctx, measurement, opt)
if err != nil {
goto ERROR
} else if itr == nil {
stuartcarnie /
Last active Sep 12, 2017
Allocation improvements for yamux

After improvements


Identifies currently allocated memory

ROUTINE ========================*Stream).readData in /Users/stuartcarnie/projects/go/influxdata/plutonium/src/
         0   815.27kB (flat, cum) 0.013% of Total
         .          .    414:	if s.recvBuf == nil {
stuartcarnie / influxql.ebnf
Last active May 17, 2017
EBNF for InfluxQL
View influxql.ebnf
// queries
query ::= statement ( ";" statement )*
statement ::= alter_retention_policy_stmt |
create_continuous_query_stmt |
create_database_stmt |
create_retention_policy_stmt |
create_subscription_stmt |
create_user_stmt |
stuartcarnie / tmux-reverse
Created Apr 7, 2017
One-liner to ensure italics are rendered as reverse when using tmux
View tmux-reverse
mkdir $HOME/.terminfo/ && \
screen_terminfo="screen-256color" && \
infocmp "$screen_terminfo" | sed \
-e 's/^screen[^|]*|[^,]*,/screen-256color|screen with italics support,/' \
-e 's/%?%p1%t;3%/%?%p1%t;7%/' \
-e 's/smso=[^,]*,/smso=\\E[7m,/' \
-e 's/rmso=[^,]*,/rmso=\\E[27m,/' \
-e '$s/$/ sitm=\\E[3m, ritm=\\E[23m,/' > /tmp/screen.terminfo && \
tic /tmp/screen.terminfo && \
echo set -g default-terminal "screen-256color" | tee -a ~/.tmux.conf
stuartcarnie / tsm.ksy
Last active Mar 25, 2017
Kaitai Struct definition for InfluxDB .tsm files
View tsm.ksy
id: tsm
title: InfluxDB TSM file
license: MIT
file-extension: tsm
endian: be
- id: header
type: header
stuartcarnie / bytes_writer.go
Last active Aug 29, 2015
Buffered ReadSeekCloser, which starts with a specified memory buffer and switches to disk if the source stream is too large
View bytes_writer.go
package extio
import (
var (
ErrBufferFull = errors.New("buffer full")
stuartcarnie / SortingLayerHelper.cs
Created Jan 19, 2014
Use to convert sorting layer IDs to render order in Unity 4.3. This is not intended for runtime use but rather at edit time and serialized.
View SortingLayerHelper.cs
using System;
using System.Reflection;
using UnityEngine;
/// <summary>
/// Helper functions to interact with sorting layers
/// </summary>
public static class SortingLayerHelper
/// <summary>
stuartcarnie / json-pretty
Last active Dec 17, 2015
Script to pretty json input
View json-pretty
#!/usr/bin/env python
r"""Command-line tool to validate and pretty-print JSON
$ echo '{"json":"obj"}' | python -m json.tool
"json": "obj"
$ echo '{ 1.2:3.4}' | python -m json.tool
stuartcarnie / clear-apc.php
Last active Apr 13, 2018
Self-contained php script to clear shared-memory cache in php5-fpm via command-line. In this instance it is clearing APC, but can be easily changed to clear other shared-memory caches.
View clear-apc.php
#!/usr/bin/env php
Copyright 2013 Stuart Carnie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
stuartcarnie / .zshrc
Last active Oct 14, 2015
My standard .zshrc with oh-my-zsh
View .zshrc
# Path to your oh-my-zsh configuration.
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
You can’t perform that action at this time.