Skip to content

Instantly share code, notes, and snippets.

View holgerbrandl's full-sized avatar

Holger Brandl holgerbrandl

View GitHub Profile
@holgerbrandl
holgerbrandl / TfExplainNotWorking.kt
Last active May 29, 2024 07:48
A small self-contained example showcasing the broken explain API in TF v1.10
package com.systema.experiments
import ai.timefold.solver.core.api.domain.entity.PlanningEntity
import ai.timefold.solver.core.api.domain.lookup.PlanningId
import ai.timefold.solver.core.api.domain.solution.PlanningEntityCollectionProperty
import ai.timefold.solver.core.api.domain.solution.PlanningScore
import ai.timefold.solver.core.api.domain.solution.PlanningSolution
import ai.timefold.solver.core.api.domain.valuerange.ValueRangeProvider
import ai.timefold.solver.core.api.domain.variable.*
import ai.timefold.solver.core.api.score.buildin.hardmediumsoft.HardMediumSoftScore
@holgerbrandl
holgerbrandl / CourseListSchedule.kt
Last active May 7, 2024 11:39
CourseListSchedule.kt
import ai.timefold.solver.core.api.domain.entity.PlanningEntity
import ai.timefold.solver.core.api.domain.lookup.PlanningId
import ai.timefold.solver.core.api.domain.solution.PlanningEntityCollectionProperty
import ai.timefold.solver.core.api.domain.solution.PlanningScore
import ai.timefold.solver.core.api.domain.solution.PlanningSolution
import ai.timefold.solver.core.api.domain.valuerange.ValueRangeProvider
import ai.timefold.solver.core.api.domain.variable.*
import ai.timefold.solver.core.api.score.buildin.hardmediumsoft.HardMediumSoftScore
import ai.timefold.solver.core.api.score.director.ScoreDirector
// Code generated by moshi-kotlin-codegen. Do not edit.
@file:Suppress("DEPRECATION", "unused", "ClassName", "REDUNDANT_PROJECTION",
"RedundantExplicitType", "LocalVariableName", "RedundantVisibilityModifier",
"PLATFORM_CLASS_MAPPED_TO_KOTLIN")
package org.kalasim.scratch
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
1 Product 1 Pa wafer 7.28571 25
2 Product 2 Pb wafer 4.28571 25
3 Product 3 test wafer 0.42 25
pacman::p_load(zeallot)
load_multiple <- function (rdataFile)
{
load(rdataFile, ex <- new.env())
mget(objects(ex, sorted = T), envir = ex)
}
foo = 1
bar = 2
CREATE STREAM ratings (title VARCHAR, release_year INT, rating DOUBLE, timestamp VARCHAR)
WITH (kafka_topic='ratings',
key='title',
timestamp='timestamp',
timestamp_format='yyyy-MM-dd HH:mm:ss',
partitions=1,
value_format='avro');
INSERT INTO ratings (title, release_year, rating, timestamp) VALUES ('Die Hard', 1998, 8.2, '2019-07-09 01:00:00');
require(dplyr)
require(ggplot2)
# make sure that purrr package is installed to use purrr::set_names
# aggregate data
df = mpg %>%
group_by(year, manufacturer) %>%
summarize(mixmpg = mean(cty + hwy)) %>%
# create dummy var which reflects order when sorted alphabetically
mutate(ord =sprintf("%02i", as.integer(rank(mixmpg))) )
@holgerbrandl
holgerbrandl / add_chr_prefix_to_bw.kts
Last active October 26, 2018 09:08
Rewrites a big-wig file while adding a 'chr' prefix to the chromosome names. Requires `kscript`.Usage `add_chr_prefix_to_bw.kts chrom_sizes.fai in.bw out.bw`
#!/usr/bin/env kscript
// kshell_kts.sh /Users/brandl/.kscript/kscript_tmp_project__adjust_bigwig_ids.kts_1540471113973/src/adjust_bigwig_ids.kts
@file:DependsOn("org.jetbrains.bio:big:0.8.3")
@file:DependsOn("com.xenomachina:kotlin-argparser:2.0.7")
import com.xenomachina.argparser.ArgParser
import com.xenomachina.argparser.DefaultHelpFormatter
import com.xenomachina.argparser.mainBody
import org.apache.log4j.ConsoleAppender
@holgerbrandl
holgerbrandl / RevisedTornadoFxSwingExample.kt
Last active September 14, 2018 07:48
Swing integration example without using unnecessary JFrame
import javafx.application.Platform
import javafx.beans.property.SimpleObjectProperty
import javafx.embed.swing.JFXPanel
import javafx.scene.image.Image
import javafx.stage.Stage
import tornadofx.*
import javax.swing.SwingUtilities
object SwingApp {
private fun createAndShowGUI() {
# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {