Skip to content

Instantly share code, notes, and snippets.

@vors
vors / 42.py
Created May 13, 2022 01:14
Print 42
i = 0
while True:
i += 1
if int((i * 1024) / 1000) != i:
print(i)
break

Old master of Jeet Kune Do taught me a lesson once. I was doing all sorts of small errands for him at the time. I struggled with moving a particularly big stone in the garden.

He invited me to join for a cup of tea and gave me a lesson in Jeet Kune Do and gardening. First he invited me to watch how the grass is growing with him. And I paid attention. Second he invited me to look at the cup that I drank tea from. And I paid attention.

And lastly he said: "If you watch how grass grows for long enough, if you look at the cup long enough, somebody will do your work for you".

@vors
vors / sv_machine.hash
Created May 5, 2021 22:12
hash of sv_machine reference implementation
e199d0da7908f1895cac5c645806ec1a0f03a409
@vors
vors / hello.ipynb
Created April 17, 2021 03:58
hello.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vors
vors / arc_sample.rs
Created June 25, 2018 02:05
Rust toy example for Arc where tsan reports a data race
use std::sync::Arc;
use std::thread;
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
println!("dropped!");
}
}
@vors
vors / platyPS-applicable.md
Created June 5, 2017 06:17
Demo for new New-ExternalHelp -ApplicableTag functionality in platyPS 0.8.0

Context

See PowerShell/platyPS#273

Before

Before if we have similar modules, or different version of the same module, we would need to have separate markdown files.

For example, let's say we have 4 modules:

using module .\SevOne.psm1
[SevOne.device]
[SevOne.something]
@vors
vors / escaping.md
Last active January 28, 2016 04:49
Lets figure out how markdown escaping works

< \< \< \\< \\< \\[
\ \
\\

@vors
vors / GenericMethods.ps1
Created November 6, 2015 20:20
Workaround to call to a generic method OfType<T>() in PowerShell, when PowerShell cannot figure out <T> from the context
# PowerShell can infer generic <T> for method calls for your, when it has a parameter of the same type <T>
# Example: Enumerable.Distinct<TSource>(IEnumerable<TSource>)
# TSource can be inferred from the argument
[System.Linq.Enumerable]::Distinct([int[]]@(1,2,3,1,2))
# Let's say you want to call a generic method without ability to infer types.
# Example: Enumerable.OfType<TResult>()
# Idially you may expect syntax like this
# [System.Linq.Enumerable].OfType[int](@(,@(1,2,'a'))
# where you tell PowerShell type explicitly.
add-type @'
namespace foo {
public class bar {
public static void foo() { throw new System.Exception("Hello from C#"); }
}
}
'@
try { [foo.bar]::foo() } catch {$_.Exception.InnerException} # output 'Hello from C#'