This file contains 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
#define ETH_P_IP 0x0800 | |
{ | |
/* --- Ethernet Header --- */ | |
0x7e, 0x2e, 0x1a, 0x3b, 0x70, 0x18, # MAC Dest | |
0xde, 0xde, 0xde, 0xde, 0xde, 0xde, # MAC Source | |
const16(ETH_P_IP), | |
/* --- IPv4 Header --- */ | |
0b01000101, 0, /* IPv4 Version, IHL, TOS */ |
This file contains 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 <string.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <netdb.h> | |
int port_scan(char *addr) |
This file contains 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
while true; do | |
ioreg -l |grep \"PerformanceStatistics\" | cut -d '{' -f 2 | tr '|' ',' | tr -d '}' | tr ',' '\n'|grep 'Temp\|Fan' | |
sleep 1 | |
done |
This file contains 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
#!/usr/bin/env bash | |
rm -rf "${HOME}/Library/Caches/CocoaPods" | |
rm -rf "`pwd`/Pods/" | |
pod update |
This file contains 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
let cppClass = CppClassWrapper(storedValue: „Some value”)! | |
print(cppClass.storedValue) // Some value | |
cppClass.storedValue = „New value” | |
print(cppClass.storedValue) // New value |
This file contains 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
@interface CppClassWrapper () | |
@property (nonatomic) CppClass* cppClass; | |
@end | |
@implementation CppClassWrapper | |
- (void)setStoredValue:(NSString*) storedValue { | |
self.cppClass->storedValue = [storedValue UTF8String]; | |
} |
This file contains 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
@interface CppClassWrapper : NSObject | |
@property (nonatomic, copy) NSString* _Nonnull storedValue; | |
- (instancetype)initWithStoredValue:(NSString* _Nonnull)value; | |
@end |
This file contains 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
final class SwiftCppClass { | |
private let cppClass: UnsafeMutableRawPointer | |
var storedValue: String! { | |
get { | |
guard | |
let currentValue = getStoredValue(cppClass), | |
let currentString = String(utf8String: currentValue) | |
else { |
This file contains 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
let object = makeObject(("Value" as NSString).utf8String) // UnsafeMutableRawPointer? type | |
setNewStoredValue(object, ("New value" as NSString).utf8String) | |
print(String(cString: getStoredValue(object))) // New value | |
removeObject(object) |
This file contains 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
class CppClass { | |
public: | |
CppClass(const char* value) { | |
storedValue = value; | |
} | |
const char* storedValue; | |
}; | |
extern "C" void* makeObject(const char* storedValue) { | |
return (void*) new CppClass(storedValue); |
NewerOlder