Skip to content

Instantly share code, notes, and snippets.

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

Nipun Tharuksha nipunTharuksha

🏠
Working from home
View GitHub Profile
@sedera-tax
sedera-tax / quadraticEquation.php
Created January 15, 2021 13:41
3. Quadratic Equation Implement the function findRoots to find the roots of the quadratic equation: ax2 + bx + c = 0. The function should return an array containing both roots in any order. If the equation has only one solution, the function should return that solution as both elements of the array. The equation will always have at least one sol…
<?php
/**
* @return array An array of two elements containing roots in any order
*/
function findRoots($a, $b, $c)
{
$delta = ($b * $b) - 4 * ($a * $c);
$x = (- $b - sqrt($delta)) / (2 * $a);
$y = (- $b + sqrt($delta)) / (2 * $a);
return [$x, $y];
@Faizanq
Faizanq / Indian States and Cities list in php
Last active March 7, 2023 07:19
Indian States and Cities array list in php
<?php
return [
'Andhra Pradesh (AP)'=>[
'Adilabad',
'Anantapur',
'Chittoor',
'Kakinada',
'Guntur',
@shandanjay
shandanjay / sl_mobile_num.php
Last active January 21, 2021 04:51
Sri Lanka Mobile number validation in PHP
<?php
$a = '+94715753168';
$b = '0715753168';
$c = '715753168';
$d = '0094715753168';
$e = '094-71-5-753-168';
is_lk_mobile($a); //true
is_lk_mobile($b); //true
is_lk_mobile($c); //true
@emmanuelbarturen
emmanuelbarturen / testing mail in droplet with laravel
Created November 3, 2017 23:12
send email from artisan with tinker of laravel
# SSH into droplet
# go to project
$ php artisan tinker
$ Mail::send('errors.401', [], function ($message) { $message->to('emmanuelbarturen@gmail.com')->subject('this works!'); });
# check your mailbox
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
@keithweaver
keithweaver / domain-to-aws-ec2-instance.md
Created March 20, 2017 23:49
Point Domain to Amazon Web Services (AWS) EC2 Instance

Point Domain to Amazon Web Services (AWS) EC2 Instance

  1. Open the Amazon Route 53 console at https://console.aws.amazon.com/route53/.
  2. If you are new to Amazon Route 53, you see a welcome page; choose Get Started Now for DNS Management. Otherwise, choose Hosted Zones in the navigation pane.
  3. Choose Create Hosted Zone.
  4. For Domain Name, type your domain name.
  5. Choose Create.
  6. Click the Hosted Zone, edit record set.
  7. In the value, add ec2-54-152-134-146.compute-1.amazonaws.com.
  8. Change your DNS file to point to the IPv4 address (This would be in something like GoDaddy).
@parmentf
parmentf / GitCommitEmoji.md
Last active September 19, 2024 17:12
Git Commit message Emoji
@danrovito
danrovito / countrydropdown.html
Last active September 20, 2024 07:41
HTML Country Select Dropdown List
<label for="country">Country</label><span style="color: red !important; display: inline; float: none;">*</span>
<select id="country" name="country" class="form-control">
<option value="Afghanistan">Afghanistan</option>
<option value="Åland Islands">Åland Islands</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
@djaiss
djaiss / gist:2938259
Created June 15, 2012 19:13
PHP List of countries
<?php
$countries =
array(
"AF" => "Afghanistan",
"AL" => "Albania",
"DZ" => "Algeria",
"AS" => "American Samoa",
"AD" => "Andorra",
"AO" => "Angola",
@boogah
boogah / .htaccess
Created February 16, 2012 04:59
Expire headers .htaccess code.
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"