This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func run() { | |
var data = Data() | |
print("empty") | |
data.append(0x01) | |
print("inline") | |
data.append(contentsOf: [UInt8](repeating: 0xFF, count: 20)) | |
print("inline slice") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 HOME | |
15 X = 10: Y = 10 | |
20 VTAB Y: HTAB X: PRINT "@"; | |
30 GET K$: IF K$ = "" THEN GOTO 30 | |
40 REM ERASE CURRENT | |
50 VTAB Y: HTAB X: PRINT " "; | |
60 REM HANDLE INPUT | |
70 IF K$ = "A" THEN X = X - 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <dispatch/dispatch.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
printf("[Main Thread] Application started.\n"); | |
printf("[Main Thread] Initiating a heavy task on a background queue...\n"); | |
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <stdio.h> | |
#import <stdlib.h> | |
#import <pthread.h> | |
#import <unistd.h> // for sleep() | |
pthread_mutex_t printLock; | |
void* countdown(void* arg) { | |
int id = *((int*)arg); | |
for (int i = 5; i >= 1; i--) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <time.h> | |
// we're aliasing here since modern MacOS doesn't use the same system toolbox | |
void SystemTask() { usleep(50000); } // Yield to system | |
int WaitNextEvent() { SystemTask(); return rand() % 2; } // 50% chance of event | |
void doStuff() { printf("Doing stuff!\n"); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef const struct _libkernel_functions { | |
/* The following functions are included in version 1 of this structure */ | |
unsigned long version; | |
void* (*LIBKERNEL_FUNCTION_PTRAUTH(dlsym))(void*, const char*); | |
void* (*LIBKERNEL_FUNCTION_PTRAUTH(malloc))(size_t); | |
void(*LIBKERNEL_FUNCTION_PTRAUTH(free))(void*); | |
void* (*LIBKERNEL_FUNCTION_PTRAUTH(realloc))(void*, size_t); | |
void(*LIBKERNEL_FUNCTION_PTRAUTH(_pthread_exit_if_canceled))(int); | |
/* The following functions are included in version 2 of this structure */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vision | |
import UIKit | |
import ImageIO | |
struct TitleEmbedding: Codable { | |
let fullNameCopy: String | |
let keyword: String | |
let embedding: [Float] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vision | |
import UIKit | |
import ImageIO | |
struct TitleEmbedding: Codable { | |
let fullNameCopy: String | |
let keyword: String | |
let embedding: [Float] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CoreMLProcessing.swift | |
private var statsEmbeddings: [StatEmbedding] = [] | |
private var titleEmbeddings: [TitleEmbedding] = [] | |
func loadCLIPModelAndEmbeddings() { | |
model = nil | |
statsEmbeddings = [] | |
titleEmbeddings = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import numpy as np | |
import coremltools as ct | |
from transformers import CLIPTokenizer | |
# 1. Load titles list with descriptions | |
titles = [] | |
with open("names.txt", "r", encoding="utf-8") as f: | |
for line in f: |
NewerOlder