Skip to content

Instantly share code, notes, and snippets.

View philipyoungg's full-sized avatar

Philip Young philipyoungg

View GitHub Profile
@IanKeen
IanKeen / FocusState.swift
Last active June 30, 2023 17:00
SwiftUI: FocusedState shim for < iOS15
import Combine
import SwiftUI
extension View {
public func focused<T>(file: StaticString = #file, _ state: FocusState<T>, equals value: T) -> some View {
modifier(FocusedModifier(state: state, id: value, file: file))
}
}
@propertyWrapper
@mjm
mjm / LinkedText.swift
Created May 21, 2020 03:56
Tappable links in SwiftUI Text view
import SwiftUI
private let linkDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
struct LinkColoredText: View {
enum Component {
case text(String)
case link(String, URL)
}
@tearfulDalvik
tearfulDalvik / nativeMessaging.swift
Last active May 19, 2023 06:01
Chrome Native Messaging in Swift 5
// MARK: Chrome Part
func getInt(_ bytes: [UInt]) -> UInt {
let lt = (bytes[3] << 24) & 0xff000000
let ls = (bytes[2] << 16) & 0x00ff0000
let lf = (bytes[1] << 8) & 0x0000ff00
let lz = (bytes[0] << 0) & 0x000000ff
return lt | ls | lf | lz
}
@z-hao-wang
z-hao-wang / wsClientAutoReconnect.ts
Last active December 31, 2020 12:13
auto reconnect websocket client
import * as WebSocket from 'ws';
import * as EventEmitter from 'events';
// credit to https://github.com/websockets/ws/wiki/Websocket-client-implementation-for-auto-reconnect
class WebSocketClient extends EventEmitter{
private number = 0; // Message number
private autoReconnectInterval = 5 * 1000; // ms
private url: string = '';
private instance: WebSocket | null = null;
@Remiii
Remiii / README.md
Last active March 6, 2024 19:52
How to delete Vault (AWS Glacier) 🗻

How to delete Vault (AWS Glacier)

This Gist give some tips in order to remove AWS Glacier Vault with AWS CLI (ie. https://aws.amazon.com/en/cli/).

Step 1 / Retrive inventory

$ aws glacier initiate-job --job-parameters '{"Type": "inventory-retrieval"}' --vault-name YOUR_VAULT_NAME --account-id YOUR_ACCOUNT_ID --region YOUR_REGION
@dropmeaword
dropmeaword / browser_history.md
Last active April 5, 2024 17:37
Playing around with Chrome's history

Browser histories

Unless you are using Safari on OSX, most browsers will have some kind of free plugin that you can use to export the browser's history. So that's probably the easiest way. The harder way, which seems to be what Safari wants is a bit more hacky but it will also work for other browsers. Turns out that most of them, including Safari, have their history saved in some kind of sqlite database file somewhere in your home directory.

The OSX Finder cheats a little bit and doesn't show us all the files that actually exist on our drive. It tries to protect us from ourselves by hiding some system and application-specific files. You can work around this by either using the terminal (my preferred method) or by using the Cmd+Shft+G in Finder.

Finder

Once you locate the file containing the browser's history, copy it to make a backup just in case we screw up.

@timpulver
timpulver / GetNameAndTitleOfActiveWindow.scpt
Created February 11, 2013 10:38
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
# taken from user Albert's answer on StackOverflow
# http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title
# tested on Mac OS X 10.7.5
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp