Skip to content

Instantly share code, notes, and snippets.

View alilosoft's full-sized avatar
🐢

Ali Fellahi alilosoft

🐢
View GitHub Profile
@jewelsea
jewelsea / JavaFXTrayIconSample.java
Last active November 13, 2023 14:54
Demonstrate using the System Tray (AWT) to control a JavaFX application.
import javafx.application.*;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.*;
import javax.imageio.ImageIO;
import java.io.IOException;
@chsh
chsh / pg_pub_sub.rb
Last active May 2, 2024 08:13
PostgreSQL LISTEN/NOTIFY example for ruby
#
# A:
# pubsub = PgPubSub.new('channelname')
# pubsub.subscribe do |data|
# puts "data: #{data} is coming!"
# end
#
# B:
# pubsub = PgPubSub.new('channelname')
# pubsub.publish("hello world")
@ramseyboy
ramseyboy / Maybe.kt
Created August 26, 2016 02:50
Optional/Maybe type in Kotlin
package me.ramseyboy.function
import java.util.*
/**
* A container object which may or may not contain a non-null value. If a value is defined, `isdefined()` will return `true` and `get()` will return the value.
*
* Additional methods that depend on the presence or absence of a contained value are provided,
* such as [orElse()][.orElse] (return a default value if value not defined)
@jonyfs
jonyfs / JavaFXTrayIconSample.java
Created October 27, 2016 20:54 — forked from jewelsea/JavaFXTrayIconSample.java
Demonstrate using the System Tray (AWT) to control a JavaFX application.
import javafx.application.*;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.*;
import javax.imageio.ImageIO;
import java.io.IOException;
@nikolaposa
nikolaposa / decoration.php
Last active December 2, 2020 16:30
New PHP language feature; favor composition over inheritance; `decorates` and `inner` keywords
<?php
declare(strict_types=1);
interface UserRepositoryInterface
{
public function find(string $id) : User;
public function findAll() : UserCollection;
}
package com.example.demo.app
import javafx.collections.ObservableList
import javafx.event.EventHandler
import javafx.scene.control.ComboBox
import javafx.scene.input.KeyCode
import javafx.scene.input.KeyEvent
fun <T> ComboBox<T>.makeAutocompletable() = AutoCompleteComboBoxExtension<T>(this)
build.gradle
apply plugin: "checkstyle"
checkstyle {
configFile = project(':').file("config/checkstyle/checkstyle.xml")
configProperties = ["suppressionFile" : project(':').file("config/checkstyle/suppressions.xml")]
toolVersion = "6.0"
}
@nicolopignatelli
nicolopignatelli / Aborted.java
Last active April 9, 2019 23:11
Result micro-library. Emoji powered.
final class Aborted extends Failure {
public Result<T> ✅(Consumer<T> f) {
return this;
}
public Result<T> ❌(Consumer<ExceptionStack> f) {
return this;
}
}
@SimonAlling
SimonAlling / algebraic.ts
Last active October 24, 2023 21:00
Algebraic Data Types in TypeScript
// Types:
type Just<T> = { Just: T }
type Nothing = {}
type Maybe<T> = Just<T> | Nothing
type Left<L> = { Left: L }
type Right<R> = { Right: R }
type Either<L, R> = Left<L> | Right<R>
// For convenience:
@michael-simons
michael-simons / Application.kt
Last active February 18, 2024 10:55
Minimal Kotlin/Gradle Example for Neo4j OGM
package so
import org.neo4j.ogm.annotation.GeneratedValue
import org.neo4j.ogm.annotation.Id
import org.neo4j.ogm.annotation.NodeEntity
import org.neo4j.ogm.annotation.Relationship
import org.neo4j.ogm.config.Configuration
import org.neo4j.ogm.session.SessionFactory
@NodeEntity