Skip to content

Instantly share code, notes, and snippets.

Avatar
🕋

Ali FELLAHI fellahi-ali

🕋
View GitHub Profile
@fellahi-ali
fellahi-ali / pg_pub_sub.rb
Created Dec 23, 2020 — forked from chsh/pg_pub_sub.rb
PostgreSQL LISTEN/NOTIFY example for ruby
View pg_pub_sub.rb
#
# A:
# pubsub = PgPubSub.new('channelname')
# pubsub.subscribe do |data|
# puts "data: #{data} is coming!"
# end
#
# B:
# pubsub = PgPubSub.new('channelname')
# pubsub.publish("hello world")
View CheckStyle Gradle Configuration
build.gradle
apply plugin: "checkstyle"
checkstyle {
configFile = project(':').file("config/checkstyle/checkstyle.xml")
configProperties = ["suppressionFile" : project(':').file("config/checkstyle/suppressions.xml")]
toolVersion = "6.0"
}
@fellahi-ali
fellahi-ali / JavaFXTrayIconSample.java
Created Aug 21, 2020 — forked from jonyfs/JavaFXTrayIconSample.java
Demonstrate using the System Tray (AWT) to control a JavaFX application.
View JavaFXTrayIconSample.java
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;
View AutoCompleteComboBoxExtension.kt
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)
@fellahi-ali
fellahi-ali / algebraic.ts
Created Oct 17, 2019 — forked from SimonAlling/algebraic.ts
Algebraic Data Types in TypeScript
View algebraic.ts
// 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:
@fellahi-ali
fellahi-ali / MyModel.kt
Last active Sep 2, 2019
ViewModel commit listener implementation
View MyModel.kt
class MyModel : ItemViewModel<DomainType>() {
// this will not be needed if the above solution is integrated to tornadofx.ViewModel
// as the notifyCommitListeners() could be called by ViewModel.commit() method.
override fun onCommit() {
// TODO: notify listeners only when something really changed
notifyCommitListeners()
}
}
@fellahi-ali
fellahi-ali / Aborted.java
Created Apr 9, 2019 — forked from nicolopignatelli/Aborted.java
Result micro-library. Emoji powered.
View Aborted.java
final class Aborted extends Failure {
public Result<T> ✅(Consumer<T> f) {
return this;
}
public Result<T> ❌(Consumer<ExceptionStack> f) {
return this;
}
}
@fellahi-ali
fellahi-ali / Application.kt
Created Feb 16, 2019 — forked from michael-simons/Application.kt
Minimal Kotlin/Gradle Example for Neo4j OGM
View Application.kt
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
View KotlinTestPluginException
Exception in thread "main" java.lang.NoSuchMethodError: io.kotlintest.runner.jvm.TestEngine.<init>(Ljava/util/List;Ljava/util/List;ILio/kotlintest/runner/jvm/TestEngineListener;)V
at io.kotlintest.runner.console.KotlinTestConsoleRunner.execute(KotlinTestConsoleRunner.kt:27)
at io.kotlintest.runner.console.LauncherKt.main(launcher.kt:19)
@fellahi-ali
fellahi-ali / mind_storms.py
Created Jun 7, 2018
1MAC Draw Turtle Mini-Project
View mind_storms.py
import turtle
def draw_square():
t = turtle.Turtle(shape="turtle")
t.color("dodger blue")
t.pensize(2)
for i in range(4):
t.forward(200)
t.right(90)