Skip to content

Instantly share code, notes, and snippets.

View danielhenrymantilla's full-sized avatar
🦀

Daniel Henry-Mantilla danielhenrymantilla

🦀
View GitHub Profile
@danielhenrymantilla
danielhenrymantilla / lib.rs
Created July 7, 2018 13:21
Rust: &self sugar vs other &identifier bindings
/* The following lib tests illustrate a lack of consistency in rust:
* the &identifier binding leads to 2 different behaviors based on whether
* - the identifier is the special 'self' first argument of a method,
* - or a simple variable / argument (called slf in the following tests)
*/
#![allow(dead_code, unused_variables, unused_parens)]
/* compiler ensures that check_ref::<T>(x) can only be called iff x: &T */
fn check_ref<T> (_: &T) {}
@danielhenrymantilla
danielhenrymantilla / hexdump_tool_by_yandros.c
Created July 30, 2018 12:41
Hexdump tool to "copy-paste" binaries into a shell. Useful for root-me.org VM challenges.
/* Hexdump tool to "copy-paste" binaries into a shell.
* Useful for root-me.org VM challenges.
* Compile with:
* $ cc -std=c99 -o slice slice.c
*
* By Yandros (https://www.root-me.org/Yandros)
*/
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
@danielhenrymantilla
danielhenrymantilla / death_letter.tex
Created October 12, 2018 14:27 — forked from aeris/death_letter.tex
Lettre de la mort GDPR
\documentclass[10pt]{lettre}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{eurosym}
\usepackage{enumitem}
\usepackage[frenchb]{babel}
\begin{document}
\begin{letter}{
@danielhenrymantilla
danielhenrymantilla / latest-stable-rustc.md
Created October 5, 2020 19:37 — forked from alexheretic/latest-stable-rustc.md
Latest stable rust as a MSRV policy

Latest stable rust as a minimum

Minimum supported rust version (MSRV) policy that indicates the most recent stable rust release is the minimum whenever a new crate version is published. It is not required to bump a crate's major version after a new stable compiler is released.

For example crate_foo version 0.1.2 published on 2018-12-28 has MSRV 1.31.1 as this compiler was published on 2018-12-20.

The advantages of this approach is simplicity in maintaining a crate's code.

Workarounds for older compiler versions

If you are unable to update your compiler, you may be unable to update crate dependencies following this policy.

@danielhenrymantilla
danielhenrymantilla / SimpleHTTPServerWithUpload.py
Created July 15, 2021 18:07 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@danielhenrymantilla
danielhenrymantilla / parse_quote_dbg.rs
Created September 17, 2021 15:14 — forked from jmg-duarte/parse_quote_dbg.rs
Yandros parse_quote! debug
// Credits: Yandros#4299
macro_rules! parse_quote {(
$($code:tt)*
) => ({
eprintln!("[{}:{}:{}] parse_quote! {{ {} }}", file!(), line!(), column!(), quote!( $($code)* ));
::syn::parse_quote!( $($code)* )
})}
macro_rules! parse_quote {(

Summary

Panics which happen inside a Drop impl currently unwind as long as the drop was not itself called during unwinding (which would otherwise abort immediated due to a double-panic). This design meeting proposes to change this behavior to always abort if a panic attempts to escape a drop, even if this drop was invoked as part of normal function execution (as opposed to unwinding).

The dicussion on this issue dates back to 2014 (rust-lang/rust#14875) where the decision was made to support unwinding in drops but leave the door open to potentially reversing this decision.

Background reading

rust-lang/rust#86027

@danielhenrymantilla
danielhenrymantilla / lib.rs
Created December 15, 2021 00:50
Poorman's alloc-instrumentation
struct MyAllocator;
#[global_allocator]
static A: MyAllocator = MyAllocator;
const _: () = {
use ::std::{
alloc::{
GlobalAlloc,
Layout,
@danielhenrymantilla
danielhenrymantilla / vec_of_array.md
Last active August 25, 2024 14:09
Vec off arrays (or slices)

Question

how can I convert an array to a vec without cloning the values

Technically-correct answer

Make a Vec of references:

array.iter_mut().collect::<Vec<_>>();
@danielhenrymantilla
danielhenrymantilla / resize-image-in-github-issue-github-flavored-markdown.md
Created February 21, 2022 14:14 — forked from stevecondylios/resize-image-in-github-issue-github-flavored-markdown.md
How to Resize an Image in a Github Issue (e.g. Github flavored Markdown)

How to Resize an Image in Github README.md (i.e. Github Flavored Markdown)

Percentage:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width=50% height=50%>

Pixels:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width="150" height="280">