Skip to content

Instantly share code, notes, and snippets.

Avatar
✈️
Working remotely

Adrian Tombu adriantombu

✈️
Working remotely
View GitHub Profile
View erroring-ts-expect-error.ts
// @ts-expect-error
doStuff("abc");
// Unused '@ts-expect-error' directive.
View typescript-test-error.ts
function doStuff(abc: string) {
assert(typeof abc === "string");
// do some stuff
}
expect(() => {
doStuff(123);
// ~~~
// error: Type 'number' is not assignable to type 'string'.
}).toThrow();
View rss-build-date.go
rssStruct := &rss{
Version: "2.0",
Title: "Blob Trotter",
Link: "https://blog.otso.fr",
Description: "Les pérégrinations d'un développeur dans le monde de Javascript et de Go",
LastBuildDate: time.Now().Format(time.RFC1123Z),
Item: articles,
}
View rss-convert-date.go
articleDate := "2020-02-06"
publishedAt, _ := time.Parse("2006-01-02", articleDate)
pubDate := publishedAt.Format(time.RFC1123Z)
View rss-struct-date.go
type rssItem struct {
Title string `xml:"title"`
Link string `xml:"link"`
Description string `xml:"description"`
Image string `xml:"image"`
PubDate string `xml:"pubDate"`
}
View rss-main.go
func main() {
articles := []rssItem{
{
Title: "Comment passer au monorepo avec Lerna",
Link: "https://blog.otso.fr/2020-05-08-passez-en-monorepo-avec-lerna.html",
Description: "Suivez-moi pas à pas dans la découverte du monde fantastique des monorepos !",
Image: "https://blog.otso.fr/images/2020-05-08-passez-en-monorepo-avec-lerna/rainbow.gif",
},
{
Title: "Les 10 erreurs les plus fréquentes que j’ai rencontrées sur des projets Go",
View rss-struct.go
type rss struct {
Version string `xml:"version,attr"`
Title string `xml:"channel>title"`
Link string `xml:"channel>link"`
Description string `xml:"channel>description"`
Item []rssItem `xml:"channel>item"`
}
type rssItem struct {
Title string `xml:"title"`
@adriantombu
adriantombu / rss-feed.go
Last active Jun 6, 2020
Un script de génération de flux RSS en go
View rss-feed.go
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"path/filepath"
"time"
)
@adriantombu
adriantombu / shush-covid19.txt
Last active Dec 3, 2020
A list of coronavirus related expression to use in the Shush! browser extension https://github.com/adriantombu/shush
View shush-covid19.txt
corona,
quarantaine,
quarantine,
covid,
ffp2,
pandemi,
covid,
stayathome,
restezchezvous,
covid19fr,