#[repr(C)]
annotation on types.#[repr(C)]
struct Foo {
tiny: bool,
normal: u32,
small: u8,
long: u64,
short: u16,
}
- tiny: single byte, padded to 4 bytes so as to be byte-aligned. It's surprising that we are wasting 3-bytes and 7-bits to represent 1 bit!!
- small: This is a single byte, but since the struct's largest value stored is a long (u64), which needs 8-bytes, this is padded as 1 byte + 7 by ...(continued)
impl fmt::Write for ByteMutWriter<'_> {
fn write_str(&mut self, s: &str) -> fmt::Result {
let cap = self.capacity();
for (i, &b) in self.buf[self.cursor..cap]
.iter_mut()
.zip(s.as_bytes().iter())
{
*i = b;
}
self.cursor = usize::min(cap, self.cursor + s.as_bytes().len());
Ok(())
}
}
buf
and then z ...(continued)
[u8]
(a Dynamically-sized view into a contiguous sequence [T]
) is ideally referred to as a bare slice. We can make the distinction that a shared slice type is &[T]
and one that is mutable is a &mut [T]
.Sized
types).let pointer_size = std::mem::size_of::<&u8>();
assert_eq!(2 * pointer_size, std::mem::size_of::<&[u8]>());
core::array::from_fn
which can be used like thisfn main( ...(continued)
Box<dyn FooTrait>
in a long time, beyond boxing std::error::Error
. I normally reach for generics with impl FooTrait
and you can get a lot done with generics (static dispatch).Any
is a poor man's enum. This code is a great idea of trying to solve something, and wr ...(continued)TIL from Solving a Simple CS Interview Question, and profiling with Flamegraph and Heaptrack in Rust
My first mistake...
pub struct SellerItems<Vec<(HashMap<_>)>>
" or something like that. It was bloody awful and my brain shutdown. Taking me outside my comfort zone, was the requirement of writing "pseudocode" in a Google doc. No NeoVim, Rust-analyzer, nada... niet!echo ""
printf '%s\n' \
'WRITE THIS DOWN IN A SECURE PLACE WITH A CRAYON' "$1" \
'Hide it in a dark hole, darker the better!' 1>&2
echo ""
do_log "INFO VeraCrypt file ${VERACRYPT_FILE} mounted at /Volumes/${VERACRYPT_MOUNT_PATH}"
# vim: ts=4:sw=4:sts=4:noet:ft=sh
0x08000000
instead of 0x08040000
, the significance here is that the bootloader resides between these two addresses. When the bootloader is effectively wiped from the H7, its Power Management controller IC (PMIC) is no longer correctly configured at cold-start, and this renders your board as DOA with the "Orange LED from Hell".Post Archive
-
April 2024
-
March 2024
-
February 2024
-
January 2024
-
June 2023
-
January 2023
-
December 2022
-
November 2022
-
October 2022
-
September 2022
-
August 2022
-
June 2022
-
April 2022
-
March 2022
-
October 2021
-
August 2021
-
July 2021
-
November 2019
-
October 2019
-
June 2019
-
May 2019
-
April 2019
-
September 2017
-
May 2017
-
March 2017
-
January 2017
-
December 2016
-
October 2016
-
August 2016
-
June 2016
-
April 2016
- You can get US$200 for FREE from Amazon. Cold hard cash.
- Using BrowserSync and Gulp with the Rails Asset Pipeline
- HOWTO: Providing Clients with an IAM Account to Manage Billing & Payment Methods for their Root AWS Account
- Sneak Peak: Building a Ruby Gem to Provision Amazon AWS Services
- Feeling Refreshed, Back from Taking Time Off (April 2016)
-
February 2016
-
January 2016
-
October 2015
-
September 2015
-
August 2015
-
July 2015
- Dissecting The Latest Spree and Solidus API Security Vulnerability
- Autoglym Product Reviews, Now Get Replies
- Freelance 101: Early Warning Signs of a Troublesome Client
- Reaching Half a Million Views on YouTube
- Stripping sensitive details copied from terminal STDOUT by piping via sed in Mac OS X
- Faking APIs in Development and Staging
- When that Startup Interviewer cares more about where you're from
-
June 2015
- Suits is back, with Season 5 and Under the Dome
- Improving my Dockerised App stack
- Jack Dorsey is CEO at Twitter, so here's a TODO list
- Replace a MySQL table in Production via a Rails 4 Migration
- Converting SVG to PNG via Linux CLI
- Getting Resque, Rails 4.2, and Unicorn to play nice
- My favourite Docker productivity tips
- Now with Resque & Redis for hooking up with Mailchimp
- Just built a Ruby 2.2.1 compatible Mailchimp wrapper
-
May 2015
-
April 2015
-
March 2015
-
February 2015
-
November 2014
-
October 2014
-
September 2014
-
August 2014
-
May 2014
-
January 2014
-
December 2013
-
October 2013
-
September 2013
-
August 2013
-
July 2013
-
June 2013
-
May 2013
-
April 2013
-
March 2013
-
February 2013
-
January 2013
-
December 2012
-
November 2012
-
October 2012
-
May 2012
-
April 2012
-
March 2012
-
February 2012
-
January 2012
-
December 2011
-
October 2011
-
January 2011
-
December 2010
-
October 2009