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
I do this way to often: | |
preg_replace('/[^a-zA-Z0-9 ]/','',$string) | |
#PHP#REGEX |
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
This function will return the name of the month by passing the month's number. (Ex: 1 will return January). | |
///Return the name of the month /// $month : the number of the month (1 - Jan) // $long (bool) : true for long name; false for short name /* Example : NumToMonth(1,true) will return January NumToMonth(1,false) will return Jan */ function NumToMonth($month,$long) { $rtn =""; $month_names = array(1 => "Jan", 2 => "Feb", 3 => "Mar", 4 => "Apr", 5 => "May", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Oct", 11 => "Nov", 12 => "Dec", 13 => "January", 14 => "February", 15 => "March", 16 => "April", 17 => "May", 18 => "June", 19 => "July", 20 => "August", 21 => "September", 22 => "October", 23 => "November", 24 => "December"); if ($month >= 1 and $month <= 24) { // multiply $month by 1 to always have a number // 03 will become 3 |
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
preg_split('/\//', $_SERVER['SCRIPT_NAME'])[count(preg_split('/\//', $_SERVER['SCRIPT_NAME']))-1] | |
Example: | |
http:\\localhost\test.php | |
Would become: | |
test.php |
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
Here is an easy way to extract the filename from a full path in Foxpro: | |
frow = ALINES(fname,fullpath,1,"\") | |
filename = fname[frow] | |
So if fullpath = c:\test.txt | |
then | |
filename will be test.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
.alt { background-color:#F0F2FF; } | |
echo '<tr '.(!isset($alt) ? $alt = 0 : $alt++ % 2 == 0 ? 'class="alt"' : '').'>'; | |
#PHP |
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
This code will allow you to send a raw MongoDB query to the server and return back a record set. This will allow you to write queries as if you are writing them for the console. | |
// Connect to the MongoDB Database/Collection | |
// Enter your Database name and Collection Name | |
MongoCollection<BsonDocument> myMongoDB = new MongoClient("mongodb://localhost").GetServer().GetDatabase("Insert Database Name").GetCollection<BsonDocument>("Insert Collection Name"); | |
// Write your query as you would in the MongoDB console | |
var query = "{somefield : \"some value\"}"; // escape your double quotes inside the 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
tr:nth-child(even){ | |
color:blue; | |
} | |
tr:nth-child(odd){ | |
color:red; | |
} |
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
CREATE USER 'username'@'%' IDENTIFIED BY 'password'; | |
GRANT SELECT ON database.* TO 'username'@'%'; | |
GRANT INSERT ON database.* TO 'username'@'%'; | |
GRANT UPDATE ON database.* TO 'username'@'%'; |
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
Run Tests: | |
clear;./vendor/bin/phpunit | |
Create a new test: | |
php artisan make:test {Class}Test | |
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
<script src="https://cdn.jsdelivr.net/npm/vue"></script> | |
<script type="text/javascript"> | |
var formValidation = new Vue({ | |
el:'', | |
data:{ | |
}, | |
methods:{ | |
methodName: function (){ | |
} |
NewerOlder