Skip to content

Instantly share code, notes, and snippets.

View tuesd4y's full-sized avatar

Chris Stelzmüller tuesd4y

View GitHub Profile
@tuesd4y
tuesd4y / prhsc
Created December 1, 2016 09:07
prhsc
DbContext
=========
class SchoolDb : DbContext {
public DbSet<Class> Classes { get; set; }
public DbSet<Person> Persons { get; set; }
public SchoolDb() : base("Data Source=(localdb)\\schooldb;Initial Catalog=SchoolDb;Integrated Security=True") {
System.Data.Entity.Database.SetInitializer(new SchoolDbInitializer());
}
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
base.OnModelCreating(modelBuilder);
@tuesd4y
tuesd4y / RestResource.kt
Created February 5, 2017 18:27
abstract User Checking RestResource
package at.tnzstz.rest
import at.tnzstz.authentication.Authenticated
import at.tnzstz.cdi.ReflectionHelper
import at.tnzstz.entity.User
import at.tnzstz.interfaces.AbstractEntity
import at.tnzstz.persistence.UserCheckingFacade
import io.swagger.annotations.Api
import javax.json.JsonObject
import javax.ws.rs.*
@tuesd4y
tuesd4y / positions.java
Created February 14, 2017 12:28
gnatsch
import org.json.JSONArray;
import org.json.JSONObject;
class Main {
static class Position {
private int positionArtId;
private String name;
private String kurzZeichen;
@tuesd4y
tuesd4y / PasswordUtils.kt
Created September 4, 2017 16:18
kotlin password hashing helper
//probably this should be something like a JavaEE Singleton...
object PasswordUtils {
val random = SecureRandom()
fun generateSalt(): ByteArray {
val salt = ByteArray(16)
random.nextBytes(salt)
return salt
}
@tuesd4y
tuesd4y / CsvFileHelper.kt
Created May 12, 2018 09:34
Helper for writing simple csv files
package at.triply.eventoverview.api
import java.io.File
class CsvFileHelper(val file: File) {
companion object {
val SEPERATOR = ";"
}
@tuesd4y
tuesd4y / BTreePrinter.java
Created November 26, 2018 13:48
asdfasdf
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class BTreePrinter {
public static void printNode(AVLNode root) {
int maxLevel = BTreePrinter.maxLevel(root);
printNodeInternal(Collections.singletonList(root), 1, maxLevel);
object BTreePrinter {
fun printNode(root: AVLNode, showHeight: Boolean = false) {
val maxLevel = BTreePrinter.maxLevel(root)
printNodeInternal(listOf(root), 1, maxLevel, showHeight)
}
private fun printNodeInternal(nodes: List<AVLNode?>, level: Int, maxLevel: Int, showHeight: Boolean) {
if (nodes.isEmpty() || BTreePrinter.isAllElementsNull(nodes))
package at.triply.backend.eventbackend.security
import at.triply.backend.eventbackend.data.entities.EventManager
import at.triply.backend.eventbackend.data.repositories.EventManagerRepository
import org.springframework.data.rest.webmvc.BasePathAwareController
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody
package at.triply.backend.eventbackend.security
interface User {
val username: String
val password: String
}
package at.triply.backend.eventbackend.security
import at.triply.backend.eventbackend.data.entities.EventManager
import at.triply.backend.eventbackend.data.repositories.EventManagerRepository
import org.springframework.data.rest.webmvc.BasePathAwareController
import org.springframework.http.ResponseEntity
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping