Skip to content

Instantly share code, notes, and snippets.

View SelvinPL's full-sized avatar

SelvinPL SelvinPL

View GitHub Profile
@SelvinPL
SelvinPL / NativeEntry.cs
Created January 26, 2023 20:25
SO75244656
using System.Runtime.InteropServices;
using System;
using System.Windows.Forms;
// this guy stolen my code without credits https://www.codeproject.com/Articles/16310/How-to-Automate-Exporting-NET-Function-to-Unmanage
using RGiesecke.DllExport;
//<Project Sdk="Microsoft.NET.Sdk">
// <PropertyGroup>
// <TargetFramework>net48</TargetFramework>
// <PlatformTarget>x86</PlatformTarget>
// </PropertyGroup>
@SelvinPL
SelvinPL / działa.ps1
Last active January 4, 2023 01:03
paste działa.ps1 into powershell console https://dotnetfiddle.net/jm3Io6
$framework = "net6.0"
#installing svcutil for dotnet
dotnet tool install --global dotnet-svcutil
mkdir CRBRLib
Set-Location CRBRLib
#getting zip with wsdl
Invoke-WebRequest -Uri https://www.gov.pl/attachment/b9c58be1-560a-4c0c-b746-254336f49e41 -OutFile CRBR.zip
#unpack zip and execute svcutil tool
$wsdlFile = ($(Expand-Archive CRBR.zip -Verbose -Force *>&1 | Foreach-Object { if ($_.message -match "Created '(.*)'.*") { Get-Item $Matches[1] }}) | Select-Object -First 1).FullName
dotnet-svcutil $wsdlFile -tf $framework
@SelvinPL
SelvinPL / DatePicker.java
Created November 24, 2022 13:48
Parent Fragment or Activity should implement DatePicker.Callback
public class DatePicker extends DialogFragment implements DatePickerDialog.OnDateSetListener {
static final Calendar MAX_DATE_VALUE = DateTimeUtils.addYears(DateTimeUtils.today(), 2);
public static DatePicker newInstance(int id, Calendar date) {
return newInstance(id, date, DateTimeUtils.today(), MAX_DATE_VALUE);
}
public static DatePicker newInstance(int id, Calendar date, Calendar minDate, Calendar maxDate) {
DatePicker frag = new DatePicker();
@SelvinPL
SelvinPL / GenericDialogFragment.java
Last active May 25, 2022 09:00
Dialogs callback
public interface GenericDialogFragment {
String MESSAGE = "MESSAGE";
String TITLE = "TITLE";
String URI = "URI";
String ID = "ID";
String ARGS = "ARGS";
String VIEW = "VIEW";
String DATE = "DATE";
String POSITIVE = "POSITIVE";
String NEGATIVE = "NEGATIVE";
@SelvinPL
SelvinPL / ConstraintRadioGroup.java
Last active March 2, 2022 15:41
ConstraintRadioGroup
/*
* Copyright (C) 2019 Sam Lu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software

Final(?) magnet implementation for GB Robbo

C using 0xCyyx  8072	11	412/  1204/ 733.8
C using map[]	5772	11	300/  944/  524.7
ASM		5060	11	276/  872/  460.0
@SelvinPL
SelvinPL / #.md
Last active November 25, 2021 13:22

Funny thing ... because SDCC do not generate good code for this uint8_t* address = (uint8_t *)((hiAddress << 8) | loAddress); new version is even worst than old ... but finally asm version is 11% faster

old image

new image

asm

ld hl, G$soundState$0_0$0+1 ;12 ld bc, xx ;12
ldi a, (hl) ;8 ld a, (bc) ;8
ld c, a ;4 ld l, a ;4
inc bc ;8//+8
ld b, (hl) ;8 ld a, (bc) ;8
ld h, a ;4//+12 - fiexed
ld a, (bc) ;8 ldi a, (hl) ;8
inc bc ;8 ;//+4
cp $01 ;same
jr z, A$sounds$101 ;same
package pl.selvin.test;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
@SelvinPL
SelvinPL / logwndproc.cs
Last active April 7, 2022 08:59
Paste it to linqpad, add references and imports (bonus NativeWindow solution)
//using System.Windows.Forms
//using System.Runtime.InteropServices
//add references to System.Windows.Forms.dll
void Main()
{
var frm = new Form();
WndProc oldWndProc = null;
WndProc newWndProc = (hWnd, Msg, wParam, lParam) =>
{