Skip to content

Instantly share code, notes, and snippets.

Wondering why Github added statuses instead of something useful

Ethan Eldridge EdgeCaseBerg

Wondering why Github added statuses instead of something useful
View GitHub Profile
EdgeCaseBerg /
Last active Jan 12, 2021
Python function to read out size data for image types with no dependencies. Found originally at and I added the ICO handler. (just ico not cursor files)
# Name: get_image_size
# Purpose: extract image dimensions given a file path using just
# core modules
# Author: Paulo Scardine (based on code from Emmanuel VAÏSSE), Ethan Eldridge (ICO)
# Created: 26/09/2013
# Copyright: (c) Paulo Scardine 2013
# Licence: MIT
EdgeCaseBerg / ActorTest.scala
Last active Oct 13, 2020
Basic Rate Limiting Actor implementation
View ActorTest.scala
package actors
import org.scalatest._
import org.scalatest.concurrent._
import org.scalatest.time.{ Millis, Seconds, Span }
import akka.util.Timeout
import java.util.concurrent.TimeUnit.MILLISECONDS
EdgeCaseBerg /
Created Jun 30, 2013
Simple singleton logging that creates logs directory wherever the process is run from. Just call SimpleLog.log( String message) ;
//Seriously why do I have to import 3 things so get the date. Java = superflous objects everywhere
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public final class SimpleLog{
EdgeCaseBerg / GuiceThrowingProvidersExample.scala
Last active Mar 31, 2020
Example of using the ThrowingProviders and CheckedProviders in Guice. See full context:
View GuiceThrowingProvidersExample.scala
import{AbstractModule, Provides, Guice}
import{ CheckedProvides, CheckedProvider, ThrowingProviderBinder }
import com.typesafe.config.{ ConfigException, ConfigFactory }
import{URL, MalformedURLException}
import javax.inject.Inject
import scala.collection.JavaConversions._
import scala.util.{Try, Success, Failure}
EdgeCaseBerg / TheCProgrammingLanguage_Exercise1_9.c
Last active May 28, 2019
Exercise 1-9 from The C Programming Language by Brian W. Kernighan, Dennis M. Ritchie​ "Write a program to copy its input to its output replacing each string of one or more blanks by a single blank"
View TheCProgrammingLanguage_Exercise1_9.c
#include <stdio.h>
int c;
while((c = getchar()) != EOF){
if(c == ' '){
while((c = getchar()) == ' ')
EdgeCaseBerg / WSClientBackend.scala
Last active Oct 16, 2018
WSClient powered backend for sttp.
View WSClientBackend.scala
package module
/* Don't import ._ because there's naming conflicts between sttp and ws for request bodies and whatnot */
import ws.{ WSClient, WSClientConfig, WSRequest, WSResponse }
import play.api.libs.iteratee.Enumerator
import com.softwaremill.sttp._
import com.softwaremill.sttp.internal.SttpFile
import com.softwaremill.sttp.monadSyntax._
EdgeCaseBerg / reverse.c
Last active Sep 7, 2018
Exercise 1-19 from The C Programming Language by Brian W. Kernighan, Dennis M. Ritchie​. "Write a function reverse(s) that reverses the character string s. Use it to write a program that reverses its input line by line" Only instead of a function I've written a small program that accepts piped in input and does it there
View reverse.c
#include <stdio.h>
#define MAXLENGTH 1000
//Write a function reverse(s) that reverses the character string s. Use it to write a program that reverses its input line by line
void reverse(char s[], int lim){
int i,j;
EdgeCaseBerg / makeZip.scala
Last active Jul 2, 2018
How to make a zip file in scala (Java 8)
View makeZip.scala
import java.nio.file.{Files, Paths, Path, FileVisitResult}
import java.nio.file.attribute.BasicFileAttributes
import java.nio.file.SimpleFileVisitor
def autoClosing[C <: Closeable, T](closeable: C)(c: C => T) = {
try {
} finally {
EdgeCaseBerg / caseInsensitive.sense
Last active May 11, 2018
Case Insensitive ElasticSearch Regular expressions
View caseInsensitive.sense
# Delete any old test index
DELETE example_copy
# Create index with appropriate mappings/settings
# Note that the pattern is meant to not match anything so that the entire field is taken as the "token"
PUT example_copy
"settings": {
"analysis": {
EdgeCaseBerg / VimeoClient.scala
Last active Apr 9, 2018
How to use Vimeo API from Scala
View VimeoClient.scala
import com.vimeo.networking._
import com.vimeo.networking.model._
import com.vimeo.networking.model.error.VimeoError;
import com.vimeo.networking.callbacks._
import scala.concurrent.{Future, Promise}
import scala.reflect.ClassTag
import scala.reflect._
import okhttp3.CacheControl