Skip to content

Instantly share code, notes, and snippets.

@eschulte
eschulte / asm-diff
Created March 26, 2019 20:10
Use objdump to view the differences between two object files
#!/bin/bash
#
# Usage: asm-diff [options] file1 file2 [-- diff options]
# Return the difference in the objudmp parsing of files
#
# OPTIONS:
# -o,--objdump CMD --- specify objdump command to use
# -j,--section NAME -- section to compare
# (default: .text)
# -c,--clean --------- specify whether to clean addresses
@eschulte
eschulte / curry-compose.el
Last active February 26, 2022 19:52
Implementation of curry, rcurry and compose in Emacs Lisp. Including some code to make Emacs display these functions in a compact and attractive manner.
;;; Commentary
;;
;; Allows for more compact anonymous functions. The following
;; examples demonstrate the usage.
;;
;; ;; partial application with `curry'
;; (mapcar (» #'+ 2) '(1 2 3 4)) ; => (3 4 5 6)
;;
;; ;; alternate order of arguments with `rcurry'
;; (mapcar (« #'- 1) '(1 2 3 4)) ; => (0 1 2 3)
@eschulte
eschulte / gist:902174
Created April 4, 2011 18:52
use bind to restructure arguments to lambda expressions
(defmacro lambdab ((&rest instrs) &rest body)
"Use `bind' to allow restructuring of argument to lambda expressions."
(declare (indent 1))
(let* ((evald-instrs instrs)
(syms (mapcar (lambda (_) (gensym)) evald-instrs)))
`(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))
;; example usage
(let ((fn (lambdab ((a b) c) (cons a c))))
(funcall fn '(1 2) 3)) ;; => (1 . 3)
# Build souffle
FROM ubuntu:18.04 as souffle
RUN apt-get -y update && apt-get -y install automake bison build-essential clang doxygen flex git libtool make mcpp openjdk-8-jdk pkg-config python sqlite3 libsqlite3-dev subversion swi-prolog zlib1g-dev
RUN git clone -b 1.4.0 https://github.com/souffle-lang/souffle
RUN cd souffle && sh ./bootstrap
RUN cd souffle && ./configure --prefix=/usr --enable-64bit-domain --disable-provenance
RUN cd souffle && make -j4 install
RUN cd souffle && cp include/souffle/RamTypes.h /usr/include/souffle/
# Build the faulty version of UnrealIRCd
# Build the faulty version of UnrealIRCd.
# This is the oldest version of Ubuntu that seems to work w/Docker.
FROM ubuntu:14.04 as unrealircd
RUN apt-get -y update && apt-get -y install automake build-essential git libssl-dev wget
RUN wget http://stalkr.net/files/unrealircd/Unreal3.2.8.1_backdoor.tar.gz
COPY Unreal3.2.8.1_backdoor.tar.gz Unreal3.2.8.1_backdoor.tar.gz
RUN tar xzf Unreal3.2.8.1_backdoor.tar.gz
WORKDIR /Unreal3.2
# This change was required to get the build to go through.
RUN sed -i 's/inline void parse_addlag/void parse_addlag/' src/parse.c
// blog.cpp --- Simple example demonstrating GTIRB usage
//
// Search a GTIRB instance printing the calls preceeding `system' calls.
//
// Compiled with (with system installs):
// g++ --std=c++17 -lgtirb blog.cpp
//
// or with (with explicit includes):
// g++ -I/gtirb/build/include/ -I/gtirb/build/protobuf-src/include/ \
// --std=c++17 -lgtirb blog.cpp
@eschulte
eschulte / loop-rec.lisp
Created November 25, 2013 19:05
compile a looping function from a recursive definition
;;; loop-rec.lisp --- compile a looping function from a recursive definition
;; Copyright (C) 2013 Eric Schulte
;;; Commentary:
;; Use the `defwhile' macro to define a looping (using while) version
;; of any recursive function.
;;
;; It maintains a fifo stack of arguments (my-args), and a pointer to
myKeys conf@(XConfig {XMonad.modMask = modm}) =
[ ((modm, xK_b), sendMessage ToggleStruts) -- Mod-b: toggle xmobar panel
, ((modm, xK_p), spawn "dmenu_run") -- needs explicit for completion
-- , ("<XF86AudioNext>", spawn "cmus-remote -n")
, ((0, xF86XK_AudioNext), spawn "cmus-remote -n")
, ((0, xF86XK_AudioPrev), spawn "cmus-remote -r")
, ((0, xF86XK_AudioPlay), spawn "cmus-remote -u")
, ((0, xF86XK_AudioStop), spawn "cmus-remote -s")
, ((0, xF86XK_AudioLowerVolume), spawn "amixer set Master 5%-")
, ((0, xF86XK_AudioRaiseVolume), spawn "amixer set Master 5%+")
def confirm_intent(prompt, answer)
puts prompt
users_answer = Capistrano::CLI.ui.ask("(type #{answer} to continue)? ") { |p| p.echo == true }
abort unless users_answer == answer
end
task :staging do
confirm_intent("Are you SURE you want to deploy to the staging server? ", "YES")
role :app, "1.2.3.4"
role :web, "1.2.3.4"
@eschulte
eschulte / feedgnuplot-repl.lisp
Last active December 24, 2015 10:08
Use feedgnuplot to visualize list data from the Common Lisp REPL
;; Use feedgnuplot to visualize list data from the Common Lisp REPL.
;;
;; Useful for visualizing distributions of large lists.
;;
;; Example usage.
;;
;; (feedgnuplot (loop :for x :below 200 :collect (sin (/ x 25))))
;; (feedgnuplot (loop :for x :below 2000 :collect (random 25)) :histogram t)
;; (feedgnuplot (loop :for x :from 1 :upto 200 :collect (list (float (/ x 25)) (sin (/ x 25)))))
;; (feedgnuplot (loop :for x :from 1 :upto 200 :collect (list (float (/ x 25)) (sin (/ x 25))))