Skip to content

Instantly share code, notes, and snippets.

View jaanus's full-sized avatar

Jaanus Kase jaanus

View GitHub Profile
@jaanus
jaanus / gist:7e14b31f7f445435aadac09d24397da8
Last active December 12, 2023 11:41
How to cleanly make swift-snapshot-testing run correctly in Xcode Cloud. You need to bundle the snapshots and resources into your test bundles (xctest), and then use this kind of code to instruct snapshot-testing to pick them up from the test bundle if present.
#if os(iOS)
import SnapshotTesting
import SwiftUI
import XCTest
public extension XCTestCase {
/// Test the layout of a full-screen SwiftUI view.
///
/// Currently, this is hardcoded to logical width and height of iPhone 14 Pro screen. It assumes that tests are ran only on iPhone 14 Pro simulator,
//
// NSFRCChangeConsolidator.swift
//
// Created by Jaanus Kase on 14/05/2019.
// Copyright © 2019 Jaanus Kase. All rights reserved.
//
import Foundation
import CoreData
@jaanus
jaanus / checksummer.py
Created October 24, 2018 07:54
Given a list of files, compute their SHA256 checksums.
#!/usr/bin/env python3
"""For a list of files, get the checksums for the rows that don’t already have it.
Run 'find . -type f > folder.tsv' to get the list of files, and then pass that file
as an argument to this script.
"""
import sys
@jaanus
jaanus / instapaper-to-pinboard.py
Created July 30, 2018 19:03
Upload Instapaper bookmarks to Pinboard. For input, uses the CSV file as exported from Instapaper, or received from their support.
#!/usr/bin/env python3
"""Upload Instapaper bookmarks to Pinboard. For input, uses the CSV file as
exported from Instapaper, or received from their support.
"""
import sys
import os
import argparse
import csv
@jaanus
jaanus / gist:defb704cb43c718a0ffb
Created September 2, 2015 09:38
Electron on Mac - patch for titleless look v2 (with toolbar)
jaanus@jaanus-imac ~/D/electron> git diff
diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm
index 64f7c11..357c305 100644
--- a/atom/browser/native_window_mac.mm
+++ b/atom/browser/native_window_mac.mm
@@ -352,7 +352,7 @@ NativeWindowMac::NativeWindowMac(
options.Get(switches::kStandardWindow, &useStandardWindow);
NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask |
- NSMiniaturizableWindowMask | NSResizableWindowMask;
@jaanus
jaanus / gist:69782e30aba65873d698
Created September 2, 2015 09:34
Electron on Mac - patch for titleless look
jaanus@jaanus-imac ~/D/electron> git diff
diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm
index 64f7c11..922cf64 100644
--- a/atom/browser/native_window_mac.mm
+++ b/atom/browser/native_window_mac.mm
@@ -352,7 +352,7 @@ NativeWindowMac::NativeWindowMac(
options.Get(switches::kStandardWindow, &useStandardWindow);
NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask |
- NSMiniaturizableWindowMask | NSResizableWindowMask;
@jaanus
jaanus / forceclick.html
Last active August 29, 2015 14:24
Webkit force mouse events demo
<html>
<head>
<title>Events</title>
<style type="text/css">
div {
font-family: HelveticaNeue, Helvetica, Arial, sans-serif;
padding-left: 1em;
}
@jaanus
jaanus / gist:fdf0e9ab0fc64c029610
Created March 25, 2015 17:58
Create NSAttributedString out of NSString with Markdown-like syntax for bold text and links.
#if TARGET_OS_IPHONE
@import UIKit;
#define JKColor UIColor
#define JKFont UIFont
#else
@import AppKit;
#define JKColor NSColor
#define JKFont NSFont
#endif
@jaanus
jaanus / gist:d12aec8b6fc90cd9d0de
Created January 25, 2015 08:07
+[NSData dataWithContentsOfURL:] will cause NSProgress to report progress.
#import <Foundation/Foundation.h>
static void *ProgressObserverContext = &ProgressObserverContext;
@interface MyObject: NSObject
@property (strong, nonatomic) NSProgress *progress;
@end
@jaanus
jaanus / gist:4c07a2d575bab1eefa3f
Last active August 29, 2015 14:03
The easiest method to capture a PNG screenshot of NSWindow
@interface NSWindow (JKScreenShot)
- (NSData *)pngScreenshotData;
@end
@implementation NSWindow (JKScreenshot)
- (NSData *)pngScreenshotData
{