Skip to content

Instantly share code, notes, and snippets.

View fcracker79's full-sized avatar
🎯
Focusing

Mirko Bonasorte fcracker79

🎯
Focusing
View GitHub Profile
@fcracker79
fcracker79 / deadlock.go
Created August 2, 2023 06:40
Errata Concurrency in Go chapter 3, page 56
package main
import (
"fmt"
"sync"
"time"
)
type Button struct {
Clicked *sync.Cond
@fcracker79
fcracker79 / gist:4f9d63106ad4c422d4f440450da18060
Created July 13, 2023 16:56
Play with interfaces and zero-value objects
package main
import (
"errors"
"fmt"
)
type MyError string
func (e MyError) Error() string {
@fcracker79
fcracker79 / gist:ebe07a4209caf5863409aed8758ed81c
Created May 3, 2023 11:58
Using OpenAI to convert SQL to ES queries
You are a great Elasticsearch expert.
I will provide an SQL query on a table named "ES_TABLE".
You will convert that SQL query to an ElasticSearch query.
SQL Query:
```
SELECT f1, f2, SUM(f3)
FROM ES_TABLE
WHERE f1 BETWEEN 'a' AND 'b'
GROUP BY f1, f2
```
@fcracker79
fcracker79 / gist:ec283cdb9a57d2d4b9f771a5d268f19e
Last active December 14, 2022 07:32
Optional and switch
public class TestOptional {
private sealed interface MyOptional<T> {
MyOptional<?> EMPTY = new MyEmpty<>();
boolean hasValue();
T get();
static <T> MyOptional<T> of(T t) {
return new MyJust<>(t);
}
@fcracker79
fcracker79 / gist:0e706e8d9309595ba40119c292d82f57
Created December 6, 2021 08:17
My testnet configuration for Cardano
{
"AlonzoGenesisFile": "testnet-alonzo-genesis.json",
"AlonzoGenesisHash": "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874",
"ApplicationName": "cardano-sl",
"ApplicationVersion": 0,
"ByronGenesisFile": "testnet-byron-genesis.json",
"ByronGenesisHash": "96fceff972c2c06bd3bb5243c39215333be6d56aaf4823073dca31afe5038471",
"LastKnownBlockVersion-Alt": 0,
"LastKnownBlockVersion-Major": 3,
"LastKnownBlockVersion-Minor": 0,
@fcracker79
fcracker79 / Playground.hs
Created November 12, 2021 06:39
Plutus Playground Smart Contract
import qualified Data.Text as T
import Playground.Contract
import Plutus.Contract
import PlutusTx.Prelude
import qualified Prelude as Haskell
-- | A 'Contract' that logs a message.
hello :: Contract () EmptySchema T.Text ()
hello = logInfo @Haskell.String "Hello, world"
newtype MyCont r a = MyCont ((a -> r) -> r)
mycont :: MyCont r a -> (a -> r) -> r
mycont (MyCont f) = f
instance Functor (MyCont r) where
fmap f (MyCont ma) = undefined
instance Applicative (MyCont r) where
pure a = undefined
@fcracker79
fcracker79 / postgres_queries_and_commands.sql
Created June 11, 2020 07:43 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@fcracker79
fcracker79 / reflection-config.json
Created January 14, 2020 19:57
Configuration for Quarkus AOT reflection when implementing Alexa skill
[
{
"name": "org.apache.commons.logging.impl.LogFactoryImpl",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredClasses": true,
"allPublicClasses": true
},
@fcracker79
fcracker79 / Main.java
Created January 3, 2020 07:46
Two threads
package io.mirko;
public class Main {
static volatile boolean condition = true;
public static void main(String ... args) throws Exception {
new Thread(new AnotherThread()).start();
if (condition) {
methodA();
}
}