Skip to content

Instantly share code, notes, and snippets.

@stinos
stinos / CloneAndBuild.ps1
Created June 29, 2023 18:28
Initial micropython-wrap test
cd $env:TEMP
mkdir testupywrap
cd testupywrap
git clone https://github.com/stinos/micropython
git -C .\micropython\ switch windows-pyd
git clone https://github.com/stinos/micropython-wrap
msbuild .\micropython\ports\windows\micropythoncore.vcxproj
msbuild .\micropython\ports\windows\micropython.vcxproj
msbuild .\micropython-wrap\micropython-wrap.vcxproj
cd .\micropython\ports\windows\build-tns
@stinos
stinos / Coordinates.cpp
Created December 8, 2020 15:50
upywrap-usercppmodule-example
//code from https://github.com/sdumetz/coordinates/tree/master/src
//original license: https://github.com/sdumetz/coordinates/blob/master/LICENSE
#include "Coordinates.h"
Coordinates::Coordinates(float x, float y) {
fromCartesian(x, y);
}
void Coordinates::fromCartesian(float x, float y) {
function Install-Msys2 () {
param (
[Parameter()] [String] $Dir = 'c:\tools\msys2'
)
if (Test-Path $Dir -PathType Any) {
$reply = Read-Host -Prompt "MSys2 destination $Dir exists. Delete and continue? [y/n]"
if ($reply -eq 'y') {
Remove-Item -Recurse -Force $Dir
} else {
return
@stinos
stinos / rpc.py
Created May 7, 2020 13:04
MicroPython Rpc
import re
import unittest
class RpcIterator:
@staticmethod
def IteratorName(name):
# Assumption here is this string is not an existing variable.
# Otherwise it gets replaced.
return name.replace('.', '_') + '_iter'
@stinos
stinos / Optimize-PSReadlineHistory.ps1
Last active April 24, 2020 08:39 — forked from rkeithhill/Optimize-PSReadlineHistory.ps1
Removes duplicate and optionally short commands from your PSReadline history file
<#
.SYNOPSIS
Optimizes your PSReadline history save file.
.DESCRIPTION
Optimizes your PSReadline history save file by removing duplicate
entries and optionally removing commands that are not longer than
a minimum length
.EXAMPLE
C:\PS> Optimize-PSReadlineHistory
Removes all the duplicate commands.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="compile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>SomeDummyDef</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<!-- If below line is commented, Message text will be 'False'-->
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="460">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Width="160">
<Button x:Name="StartButton" Content="Start Python"/>
<TextBlock x:Name="Status"/>
</StackPanel>
<ContentControl Grid.Column="1" x:Name="PythonWinHost" Width="300"/>