Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mtrojahn's full-sized avatar

Marcelus Trojahn mtrojahn

View GitHub Profile
@mtrojahn
mtrojahn / DefaultKeyBindings.dict
Created January 29, 2022 11:19
MacOS keybindings
// ~/Library/KeyBinding/DefaultKeyBindings.dict
{
"\UF729" = moveToBeginningOfLine:; // home
"\UF72B" = moveToEndOfLine:; // end
"$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
"$^\UF729" = moveToBeginningOfDocumentAndModifySelection:; // shift-ctrl-home
@mtrojahn
mtrojahn / pre-commit.py
Created September 29, 2021 03:00
A pre-commit hook that helps to protect a list of local branches from undesired commits.
#!/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 June 22, 2021 13:57
Binary comparison example
const (
roleUser = 1 << iota
roleSuperUser
roleAdmin
)
type User struct {
name string
role uint
}
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
package com.marcelustrojahn.models
import io.ebean.Finder
import java.time.LocalDate
import javax.persistence.*
@Entity
@Inheritance
abstract class BaseEntity(
@Id
@mtrojahn
mtrojahn / Script.kt
Last active September 14, 2019 01:17
@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,
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
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
package com.marcelustrojahn.models
import io.ebean.Finder
import java.time.LocalDate
import javax.persistence.*
@Entity
@Inheritance
abstract class BaseEntity(
@Id