Skip to content

Instantly share code, notes, and snippets.

View ItsDoot's full-sized avatar

Christian Hughes ItsDoot

  • Texas, United States
  • 17:20 (UTC -05:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am xdotdash on github.
  • I am dotdash (https://keybase.io/dotdash) on keybase.
  • I have a public key ASAJEDSPia-uGlCWTgshVKiVCdwllZefGeYn-J92_f8t3Ao

To claim this, I am signing this object:

@ItsDoot
ItsDoot / unsafeCast_.java
Created November 1, 2017 02:17
Unsafe type casting in Ceylon (through Java)
import ceylon.language.SharedAnnotation$annotation$;
import com.redhat.ceylon.compiler.java.metadata.*;
import com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor;
import java.lang.Object;
@Ceylon(major = 8)
@Method
public class unsafeCast_ {
@Listener
public void onChat(MessageChannelEvent.Chat event, @First Player player) {
}
class Either<A, B>() {}
interface Monad<M> given M<E> {
shared formal M<A> point<A>(A t) ;
shared formal M<B> bind<A, B>(M<A> box)(M<B>(A) func) ;
}
interface EitherMoad<A> satisfies Monad<<B> => Either<A,B>> {
interface Monad<M> given M<E> {
shared formal M<A> point<A>(A t) ;
shared formal M<B> bind<A, B>(M<A> box)(M<B>(A) func) ;
}
interface EitherMoad<A> satisfies Monad<<B> => A|B> {
shared formal actual A|B point<B>(B b);
shared abstract class UserStatus of online | idle | doNotDisturb | invisible | offline {
shared static UserStatus|ParseException parse(String string) =>
parseUserStatus(string) else ParseException("illegal format for UserStatus");
shared new () {}
}
"A value representing online status for a [[User]]."
shared object online extends UserStatus() {
2018-05-03 14:05:26,435 [6299766] ERROR - til.concurrency.QueueProcessor - IntelliJ IDEA 2017.2.7 Build #IU-172.4574.19
2018-05-03 14:05:26,435 [6299766] ERROR - til.concurrency.QueueProcessor - JDK: 1.8.0_152-release
2018-05-03 14:05:26,435 [6299766] ERROR - til.concurrency.QueueProcessor - VM: OpenJDK 64-Bit Server VM
2018-05-03 14:05:26,435 [6299766] ERROR - til.concurrency.QueueProcessor - Vendor: JetBrains s.r.o
2018-05-03 14:05:26,435 [6299766] ERROR - til.concurrency.QueueProcessor - OS: Windows 10
2018-05-03 14:05:26,435 [6299766] ERROR - til.concurrency.QueueProcessor - Last Action: ShowIntentionActions
2018-05-03 14:05:51,122 [6324453] INFO - lij.openapi.util.io.FileUtilRt -
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
@ItsDoot
ItsDoot / Table.ceylon
Created May 13, 2018 23:31
sql framework experiment
shared abstract class Table<Col, Columns>(name)
given Columns satisfies Col[] {
shared String name;
shared formal Column<Col>[] columns;
shared class Column<out Value>(name, default = null)
given Value satisfies Col {
@ItsDoot
ItsDoot / Map.kt
Last active July 1, 2018 20:14
Map creation with only 1 extra object allocation.
/**
* Creates a HashMap with starter entries, with only 1 extra object allocation.
*/
inline fun <K, V> newHashMap(init: MapBuilder<K, V>.() -> Unit): HashMap<K, V> {
val builder = MapBuilder<K, V>()
builder.init()
return builder.map
}
class MapBuilder<K, V> {
import org.spongepowered.api.event.Event;
import org.spongepowered.api.event.Listener;
public class MyEventHandler<T extends Event> {
@Listener
public void onEvent(T event) {
}
}