Skip to content

Instantly share code, notes, and snippets.

View edma2's full-sized avatar

Eugene Ma edma2

  • San Francisco, CA
View GitHub Profile
@edma2
edma2 / pants.vim
Last active August 29, 2015 14:19
" pants.vim - Pants build integration for Vim
" Maintainer: Eugene Ma <http://github.com/edma2/>
" Version: 0.1
function! s:Pants(...)
let pants = findfile('pants', '.;')
if strlen(pants) == 0
echoerr "pants not found"
return 1
end
#!/usr/bin/env lein exec
;; formats Clojure code from stdin, and prints formatted code to stdout
(require 'leiningen.exec)
;; Add a dependency to the classpath on the fly
(leiningen.exec/deps '[[cljfmt "0.1.7"]])
(require '[cljfmt.core :as cljfmt])
#!/usr/local/plan9/bin/rc
# Given a list of tags, plumb the corresponding file:line to edit.
if(test $#* -lt 1) {
echo 'usage: '$0' tag [-f tagfile] [tag...]' >[1=2]
exit usage
}
flagfmt='f tagfile'
--langdef=scala
--langmap=scala:.scala
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\4/c,classes/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*object[ \t]+([a-zA-Z0-9_]+)/\4/c,objects/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*case class[ \t]+([a-zA-Z0-9_]+)/\4/c,case classes/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*case object[ \t]+([a-zA-Z0-9_]+)/\4/c,case objects/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\4/t,traits/
--regex-scala=/^[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\1/T,types/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*def[ \t]+([a-zA-Z0-9_]+)/\3/m,methods/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*val[ \t]+([a-zA-Z0-9_]+)/\3/l,constants/
@edma2
edma2 / elf.c
Created February 18, 2013 21:18
#include <elf.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
Elf32_Ehdr Elf_Header;
Elf32_Shdr Section_Header;
/**
* Load the ELF header.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define START_SIZE 10
#define GROWTH_FACTOR 1.5
typedef struct {
int size; /* total available size */
int count; /* number of elements */
/* Conway's Game of Life
* Author: Eugene Ma (edma2) */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define for_each_cell(g) \
do { \
int x, y; \
for (y = 0; y < g->h; y++) { \
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <png.h>
/* The boundaries of the plot */
#define RE_MAX 1.0
#define RE_MIN -2.0
#define IM_MAX 1.0
import java.awt.image.BufferedImage
import javax.imageio.ImageIO
import java.io.File
/** The Mandelbrot image with given width and height in pixels. */
class Mandelbrot(width: Int, height: Int) {
case class Complex(re: Double, im: Double) {
def *(op: Complex): Complex = {
Complex(re * op.re - im * op.im, re * op.im + im * op.re)
}
#include <stdio.h>
#define EVEN(x) ((x % 2) == 0)
static char *base32_encoder = "0123456789bcdefghjkmnpqrstuvwxyz";
typedef struct {
double current_guess;
double error_margin;
double real_value;