Skip to content

Instantly share code, notes, and snippets.

@pstephens
pstephens / Program.scala
Last active May 17, 2017 09:13
A Spark doodle
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.io.{LongWritable, Text}
import org.apache.hadoop.mapreduce.lib.input.{FileSplit, TextInputFormat}
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.NewHadoopRDD
object Program {
def main(args: Array[String]): Unit = {
val srcFile = "hdfs://sandbox/Numbers.txt"
val conf = new SparkConf().setAppName("spark-numbers")
@pstephens
pstephens / theanswer.asm
Created December 11, 2016 05:18
My first assembler program on Linux :-)
section .text
global _start
_start:
mov rdi, 42
mov rax, 60 ; sys_exit
syscall
; assemble the elf64 object file with nasm:
@pstephens
pstephens / RiderNonRepro.fs
Created August 27, 2017 20:07
RiderNonRepro
namespace Collections
module RiderReproTests =
open FsCheck.Xunit
open Xunit
[<Property>]
let repro_test_pass (_:int) = true
@pstephens
pstephens / calc.py
Created December 26, 2017 18:11
A simple expression evaluator in Python.
"""Implements a simple expression evaluator.
Supported syntax:
1. Balanced parenthesis for grouping.
2. Numbers. Can include a decimal point.
3. Negation ('-' as a prefix unary operator)
4. Binary operators for '*', '/', '+', and '-'.
Order of operations follow typical rules:
1. Grouping. (1+2)
@pstephens
pstephens / lambda_test.c
Created June 28, 2018 03:31
What would transducers look like in C?
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
typedef struct thing thing_t;
struct thing {
long num;
int cnt;
@pstephens
pstephens / README.md
Last active August 8, 2018 19:31 — forked from magnetikonline/README.md
Bash array usage cheatsheet.
@pstephens
pstephens / arc_str.rs
Last active February 15, 2023 17:16 — forked from rust-play/playground.rs
Code shared from the Rust Playground
//! Proof of concept for a reference counted [str]
//! Primary innovation over a plain Rc<str> is that is one less level of
//! indirection and heap allocation
#![feature(const_alloc_layout)]
use core::ptr::NonNull;
use std::alloc::Layout;
use std::alloc::{GlobalAlloc, System};