Skip to content

Instantly share code, notes, and snippets.

View bmjsmith's full-sized avatar

Brian Smith bmjsmith

View GitHub Profile
@reegnz
reegnz / README.md
Created June 19, 2020 10:39
CamelCase <--> snake_case conversion in jq

CamelCase <--> snake_case conversion with jq

tl;dr

I provide you with 3 jq lib functions that will help you in converting between snake_case and CamelCase.

The interface

I want to change keys in my json from camelcase to snake_case.

@stanch
stanch / jwk-to-pem.scala
Last active February 27, 2018 22:47
A quick script to convert JWK public keys to .pem files
load.ivy("com.nimbusds" % "nimbus-jose-jwt" % "4.21")
load.ivy("org.bouncycastle" % "bcprov-jdk15on" % "1.51")
@
import com.nimbusds.jose.jwk._
import org.bouncycastle.util.io.pem._
import java.io._
def main(input: String) = {
@pathikrit
pathikrit / Not.scala
Last active August 3, 2016 16:17
Simple Negation Types in Scala
trait NotSubTypeOf[A, B] // encoding to capture A is not a subtype of B
// Note: We can use infix notation to write `A NotSubTypeOf B` instead of `NotSubTypeOf[A, B]`
// evidence for any two arbitrary types A and B, A is not a subtype of B
implicit def isSub[A, B]: A NotSubTypeOf B = null
// define ambigous implicits to trigger compile error in case A is a subtype of B (or A =:= B)
implicit def iSubAmbig1[A, B >: A]: A NotSubTypeOf B = null
implicit def iSubAmbig2[A, B >: A]: A NotSubTypeOf B = null
@javierarques
javierarques / protractorAPICheatsheet.md
Last active January 31, 2023 08:51
Protractor API Cheatsheet
// Quasiquoted excerpt
def cdef = q"""
class $ClassName[..$classTypeParams](..$primaryParams) extends ..$classParents {
..$primaryAccessors
def get = this
def isEmpty = ${quasi.isEmpty}
def copy(..$primaryWithDefaults) = $ObjectName(..$primaryNames)
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@paulp
paulp / test.scala
Created February 1, 2013 17:57
statically typed companion objects
package s
object Test {
// Observe that x.companion is statically typed such that foo is callable
def f1() = {
val x = new Foo
println(x) // Foo instance
println(x.companion) // Foo companion
println(x.companion.foo) // I'm foo!
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@tonymorris
tonymorris / SKI_Applicative.scala
Created August 2, 2012 04:59
Applicative Functor / SKI combinator calculus
object SKI_Applicative {
/*
First, let's talk about the SK combinator calculus and how it contributes to solving your problem.
The SK combinator calculus is made of two functions (aka combinators): S and K. It is sometimes called the SKI combinator calculus, however, the I combinator can be derived from S and K. The key observation of SK is that it is a turing-complete system and therefore, anything that can be expressed as SK is also turing-complete. Here is a demonstration that Scala's type system is turing-complete (and therefore, undecidable) for example[1].
The K combinator is the most trivial of the two. It is sometimes called "const" (as in Haskell). There is also some discussion about its evaluation strategy in Scala and how to best express it[2]. The K function might be paraphrased as, "takes a value and returns a (constant) unary function that always returns that value."
*/
def k[A, B]: A => B => A =
a => _ => a
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 3, 2024 19:09
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname