Skip to content

Instantly share code, notes, and snippets.

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
View learning_scala.org
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active May 13, 2021
Jenkinsfile idiosynchrasies with escaping and quotes
View Jenkinsfile.groovy
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@rrodseth
rrodseth / UnfoldPages.scala
Last active Dec 18, 2020
Create akka-stream Source from a pagination, using Source.unfoldAsync
View UnfoldPages.scala
// Inspired by a tweet from @trautonen 1/13/2016
// Use Source.unfoldAsync to turn paginated database results into an akka-streams Source
// unfold is the inverse of fold
case class Page[T](pageNumber:Long, totalPages:Long, contents:List[T])
case class Thing(id: Long, name: String = "foo")
val totalPages = 5 //
val pageSize = 3
@haywood
haywood / DBObjectJsValue.scala
Created Apr 8, 2015
Casbah DBObject/Play JsValue Conversion
View DBObjectJsValue.scala
/**
* 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.
*
@freiguy1
freiguy1 / Grunt.scala
Created Mar 20, 2015
Using grunt to compile runtime assets in Play Framework app
View Grunt.scala
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 {
@koelling
koelling / gist:ef9b2b9d0be6d6dbab63
Last active Feb 7, 2017
CVE-2015-0235 (GHOST) test code
View gist:ef9b2b9d0be6d6dbab63
#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];
@davegurnell
davegurnell / anorm.scala
Last active Apr 16, 2020
A short guide to Anorm
View anorm.scala
/*
Overview
--------
To run a query using anorm you need to do three things:
1. Connect to the database (with or without a transaction)
2. Create an instance of `anorm.SqlQuery` using the `SQL` string interpolator
3. Call one of the methods on `SqlQuery` to actually run the query
@chaotic3quilibrium
chaotic3quilibrium / DIY Scala Enumeration - README.txt
Last active Sep 13, 2020
DIY Scala Enumeration (closest possible Java Enum equivalent with guaranteed pattern matching exhaustiveness checking)
View DIY Scala Enumeration - README.txt
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`:
@fancellu
fancellu / ExceptionDig.scala
Last active Aug 29, 2015
Various ways to recurse down Exception causes in Scala
View ExceptionDig.scala
// Using vars, lots of local mutation
def getThemVar(th:Throwable)={
var now=th
var li=List[Throwable](now)
var cause=now.getCause
while (cause!=null){
li=cause::li
now=cause
cause=now.getCause
}
View evills
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
__all__ = ["transform"]
__version__ = '0.3'
__author__ = 'Christoph Burgmer <cburgmer@ira.uka.de>'
__url__ = 'http://github.com/cburgmer/upsidedown'