Skip to content

Instantly share code, notes, and snippets.

View seanho's full-sized avatar

Sean Ho seanho

View GitHub Profile
@seanho
seanho / markdown.swift
Created July 28, 2025 23:46
AttribuedString markdown parsing
let attrString = try AttributedString(markdown: markdown)
for (intentBlock, intentRange) in attrString.runs[\.presentationIntent] {
guard let intentBlock else { continue }
for intent in intentBlock.components {
switch intent.kind {
case .paragraph:
case let .header(level):
case .orderedList:
case .unorderedList:
@seanho
seanho / Lens.swift
Last active February 21, 2019 00:25
KeyPath based Lens implementation
protocol LensType {
associatedtype Container
associatedtype View
func get() -> View
func set(_ newValue: View) -> Container
}
protocol KeyPathInstantiatable {
init(mapper: KeyPathMapper<Self>)
@seanho
seanho / Log.swift
Created August 4, 2017 12:12
os_log() wrapper
import os.log
import Foundation
public struct Log {
static let log = OSLog(subsystem: "domain", category: "App")
static public func debug(_ message: Any) {
os_log("⚪️ DEBUG - %@", log: log, type: .debug, "\(message)")
}

Install Node.js version manager

Install nvm or n


Install Node.js version 6

nvm install 6 or n 6.11

RubyMotion 2.8 is released

This update includes support for iOS 7, 64bit binaries and most importantly faster build time! Clean compilation takes 1/3 of the time compared to previous version.


AFNetworking 2.0 is released

The most widely used open source projects for iOS is going to release its first major update later this week. This includes better serialization, real-time connection support and more. Interestingly it supports iOS 7 only.

@seanho
seanho / test.md
Created July 3, 2013 07:49
Test Edit

Test

using System;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using HtmlAgilityPack;
namespace EmbedHtml
{
public class Embeder
{
NSString *url = @"http://brandontreb.com";
NSString *apiEndpoint = [NSString stringWithFormat:@"http://api.tr.im/v1/trim_simple?url=%@",url];
NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint]
encoding:NSASCIIStringEncoding
error:nil];
NSLog(@"Long: %@ - Short: %@",url,shortURL);
// Outputs Long: http://brandontreb.com - Short: http://tr.im/MRDd
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #FCF8E0;
margin-left: 10px;