Skip to content

Instantly share code, notes, and snippets.

View fdstevex's full-sized avatar

stevex fdstevex

View GitHub Profile
struct Settings {
static var documentSelected = false
}
struct FolderPage: View {
@State var documentsLabel: String = Settings.documentSelected ? "Selected" : "Not selected"
var body: some View {
VStack {
VStack {
// How is it I can use SF Symbols images in text strings?
echo >bug.txt 􀌛
hexdump bug.txt
> f4 80 8c 9b
f4 = 11110100
80 = 10000000
8c = 10001100
9b = 10011011
#!/bin/swift
// Print all the characters in the "Supplementary Private Use Area-B" block.
import Cocoa
for ch:UInt32 in 0x100000..<0x10FFFF {
let arr = [ch]
let array: [UInt32] = [CFSwapInt32(ch)]
let data = array.withUnsafeBytes { (ptr) -> Data in
@fdstevex
fdstevex / LoginView.swift
Last active July 7, 2020 15:09
Login view based on @jordansinger's but with a placeholder for a function to do the login.
import SwiftUI
import PlaygroundSupport
struct SignUpView: View {
@State var username = ""
@State var password = ""
@State var loggedIn = false
var body: some View {
NavigationView {
@fdstevex
fdstevex / NSFetchedResultsController-UICollectionView-Example.m
Last active June 18, 2020 09:13
Changed implementation to use array of raw blocks instead of NSBlockOperation so it's easy to run them on the main thread.
// Properties:
@property (nonatomic) BOOL shouldReloadCollectionView;
@property (strong, nonatomic) NSMutableArray *collectionViewUpdateBlocks;
// NSFetchedResultsController Delegate Methods:
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
self.shouldReloadCollectionView = NO;
@fdstevex
fdstevex / slackbot.js
Last active November 29, 2018 21:01
JS code that connects to Slack as a bot and answers 'ping' with 'pong'.
const { RTMClient, WebClient } = require('@slack/client');
var CLIENT_EVENTS = require('@slack/client').CLIENT_EVENTS;
const token = 'xoxb-token-here';
async function runBot() {
const rtm = new RTMClient(token);
const web = new WebClient(token);
@fdstevex
fdstevex / gist:52da0d7e5892fe2965eae105b8cf3883
Created May 31, 2016 13:05
Running buildkite-agent as a Windows service
1. Download the Windows Service Wrapper binary from this project: https://github.com/kohsuke/winsw
2. Copy to your Buildkite directory and rename to "buildkite-service.exe"
3. Create buildkite-service.xml:
<service>
<id>buildkite-service</id>
<name>buildkite-service</name>
<description>The BuildKite build agent.</description>
@fdstevex
fdstevex / SPVideoRecorder.h
Last active May 23, 2016 02:18
SPVideoRecorder from http://stackoverflow.com/questions/6795157/what-is-a-10-6-compatible-means-of-recording-video-frames-to-a-movie-without-usi updated with changes required for ffmpeg libavformat circa ffmpeg 3.0.1
#import <Foundation/Foundation.h>
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include <libavutil/imgutils.h>
uint64_t getNanoseconds(void);
@fdstevex
fdstevex / allbonjour.swift
Created May 15, 2016 02:32
Swift command-line script to find Bonjour services on your local network.
#!/usr/bin/swift
// Swift script to search for Bonjour services on the local network.
// Found services are printed to the console.
import Foundation
import CoreFoundation
// Inner search, finds services of a particular type
@fdstevex
fdstevex / AVURLAsset.audiovisualMIMETypes()
Created May 13, 2016 11:03
Output from AVURLAsset.audiovisualMIMETypes for easy reference.
(lldb) p types
([String]) $R0 = 56 values {
[0] = "video/mp4"
[1] = "video/x-m4v"
[2] = "video/mpg"
[3] = "audio/x-m4r"
[4] = "audio/AMR"
[5] = "video/x-mpg"
[6] = "video/3gpp2"
[7] = "video/mp2p"