Skip to content

Instantly share code, notes, and snippets.

View griffin-stewie's full-sized avatar

griffin-stewie griffin-stewie

View GitHub Profile
@mono0926
mono0926 / index.ts
Last active March 10, 2025 04:00
Apple ⇄ Google Maps convert function
import * as logger from 'firebase-functions/logger'
import { defineSecret } from 'firebase-functions/params'
import { HttpsError, onRequest } from 'firebase-functions/v2/https'
const secretKey = defineSecret('convertMapSecretKey')
const googleMapsApiKey = defineSecret('convertMapGoogleMapsApiKey')
async function getFtidFromShortUrl(shortUrl: string): Promise<string> {
const response = await fetch(shortUrl, {
method: 'GET',
import SwiftUI
import MapKit
struct MonotoneMap: View {
@State var position = MapCameraPosition.region(
MKCoordinateRegion(
center: CLLocationCoordinate2DMake(35.685175, 139.7528),
span: MKCoordinateSpan(latitudeDelta: 0.03, longitudeDelta: 0.03)
)
)
@niw
niw / use_var_in_struct.md
Last active January 27, 2025 04:58
Use `var` in `struct` in Swift

Use var in struct in Swift

TL;DR: Use var for properties in struct as long as it serves as a nominal tuple. In most cases, there is no obvious benefit to using let for struct properties.

Simple Example

Let's start with a simple example:

struct MyStruct {
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
TextSampleView(style: .foreground)
TextSampleView(style: .mint)
TextSampleView(style: linearGradient)
}
.font(.largeTitle)
import SwiftUI
struct ContentView: View {
@State var rating: Double = 0
var body: some View {
HStack(spacing: 18) {
Button(
action: { withAnimation { rating -= 1 } },
label: { Image(systemName: "minus.circle") }
@usagimaru
usagimaru / DumpAllMethods.swift
Last active March 28, 2024 19:52
Get all methods of an class or instance in Swift
// Dump all NSApplication’s class methods
let dump = NSApplication.perform(NSSelectorFromString("fp_methodDescription")).takeUnretainedValue() as? String
// Dump all NSApplication’s instance methods
let dump = NSApp.perform(NSSelectorFromString("fp_methodDescription")).takeUnretainedValue() as? String
// or
print(NSApplication.value(forKey: "fp_methodDescription"))
print(NSApp.value(forKey: "fp_methodDescription"))
#include <M5StickC.h>
#include <WiFi.h>
#include <ssl_client.h>
#include <HTTPClient.h>
#define PIN_SW 26
const char* ssid = "ssid";
const char* password = "pass";
const char* WEBHOOK_URL = "url";
@usagimaru
usagimaru / customize_sketch_keyboard_shortcuts.md
Last active August 24, 2023 10:56
Customize Sketch.app’s Open and Save keyboard shortcuts.

Scripts

# Print any keyequivalent definitions
PlistBuddy -c "print NSUserKeyEquivalents" ~/Library/Preferences/com.bohemiancoding.sketch3.plist
# Set keyequivalent of 'Open…' as '^⌘O'
PlistBuddy -c "set NSUserKeyEquivalents:'Open…' '@^o'" ~/Library/Preferences/com.bohemiancoding.sketch3.plist
withAnimation(.bouncy(duration: 0.5, extraBounce: 0.5)) {
isDraggingRight = false
}
@Koshimizu-Takehito
Koshimizu-Takehito / RandomMetaballDemoScreen.swift
Last active April 27, 2025 02:50
A view that displays a glowing "metaball" particle effect with randomized circles.
import Combine
import SwiftUI
// MARK: - Demo View
/// A demo screen showcasing the `RandomMetaball2DView`.
///
/// This screen expands to fill the entire safe area.
struct RandomMetaballDemoScreen: View {
var body: some View {