Skip to content

Instantly share code, notes, and snippets.

View devshorts's full-sized avatar

Anton Kropp devshorts

View GitHub Profile
data "aws_iam_policy_document" "do_not_delete_important_stuff" {
statement {
effect = "Deny"
actions = [
// cognito
"cognito-idp:AdminDeleteUser",
"cognito-idp:DeleteGroup",
"cognito-idp:DeleteIdentityProvider",
[
{
"code": 200,
"request": {},
"headers": {
"content-type": "application/json; charset=utf-8",
"cache-control": "no-cache",
"content-length": "52",
"date": "Wed, 13 Apr 2022 23:53:11 GMT",
"connection": "close"
const accountResponse = {
balance: 25.3,
name: 'My checking account',
};
const transactions = [
{
amount: -10.2,
date: 1583266558054,
category: 'food',
@devshorts
devshorts / zip.go
Created August 29, 2018 16:44
golang zip
package packaging
import (
"archive/zip"
"io"
)
type PackageContents struct {
Data io.Reader
FileName string
#!/usr/bin/env ruby
require 'octokit'
require 'pp'
Octokit.auto_paginate = true
org=ARGV[0]
client = Octokit::Client.new(:access_token => "#{ENV['GIT_ACCESS_TOKEN']}")
/**
* Encoding for "A is not a subtype of B"
* @note original credit: https://gist.github.com/milessabin/c9f8befa932d98dcc7a4
*/
trait NotTypeOf[A, B]
trait NotTypeImplicits {
// Uses ambiguity to rule out the cases we're trying to exclude
implicit def allowedType[A, B] : A NotTypeOf B = null
implicit def typeSuperTypeOfInvalid[A, B >: A] : A NotTypeOf B = null
object EditDistance {
def within(s1: String, s2: String, n: Int = 1): Boolean = {
if (s1 != s2 && Math.abs(s1.length - s2.length) > 1) {
return false
}
var s1Idx = 0
var s2Idx = 0
def withinN() = Math.abs(s1Idx - s2Idx) <= n
trait BigIntegerTypesComponent extends RelationalTypesComponent {
self: JdbcProfile =>
implicit def bigIntType = new BigIntegerJdbcType
implicit val bigIntSetParam = new SetParameter[BigInteger] {
override def apply(v1: BigInteger, v2: PositionedParameters): Unit = v2.setObject(v1, java.sql.Types.BIGINT)
}
class BigIntegerJdbcType extends DriverJdbcType[BigInteger] with NumericTypedType {
object BitGroup {
def zero(max: Int): BitGroup = {
val bytesRequired = max / 8
new BitGroup(new Array[Byte](bytesRequired + 1), max)
}
def filled(max: Int): BitGroup = {
val bytesRequired = max / 8
case class StringAnyVal @JsonCreator()(@(JsonValue@getter) value: String) extends AnyVal
case class AnyValHolder(anyVal: StringAnyVal)
class Jackson extends FlatSpec with Matchers {
val finatra = FinatraObjectMapper.create().objectMapper
val jackson = {
val o = new ObjectMapper with ScalaObjectMapper
o.registerModule(DefaultScalaModule)