Skip to content

Instantly share code, notes, and snippets.

View sw17ch's full-sized avatar

John VanEnk sw17ch

View GitHub Profile
#include <stdio.h>
typedef struct {} a;
typedef struct { a a1; a a2; } b;
int main(int argc, char * argv[])
{
a as[999999];
printf("%d\n", sizeof(b) == sizeof(a));
@sw17ch
sw17ch / proposed_test_interface.c
Created August 28, 2012 13:57
A change similar to what we might think about doing to Unity down the road.
#include <stdio.h>
/* This stuff would be updated/added to unity. */
typedef struct {
char * desc;
char * file;
int line;
} test_information_t;
#define TEST_INFO_NAME(x, y) test_info_ ## x ## _ ## y
@sw17ch
sw17ch / vcs_prompt.sh
Created August 29, 2012 15:46
How I generate my prompt.
function __svn_ps1 {
local d=$(svn info 2>&1 | grep -Po "/(branches|trunk).*$")
if [ -n "$d" ]; then
echo -en "[svn:$d]"
fi
}
function __git_ps1 {
local d=$(git st 2>&1| grep -Po "branch .*")
if [ -n "$d" ]; then
@sw17ch
sw17ch / all_n_at_greatest_n.rb
Created September 13, 2012 14:59
Use ActiveRecord to select records where a field is equal to the greatest value found for that field when limited by a set of columns.
# A file demonstrating how I use ActiveRecord to perform "All records where N
# is greatest N" queries.
#
# This script contains the schema, the models, and the example code. Normally
# these pieces would be broken out into separate files.
#
# The example demonstrates the use by producing a set of relationships between
# users, services, and "logins" of those users to the services. Then, we
# perform some queries that relate to the longest session time when stratified
# different ways.

The File

int * global_ptr;

int * func(int * param_ptr)
{
  int * local_ptr = 0;

  {
 int * sub_scope_ptr = 0;
@sw17ch
sw17ch / talk_titles.md
Created December 14, 2012 04:57
Possible Talk Titles

Possible Talk Titles

  • I Hate Software
    • My strugle with realizing that my best work is not what I make, but what I avoid making.
  • Why is Embedded Software Stagnant?
    • We're not good enough to stay here.
  • C Programmers are the (Soon to be Replaced by Machines) Artisans of the 21st Century
  • Programmers are Never Done Learning
  • Ideas are Worthless (yes, even yours)
  • Hardware Bring-up is Hell
/* Structures */
/* NO! */
typedef struct foo foo_t;
/* YES! */
struct foo;
/* Unions */
@sw17ch
sw17ch / Makefile
Last active December 10, 2015 13:08
main: main.c shim.o
shim.o: foo.c foo_shim.c foo.h
#
# Compile Files
gcc foo.c -c -o foo.o
gcc foo_shim.c -c -o foo_shim.o
#
# Rename the symbol we care about: foo -> old_foo
objcopy --redefine-sym foo=old_foo foo.o _foo.o
#
[3] pry(main)> module Foo
[3] pry(main)* def self.bar
[3] pry(main)* puts "I AM BAR"
[3] pry(main)* end
[3] pry(main)* end
=> nil
[4] pry(main)> Foo.method(:bar)
=> #<Method: Foo.bar>
[5] pry(main)> Foo.method(:bar).call
I AM BAR
@sw17ch
sw17ch / c_is_madness.md
Created January 8, 2013 00:32
C is MADNESS

foo.h

#ifndef FOO_H
#define FOO_H

typedef int sometype_t;

void foo(sometype_t t);

#endif /* FOO_H */