Skip to content

Instantly share code, notes, and snippets.

@hgc81538
hgc81538 / gist:7e20c0badae7db7bae2696201216b7fa
Last active April 17, 2018 07:23
ubuntu 16.04 high concurrent connection
/etc/sysctl.conf
net.core.somaxconn = 8192
net.ipv4.tcp_max_syn_backlog = 8192
// mysql
Connection failed: SQLSTATE[HY000] [1040] Too many connections
Connection failed: SQLSTATE[HY000] [2002] Resource temporarily unavailable
fix:
/etc/systemd/system/mysql.service
@hgc81538
hgc81538 / gist:ced674849971790f8d3b
Last active March 19, 2024 07:13
MySQL create database and user in command line
# mysql 8 / mariadb 10.11
mysql -u root
CREATE DATABASE <database_name> CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
CREATE DATABASE <database_name> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON <database_name>.* TO '<username>'@'localhost';
flush privileges;
@hgc81538
hgc81538 / gist:b3f71475ad0b5297d897
Created June 15, 2015 10:47
Wordpress manually set 404
<?php
global $wp_query;
$wp_query->set_404();
status_header(404);
include '404.php';
exit;
@hgc81538
hgc81538 / gist:1566cabd816bb27bb254
Last active August 29, 2015 14:06
ERROR: While executing gem ... (ArgumentError) invalid byte sequence in UTF-8
In Windows environment, the error is occured when executing "gem install compass" in cygwin.
$ gem install compass
ERROR: While executing gem ... (ArgumentError)
invalid byte sequence in UTF-8
How to solve:
1) open C:\cygwin\usr\share\ruby\2.0.0\win32\registry.rb
(change to your version when necessary)
2) comment out line 172 and change "\r" to "\r\n" in line 173 (line numbers may vary)
<?php
// original code is from http://stackoverflow.com/questions/7489742/php-read-exif-data-and-adjust-orientation
function image_fix_orientation($path){
$image = imagecreatefromjpeg($path);
$exif = exif_read_data($path);
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 3: