Skip to content

Instantly share code, notes, and snippets.

View joshlemer's full-sized avatar
🏠
Working from home

Josh joshlemer

🏠
Working from home
  • Winnipeg, Canada
View GitHub Profile
@joshlemer
joshlemer / Configuration.scala
Last active November 16, 2015 23:10
Configuration code snippet
import com.typesafe.config.{ConfigFactory, Config}
trait Configuration {
val config: Config = ConfigFactory.load()
}
trait Configured[+C <: Configuration] {
def configuration: C
}
@joshlemer
joshlemer / brain.py
Last active December 20, 2015 10:20
The idea behind this project is that the functionality of a neuron is really simple (as far as my knowledge goes). There are inputs and an output. If there are enough inputs firing at a time, then the neuron will output 1. Otherwise 0. And also there can be "negative" inputs - inputs which decrement the count when turned on rather than increment…
from neuron import *
import sys
class Brain:
def __init__(self, ins, middles, outs):
input_string = "0" * ins
input_bits = self.get_input(input_string)
#print input_string
@joshlemer
joshlemer / commands.scala
Created January 16, 2016 01:01
Commands
package com.pulseenergy.lassie.translations
import org.scalacheck.{Arbitrary, Gen, Commands}
import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.Gen._
import org.scalatest.{Matchers, FlatSpec}
import org.scalatest.prop.{PropertyChecks, Checkers}
class Counter {
@joshlemer
joshlemer / ch10.scala
Last active March 7, 2016 16:47
fpinscala
package fpinscala
object Ch10 {
trait Monoid[T] {
def op(x: T, y: T): T
def zero: T
}
// 10.1
@joshlemer
joshlemer / atlas.scala
Created March 10, 2016 18:31
Atlas Client Prototype
object AtlasClient2 {
case class Settings(url: String, authorization: String, version: String, dbService: String)
object Settings {
def fromConfig(config: Config) = Settings("foo","bar","baz","boo")
}
def apply(settings: Settings) = new AtlasClient2(settings)
def apply(config: Config = ConfigFactory.load()) = new AtlasClient2(Settings.fromConfig(config))
}
[trace] Stack trace suppressed: run last *:publishSigned for the full output.
[error] (*:publishSigned) java.io.IOException: Access to URL https://oss.sonatype.org/content/repositories/snapshots/default/multiindex_2.11/0.0.1-SNAPSHOT/multiindex_2.11-0.0.1-SNAPSHOT.jar was refused by the server: Forbidden
[error] Total time: 17 s, completed 2-Oct-2016 1:24:36 PM
CREATE TABLE my_keyspace.slots (
day int,
skuid text,
priority int,
badge text,
PRIMARY KEY ((day, skuid), priority)
);
CREATE TABLE my_keyspace.skus_by_badge (
badge text,
import java.nio.file.{Path, Paths}
import better.files.File.OpenOptions
import org.apache.commons.compress
import better.files._
import org.apache.commons.compress.archivers.ArchiveStreamFactory
import org.apache.commons.compress.archivers.tar.{TarArchiveEntry, TarArchiveInputStream}
object TarFile {
val mb = 1024 * 1024
# Set a Ctrl-b shortcut for reloading your tmux config
bind r source-file ~/.tmux.conf
# For no time after pressing ESC, should we consider ALT to be pressed down
# (Why was that default in the first place???)
set -g escape-time 0
# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
object OtherMain extends App {
import scala.concurrent.{ExecutionContext, Future}
import java.util.concurrent.{ArrayBlockingQueue, Executors, ThreadPoolExecutor, TimeUnit}
val numWorkers = 2
val queueCapacity = 10
val q =
new ArrayBlockingQueue[Runnable](queueCapacity) {
override def offer(e: Runnable) = {