Skip to content

Instantly share code, notes, and snippets.

View multinerd's full-sized avatar
💭
Nerding out

Multinerd multinerd

💭
Nerding out
View GitHub Profile

Developement Checklist

App.xaml(.cs)

  1. Override OnStartup and OnExit.
  • Create TempDirectory (if needed)
  • Implement InstanceChecker to prevent multiple instances of an application from running.
  • Setup CrashReporter events and handlers
/// <summary>
/// Cleans paths of invalid characters.
/// </summary>
public static class PathSanitizer
{
/// <summary>
/// The set of invalid filename characters, kept sorted for fast binary search
/// </summary>
private readonly static char[] invalidFilenameChars;
/// <summary>
@multinerd
multinerd / gist:a61d04622f1230cb19e5f1caaf52771e
Created October 10, 2017 21:35
Syncing data across multiple devices to a single db

Source: https://stackoverflow.com/questions/5035132/how-to-sync-iphone-core-data-with-web-server-and-then-push-to-other-devices

I've done something similar to what you're trying to do. Let me tell you what I've learned and how I did it.

I assume you have a one-to-one relationship between your Core Data object and the model (or db schema) on the server. You simply want to keep the server contents in sync with the clients, but clients can also modify and add data. If I got that right, then keep reading.

I added four fields to assist with synchronization:

  1. sync_status - Add this field to your core data model only. It's used by the app to determine if you have a pending change on the item. I use the following codes: 0 means no changes, 1 means it's queued to be synchronized to the server, and 2 means it's a temporary object and can be purged.
// MARK: - UIView Extension for Dance
@available(iOS 10.0, *)
extension UIView {
fileprivate struct DanceAssociatedKey {
static var dance = "dance_key"
}
public var dance: Dance {

Symbolic Breakpoint

Debugging Constraints
Symbol: UIViewAlertForUnsatisfiableConstraints
Debugger Action: po [[UIWindow keyWindow] _autolayoutTrace]
-- Convert Base64 value in a variable to varbinary:
declare @str varchar(20);
set @str = '3qAAAA==';
select cast(N'' as xml).value('xs:base64Binary(sql:variable("@str"))', 'varbinary(20)');
-- Convert binary value in a variable to Base64:
declare @bin varbinary(20);
set @bin = 0xDEA00000;
select cast(N'' as xml).value('xs:base64Binary(xs:hexBinary(sql:variable("@bin")))', 'varchar(20)');