Skip to content

Instantly share code, notes, and snippets.

View bbarker's full-sized avatar

Brandon Elam Barker bbarker

View GitHub Profile
@bbarker
bbarker / COBRA Style Guide
Last active December 23, 2015 00:09
Style guide for the COBRA Toolbox (MATLAB code).
1) Indentation: No tabs should be used. An indentation should be four spaces in length only.
Many editors have a way to insert the appropriate number of spaces when the tab key is pressed;
please see your editor's documentation. MATLAB's own editor adopts this convention by default.
2) Comments on function inputs (including optional inputs) and outputs should be explained
in detail directly below the function signature. This should be done in the following sections:
INPUT
OPTIONAL INPUTS
@bbarker
bbarker / const_test.c
Last active August 29, 2015 14:24
Experiments with const in C
#include <malloc.h>
#define ARRSZ 10
int main() {
int x = 5;
const int* xp = &x;
int y = 5;
int* yp = &y;
@bbarker
bbarker / Test_doc.md
Last active November 11, 2015 16:25
This is just a test

An h2 header

A list:

  • List item 1
  • List item 2

An external url.

Use the following html content (the script tag) to render this page on your own site:

@bbarker
bbarker / scala_maven_plugin_for_java_project.md
Created November 16, 2015 15:43
pom.xml additions for getting Scala going in a Maven/Java project

Under /pom:project/pom:dependencyManagement/pom:dependencies:

       <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.11.7</version>
      </dependency>
import pl.metastack.metarx.Dict
val myDict: Dict[Int, String] = Dict()
myDict.changes.attach {
case d: Dict.Delta.Insert[Int, String] =>
println(f"Insert:: ${d.key}%d : ${d.value}%s")
case d: Dict.Delta.Update[Int, String] =>
println(f"Update:: ${d.key}%d : ${d.value}%s")
case _ => ()
@bbarker
bbarker / metaRxDictExample1.scala
Last active March 6, 2016 01:03
Mutable reactive maps being mapped to each other
protected val controlMap: Dict[TableIndex, ControlTypes] = Dict()
protected val textInMap: Dict[TableIndex, String] = Dict()
protected val textMap: Dict[TableIndex, String] = Dict()
val controlToText = controlMap.changes.attach{
case delta: Dict.Delta.Insert[TableIndex, ControlTypes] =>
val te = implicitly[ControlTableEntry[ControlTypes, String]]
textMap(delta.key) = te.getEntry(delta.value)
case delta: Dict.Delta.Update[TableIndex, ControlTypes] =>
val te = implicitly[ControlTableEntry[ControlTypes, String]]
import bpy
scene = bpy.context.scene
for ob in scene.objects:
print("--", ob.name)
if ob.type == 'MESH':
@bbarker
bbarker / generate_branch_log.pl
Last active March 31, 2016 13:23
A staging summary script organized by file
#!/usr/bin/perl -w
use warnings;
use strict;
use Cwd;
my $git_out = `git log --name-status --pretty=oneline master..develop`;
my %modifications;
my %messages;
my $last_message;
foreach my $git_line (split(/\n/, $git_out)) {
@bbarker
bbarker / print_unique_regex_matches.pl
Created March 31, 2016 21:48
Find regex values in glob of html files and print all unique matches
#!/usr/bin/perl -w
use warnings;
use strict;
use Cwd;
use File::Slurp;
use HTML::Strip;
my $hs = HTML::Strip->new();
my %acronyms;
@bbarker
bbarker / ExtractorOptionNeedsNoneCase.scala
Created September 15, 2016 12:56
Showing that you need to remember to add the None case to your extractor
object ExtTest {
def unapply(arg: Int): Option[Int] = arg match {
case a if a < 5 => Some(a)
}
}
val x = 3
x match {
case ExtTest(a) => println(a)