Skip to content

Instantly share code, notes, and snippets.

View alexdobry's full-sized avatar

Alexander Dobrynin alexdobry

View GitHub Profile
@dankrause
dankrause / postgresql_recursive.sql
Last active February 26, 2024 16:03
An example of creating a recursive postgresql query to generate data about parent-child relationships within a single table.
CREATE TABLE test
(
id INTEGER,
parent INTEGER
);
INSERT INTO test (id, parent) VALUES
(1, NULL),
(2, 1),
@thomasdarimont
thomasdarimont / KeycloakAdminClientExample.java
Last active April 30, 2024 22:18
Using Keycloak Admin Client to create user with roles (Realm and Client level)
package demo.plain;
import org.keycloak.OAuth2Constants;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.representations.idm.ClientRepresentation;
@gilyes
gilyes / Backup, restore postgres in docker container
Last active March 23, 2024 09:30
Backup/restore postgres in docker container
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
@cb372
cb372 / jargon.md
Last active May 14, 2024 03:45
Category theory jargon cheat sheet

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.

@baig
baig / csv2table.hs
Last active November 27, 2023 14:27
A Pandoc filter that replaces Image links having *.csv extension with Pandoc Markdown Tables.
#!/usr/bin/env runhaskell
{-
The MIT License (MIT)
Copyright (c) 2015 Wasif Hasan Baig <pr.wasif@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@lshoo
lshoo / gist:9785645
Created March 26, 2014 15:13
Slick2 generic dao
package slicks.docs.dao
import scala.slick.driver.PostgresDriver.simple._
import scala.slick.driver._
trait Profile {
val profile: JdbcProfile
}
@xuanlongma
xuanlongma / pandoc_multi_input.md
Last active May 1, 2024 19:18
Combine multiple input files when using Pandoc

If multiple input files are given, pandoc will concatenate them all (with blank lines between them) before parsing. -- from Pandoc website

Pandoc command: pandoc -s input1.md input2.md input3.md -o output.html

@akoskovacs
akoskovacs / MyList.hs
Last active September 3, 2023 09:46
A simple Haskell linked list implementation
module MyList where
data MyList a = Cons a (MyList a)
| MyNil deriving (Show, Eq)
{-
A simple linked list module
Some examples:
mylist = (Cons 10 (Cons 99 (Cons 11 (Cons 1 MyNil))))
myHead myList # => 10
myTail myList # => Cons 99 (Cons 11 (Cons 1 MyNil))