Skip to content

Instantly share code, notes, and snippets.

View Kureev's full-sized avatar
👋

Alexey Kureev Kureev

👋
View GitHub Profile

Problem

I have an issue calling Obsidian.obtain. It seems that sometimes it throws exceeding max stack error. Fix it

Long story short: https://twitter.com/GcCarmeli/status/1645482647315988486

The idea was to embed the codebase and create a custom agent that will be able to fix the code using baby AI-inspired approach. Here are some high-level results. Whatever happens after this line is pure AI-generated output.

FIND RESULT:

 obtain, P = any>(
@Kureev
Kureev / index.ts
Created October 1, 2020 15:13
How to initialize Flex with an `errorPage`
Flex
.provideLoginInfo(configuration, "#container")
.then(() => Flex.Manager.create(configuration))
.then(manager => { /* use manager here */ })
.catch(error => Flex.errorPage(error, "#container"));
if (ts.isFunctionTypeNode(typeNode)) {
let argument: Schemify.TypeAnnotation;
this.checker
.getSignaturesOfType(type, ts.SignatureKind.Call)
/**
* At this moment, react-native doesn't support more than one argument
* (Event) passed back from the native side, however the implementation
* I wrote was designed to support multiple parameters (just in case).
*
* That said, I assume the "getParameters" to always return an array
- (void)renderElementOfType:(NSString *)name size:(NSSize)size {
EBWindow *window = [[EBWindow alloc] init];
EBUIManager *manager = [EBUIManager sharedInstance];
[window openWithSize:NSMakeSize((CGFloat)size.width, (CGFloat)size.height)];
NSString *uuid = [[NSUUID UUID] UUIDString];
[manager addValue:window forKey:uuid];
}
#import <Foundation/Foundation.h>
@interface EBUIManager : NSObject
+ (instancetype)sharedInstance;
- (void)addValue:(id)value forKey:(NSString *)key;
@end
- (void)renderElementOfType:(NSString *)name size:(NSSize)size {
GGWindow *window = [[GGWindow alloc] init];
[window openWithSize:NSMakeSize((CGFloat)size.width, (CGFloat)size.height)];
}
@Kureev
Kureev / render.cpp
Last active October 19, 2016 18:57
JsValueRef render(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) {
NSString *type = [NSString stringWithUTF8String:ChakraUtils::toString(arguments[1])];
float w {ChakraUtils::toFloat(arguments[2])};
float h {ChakraUtils::toFloat(arguments[3])};
dispatch_async(dispatch_get_main_queue(), ^{
id delegate = [[NSApplication sharedApplication] delegate];
[delegate renderElementOfType:type size:NSMakeSize((CGFloat)w, (CGFloat)h)];
});
function SetupGlobalEnvironment() {
var globalObject = JsGetGlobalObject();
var bridge = {
render: render,
};
globalObject.bridge = bridge;
return 0;
}
JsErrorCode SetupGlobalEnvironment() {
JsValueRef globalObject;
JsGetGlobalObject(&globalObject);
JsValueRef bridgeObject;
JsCreateObject(&bridgeObject);
ChakraUtils::setObjectProperty(globalObject, 'bridge', bridgeObject);
ChakraUtils::setObjectFunctionProperty(bridgeObject, 'render', render);
@implementation ChakraProxy
-(void)run {
unsigned currentSourceContext = 0;
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"main" ofType:@"js"];
NSError *error;
NSString *fileContents = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:&error];
if (error) {