Skip to content

Instantly share code, notes, and snippets.

View ilyvion's full-sized avatar

Alexander Krivács Schrøder ilyvion

View GitHub Profile
@T-Dark0
T-Dark0 / what_as_does.md
Last active July 18, 2023 08:26
What `as` does

as does a huge number of things. Probably too many. Here's a comprehensive list of everything it can do. Note that as conversions are transitive: If a as B as C compiles, then so does a as C, though it might not take the same "path" through intermediate conversions.

  • int <-> int
    • zero_extend: unsigned int -> bigger unsigned int. Pads the number with leading zeroes.
    • sign_extend: signed int -> bigger signed int. Pads the number with leading zeroes if positive, and leading ones if negative.
    • truncate: bigger int -> smaller int (regardless of signedness). Throws away the high bits of the number
    • reinterpret_sign: int -> int of the same size and opposite signedness. Does nothing to the bits.
  • int <-> float
    • cast_saturate_to_infinity: Yields the float closest to the specified integer. Yields infinity if the integer is out of bounds.
  • cast_nan_to_zero_saturating_when_out_of_bounds: Truncates the float and yields the corresponding integer.
@werwolfby
werwolfby / <Custom>DbContext.cs
Last active March 7, 2023 13:18
EF Core DateTime Utc kind
public class CustomDbContext : DbContext
{
// ...
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
// Replace default materializer source to custom, to convert DateTimes
options.ReplaceService<IEntityMaterializerSource, DateTimeKindEntityMaterializerSource>();
base.OnConfiguring(options);
@oxguy3
oxguy3 / deploy.php
Last active August 5, 2023 20:21
Script used to automatically deploy from GitHub to a cPanel shared hosting server
<?php
/**
* deploy.php by Hayden Schiff (oxguy3)
* Available at https://gist.github.com/oxguy3/70ea582d951d4b0f78edec282a2bebf9
*
* No rights reserved. Dedicated to public domain via CC0 1.0 Universal.
* See https://creativecommons.org/publicdomain/zero/1.0/ for terms.
*/
// random string of characters; must match the "Secret" defined in your GitHub webhook