Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcelus Trojahn mtrojahn

View GitHub Profile
@mtrojahn
mtrojahn / pre-commit.py
Created Sep 29, 2021
A pre-commit hook that helps to protect a list of local branches from undesired commits.
View pre-commit.py
#!/usr/bin/python
'''
We are bound to forget to checkout some new branch we have just created and
commit something to a branch that is supposed to be protected. This pre-commit
hook helps us to set a list of branches we dont want to allow any commits.
Install
Create the file .git/hooks/pre-commit on your repository and make it
executable with `chmod +x <file>`. After, add the following code to it,
changing the list of protected branches to whatever you like.
@mtrojahn
mtrojahn / binary_comparison.go
Last active Jun 22, 2021
Binary comparison example
View binary_comparison.go
const (
roleUser = 1 << iota
roleSuperUser
roleAdmin
)
type User struct {
name string
role uint
}
View BaseEntityTests.kt
package com.marcelustrojahn.models
import io.ebean.Ebean
import io.kotlintest.matchers.shouldBe
import io.kotlintest.matchers.shouldNotBe
import io.kotlintest.specs.FreeSpec
class BaseEntityTests: FreeSpec() {
init {
// remember the database will always be empty in the beggining of tests
View BaseEntityRelated.kt
package com.marcelustrojahn.models
import io.ebean.Finder
import java.time.LocalDate
import javax.persistence.*
@Entity
@Inheritance
abstract class BaseEntity(
@Id
View Script.kt
@Entity
class Script(
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
var id: Long? = null,
var name: String = "",
var source: String = "",
var description: String = "",
@Version
var version: Long = 0L,
View BaseEntityTests.kt
package com.marcelustrojahn.models
import io.ebean.Ebean
import io.kotlintest.matchers.shouldBe
import io.kotlintest.matchers.shouldNotBe
import io.kotlintest.specs.FreeSpec
class BaseEntityTests: FreeSpec() {
init {
// remember the database will always be empty in the beggining of tests
View application.properties
ebean.packages=com.marcelustrojahn.models
ebean.db.ddl.generate=true
ebean.db.ddl.run=true
datasource.db.username=sa
datasource.db.password=
datasource.db.databaseUrl=jdbc:h2:file:~/monies_db_test;AUTO_SERVER=true
datasource.db.databaseDriver=org.h2.Driver
View BaseEntityRelated.kt
package com.marcelustrojahn.models
import io.ebean.Finder
import java.time.LocalDate
import javax.persistence.*
@Entity
@Inheritance
abstract class BaseEntity(
@Id