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
<?php | |
//Blog post: https://mentoringcomputer.blogspot.com/2023/11/detecting-phone-number-and-email-in.html | |
// Your OpenAI API key | |
$apiKey = 'your-api-key'; | |
$user_data_list = [ | |
[ | |
'user_message' => "şunu dene beşyüzotuz sonra bakarız", | |
'containsEmail' => false, |
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
<?php | |
//This code was generated with chatGPT4 | |
//DaVinci model does not performa well. For a better solution use gpt-4 (see https://gist.github.com/samilkorkmaz/8a94c3e5caf8403d719566b251ebc40c) | |
$api_key = 'your-api-key'; | |
$model = 'text-davinci-003'; | |
$endpoint = 'https://api.openai.com/v1/engines/'.$model.'/completions'; | |
// The user message you want to check |
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
//blog post: https://simulinkforsoftwareengineers.blogspot.com/2023/11/handling-left-over-carriage-return.html | |
#include <iostream> | |
#include <string> | |
bool isCarriageReturn(const char c) { | |
return c == '\r'; | |
} | |
int main() { | |
std::string line = "\r1.2\r4.56"; |
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
//To run from terminal, cd into folder containing index.php: php -S localhost:8000 | |
<?php | |
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | |
// The request is using the POST method | |
$received_data = json_decode(file_get_contents('php://input'), true); | |
header('Content-Type: application/json'); | |
echo json_encode(array('ticketID' => 5)); | |
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { | |
// The request is using the GET method | |
if (isset($_GET['method'])) { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
.floating-whatsapp-button { | |
position: fixed; | |
bottom: 20px; | |
left: 20px; | |
cursor: pointer; | |
z-index: 9999; |
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
// Simple corruption and checksum | |
// Reference: https://www.youtube.com/watch?v=q-BvQgZVRGA&ab_channel=JacobSorber | |
// Şamil Korkmaz, April 23rd, 2023 | |
#include <iostream> | |
#include <string.h> | |
const char* corrupt(const char* msg, size_t nBits) { | |
char* result = strdup(msg); | |
for (size_t i = 0; i < nBits; i++) { | |
int rbyte = rand() % strlen(msg); |
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
# Blender 3.5 custom property demo | |
# Modifed from https://docs.blender.org/api/current/bpy.props.html#operator-example | |
# Şamil Korkmaz, January 2023 | |
import bpy | |
#Button | |
class OBJECT_OT_property_example(bpy.types.Operator): | |
bl_idname = "object.property_example" | |
bl_label = "Show property values in console" |
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
//C++ simple serialization demo, converting struct to char (byte) array and back. | |
//Şamil Korkmaz, January 2023 | |
#include <iostream> | |
#include <string.h> //for memcpy | |
typedef struct { | |
int d; | |
int i; | |
} MY_DATA; |
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
# https://www.geeksforgeeks.org/finite-automata-algorithm-for-pattern-searching/ | |
# Finite Automata pattern searching | |
# Automatically generates transition functions for input pattern string | |
# Jan 2023 | |
def getNextState(pat, lenPat, state, c): | |
# https://www.youtube.com/watch?v=x8PSF9IJIhc&ab_channel | |
# If the character c is same as next character in pattern, increment state | |
if state < lenPat and c == pat[state]: return state + 1 | |
# Find longest string where prefix == suffix |
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
//Code generated by chatGPT, updated by Şamil Korkmaz, December 2022 | |
#include<iostream> | |
#include<vector> | |
#include<queue> | |
#include<climits> | |
#include<algorithm> | |
//Dijkstra's algorithm to find shortest paths between source node and all other nodes | |
//source: Start node. Nodes are expressed as integers, e.g. 0, 1, ..., nNodes |