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
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active March 6, 2024 18:14
Jenkinsfile idiosynchrasies with escaping and quotes
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 June 14, 2021 18:36
Create akka-stream Source from a pagination, using Source.unfoldAsync
// 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 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.
*
@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 {
@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];
@davegurnell
davegurnell / anorm.scala
Last active August 14, 2023 16:42
A short guide to Anorm
/*
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 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`:
@fancellu
fancellu / ExceptionDig.scala
Last active December 13, 2023 06:07
Various ways to recurse down Exception causes in 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
}
#!/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'