Skip to content

Instantly share code, notes, and snippets.

View EdgeCaseBerg's full-sized avatar
📉
Wondering why Github added statuses instead of something useful

Ethan Eldridge EdgeCaseBerg

📉
Wondering why Github added statuses instead of something useful
View GitHub Profile
@freiguy1
freiguy1 / Grunt.scala
Created March 20, 2015 04:00
Using grunt to compile runtime assets in Play Framework app
import sbt._
import Keys._
import java.net._
import java.io.File
import play.PlayRunHook
/*
Grunt runner should be in project directory to be picked up by sbt
*/
object Grunt {
import scala.annotation.tailrec
import scala.App
object Test extends App {
val NumberOfRepetitions = 20
val longText = "This is a test text containing something and SoMETHING else." * 10000
println(s"Ready to start. Text size ${longText.length}")
@koelling
koelling / gist:ef9b2b9d0be6d6dbab63
Last active February 7, 2017 16:21
CVE-2015-0235 (GHOST) test code
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
@haywood
haywood / DBObjectJsValue.scala
Created April 8, 2015 03:50
Casbah DBObject/Play JsValue Conversion
/**
* This was something I explored today.
* The approach is fundamentally flawed for a couple of reasons.
*
* 1. play JSON serializes dates to strings,
* but they are better represented as timestamps or ISODates in mongo.
*
* 2. ObjectId's cannot be round-tripped, since they turn into JSON
* strings on the way out.
*
@glamp
glamp / cows_and_wolves.txt
Last active July 3, 2017 14:23
plotting wolf/cow fence boundaries
o o o
o x
o x x x
x o
x x x o
x
o o
o
@jrudolph
jrudolph / JsonRejectionHandler.scala
Created March 6, 2014 11:29
Custom rejection handler that returns JSON
case class ErrorMessage(message: String, cause: String)
object ErrorMessage {
import spray.json.DefaultJsonProtocol._
implicit val errorFormat = jsonFormat2(ErrorMessage.apply)
}
import spray.httpx.SprayJsonSupport._
implicit val jsonRejectionHandler = RejectionHandler {
case MalformedRequestContentRejection(msg, cause) :: Nil =>
complete(StatusCodes.BadRequest, ErrorMessage("The request content was malformed", msg))
@edwinwebb
edwinwebb / gist:5155504
Last active February 1, 2019 15:39
A simple less loop with comments and simple from, to syntax.
/* Define two variables as the loop limits */
@from : 0;
@to : 10;
/* Create a Parametric mixin and add a guard operation */
.loop(@index) when(@index =< @to) {
/* As the mixin is called CSS is outputted */
div:nth-child(@{index}) {
top: unit(@index * 100, px);
@chaotic3quilibrium
chaotic3quilibrium / DIY Scala Enumeration - README.txt
Last active September 13, 2020 22:20
DIY Scala Enumeration (closest possible Java Enum equivalent with guaranteed pattern matching exhaustiveness checking)
README.txt - DIY Scala Enumeration
Copyright (C) 2014-2016 Jim O'Flaherty
Overview:
Provide in Scala the closest equivalent to Java Enum
- includes decorating each declared Enum member with extended information
- guarantees pattern matching exhaustiveness checking
- this is not available with scala.Enumeration
ScalaOlio library (GPLv3) which contains more up-to-date versions of both `org.scalaolio.util.Enumeration` and `org.scalaolio.util.EnumerationDecorated`:
@jcyamo
jcyamo / i3-exit
Last active October 9, 2020 10:26
Exit script for the i3 window manager based off of exit script from CrunchBang Linux.
#!/usr/bin/env python
# based on cb-exit used in CrunchBang Linux <http://crunchbanglinux.org/>
import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass
@julienrf
julienrf / Action.scala
Created April 9, 2012 16:20
How to implement a custom PathBindable with Play 2
def show(article: Article) = Action {
Ok(views.html.article(article))
}