Skip to content

Instantly share code, notes, and snippets.

View fakedrake's full-sized avatar

Chris Perivolaropoulos fakedrake

View GitHub Profile
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define CONSUMER_ERROR(msg) \
do {perror("Consumer Error: " msg "\n"); exit(1); }while(0)
foo
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define CONSUMER_ERROR(msg) \
do {perror("Consumer Error: " msg "\n"); exit(1); }while(0)
class BaseOperator<T> implements IOperator<T> {
public T operate(T x, T y) {}
public boolean apply (Stack<T> stack) {
try {
T x = stack.pop();
T y = stack.pop();
} catch (EmptyStackException e) {
System.out.println("Stack has to few arguments, you cant operate on it.");
class BaseOperator<T> implements IOperator<T> {
public T operate(T x, T y) {}
public boolean apply (Stack<T> stack) {
try {
T x = stack.pop();
T y = stack.pop();
} catch (EmptyStackException e) {
System.out.println("Stack has to few arguments, you cant operate on it.");
import java.text.*;
import java.util.*;
// Calculator will only accept numbers of type T
// A calculator knows how to parse a given string
public class Calculator <T extends Number> {
Stack<T> st = new Stack<T>();
List<IOperator<T>> operators = new LinkedList<IOperator<T>>();
Calculator (List<IOperator<T>> ops) {
(defun my-cc-newline-and-indent ()
"If we are between braces (that were mos probably created by
electric-pairs) prepare for writing the body of something"
(interactive)
(if (and (looking-at "}") (looking-back "{"))
(progn (newline-and-indent) (newline-and-indent) (previous-line) (c-indent-line-or-region))
(newline-and-indent)))
abstract class NumberHandler implements ActionListener {
CalculatorGui gui;
int number;
public NumberHandler(CalculatorGui _gui, int num) {
gui = _gui;
number = num;
}
public void actionPerformed(ActionEvent e) {