Skip to content

Instantly share code, notes, and snippets.

View evincarofautumn's full-sized avatar

Jon Purdy evincarofautumn

View GitHub Profile
@evincarofautumn
evincarofautumn / gist:3c2309e7941751573eb4
Created August 14, 2014 05:02
Statistical manipulations in Kitten.
// “μσ” calculates the mean and standard deviation of a list, given the sum of the squares of the elements, the sum of the elements, and the reciprocal of the length. Uses real characters for more mathiness.
// With local variables, in infix:
def μσ (float float float → float float):
→ ss s in;
s ×. in → μ;
(ss ×. in −. μ sq) sqrt → σ;
μ σ
// With local variables, in postfix:
@evincarofautumn
evincarofautumn / adaptive-wrap-fill-context-prefix
Last active August 29, 2015 14:05
Hack to make “adaptive-wrap-prefix-mode” work with tabs and show a fill indicator.
(defun adaptive-wrap-fill-context-prefix (begin end)
"Like `fill-context-prefix', but with length adjusted by `adaptive-wrap-extra-indent'."
;; Note: fill-context-prefix may return nil; See:
;; http://article.gmane.org/gmane.emacs.devel/156285
(let* ((fcp (or (fill-context-prefix begin end) ""))
(fcp-len (string-width fcp)))
(if (>= adaptive-wrap-extra-indent 0)
(concat (make-string fcp-len ?\ )
"│"
(make-string adaptive-wrap-extra-indent ?\ ))
@evincarofautumn
evincarofautumn / sigsegv-experiments.c
Last active August 29, 2015 14:07
SIGSEGV experiments
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <unistd.h>
static char *buffer1;
static char *buffer2;
static const int page_size = 1 << 12;
@evincarofautumn
evincarofautumn / gist:7006675d11d400850e45
Created October 9, 2014 19:06
Installing GTK# on OS X 10.9.4
brew install pango
brew install atk
brew install gtk+
tar xvf gtk-sharp-2.12.10.tar.gz
cd gtk-sharp-2.12.10
# Set PKG_CONFIG_PATH so that cairo knows where to find xcb-shm.
# Set __GLIB_H_INSIDE__ to stop glib from preventing GTK# from including its headers other than glib.h.
# Alias _glibsharp_g_thread_supported to the missing _g_thread_supported.
./configure --prefix=/usr/local PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig CFLAGS="-D__GLIB_H_INSIDE__" LDFLAGS="-Wl,-alias,_glibsharp_g_thread_supported,_g_thread_supported"
make -j4
#include <stdio.h>
#include <unistd.h>
int main() {
if (geteuid() == 0) {
puts("Okay.");
return 0;
}
puts("What? Make it yourself.");
return 1;
@evincarofautumn
evincarofautumn / timestamp.pl
Created October 24, 2014 01:33
Watches the RSS of a process and gives you a list of timestamp–RSS pairs.
#!/usr/bin/env perl
use warnings;
use strict;
use POSIX 'strftime';
use Time::HiRes 'gettimeofday';
my $timestamp = gettimeofday;
printf "%.3f", $timestamp;
// Translation of https://gist.github.com/jeaye/ae36de6b677c4000ce67
data queue:
case queue ([<s...> (s... -> s...)])
define push<s...> (queue (s... -> s...) -> queue):
-> f;
match:
case queue:
f append queue
@evincarofautumn
evincarofautumn / main.c
Created December 5, 2014 22:15
Clang Optimisation Bug
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
int sum(int a, int b, int c, int d) {
return a + b + c + d;
}
int product(int a, int b, int c, int d) {
return a * b * c * d;
Git submodules updated successfully
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in po
Making all in mcs
make[3]: Nothing to be done for `all-am'.
Making all in libgc
Making all in m4
make[3]: Nothing to be done for `all'.
Making all in include
Making all in private
@evincarofautumn
evincarofautumn / gist:0917acd8d671e7ef9b9a
Created February 24, 2015 21:07
Diagnostic output for XamarinAndroid project in Mobile-App-Performance benchmark
Building: Shared (Debug)
Building: XamarinAndroid (Debug)
Build started 2/24/2015 1:06:44 PM.
__________________________________________________
Project "/Users/jonathanpurdy/Projects/Mobile-App-Performance/Xamarin/XamarinAndroid/XamarinAndroid.csproj" (Build target(s)):
Initial Properties:
__CF_USER_TEXT_ENCODING = 0x1F5:0:0