Skip to content

Instantly share code, notes, and snippets.

View ashawley's full-sized avatar
✍️
Artwork by Arthur Baelde, Wikimedia Commons

Aaron S. Hawley ashawley

✍️
Artwork by Arthur Baelde, Wikimedia Commons
View GitHub Profile
@ashawley
ashawley / gist:5058193
Created February 28, 2013 16:56
Whitespace problems, I feel bad for you son.
;; Billy Mays here talking about zap to whitespace.
;; Deletes your whitespace forward.
;; Got to fix indentation before you merge? No problem!
(global-set-key "\C-c " 'zap-whitespace-forward) ;; C-c SPC
;; But I'm still not done.
(defalias 'zap-whitespace-forward 'ash-delete-syntax-forward)
;; There's more!
;; Delete word characters forward, delete punctuation forward,
def runSecondThenFirst(first: => Unit)(second: => Unit) = {
second;
first
}
runSecondThenFirst {
println("First")
} {
println("Second")
}
@ashawley
ashawley / Main.scala
Created May 25, 2016 17:47
runMany: repeat runMain task in SBT
package proj
object Main extends App
/**
* NegNumbers
*
* A singleton that takes the code out for a spin.
*/
object NegNumbers {
// Instance:
val some = new SomeNumbers {
// Defining an abstract member is what instances do best!
import java.lang._
import scala._
import scala.Predef._
import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
object ComposeFutures extends App {
@ashawley
ashawley / Main.scala
Created October 25, 2016 02:14
Puzzle.scala
package org.npr.weekendedition.sunday.puzzle.people.will.shortz
/**
* Find all the permutations of numbers and ops
* Build infix expresions
* Find all expressions that evaluate within interval (e.g. 1 to 40)
*
*/
object Main extends App {
// Based on the following Usenet posting
// as seen on "Scala: The First Ten Years", Scala Days Berlin, 2014
// From: Miles Sabin
// Date: 2004-04-04 10:24:54 GMT
// Subject: Member types in Scala
// Newgroup: comp.lang.scala
package com.milessabin.example
/**
* Based on Java listings by Bruce Eckel
* Dining Philosophers in Java 8, Dec-29 2016
* http://bruceeckel.github.io/2016/12/29/dining-philosophers-in-java-8/
*/
package concurrent
// concurrent/StickHolder.scala
;; Disable `M-p' and `M-n; in Ensime minor mode
(eval-after-load "ensime-mode"
'(progn
(define-key ensime-mode-map (kbd "M-n") nil)
(define-key ensime-mode-map (kbd "M-p") nil)))
/** fizzbuzz.c */
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include "fizzbuzz.h"
const char* fizzbuzz(signed long n)