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> | |
void process_data(char *input) { | |
char buffer[50]; | |
strcpy(buffer, input); // Potential overflow here | |
// ... Process data | |
} | |
int main() { | |
char data[100]; |
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 <stdbool.h> | |
bool authenticate(char *username, char *password) { | |
char stored_password[16]; | |
strcpy(stored_password, "secret"); // The real password | |
return strcmp(password, stored_password) == 0; | |
} | |
int main() { |
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> | |
void greet(char *input) { | |
char buffer[10]; | |
strcpy(buffer, input); // Copy input to buffer | |
printf("Hello, %s!\n", buffer); | |
} | |
int main() { | |
char name[20]; |
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
<?xml version="1.0"?> | |
<definitions name="SimpleWeatherService" | |
targetNamespace="http://example.com/simpleWeather.wsdl" | |
xmlns:tns="http://example.com/simpleWeather.wsdl" | |
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | |
xmlns="http://schemas.xmlsoap.org/wsdl/"> | |
<types> |
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
import grpc | |
import weather_pb2 | |
import weather_pb2_grpc | |
def run(): | |
with grpc.insecure_channel('localhost:50051') as channel: | |
stub = weather_pb2_grpc.WeatherServiceStub(channel) | |
response = stub.GetWeather(weather_pb2.GetWeatherRequest(city_name="New York")) | |
print(f"Weather: {response.temperature} degrees") |
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
from concurrent import futures | |
import grpc | |
import weather_pb2 | |
import weather_pb2_grpc | |
class WeatherServicer(weather_pb2_grpc.WeatherServiceServicer): | |
def GetWeather(self, request, context): | |
# Implement the logic to retrieve the weather here. For simplicity, returning a fixed value. | |
return weather_pb2.GetWeatherResponse(temperature=22.5) |
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
syntax = "proto3"; | |
package weather; | |
// The weather service definition. | |
service WeatherService { | |
// Sends a request to get the current weather for a city | |
rpc GetWeather(GetWeatherRequest) returns (GetWeatherResponse) {} | |
} |
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
extractFieldValuesChatGPT(text: string, delimiters: string[]): string[] { | |
const regexSafeDelimiters = delimiters.map(d => d.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')); | |
let fieldValues = text.split(new RegExp(regexSafeDelimiters.join('|'), 'g')); | |
fieldValues = fieldValues.filter(p => p); | |
return fieldValues; | |
} |
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
extractFieldValuesChatGPT(text: string, delimiters: string[]): string[] { | |
let currentTextFieldValues = [text]; // Start with the entire text | |
for (const delimiter of delimiters) { | |
let newFieldValues = []; | |
for (const FieldValue of currentTextFieldValues) { | |
if (part.includes(delimiter)) { | |
// Split the FieldValue by the current delimiter and add the resulting parts to newFieldValues | |
newFieldValues.push(…FieldValue.split(delimiter)); |
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
extractFieldValuesHuman(text: string, delimiters: string []): string[] { | |
const textToExtractFrom = text.slice(); // use slice() to avoid mutating the original text | |
if (!delimiters) { | |
return [textToExtractFrom]; | |
} | |
let fieldValues: string[] = []; | |
const indexFirstDelimiter = 0; | |
const delimiter = delimiters[indexFirstDelimiter]; | |
const delimiterAtTheStartOfText = textToExtractFrom.indexOf(delimiter) === 0; |