Skip to content

Instantly share code, notes, and snippets.

View mustafauysal's full-sized avatar
💭
addressing some issues... 🧑🏻‍💻

Mustafa Uysal mustafauysal

💭
addressing some issues... 🧑🏻‍💻
View GitHub Profile
@mustafauysal
mustafauysal / update.sql
Created May 19, 2023 14:18
Convert latin1_* to utf8_
ALTER TABLE wp_posts CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
UPDATE wp_posts SET post_content = CONVERT(CAST(CONVERT(post_content USING latin1) AS BINARY) USING utf8);
UPDATE wp_posts SET post_title = CONVERT(CAST(CONVERT(post_title USING latin1) AS BINARY) USING utf8);
UPDATE wp_posts SET post_excerpt = CONVERT(CAST(CONVERT(post_excerpt USING latin1) AS BINARY) USING utf8);
UPDATE wp_posts SET post_status = CONVERT(CAST(CONVERT(post_status USING latin1) AS BINARY) USING utf8);
UPDATE wp_posts SET comment_status = CONVERT(CAST(CONVERT(comment_status USING latin1) AS BINARY) USING utf8);
UPDATE wp_posts SET ping_status = CONVERT(CAST(CONVERT(ping_status USING latin1) AS BINARY) USING utf8);
UPDATE wp_posts SET post_password = CONVERT(CAST(CONVERT(post_password USING latin1) AS BINARY) USING utf8);
UPDATE wp_posts SET post_name = CONVERT(CAST(CONVERT(post_name USING latin1) AS BINARY) USING utf8);
UPDATE wp_posts SET to_ping = CONVERT(CAST(CONVERT(to_ping USING latin1) AS BINARY) USING
@mustafauysal
mustafauysal / drop-tables-ms.php
Created January 10, 2023 19:27
Drop all tables belonging to the site during the deletion of the site on multisite.
<?php
/**
* Drop all tables belongs to site.
*
* @param array $tables The tables to drop.
* @param int $blog_id The site ID.
*
* @return array
*/
@mustafauysal
mustafauysal / drop-hustle-and-forminator-tables-on-ms.php
Created January 9, 2023 15:51
Removes hustle and forminator tables when deleting a blog on multisite installation
<?php[
add_filter( 'wpmu_drop_tables', function ( $tables, $blog_id ) {
global $wpdb;
$hustle = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->get_blog_prefix( $blog_id ) . 'hustle' ) . '%' ), ARRAY_A );
if ( ! empty( $hustle ) ) {
foreach ( $hustle as $hustle_table ) {
$hustle_table = array_values( $hustle_table );
@mustafauysal
mustafauysal / change-magic-login-strings.php
Created November 29, 2022 20:14
Change magic login strings
<?php
add_filter( 'gettext', 'change_magic_login_strings', 10, 3 );
function change_magic_login_strings( $translated_text, $untranslated_text, $domain ) {
if ( 'magic-login' !== $domain ) {
return $translated_text;
}
if ( 'Username or Email Address' === $untranslated_text ) {
@mustafauysal
mustafauysal / apache-webp-rewrite.conf
Created August 11, 2020 19:20 — forked from seeekr/apache-webp-rewrite.conf
enabling apache to serve WebP image files if accepted by browser (and .webp files available)
## !! This snippet has been updated, but not tested in practice. It should work, please check / leave comments in case it doesn't. !! ##
# originally from https://groups.google.com/a/webmproject.org/group/webp-discuss/browse_thread/thread/196ac4ea705688d8
<IfModule mod_rewrite.c>
# TODO: don't forget to put
# AddType image/webp .webp
# in your mods-available/mime.conf
# (though this is optional because we're setting
# the mime type manually in the RewriteRule)
@mustafauysal
mustafauysal / 49-haproxy.conf
Last active May 22, 2019 13:14
HAProxy to Graylog
# Create an additional socket in haproxy's chroot in order to allow logging via
# /dev/log to chroot'ed HAProxy processes
$template GRAYLOGRFC5424,"<%PRI%>%PROTOCOL-VERSION% %TIMESTAMP:::date-rfc3339% %HOSTNAME% %APP-NAME% %PROCID% %MSGID% %STRUCTURED-DATA% %msg%\n"
$AddUnixListenSocket /var/lib/haproxy/dev/log
# Send HAProxy messages to a dedicated logfile
if $programname startswith 'haproxy' then /var/log/haproxy.log
if $syslogtag contains 'haproxy' then @192.168.1.10:1514;GRAYLOGRFC5424
&~
@mustafauysal
mustafauysal / nginx-tuning.md
Created May 20, 2019 15:28 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@mustafauysal
mustafauysal / nginx.conf
Created May 20, 2019 14:34 — forked from v0lkan/nginx.conf
Configuring NGINX for Maximum Throughput Under High Concurrency
user web;
# One worker process per CPU core.
worker_processes 8;
# Also set
# /etc/security/limits.conf
# web soft nofile 65535
# web hard nofile 65535
# /etc/default/nginx
<?php
add_action( 'bcn_after_fill', 'project_rebuild_breadcrumbs' );
/**
* Rebuild the breadcrumb created by Breadcrumb NavXT.
*
* @param bcn_breadcrumb_trail $breadcrumb Instance of the currently active breadcrumb trail.
*/
function project_rebuild_breadcrumbs( $breadcrumb ) {
@mustafauysal
mustafauysal / db-config.php
Created February 24, 2019 14:23
different dataset for table
<?php
$wpdb->add_database( array(
'host' => 'global.db.example.com',
'user' => 'globaluser',
'password' => 'globalpassword',
'name' => 'globaldb',
) );
$wpdb->add_database( array(