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
# Python handles memory management for you | |
list_of_items = ['item1', 'item2', 'item3'] | |
print("Current list:", list_of_items) | |
# When objects like lists are no longer needed, Python cleans up | |
del list_of_items # This frees up memory space automatically | |
# The garbage collector in Python manages the allocation and deallocation of memory |
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_command(char *input) { | |
char buffer[30]; | |
strcpy(buffer, input); // Potential overflow here | |
// ... Process command | |
} | |
int main() { | |
char command[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> | |
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; | |
} |
NewerOlder