Skip to content

Instantly share code, notes, and snippets.

View YanSte's full-sized avatar
🌎
Working from Zurich

Yannick Stephan YanSte

🌎
Working from Zurich
View GitHub Profile
@YanSte
YanSte / Langchain FastAPI and Stream Response.py
Created April 19, 2024 11:02
Langchain FastAPI and Stream Response
# Fast API
```
@router.get("/myExample")
async def mySpecialAPI(
session_id: UUID,
input="Hello",
) -> StreamResponse:
# Note: Don't write await we need a coroutine
invoke = chain.ainvoke(..)
@esenthil2018
esenthil2018 / semi_structured_rag_v1.ipynb
Created February 3, 2024 03:04
Semi_Structured_RAG_V1.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import gc
import os
import sys
import psutil
import threading
import argparse
import transformers
import datasets
import numpy as np
import torch
@IanKeen
IanKeen / AnyPublisher+Extension.swift
Created March 17, 2021 17:02
Extension to create an AnyPublisher to easily 'lift' async code into Combine
extension AnyPublisher where Failure: Error {
struct Subscriber {
fileprivate let send: (Output) -> Void
fileprivate let complete: (Subscribers.Completion<Failure>) -> Void
func send(_ value: Output) { self.send(value) }
func send(completion: Subscribers.Completion<Failure>) { self.complete(completion) }
}
init(_ closure: (Subscriber) -> AnyCancellable) {
@YanSte
YanSte / VibrationService.swift
Last active April 16, 2021 08:34
Vibration service on iOS
//
// Vibration.swift
//
// Created by Yannick Stephan on 2020-11-21.
//
import UIKit
import AudioToolbox
enum VibrationService {
@liamnichols
liamnichols / URL+StaticString.swift
Created July 10, 2020 06:52
A non-failable initialiser extension for URL that accepts StaticString
import Foundation
extension URL {
/// Initialize with a static string.
///
/// If the `URL` cannot be formed with the string (for example, if the string contains characters that are illegal in a URL, or is an empty string), a precondition failure will trigger at runtime.
init(staticString: StaticString) {
guard let url = Self.init(string: String(describing: staticString)) else {
preconditionFailure("'\(staticString)' does not represent a legal URL")
}
@stinger
stinger / CombineFetcher.swift
Last active January 28, 2023 18:07
Combine - fetching data using URLSession publishers
import Foundation
import Combine
enum APIError: Error, LocalizedError {
case unknown, apiError(reason: String)
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error"
enum Shortcuts: String {
case refreshList = "com.vialyx.MVD.refresh_list"
var identifier: String {
return rawValue
}
var title: String {
switch self {
case .refreshList:
@dankogai
dankogai / gist:52cd6ef645c9fc248547b79dccd8e893
Created September 22, 2018 12:25
swift 4.2 on ubuntu 18.04 quick start
$ cd ~ # home directory で作業
$ sudo apt-get install clang libicu-dev libcurl4
$ wget https://swift.org/builds/swift-4.2-release/ubuntu1804/swift-4.2-RELEASE/swift-4.2-RELEASE-ubuntu18.04.tar.gz
$ tar xvpf swift-4.2-RELEASE-ubuntu18.04.tar.gz
$ export PATH=~/swift-4.2-RELEASE-ubuntu18.04/usr/bin:$PATH
@Azoy
Azoy / install-swift-ubuntu.md
Last active December 9, 2022 03:42
Guide on how to install Swift on Ubuntu

Install Swift on Ubuntu

Requirements

  1. Ubuntu 14.04, 16.04, or 16.10

Step 1 - Dependencies

  1. Open up terminal
  2. Install core deps: sudo apt-get install clang libicu-dev git

Step 1.1 - Ubuntu 14.04 Clang