Skip to content

Instantly share code, notes, and snippets.

View soffes's full-sized avatar

Sam Soffes soffes

View GitHub Profile
@chockenberry
chockenberry / ql.sh
Last active March 4, 2024 23:40
QuickLook for macOS shell
#!/bin/sh
# usage:
# ql /tmp/file.jpg
# cat /tmp/file.jpg | ql
# cal -h | ql
if [ -z "$*" ]; then
cat > /tmp/ql.stdin
mime_type=$(file --brief --mime-type /tmp/ql.stdin)
@kylebshr
kylebshr / ViewController.swift
Last active June 7, 2021 23:36
UISheetPresentationController
//
// ViewController.swift
// Sheets
//
// Created by Kyle Bashour on 6/7/21.
//
import UIKit
class ViewController: UIViewController, UISheetPresentationControllerDelegate {
@tenderlove
tenderlove / ngpng.rb
Last active December 12, 2020 14:09
Simple PNG generation example that only depends on zlib in Ruby
# Not Great PNG class. This is a very simple example of writing a PNG. It
# only supports colors from the color palette stored in `@palette`. This is
# meant to be example code, but I am using it in a program for visualizing
# heap dumps from Ruby.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
@absoftware
absoftware / abswift-playground-decodable-any.swift
Last active April 8, 2021 00:05
Hot to make Swift's [String: Any] decodable?
import Foundation
let json = """
{
"keyNumber1": {
"type": "payload",
"data": {
"id": "someId1",
"eventName": "Event Name 1",
"metadata": []
class AppleSignInController < ApplicationController
APPLE_PEM_URL = "https://appleid.apple.com/auth/keys"
# /api/apple/validate
def validate
name = params[:name]
userIdentity = params[:userIdentity]
jwt = params[:jwt]
@chockenberry
chockenberry / Debug.swift
Last active April 11, 2024 13:22
Debug and release logging in Swift that's reminiscent of NSLog()
//
// Debug.swift
//
// Created by Craig Hockenberry on 3/15/17.
// Updated by Craig Hockenberry on 2/20/24.
// Usage:
//
// SplineReticulationManager.swift:
//
// gcc -lcmark -o test test.c
#include <cmark.h>
int main(int argc, char *argv[]) {
int options = CMARK_OPT_DEFAULT;
cmark_parser *parser = cmark_parser_new(options);
cmark_parser_feed(parser, "Hello **world**.\n", 17);
cmark_node *document = cmark_parser_finish(parser);
void addMainThreadCheck(Class cls, SEL selector) {
#if DEBUG
void *symbol = dlsym(RTLD_DEFAULT, "__main_thread_add_check_for_selector");
if (!symbol) {
return;
}
void (*addCheck)(Class, SEL) = (__typeof__(addCheck))symbol;
addCheck(cls, selector);
#endif
}
@0xced
0xced / Emoji.json
Last active November 22, 2023 15:53
Extract emoji by category using the EmojiFoundation framework
{
"People" : [
"😀",
"😃",
"😄",
"😁",
"😆",
"😅",
"😂",
"🤣",
@taviso
taviso / delete-twitter-dm.js
Created November 3, 2017 16:33
Automate deleting twitter direct messages.
// Open direct messages window, paste this into console.
function deleteNextConversation()
{
if (!(dm = document.getElementsByClassName("DMInbox-conversationItem")[0])) {
clearInterval(tmr)
return;
}
dm.firstChild.click();
setTimeout('document.getElementsByClassName("js-actionDeleteConversation")[0].click()', 1000);