Skip to content

Instantly share code, notes, and snippets.

View theleoborges's full-sized avatar

Leonardo Borges theleoborges

View GitHub Profile
@theleoborges
theleoborges / gist:a26c1566f14ff6304bf0
Last active March 7, 2019 23:03
20 intermediate haskell exercises
-- From: http://tonymorris.github.io/blog/20-intermediate-haskell-exercises/
-- which seems to be offline now
class Fluffy f where
furry :: (a -> b) -> f a -> f b
-- Exercise 1
-- Relative Difficulty: 1
instance Fluffy [] where
furry = error "todo"
@theleoborges
theleoborges / sequence.scala
Last active August 29, 2015 14:04
sequence, type lambdas and sequenceU
case class Error(reason: String)
val eithers: List[\/[Error, String]] = List(\/-("Ok"), -\/(Error("notOk")))
eithers.sequence
// error: could not find implicit value for parameter ev: scalaz.Leibniz.===[scalaz.\/[Error,String],G[B]]
eithers.sequence[({type λ[α] = \/[Error, α]})#λ, String]
// scalaz.\/[Error,List[String]] = -\/(Error(notOk))
eithers.sequenceU
(async
(let [a (await (async-task-a))
b (await (async-task-b))
c (await (async-task-c (* a b)))]
(+ a b c)))
;; whish is equivalent to:
(async
(let [a (await (async-task-a))
(setq hs-show-all-p t)
(defun hs-mode-toggle-show-all ()
(interactive)
(if hs-show-all-p
(hs-hide-all)
(hs-show-all))
(setq hs-show-all-p (not hs-show-all-p)))
(global-set-key (kbd "C-.") 'hs-toggle-hiding)
(global-set-key (kbd "C-c C-.") 'hs-mode-toggle-show-all)
@theleoborges
theleoborges / main.py
Last active January 6, 2025 06:14
Intent classification with BERT
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_name = 'Falconsai/intent_classification'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
input_text = "My order hasn't been delivered."
inputs = tokenizer(input_text, return_tensors='pt', padding=True, truncation=True, max_length=64)