Skip to content

Instantly share code, notes, and snippets.

View fosskers's full-sized avatar

Colin Woodbury fosskers

View GitHub Profile
#slightly modified
#made it part of a module for your using pleasure
module SentenceParser
#finds the earliest sentence-ending punctuation in the given String
#i realize this isn't pretty
#finds the earliest sentence-ending punctuation in the given String
def find_partition_pos(line)
found = false
pos = nil #the position of the valid sentence ending punctuation
@fosskers
fosskers / gist:3787785
Created September 26, 2012 12:39
Arch Packages

Arch Packages

and what you should know about them

The Arch Way states:

Arch Linux targets and accommodates competent GNU/Linux users by
giving them complete control and *responsibility* over the system.

Part of this comes from package choice. Users either install from

@fosskers
fosskers / emacs-ensime-implicit-highlighting
Created May 17, 2016 21:30
In my emacs, basically all of this code has implicit underlining across the entire screen.
class Backend($: BackendScope[ModelProxy[DisplayModel], Unit]) {
def render(proxy: ModelProxy[DisplayModel]) = {
val x = Array[String]().toVector // This highlights correctly
<.div(
proxy().metadata.render(md => {
<.div(
<.h3("Layer Metadata"),
<.p(s"CellType: ${md.cellType}"),
@fosskers
fosskers / MapAlgebra.scala
Created August 15, 2016 16:14
A suggestion for Monadizing Map Algebra operations, so that they're generic across any Tile type.
/* Eugene (et al.), our mistake might have been that `MapAlgebra` isn't the Monad,
* RDDs are. We'd like to do things like:
* rdd1.localMean(rdd2).flatMap(r => r.focalGradient).flatMap(r => r.moreStuff)
*/
implicit class KeyedRDDMethods[K: Key, A](rdd: RDD[(K,A)]) {
/* Binary operations are naturally expressed as an FP `zipWith` operation.
* There is a keyed variant that works across Map-like containers.

Benchmark Timing Oddities

Anecdotally, I had noticed that from run to run, the VectorTile benchmarks weren't returning consistent numbers. My three avenues of suspicion were:

  1. My VT implementation
  2. Scaliper
  3. The JVM
@fosskers
fosskers / SpatialSort.hs
Last active October 15, 2016 02:03
Spatial Sort
module SpatialSort
( Point(..)
, spatialSort
) where
import Data.List (sortBy)
import Data.Monoid
import Data.Vector (Vector)
import qualified Data.Vector as V
import qualified Data.Vector.Algorithms.Insertion as I
@fosskers
fosskers / 2019-polyglot-haskell-dancing.org
Created May 27, 2019 16:16
Dancing in Haskell: Beauty, Correctness, and Good Technique

Dancing in Haskell: Beauty, Correctness, and Good Technique

Beauty, Correctness, and Good Technique

Haskell in Production: Adventures in Blockchain Building

@fosskers
fosskers / guild-design.org
Last active January 6, 2023 00:48
The New Guild

The New Guild: a Build Tool for Guile

Test push.

@fosskers
fosskers / audio.el
Last active February 10, 2023 04:29
Emacs Lisp: Extract all the audio from a file or directory of files
(defun extract-audio (choice)
"Extract the audio from a chosen file or directory of files."
(interactive "fVideo File or Directory: ")
(cond ((file-directory-p choice)
(thread-last (directory-files choice 'full)
(seq-filter (lambda (file) (not (file-directory-p file))))
(mapc #'extract-audio-from-file))
(message "Done converting: %s" choice))
(t (extract-audio-from-file choice))))