Skip to content

Instantly share code, notes, and snippets.

View kamrankr's full-sized avatar

kamran adil kamrankr

  • Dubai, United Arab Emirates
View GitHub Profile
<?php
function sum($a, $b): float {
return $a + $b;
}
// Note that a float will be returned.
var_dump(sum(1, 2));
?>
@kamrankr
kamrankr / nginx-subdomain-and-multiple-domains.conf
Last active August 11, 2022 03:02
how to configure Nginx for multiple domains and sundomains on Ec2 instance with default amazon ami
server
{
server_name mysite.com; #first domain
root /var/www/html;
index index.php index.html index.htm;
error_page 404 /404.html;
location /
{
try_files $uri $uri/ /index.php?q=$uri&$args; # this rewrite rule is for wordpress blog
}
listen = 127.0.0.1:9000
;listen = /var/run/php-fpm/php-fpm.sock #uncomment this if you want to use socket instead of port
;listen.owner = nobody
listen.owner = nginx
;listen.group = nobody
listen.group = nginx
;listen.mode = 0666
listen.mode = 0664
user = nginx
group = nginx
server
{
root /var/www/html;
location /
{
index index.php index.html index.htm;
}
location ~ \.php$
{
fastcgi_pass 127.0.0.0.1:9000
/*
* Write a function that will return the
* count of distinct case-insensitive alphabetic
* characters that occur more than once in the
* given string. The given string can be
* assumed to contain only uppercase and
* lowercase alphabets.
*
* @Input: a string
* @Output: the number of unique characters that appear more than once
<?php
$polynomial = array (1,1,0,1); // x^3+x+1
$derivative = array();
for ($i = 1 ; $i < count($polynomial); $i++ )
{
$derivate = $i * $polynomial[$i];
$index = $i - 1;
if ( $index > -1 )
{
$derivative[$index] = $derivate;
@kamrankr
kamrankr / polymorphism.php
Last active May 22, 2023 22:16
simplest Polymorphism example in Php
<?php
/* simplest Polymorphism example in Php */
abstract class Animal
{
static function makeSound(Animal $animal)
{
return $animal->getsound();
}
}
@kamrankr
kamrankr / singleton.php
Last active May 22, 2023 22:17
Php Singleton example
<?php
class Mysingleton
{
private static $instance;
private function __construct()
{}
public static function getInstance()
{
if ( self::$instance == NULL )