This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zio._ | |
import scala.{ Console => SConsole } | |
import scala.io.StdIn | |
import java.io.{ BufferedReader, IOException } | |
import scala.util.Try | |
object InterruptableReadLine extends ZIOAppDefault { | |
def altReadLine(reader: BufferedReader = SConsole.in) = | |
ZIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zio._ | |
object FakeConsoleExample extends ZIOAppDefault { | |
private val program = ZIO.serviceWithZIO[Console] { console => | |
for { | |
_ <- console.printLine("Going to the grocery store") | |
input <- console.readLine("How are you? ") | |
_ <- console.printLine(s"You said: $input") | |
} yield () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"sync" | |
"time" | |
"unsafe" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func greet(st string, done chan bool) { | |
fmt.Println(st) | |
done <- true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strconv" | |
) | |
// Maps over collection of T and applies function f to each item | |
// Returns a new slice with the transformed items | |
func mapf[T any, U any](items []T, f func(T) U) []U { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.effect.{IO, IOApp} | |
import fs2.{Stream, text} | |
import fs2.io.file.{Files, Path} | |
import fs2.io.{stdout, stderr} | |
import scala.util.Try | |
object WindowedAverage extends IOApp.Simple: | |
private object Fahrenheit: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.annotation.targetName | |
import scala.util.boundary | |
import scala.util.boundary.{Label, break} | |
// Works in Scala 3.4.1 | |
def firstIndex[T](xs: List[T], p: T): Int = { | |
boundary: | |
for (x, i) <- xs.zipWithIndex do if (x == p) break(i) | |
-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_dicts_list(dict_list): | |
""" | |
This function adds a list of dictionaries element-wise. | |
Args: | |
dict_list: A list of dictionaries with k->int elements. | |
Returns: | |
A new dictionary with the sum of the corresponding elements from all dictionaries in dict_list. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://huggingface.co/spaces/Fancellu/streamlit-demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
from transformers import BeitImageProcessor, BeitForImageClassification | |
import os | |
# Define the directory containing images | |
image_dir = "e:/media" | |
# Load the model and processor | |
processor = BeitImageProcessor.from_pretrained('microsoft/beit-base-patch16-224-pt22k-ft22k') | |
model = BeitForImageClassification.from_pretrained('microsoft/beit-base-patch16-224-pt22k-ft22k') |
NewerOlder