Skip to content

Instantly share code, notes, and snippets.

@yipo
yipo / Dockerfile
Created June 30, 2024 19:44
Build a PowerShell Docker image based on Alpine Linux.
FROM alpine
@yipo
yipo / after.png
Last active April 6, 2024 14:29
SimCity 3000 Unlimited: Traditional Chinese (Taiwan) language support
after.png
@yipo
yipo / after.png
Last active April 6, 2024 14:32
SimCity 3000 Unlimited: Unlock supported resolution
after.png
*.pyc
/venv/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yipo
yipo / .gitignore
Last active November 22, 2022 03:02
Python look-up speed test
*.pyc
@yipo
yipo / time_cost.py
Last active November 22, 2022 03:09
Calculate the time cost
#!/usr/bin/env python
import time
from contextlib import contextmanager
from datetime import timedelta
@contextmanager
def time_cost():
begin = time.time()
@yipo
yipo / test.cpp
Last active September 3, 2021 02:49
Omit unused parameters of lambda.
#include <functional>
#include <string>
void test(std::function<int(const std::string & a, const std::string & b, const std::string & c)> func)
{
func({}, {}, {});
}
int main()
{
@yipo
yipo / script.ps1
Last active April 29, 2021 10:02
Update the source file list of CMakeLists.txt under one directory.
$ErrorActionPreference = 'Stop'
function Get-SourceFiles ([String]$Dir) {
Push-Location $Dir
try {
Get-ChildItem . -File -Recurse | Where-Object { $_.Extension -match '^\.(c|cpp|h|hpp)$' } | Resolve-Path -Relative | ForEach-Object { $_.TrimStart('.\').Replace('\', '/') } | Sort-Object
}
finally {
Pop-Location
@yipo
yipo / script.ps1
Last active April 11, 2021 07:03
Get taken datetime from images.
Add-Type -AssemblyName 'System.Drawing'
function Get-ExifDate ([String]$File) {
try {
$bitmap = New-Object System.Drawing.Bitmap -ArgumentList $File
$binary = $bitmap.GetPropertyItem(0x9003).Value
$string = [System.Text.Encoding]::ASCII.GetString($binary, 0, $binary.Length - 1)
return [DateTime]::ParseExact($string, 'yyyy:MM:dd HH:mm:ss', $null)
}