Skip to content

Instantly share code, notes, and snippets.

View Ben-G's full-sized avatar
💭
💻

Benjamin Encz Ben-G

💭
💻
View GitHub Profile
#!/usr/sbin/dtrace -q -s
/*
set(char *key, char *domain, char *user, char *host, char *container, char *value)
*/
CFPreferences$target:::set {
printf("Set request at %Y ( key: %s, domain: %s, user:%s, host: %s, container: %s, value: %s)\n", walltimestamp, copyinstr(arg0), copyinstr(arg1), copyinstr(arg2), copyinstr(arg3), copyinstr(arg4), copyinstr(arg5));
ustack();
printf("\n\n\n");
}
with
dau as (
-- This part of the query can be pretty much anything.
-- The only requirement is that it have three columns:
-- dt, user_id, inc_amt
-- Where dt is a date and user_id is some unique identifier for a user.
-- Each dt-user_id pair should be unique in this table.
-- inc_amt represents the amount of value that this user created on dt.
-- The most common case is
-- inc_amt = incremental revenue from the user on dt
@ilyaigpetrov
ilyaigpetrov / client-server-data-sync.markdown
Last active January 26, 2020 14:58
Client/Server Data Synchronization Solutions | by https://git.io/ilyaigpetrov

Client/Server Data Synchronization

Open Source

  • Redis
    In-memory db with notifications, may be used alongside other DB.
  • Meteor
    • MongoDB | Livequery | server DDP | DDP client | minimongo
    • Livequery for DB updates subscriptions (MongoDB)
    • Minimongo is MongoDB imitation, used for latency compenstion.
  • Opinionated, heavy, not very modular.
@praeclarum
praeclarum / ArrayDiff.swift
Last active January 8, 2021 06:10
A generic diffing operation that can calculate the minimal steps needed to convert one array to another. It can be used to generate standard diffs, or it can be used more creatively to calculate minimal UI updates.
//
// ArrayDiff.swift
//
// Created by Frank A. Krueger on 6/30/15.
// Copyright © 2015 Krueger Systems, Inc. All rights reserved.
// License: MIT http://opensource.org/licenses/MIT
//
import Foundation
@chriseidhof
chriseidhof / json.swift
Last active March 21, 2019 07:45
Reflection
import Cocoa
struct Person {
var name: String = "John"
var age: Int = 50
var dutch: Bool = false
var address: Address? = Address(street: "Market St.")
}
struct Address {
@CodaFi
CodaFi / alltheflags.md
Last active October 26, 2022 20:09
Every Option and Flag /swift (1.2) Accepts Ever

#Every Single Option Under The Sun

  • optimization level options
  • automatic crashing options
  • debug info options
  • swift internal options
  • swift debug/development internal options
  • linker-specific options
  • mode options
@JadenGeller
JadenGeller / Type-Level Assertions.swift
Last active March 9, 2018 03:06
Type-Level Assertions (or, almost-dependent types)
/*
* We've defined "traits" by which we can type an integer that are characteristic of its value.
* These traits can even be subtraits of other traits (like both positive and negative being nonzero).
*
* We can use these traits in the type signatures of functions to indicate what trait will be returned
* as a function of the passed-in traits.
*
* Even cooler, we can specify properties of the traits such that we can runtime-verify the correctness
* of these labels (in case a function was improperly annotated, for example).
*/
#!/usr/bin/xcrun swift
import Cocoa
import ObjectiveC
// Pretend to be Finder
extension Bundle { var __bundleIdentifier: String? { return "com.apple.finder" } }
guard let bundleClass : AnyClass = NSClassFromString("NSBundle")
else { fatalError("Unable to fetch NSBundle class") }
let id1 = class_getInstanceMethod(bundleClass, #selector(getter: Bundle.bundleIdentifier))
let id2 = class_getInstanceMethod(bundleClass, #selector(getter: Bundle.__bundleIdentifier))
@davbeck
davbeck / GQL.swift
Created May 2, 2015 15:52
GraphQL data structure implemented in Swift
import Foundation
protocol GQLNodeArgument {}
extension String: GQLNodeArgument {}
extension NSNumber: GQLNodeArgument {}
class GQLNode: StringLiteralConvertible, ArrayLiteralConvertible, Printable, DebugPrintable {
let name: String?
protocol Calendar {
typealias Unit: BidirectionalIndexType
typealias Era: Unit
typealias Year: Unit
typealias Month: Unit
typealias Week: Unit
typealias Day: Unit
typealias Weekday: Unit
typealias Hour: Unit