Skip to content

Instantly share code, notes, and snippets.

View lostmsu's full-sized avatar
💭
–2147483648x developer

Victor lostmsu

💭
–2147483648x developer
View GitHub Profile
@lostmsu
lostmsu / CommandLineDataSource.xaml
Created August 24, 2022 17:48
example for command line calls from Stack
<!--
xmlns:dataSources="clr-namespace:LostTech.Stack.Widgets.DataSources;assembly=LostTech.Stack.Widgets"
-->
<dataSources:CommandLineDataSource x:Key="RemoteCall"
dataSources:DataSource.RefreshInterval="0:0:10">
<dataSources:CommandLineValueSource Program="ssh">
<dataSources:CommandLineValueSource.Arguments>
<x:String>-T</x:String>
<x:String>remote.pc.name.local</x:String>
<x:String>nvidia-smi</x:String>
@lostmsu
lostmsu / autocapture.xaml
Created August 24, 2022 17:41
zone auto capture samples
<!--
xmlns:stack="https://schemas.losttech.software/stack/2022/xaml/all"
-->
<zones:Zone>
<stack:AutoCapture.CaptureFilters>
<stack:CaptureFilter>
<filters:ProcessName Value="HxOutlook"/> <!-- Windows Mail App -->
<filters:ProcessName Value="WindowsTerminal"/> <!-- The new Windows Terminal app -->
<filters:Title Value="Google Voice - Voice"/>
<filters:Title Value="Messenger" Match="Exact"/>
@lostmsu
lostmsu / weather.xaml
Created August 24, 2022 17:36
Weather widget for Stack 3.0+
<!--
xmlns:binding="clr-namespace:LostTech.Stack.Widgets.DataBinding;assembly=LostTech.Stack.Widgets"
xmlns:dataSources="clr-namespace:LostTech.Stack.Widgets.DataSources;assembly=LostTech.Stack.Widgets"
-->
<StackPanel Orientation="Horizontal">
<StackPanel.Resources>
<dataSources:WebDataSource x:Key="Weather"
Url="https://api.openweathermap.org/data/2.5/weather?lat=YOUR_LAT&amp;lon=YOUR_LON&amp;units=metric&amp;appid=PUT_YOUR_OWN_HERE"
dataSources:DataSource.RefreshInterval="0:15:0" />
@lostmsu
lostmsu / ProcessJob.cs
Created May 20, 2022 17:53
make child process terminate automatically when the current process terminates
using System;
using System.Runtime.InteropServices;
using static PInvoke.Kernel32;
// usage: new Job().AddProcess(new SafeObjectHandle(win32childProcessHandle, ownsHandle: false);
// might need to keep Job instance alive
public class Job : IDisposable
{
@lostmsu
lostmsu / clock.py
Created March 12, 2022 00:46
A infitite PyTorch "dataset", that simulates behavior of digital clock
import torch
from torch import device as Device
from torch.utils.data import IterableDataset
from typing import Optional
MS_IN_SECOND = 1000
MS_IN_MINUTE = 60 * MS_IN_SECOND
MS_IN_HOUR = 60 * MS_IN_MINUTE
MS_IN_DAY = 24 * MS_IN_HOUR
MS_IN_YEAR = 365 * MS_IN_DAY
@lostmsu
lostmsu / StyleTabs.xaml
Created February 3, 2022 06:27
Style Stack tabs
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:zones="clr-namespace:LostTech.Stack.Zones;assembly=Stack"
zones:Layout.Version="2"
mc:Ignorable="d"
Width="1024" Height="576"
using System;
Func<int, int, int> addImpl = (a, b) => a + b;
var add = Infix.Create(addImpl);
Console.WriteLine(41 |add| 1);
public class Infix<T1, T2, TResult> {
public Func<T1, T2, TResult> Op;
public static Infix<T2, TResult> operator |
@lostmsu
lostmsu / IM Layout.xaml
Created January 24, 2022 18:48
Sample screen layout with zones directly capturing certain windows
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:filters="clr-namespace:LostTech.Stack.Extensibility.Filters;assembly=LostTech.Stack.Extensibility"
xmlns:stack="https://schemas.losttech.software/stack/2022/xaml/all"
stack:Layout.Version="2"
>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
@lostmsu
lostmsu / SerializeEquality.cs
Created November 24, 2021 03:13
BinaryFormatter serializes two distinct objects as one
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
unsafe {
IntPtr resource1 = Marshal.AllocHGlobal(sizeof(FakeUnmanagedRefcountedObject));
*(FakeUnmanagedRefcountedObject*)resource1 = default; // zero memory
var i1 = new UnmanagedRefcountWrapper(resource1);
i1.Value = 10;
@lostmsu
lostmsu / ILGPU.Segfault.cs
Created September 9, 2021 17:19
ILGPU crashes when trying to run a specialized kernel
// <PackageReference Include="ILGPU" Version="1.0.0-beta3" />
// <PackageReference Include="TypeNum" Version="0.2.0-CI-20210909-064812" />
using System.Runtime.InteropServices;
using ILGPU;
using ILGPU.Runtime;
using ILGPU.Runtime.CPU;
using TypeNum;