Skip to content

Instantly share code, notes, and snippets.

View bioball's full-sized avatar

Daniel Chao bioball

View GitHub Profile
@bioball
bioball / AppConfig.pkl
Last active June 21, 2024 20:05
Pkl multiple inheritance example
module com.example.AppConfig
// self import
import "AppConfig.pkl"
/// The profile to use.
local profile = read?("prop:profile") as ("dev"|"prod")?
/// The modifier to apply, if any.
local modifier = read?("prop:modifier") as ("canary"|"ci")?
@bioball
bioball / convert.pkl
Created March 15, 2024 16:35
AWS CloudFormation generate pkl
import "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib@1.0.3#/internal/ModulesGenerator.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1.0.1#/Parser.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.0#/URI.pkl"
jsonFiles = read*("schemas/*.json")
converted: Listing<ModulesGenerator> = new Listing {
for (filename, file in jsonFiles) {
new ModulesGenerator {
rootSchema = Parser.parse(file)
@bioball
bioball / changes.diff
Last active February 28, 2024 00:26
Executor SPI changes
diff --git a/pkl-core/src/main/java/org/pkl/core/service/ExecutorSpiImpl.java b/pkl-core/src/main/java/org/pkl/core/service/ExecutorSpiImpl.java
index e1b6d236f..2fdb39b82 100644
--- a/pkl-core/src/main/java/org/pkl/core/service/ExecutorSpiImpl.java
+++ b/pkl-core/src/main/java/org/pkl/core/service/ExecutorSpiImpl.java
@@ -37,11 +37,9 @@ import org.pkl.core.resource.ResourceReaders;
import org.pkl.executor.spi.v1.ExecutorSpi;
import org.pkl.executor.spi.v1.ExecutorSpiException;
import org.pkl.executor.spi.v1.ExecutorSpiOptions;
-import org.pkl.executor.spi.v2.ExecutorSpi2;
-import org.pkl.executor.spi.v2.ExecutorSpiException2;
#include <iostream>
using namespace std;
template<class T>
class LinkedList
{
private:
T* value;
LinkedList* nextNode = nullptr;
@bioball
bioball / part1.cpp
Created December 21, 2015 18:32
AOC day 3
//
// Created by Daniel Chao on 12/18/15.
//
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <fstream>
package com.typeclassified.cssr
import breeze.linalg.DenseVector
import com.typeclassified.cssr.parse.ParseNode
import scala.collection.mutable.ArrayBuffer
object CSSRState {
def apply(histories: ArrayBuffer[ParseNode] = ArrayBuffer()) = new CSSRState(histories)
}
@bioball
bioball / cheryls_birthday
Created April 20, 2015 16:46
Cheryl's birthday
1. Albert knows the date, but not the month. Otherwise, he wouldn't know for sure that Bernard also doesn't know Cheryl's birthday. There are two dates in there that's unique.
2. Since Bernard knows it's not a unique date, he knows it's not June 18th nor May 19th
3. If you take out those two months, there's only one month left that only occurs once. Since Bernard now knows the month for sure, we know it's in June.
Conclusion: Cheryl's birthday is on June 17th
@bioball
bioball / authentication.js
Last active August 29, 2015 14:15
Angular AUTH example
angular.module('app')
.factory('authentication', [
'user',
'$state',
function(user, $state){
return {
authenticate: function(protect){
return user.identify()
.then(function(){
return true;
@bioball
bioball / authentication.js
Created February 12, 2015 06:12
Angular AUTH example
angular.module('app')
.factory('authentication', [
'user',
function(user){
return {
authentication: function(){
return user.identify();
}
};
}
@bioball
bioball / authentication.js
Created February 12, 2015 06:12
Angular AUTH example
angular.module('app')
.factory('authentication', [
'user',
function(user){
return {
authentication: function(){
return user.identify();
}
};
}