Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View niw's full-sized avatar
🐱
Meow

Yoshimasa Niwa niw

🐱
Meow
  • San Francisco, CA
  • X @niw
View GitHub Profile
commit 6ac1a2feb7143a8bc0e57af5c8dc57cbbb05d85f
Author: Yoshimasa Niwa <niw@niw.at>
Date: Fri Apr 19 22:14:55 2024 -0700
wip
diff --git a/3_bidirectional_cxx_interop/include/fibonacci/fibonacci.h b/3_bidirectional_cxx_interop/include/fibonacci/fibonacci.h
index 911e7d7..ed3f909 100644
--- a/3_bidirectional_cxx_interop/include/fibonacci/fibonacci.h
+++ b/3_bidirectional_cxx_interop/include/fibonacci/fibonacci.h
@niw
niw / uninstall_xquartz.sh
Last active April 19, 2024 14:28
A simple XQuartz uninstall script
#!/usr/bin/env bash
set -e
[[ $USER == "root" ]] || {
echo "You must be root to run this script." >&2
exit 1
}
echo "Unload launchd daemons and agents..."
@niw
niw / fetch_nike_puls_all_activities.bash
Last active April 10, 2024 08:48
A simple NikePlus API description to fetch past run metrics
#!/usr/bin/env bash
# fetch_nike_puls_all_activities.bash
# A simple bash script to fetch all activities and metrics from NikePlus.
# See `nike_plus_api.md` for the API details.
readonly bearer_token="$1"
if [[ -z "$bearer_token" ]]; then
echo "Usage: $0 bearer_token"
exit
@niw
niw / QEMU_EFI-8c552e8-edk2-stable202008-without-xhci.tar.gz
Last active February 22, 2024 17:44
Prebuild version of QEMU_EFI.fd
This file has been truncated, but you can view the full file.
@niw
niw / Vagrantfile
Last active February 22, 2024 10:21
A simple Vagrantfile to setup Ubuntu desktop environment with Google Chrome and Japanese input
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provider :virtualbox do |v|
v.gui = true
v.memory = 2048
end
# Currently "ubuntu/bionic64" on VirtualBox requires `type: "virtualbox"`
# to make synced folder works.
@niw
niw / README.en.md
Last active February 13, 2024 04:24
How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

Here is easy steps to try Windows 10 on ARM or Ubuntu for ARM64 on your Apple Silicon Mac. Enjoy!

NOTE: that this is current, 10/1/2021 state.

Running Windows 10 on ARM

  1. Install Xcode from App Store or install Command Line Tools on your Mac
@niw
niw / Gateron_Low_Profile_Socket.kicad_mod
Last active January 11, 2024 00:26
KiCad footprint for Gateron Low Profile socket
(footprint "Gateron_Low_Profile_Socket" (version 20211014) (generator pcbnew)
(layer "F.Cu")
(tedit 5E123764)
(descr "Hot Swap Socket for Gateron Low Profile Switch")
(attr smd)
(fp_text reference "REF**" (at 0 9.5) (layer "B.SilkS")
(effects (font (size 1 1) (thickness 0.15)) (justify mirror))
(tstamp 1b4a9a9f-50fb-40ce-9b05-77578a9b9c54)
)
(fp_text value "Gateron_Low_Profile_Socket" (at 0 8.5) (layer "F.Fab")
@niw
niw / ios11_uinavigationbar_behavior.md
Last active January 3, 2024 11:35
A note of my observation about iOS 11 UINavigationBar behavior.

UINavigationBar on iOS 11

NOTE This note is written based on Xcode version 9.0 beta 6 (9M214v) and its simulator binary.

iOS 11 changes UINavigationBar a lot, not just only for its large title, but also the internal view hierarchy and lay outing views are changed. This is a small note about UINavigationBar behavior on iOS 11, mainly focusing on migrating the application to iOS 11.

Lay outing views

UINavigationBar has been using manual lay outing until iOS 10, so all its content views like titleView has been directly child view of the UINavigationBar. However, since iOS 11, it is using auto layout with bunch of layout guides to lay out its content views in its own internal container view, _UINavigationBarContentView.

@niw
niw / main.swift
Last active November 29, 2023 05:28
Texting line height on NSTextView with TextKit 2
import AppKit
import Foundation
final class MainView: NSView {
private let textView: NSTextView
override init(frame frameRect: NSRect) {
textView = NSTextView(usingTextLayoutManager: true)
super.init(frame: frameRect)
@niw
niw / libpng_test.c
Last active November 12, 2023 19:54
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng16 libpng_test.c