Skip to content

Instantly share code, notes, and snippets.

@ninjitaru
ninjitaru / gist:9124fc157363a80b68e7c4c231477d31
Created December 24, 2019 09:35
Get reservation table history
async function printReservation() {
const companyId = '-Kl2_DOjdmBh4Rlj58C1';
const branchId = '-Kl2_DOjdmBh4Rlj58C2';
const db = getCachedAdminDB(companyId);
const tableData = (await db.ref(`branchTables/${companyId}/${branchId}`).once('value')).val();
const tableMap = {};
for (const [sectionId, section] of Object.entries(tableData)) {
for (const [tableId, table] of Object.entries(section.tables)) {
@ninjitaru
ninjitaru / coredata.swift
Created September 10, 2021 07:58
NSAsynchronousFetchRequest test
let asyncRequest = NSAsynchronousFetchRequest(fetchRequest: request) { fetchResult in
// this may or may not right in the same thread as the context thread
// except when the context is main thread, this will always run in main thread
// TODO: can i access NSManagedObject safely if this is not the same thread?
print("ttt: blk thread: \(Thread.current)")
Thread.sleep(forTimeInterval: 100)
guard let dataResult = fetchResult.finalResult else {
return
}