Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#define IGNORE(X) ((void)X)
#define MAX_ALLOC (1024 * 1024)
#define MIN_ALLOC (128)
int main(int argc, char * argv[]) {
IGNORE(argc);
IGNORE(argv);
@sw17ch
sw17ch / indented_parsec_example.lhs
Created March 16, 2012 04:31
A full example demonstrating the use of the indentation parser provided by the 'indents' package: http://hackage.haskell.org/package/indents
> module Main where
First, import all the needed modules.
> import Text.Parsec hiding (State)
> import Text.Parsec.Indent
> import Control.Monad.State
Next, define our new Parser type. This replaces the Identity monad
with the (State SourcePos) monad.
@sw17ch
sw17ch / rr_kosher.rb
Created January 9, 2012 17:06
is this kosher?
describe "thing" do
before do
@obj_1 = Object.new
@obj_2 = Object.new
stub(@obj_1).foo { puts "stubbed foo (1)" }
stub(@obj_2).foo { puts "stubbed foo (2)" }
end
it "1 does things" do
mock(@obj_1).foo { puts "mocked foo (1)" }
@sw17ch
sw17ch / gist:6511618
Created September 10, 2013 16:03
$ cat ~/.bash_history | cut -f 1 -d " " | sort | uniq
ack
bundle
cat
cd
cd-
ceedling
cp
curl
diff
find
@sw17ch
sw17ch / toy.c
Created November 10, 2017 15:18
#include <assert.h>
#include <err.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <time.h>
@sw17ch
sw17ch / ccc_analyzer_hates_me.c
Last active March 30, 2017 18:47
some weird stuff in scan-build/ccc-analyzer
#include <stdint.h>
#define STACKY_LEN (1024 * STACKY_MULT)
int main(int argc, char * argv[]) {
(void)argc;
(void)argv;
#ifndef GOTTA_GO_FAST
uint8_t const stacky[STACKY_LEN] = {
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
struct xbee_enc_state {
uint8_t const * input;
size_t size;
@sw17ch
sw17ch / a.lua
Created September 13, 2016 00:19
local a = function ()
print("i am a")
end
error("no")
return a
# To install prerequisites for this sample code, run
# the following commands in a directory with all the
# files in this gist:
#
# > gem install bundler
# > bundler install
source "http://rubygems.org/"
gem "thor", "0.15.4"
#!/usr/bin/env python
import sys
import os
import hashlib
ALIGN = 256
for f in sys.argv[1:]:
if os.path.isfile(f):