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 | |
// Online tool: https://mxtoolbox.com/ | |
function getMXRecords($domain) { | |
$mxhosts = []; | |
$weights = []; | |
// Get MX records associated with the domain | |
if (getmxrr($domain, $mxhosts, $weights)) { |
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
function displayPreviewsOfExistingWebPImages () { // Call this function when page is ready, i.e. $(document).ready(displayPreviewsOfExistingWebPImages); | |
// Initialize Dropify on all elements with the class .dropify | |
var dropifyInstances = $('.dropify').dropify(); | |
// Iterate over each Dropify instance | |
dropifyInstances.each(function() { | |
// Get the current instance's element and defaultFile data attribute | |
var element = $(this); | |
var defaultFile = element.data('default-file'); |
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 | |
// Delete image files in image/product/ folder that do not exist in database table products_photos, column photo | |
$directoryPath = 'c:/xampp_8_2_12/htdocs/image/product/'; | |
$removePath = 'c:/xampp_8_2_12/htdocs'; | |
$filesAndFolders = glob($directoryPath . '*'); // Note that some files don't have a file extension | |
$filesNotExistingInDatabase = array(); | |
$counter = 0; | |
// Part of the path to remove | |
foreach ($filesAndFolders as $i => $absolutePath) { | |
if (is_file($absolutePath)) { // exclude directories |
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 | |
//Convert PNG and JPEG images to WebP | |
function convertToWebp($source, $destination, $quality = 80) { | |
$startTime = microtime(true); | |
$info = getimagesize($source); | |
if ($info['mime'] == 'image/jpeg' || $info['mime'] == 'image/jpg' || $info['mime'] == 'image/jfif') { | |
echo "Original image is jpeg<br>"; | |
// Load the JPEG file | |
$image = imagecreatefromjpeg($source); |
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
# Calculate inflation adjusted value. Generated with chatGPT4 | |
from datetime import datetime | |
start_amount = 140000 | |
start_year = 2019 | |
end_year = 2024 | |
# Inflation rates by year, from 2019 to the current year | |
# Note: These are fictional rates for demonstration purposes. | |
# In a real-world scenario, you would use actual inflation rates obtained from a reliable financial source. |
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
::Test pass criteria: Exe has to finish within maxExeRunTime_s and exe output's last line must be equal to expectedLastLine | |
@echo off | |
set currentDir=%CD% | |
:: Set variables | |
set secondWindowTitle=My second window | |
set exeName=MyExe.exe | |
set exeFolder=x64/Release | |
set maxExeRunTime_s=5 | |
set tempOutFile=temp_output.txt |
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
private static function getPageSpeedInsights($url) { | |
$apiUrl = "https://www.googleapis.com/pagespeedonline/v5/runPagespeed"; | |
/*$queryParams = http_build_query([ | |
'url' => $url, | |
'key' => 'YOUR_API_KEY' // If you plan on using the API in an automated way and making multiple queries per second, you'll need an API key | |
]);*/ | |
$queryParams = http_build_query([ | |
'url' => $url | |
]); |
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
#Download raster (*.tif) files from https://www.naturalearthdata.com/downloads/50m-raster-data/ | |
import matplotlib.pyplot as plt | |
import cartopy.crs as ccrs | |
import rasterio | |
from rasterio.plot import show | |
class InteractiveMap: | |
def __init__(self, raster_path): | |
self.raster_path = raster_path |
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
#You can download shape files (.sh and .shx) from https://www.naturalearthdata.com/downloads/ | |
#Put .shx files into the same folder as .sh file | |
#Şamil Korkmaz, December 9th 2023 | |
import geopandas as gpd | |
import matplotlib.pyplot as plt | |
def plot_shapefile(shapefile_path1, shapefile_path2, shapefile_path3): | |
# Load shape files | |
gdf1 = gpd.read_file(shapefile_path1) |
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
#!/bin/bash | |
#1.On online Ubuntu 22.04, create a folder, save this script as download_build_essential.sh | |
#2.Make script executable with chmod +x download_build_essential.sh | |
#3.Run script with ./download_build_essential.sh | |
#4.Copy downladed .deb files (~76MB) to the offline Ubuntu 22.04 | |
#5.On offline Ubuntu, run sudo dpkg -i *.deb | |
#6.Verify installation with make --version | |
# Function to download a package and its dependencies |
NewerOlder