Skip to content

Instantly share code, notes, and snippets.

View lemonmojo's full-sized avatar

Felix Deimel lemonmojo

View GitHub Profile
@lemonmojo
lemonmojo / keepalivetest.c
Last active January 19, 2023 10:59
A small utility to test TCP keep-alive on macOS
//
// keepalivetest.c
//
// Created by Felix Deimel on 07.11.19
// Copyright (c) 2019 Felix Deimel
//
// [INSTRUCTIONS]
//
// Compile with "cc -o keepalivetest keepalivetest.c"
// Run with "./keepalivetest HOSTNAME PORT"
#ifndef LMExceptionError_h
#define LMExceptionError_h
#define LMExceptionErrorClass NSClassFromString(@"LMExceptionError")
@protocol LMExceptionError <NSObject>
@property (readonly) NSString* exceptionTypeName;
@property (readonly) NSString* message;
public static class Exception_ObjC_Extensions
{
public static __ObjC_LMExceptionError ToLMExceptionError(this Exception exception)
{
return __ObjC_LMExceptionError.FromException(exception);
}
}
[Register("LMExceptionError")]
@lemonmojo
lemonmojo / gist:e4d6f93075fe6d3a91a1
Created April 16, 2015 19:57
OS X Proxy Password
+ (NSString*)passwordForProxy:(NSString*)proxy port:(int)port user:(NSString*)user protocol:(SecProtocolType)protocol {
void *password;
UInt32 passwordLength = 0;
NSString *passwordStr = nil;
OSStatus status = SecKeychainFindInternetPassword(NULL,
(int)[proxy length], [proxy UTF8String], 0, NULL,
(int)[user length], [user UTF8String], 0, NULL,
port, protocol,
kSecAuthenticationTypeAny,
@lemonmojo
lemonmojo / gist:10449961
Created April 11, 2014 08:29
FreeRDP TSG connection fails with segfault (valgrind log)
This file has been truncated, but you can view the full file.
valgrind --track-origins=yes -v ./xfreerdp /u:DEST_USER /p:DEST_PASS /g:GW_HOST /gu:GW_USER /gd:GW_DOM /gp:GW_PASS /admin /sec:rdp /v:DEST_HOST
==28531== Memcheck, a memory error detector
==28531== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==28531== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==28531== Command: ./xfreerdp /u:DEST_USER /p:DEST_PASS /g:GW_HOST /gu:GW_USER /gd:GW_DOM /gp:GW_PASS /admin /sec:rdp /v:DEST_HOST
==28531==
==28531== WARNING: Support on MacOS 10.8/10.9 is experimental and mostly broken.
==28531== WARNING: Expect incorrect results, assertions and crashes.
==28531== WARNING: In particular, Memcheck on 32-bit programs will fail to
==28531== WARNING: detect any errors associated with heap-allocated data.