Skip to content

Instantly share code, notes, and snippets.

View adozenlines's full-sized avatar

Sean Batson adozenlines

View GitHub Profile
@adozenlines
adozenlines / SnapshotDiffableDataSource.swift
Created January 5, 2023 02:38 — forked from mrpcalcantara/SnapshotDiffableDataSource.swift
Example on how to use the UITableViewDiffableDataSource
//
// SnapshotDiffableDataSource.swift
// testDiffableDataSource
//
// Created by Miguel Alcântara on 22/01/2020.
// Copyright © 2020 Miguel Alcântara. All rights reserved.
//
import UIKit
@adozenlines
adozenlines / clean_code.md
Created August 23, 2021 02:32 — forked from cedrickchee/clean_code.md
Summary of "Clean Code" by Robert C. Martin

Summary of "Clean Code" by Robert C. Martin

A summary of the main ideas from the "Clean Code: A Handbook of Agile Software Craftsmanship" book by Robert C. Martin (aka. Uncle Bob).

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

@adozenlines
adozenlines / UIDevice+Ext.swift
Created June 25, 2021 16:21 — forked from SergLam/UIDevice+Ext.swift
Swift - get device IP address
import UIKit
extension UIDevice {
/**
Returns device ip address. Nil if connected via celluar.
*/
func getIP() -> String? {
var address: String?
@adozenlines
adozenlines / dec2hex.swift
Last active August 6, 2020 16:33
Convert a decimal value to a hex string
import Foundation
let dec: Int = 2806
var buffer = [Int]()
func convert(_ dec: Int) -> [Int] {
if dec == 0 {
return buffer.reversed()
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@adozenlines
adozenlines / MyContentProvider.java
Created December 23, 2015 16:25 — forked from saik0/MyContentProvider.java
Sample ContentProvider that performs all operations transactionally and notifies once in batch operations.
public class MyContentProvider extends ContentProvider {
private final ThreadLocal<Boolean> mApplyingBatch;
private final ThreadLocal<Set<Uri>> mChangedUris;
private boolean applyingBatch() {
return mApplyingBatch.get() != null && mApplyingBatch.get();
}
private Uri insert(final Uri uri, final ContentValues values, final SQLiteDatabase db) {
// do the uri matching and insert
#import "DDXML.h";
#import "DDXMLNode+HTML.h"
#import "DDXMLDocument+HTML.h"