Skip to content

Instantly share code, notes, and snippets.

@hexagit
hexagit / GrowUp.py
Last active June 12, 2019 05:28
m5stackで植物を育てる
from m5stack import lcd
from m5stack import *
import utime
lcd.clear()
lcd.setCursor(0, 0)
lcd.setColor(lcd.WHITE)
#画像データ名
imgs=["desert","flower_1","flower_2","flower_3","flower_4"]
@hexagit
hexagit / get_array_instance.cs
Last active February 20, 2019 09:36
Arrayインスタンス取得
// OpCodeがldtokenの段階で初期化子を解決できるのでそこで行います。
var operand = method.Module.ResolveMember(metadataToken, typeArguments, methodArguments);
var field = (FieldInfo)operand;
var byteSize = Marshal.SizeOf(field.FieldType);
var typeSize = ResolvePrimitiveTypeSize(newarrType); // Primitiveな型のサイズを取得する
var elementCount = byteSize / typeSize;
var array = Array.CreateInstance(newarrType, elementCount);
RuntimeHelpers.InitializeArray(array, field.FieldHandle);
@hexagit
hexagit / ldtoken_operand_type.txt
Created February 20, 2019 09:22
ldtokenのoperandの型情報
.class nested private explicit ansi sealed '__StaticArrayInitTypeSize=12'
extends [netstandard]System.ValueType
{
.pack 1
.size 12
} // end of class __StaticArrayInitTypeSize=12
@hexagit
hexagit / sample_code_ilspy.txt
Created February 20, 2019 09:20
サンプルコードのILSpy結果
.method private hidebysig
instance void Main (
string[] arguments
) cil managed
{
.custom instance void [Astral.CSharp]Astral.EntryPointAttribute::.ctor() = (
01 00 00 00
)
// Method begins at RVA 0x2098
// Code size 20 (0x14)
@hexagit
hexagit / sample_code.cs
Created February 20, 2019 09:15
サンプルコード
class Application {
void Main(string[] arguments) {
var test = new int[] { 1, 2, 3 };
}
}
@hexagit
hexagit / MyApp.cs
Created December 17, 2018 08:26
Windows7を便利にしたい3
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Reflection;
namespace MyApp
{
partial class MyApp : Form
{
// タスクトレイアイコン
@hexagit
hexagit / TopMostWindow.cs
Created December 17, 2018 08:26
Windows7を便利にしたい2
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace TopMostWindow
{
// Win32API
public class WinAPI
@hexagit
hexagit / MouseUnderScroll.cs
Last active December 17, 2018 08:27
Windows7を便利にしたい1
using System;
using System.Runtime.InteropServices;
namespace MouseUnderScroll
{
// Win32API
public class WinAPI
{
[StructLayout(LayoutKind.Sequential)]
public struct POINT
using System;
using UnityEngine;
public partial class Bitmap
{
private const int lanczosDefaultN = 3;
private Bitmap resizeLanczos(uint width, uint height, uint range = lanczosDefaultN)
{
var bitmap = new Bitmap(width, height);
using System;
using System.ComponentModel.Composition;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio.Utilities;