Skip to content

Instantly share code, notes, and snippets.

@reednj
reednj / mult.md
Last active September 25, 2022 06:23

Multiplication from Scratch

Imagine you need to implement (integer) mulitplication in code. Maybe you are on a system which doesn't have it or something. How to do this, and what is the minimal set of operators that are required?

Repeated addition

The most obvious way to do multiplition is through repeated addition. To get the answer to 56 x 67 you add 56 to itself 67 times (or 67, 56 times - the order doesn't matter).

This is simple to implement if we assume for the moment that both a and b are positive (we will deal with negative integers later)

Write-Host "Synchronizing your docker time."
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if ($principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
$name = (Get-VMIntegrationService -VMName DockerDesktopVM | Where-Object { $_.Id.StartsWith("Microsoft:") -and $_.Id.EndsWith("\2497F4DE-E9FA-4204-80E4-4B75C46419C0") }).Name # "Time Synchronization" for English Windows
Get-VMIntegrationService -VMName DockerDesktopVM -Name $name | Disable-VMIntegrationService
Get-VMIntegrationService -VMName DockerDesktopVM -Name $name | Enable-VMIntegrationService
echo $name
Write-Host "Time synced!"
Read-Host -Prompt "Press Enter to exit."
@houtianze
houtianze / on.y.combinator.md
Last active August 2, 2024 07:07
On Y Combinator

Hopefully this may speed your groking of the forking torturing Y Combinator a little bit.

Disclaimer: I don't assert what I say here is accurate, or even correct (I'm not authorative, obviously), but it's my understanding and I'm sharing in the hope that someone who also struggles on the Y Combinator may benefit a tad.

Prerequisite Understandings

  • In Lambda Caculus, everything is a Lambda Caculus (Anonymous function that takes one parameter). And the best thing is that, ... drump roll ..., it's Turing Complete. So theoretically, it can caculate anything a computer can.
  • In this note, I use the term function, which (I think) means Lambda Caculus, to sound (at least to myself) more accustomed.

The definition of Y Combinator

  • Y = λf.(λx.f (x x)) (λx.f (x x))
@justincbagley
justincbagley / How_to_Convert_Markdown_to_PDF.md
Last active November 6, 2024 10:34
How To Convert Markdown to PDF

How to convert markdown to PDF:

This post reviews several methods for converting a Markdown (.md) formatted file to PDF, from UNIX or Linux machines.

Using Pandoc:

$ pandoc How_I_got_svg-resizer_working_on_Mac_OSX.md -s -o test1.pdf

Just some notes and references for myself.

  • In bash, you can access your C:\ drive via /mnt/c/
  • ~ = C:\Users\MLM\AppData\Local\lxss\home\mlm and is different from your Windows user directory C:\Users\MLM

How to google things

@rxaviers
rxaviers / gist:7360908
Last active November 12, 2024 14:32
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@staxmanade
staxmanade / StaticCLassItemMetadata.cs
Created January 13, 2012 06:39
Sort of like an Enum with more data or behavior possibilities.
public class Sample
{
[Test]
public void MetadataSample()
{
Items.ItemA.ShouldEqual(Items.ItemA);
Items.ItemA.Description.ShouldEndWith("Description for A");
}
}