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 MYSQL | |
List your entire schema + tables + columns charset and collations to overall review | |
WHAT IT DOES: | |
- The stored procedure goes into MySQL's information_schema table | |
and retrieves the overall info about your database; | |
HOW TO USE: |
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://stackoverflow.com/questions/37364618/utf8mb4-unicode-ci-vs-utf8mb4-bin | |
https://drupal.stackexchange.com/questions/166405/why-are-we-using-utf8mb4-general-ci-and-not-utf8mb4-unicode-ci/184528#184528?newreg=82d15487d4b84bbe978ce38e687baaa9 | |
https://pentahointegra.blogspot.com/2015/09/utf8generalci-vs-utf8unicodeci-what.html | |
Note: in new versions of MySQL use utf8mb4, rather than utf8, which is the same | |
UTF-8 data format with same performance but previously only accepted the first | |
65,536 Unicode characters. | |
Accuracy |
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
#301 Redirects for .htaccess | |
#Redirect a single page: | |
Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
#Redirect an entire site: | |
Redirect 301 / http://www.domain.com/ | |
#Redirect an entire site to a sub folder | |
Redirect 301 / http://www.domain.com/subfolder/ |
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 declare(strict_types = 1); | |
namespace Traits; | |
use Exception; | |
use Illuminate\Http\Response; | |
trait HasDailyLimit | |
{ |
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 | |
function flagWords($text, $badwords) | |
{ | |
$badword = reset($badwords); | |
while ($badword) { | |
$text = preg_replace( | |
'/('. preg_quote($badword) .')/i', | |
'<span style="color:red;">$1</span>', | |
$text | |
); |
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 method was created to easily parse any URI helping | |
* with HTTP Clients requests when adding routes | |
* | |
* @param string $uri | |
* @return string | |
**/ | |
function uriSanitizer(string $uri): string | |
{ |
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
Bulk Insert into MS SQL Compact Edition Database from CSV files using C# | |
In MS SQL Server, bulk insert into database from CSV files can be easily done by calling 'LOAD' command from SQL query. However, this command is not supported in MS SQL compact edition. By inserting line by line into sqlce database is obviously too slow for most application that consumes large amount of data. Below is a source code written in C# for sqlce which allows users to obtain performance similar to bulk insert in MS SQL Server | |
public void BulkInsertFromCSV(string file_path, string table_name, string connection_string, Dictionary<string, Type> data_types) | |
{ | |
string line; | |
List<string> column_names = new List<string>(); | |
using (StreamReader reader = new StreamReader(file_path)) | |
{ | |
line = reader.ReadLine(); |
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
# Main inspiration/initial credits: https://gist.github.com/graymouser/a33fbb75f94f08af7e36 | |
# Open the console and run this js: | |
var pattern = /(MOBI|EPUB|PDF( ?\(H.\))?|CBZ|Download)$/i; | |
var nodes = document.getElementsByTagName('a'); | |
var downloadCmd = ''; | |
for (i in nodes) { | |
var a = nodes[i]; | |
if (a && a.text && pattern.test(a.text.trim()) && a.attributes['href']) { | |
downloadCmd += a.attributes['href'].value + "\"\n"; |
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 | |
/** | |
* Builds HTML dropdowns in a simple way | |
* @param array $array | |
* @param bool $hasAll | |
*/ | |
function mountDropdownHtml($array, $hasAll = false) | |
{ | |
if (!is_array($array)) { | |
throw new Exception('Invalid argument: First argument must be an array'); |
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 | |
class MY_Controller | |
{ | |
private function ipVersion($ip) | |
{ | |
return strpos($ip, ':') === false ? 4 : 6; | |
} | |
public function isLocal() | |
{ |