Skip to content

Instantly share code, notes, and snippets.

View corebreaker's full-sized avatar
📐
Working

Frédéric Meyer corebreaker

📐
Working
  • Frrance
View GitHub Profile
@corebreaker
corebreaker / dynamic-join-all-for-async.rs
Last active March 14, 2024 16:47
Rust: How to join_all a dynamic number of async
/**
The macro `join!` cannot be used in this context
because we need to add any number of asyncs,
not known at compile time.
Here we provide a list: Vec<FutureWrapper>,
and this list is used to call the function `join_all`.
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=eb3732a22a43ada448e35eebbd1e188a
@corebreaker
corebreaker / example.go
Last active March 11, 2018 16:15
GO: AtExit function without modification in main
// A litte example
package main
import (
"fmt"
"progtrailer"
)
func main() {
defer func() {
@corebreaker
corebreaker / try-catch-finally.go
Last active December 1, 2018 18:41
Even if the syntax seems be different, the try/catch/finally paradigm exists in Go
/*
Java code:
----------
try // <-- TRY HEADER
{
throw new Exception("Error"); // <-- TRY BODY (RAISE Exception)
}
catch(final Exception err) // <-- CATCH HEADER
@corebreaker
corebreaker / verbose-errors.go
Last active October 11, 2016 05:28
Golang: Verbose errors with stacktraces
/*
Example:
--------
import (
"os"
"log"
"io/ioutil"
"verbose_errors"
@corebreaker
corebreaker / djson.py
Last active October 11, 2016 05:28
JSON for Django 1.9.x with Datetimes and Models
class JSON:
def __init__(self):
import re
from dateutil.parser import parse
from django.db.models import Model
from django.apps import apps
pattern = re.compile(r'^(\d{4}-\d{2}-\d{2})?(T)?(\d{2}:\d{2}:\d{2}(?:\.\d{6})?(?:[+-]\d{2}:\d{2})?)?$')
def model_decoder(o):
@corebreaker
corebreaker / lists.py
Last active October 11, 2016 05:27
Templates Tags in Django 1.9.x as tools for list manipulations
from django.template.library import Library
register = Library()
@register.filter
def split(s, sep= None):
'''
Example:
{# For details on 'assign' tag, see https://gist.github.com/corebreaker/6d94b7d06f7ed9d8bfc4985b094bf6d4 #}
@corebreaker
corebreaker / variables.py
Last active October 11, 2016 05:27
Templates Tags in Django 1.9.x as tools for using variables
from django.utils.encoding import force_text
from django.template.base import TemplateSyntaxError
from django.template.library import Library, Node
register = Library()
@register.simple_tag
def assign(value):
'''