Skip to content

Instantly share code, notes, and snippets.

View toledorobia's full-sized avatar
🏠
Working from home

Jonathan Toledo Orobia toledorobia

🏠
Working from home
  • Santiago, Chile
View GitHub Profile
@toledorobia
toledorobia / nginx-tuning.md
Created September 23, 2019 02:32 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

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.

@toledorobia
toledorobia / remove_duplicate_rows.sql
Created January 8, 2018 20:48
MYSQL - Remove duplicate rows
-- The greater ID:
DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.name = n2.name
--The lower ID:
DELETE n1 FROM names n1, names n2 WHERE n1.id < n2.id AND n1.name = n2.name
@toledorobia
toledorobia / InputArrayModel.cs
Last active January 5, 2018 15:33
ASP.NET MVC - Form input array
public class InputArrayModel
{
public int? Id { get; set; }
public ICollection<int?> ItemIds { get; set; }
}
@toledorobia
toledorobia / ends_with.php
Created January 5, 2018 15:24
PHP - Ends with
<?php
function ends_with($haystack, $needle) {
return $needle === "" || substr($haystack, -strlen($needle)) === $needle;
}
?>
@toledorobia
toledorobia / revert_changes_git.sh
Created January 5, 2018 15:23
Git - Revert changes
# Revert modified files
git reset --hard
# Remove new files and folders
git clean -fd
@toledorobia
toledorobia / check_hdd_ubuntu.sh
Created January 5, 2018 15:18
Linux - Check HDD ubuntu
sudo smartctl -l selftest -i -H -A /dev/sda
@toledorobia
toledorobia / search_dirst_recursively.sh
Created January 5, 2018 15:15
Linux - Search dirs recursively
find . -type d -name "dirs_to_search"
@toledorobia
toledorobia / is_dir_empty.php
Last active January 5, 2018 15:12
PHP - Check dir is empty
<?php
function is_dir_empty($dir) {
if (!is_readable($dir)) {
return null;
}
return (count(scandir($dir)) == 2);
}
?>
@toledorobia
toledorobia / validate_email.sql
Last active August 14, 2023 04:45
MySQL - Validate email
SELECT *
FROM user
WHERE email NOT REGEXP '^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9_\-]@[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}$'
@toledorobia
toledorobia / delete_dirs_recursively.php
Last active January 5, 2018 15:11
PHP - Delete dirs recursively
<?php
function rmdir_recursive($dir) {
foreach(scandir($dir) as $file) {
if ('.' === $file || '..' === $file) continue;
if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file");
else unlink("$dir/$file");
}
rmdir($dir);
}
?>