Skip to content

Instantly share code, notes, and snippets.

View 20chan's full-sized avatar
๐ŸŽธ
rockin'

20chan 20chan

๐ŸŽธ
rockin'
View GitHub Profile
@20chan
20chan / AsyncMain.cs
Created September 26, 2017 08:05
Test async main in C#
class Program
{
static async Task Main(string[] args)
{
var t = new AsyncTest();
await t.DoTest();
}
}
class AsyncTest
@20chan
20chan / expression.cs
Created September 21, 2017 05:43
Execute expression using JIT, compiled expression, lambda in C#
using System;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
namespace AssemblySharp
{
public static class Program
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
@20chan
20chan / MachineCodeSharp.cs
Created September 20, 2017 16:28
Execute machine code in C#
using System;
using System.Runtime.InteropServices;
namespace AssemblySharp
{
class Program
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
@20chan
20chan / struct-list-reference-test.cs
Created September 14, 2017 05:36
C# list of structures reference testing
using System;
using System.Collections.Generic;
namespace struct_reference
{
class Program
{
static void Main(string[] args)
{
Point p1 = new Point(10, 10);
@20chan
20chan / ๊ธ€์ž.cs
Created September 9, 2017 18:14
ํ•œ๊ธ€ ์ฒ˜๋ฆฌ C# ํด๋ž˜์Šค
public struct ๊ธ€์ž
{
/// <summary>
/// ํ•œ๊ธ€์—ฌ๋ถ€(H, NH)
/// </summary>
public string ํ•œ๊ธ€์ธ๊ฐ€;
/// <summary>
/// ๋ถ„์„ ํ•œ๊ธ€
/// </summary>
public char ์›๋ž˜๊ธ€์ž;
@20chan
20chan / tests.py
Created August 29, 2017 07:42
ํ…Œ์ŠคํŠธ!
import unittest
from lexer import parse
from builder import build
from machine import execute
from tok import Token, TokenType
import node
class LexerTest(unittest.TestCase):
def test_integer(self):
self.assertEqual(parse('1'), [Token('1', TokenType.INTEGER)])
@20chan
20chan / ๊ตฌ์ƒ.md
Created August 1, 2017 07:09
๋งŒ๋“ค๊ณ  ์‹ถ์€ ์—ด์ฐจ ๊ฒŒ์ž„ ๊ตฌ์ƒ

๊ธฐ์ฐจ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ

Train Simulator๋Š” 1์ธ์นญ ๊ธฐ์ฐจ ์šด์ „์— ์ค‘์ ์„ ๋‘๊ณ  ์žˆ๊ณ , ๋ฏธ๋‹ˆ ๋ฉ”ํŠธ๋กœ๋Š” ๋…ธ์„  ๋””์ž์ธ์— ์ค‘์ ์„ ๋‘๊ณ  ์žˆ์Œ.

https://www.youtube.com/watch?v=VzIQuzoMlqk ๊ฐ™์€ ์˜์ƒ์„ ๋ณด๋ฉด ๋А๋‚„ ์ˆ˜ ์žˆ๋Š” ์พŒ๊ฐ์„ ์ œ์ž‘/์‹œ๋ฎฌ ๋‘˜์—์„œ ๋†“์น˜์ง€ ์•Š๊ฒŒ ๋А๋‚„ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๊ณ  ์‹ถ์Œ.


๊ฒŒ์ž„ ๋ฐฉ์‹

@20chan
20chan / Flatten.cs
Last active July 8, 2017 16:19
์ด๋ฏธ์ง€๋ฅผ Flattenํ•œ ๋ฐฐ์—ด๋กœ ๊ฐ€์ ธ์˜ฌ ๋•Œ ์†๋„ ๋น„๊ต
static Bitmap b;
static void Main(string[] args)
{
var methods = typeof(Program).GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
foreach (var method in methods)
{
if (method.GetCustomAttribute<GetRuntime>() != null)
{
int range = 10;
DateTime before = DateTime.Now;
@20chan
20chan / ImageFlatten.py
Created July 8, 2017 15:56
Bitmap ์„ Flattenํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์„œ 1์ฐจ์› ๋ฐฐ์—ด๋กœ ๋งŒ๋“ค์–ด๋ฒ„๋ฆฌ๊ธฐ
Bitmap b = new Bitmap(@"D:\Image\design\์น˜์›Œ\ํžˆ์˜ค์Šค.png");
var bitmapData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, b.PixelFormat);
var length = bitmapData.Stride * bitmapData.Height;
byte[] bytes = new byte[length];
// Copy bitmap to byte[]
Marshal.Copy(bitmapData.Scan0, bytes, 0, length);
b.UnlockBits(bitmapData);
@20chan
20chan / contract.py
Created July 3, 2017 06:25
The Fun of Reinvention ์ตœ์ข…
_contracts = {}
class Contract:
@classmethod
def __init_subclass__(cls):
_contracts[cls.__name__] = cls
def __set__(self, instance, value):
self.check(value)