Skip to content

Instantly share code, notes, and snippets.

View Vijaysinh's full-sized avatar
🌶️
Working from home

Vijaysinh Parmar Vijaysinh

🌶️
Working from home
View GitHub Profile
@Vijaysinh
Vijaysinh / timezones_array.php
Created May 13, 2022 18:15 — forked from pavellauko/timezones_array.php
Time zones as arrays (PHP)
<?php
$timezones = array(
'America/Adak' => '(GMT-10:00) America/Adak (Hawaii-Aleutian Standard Time)',
'America/Atka' => '(GMT-10:00) America/Atka (Hawaii-Aleutian Standard Time)',
'America/Anchorage' => '(GMT-9:00) America/Anchorage (Alaska Standard Time)',
'America/Juneau' => '(GMT-9:00) America/Juneau (Alaska Standard Time)',
'America/Nome' => '(GMT-9:00) America/Nome (Alaska Standard Time)',
'America/Yakutat' => '(GMT-9:00) America/Yakutat (Alaska Standard Time)',
'America/Dawson' => '(GMT-8:00) America/Dawson (Pacific Standard Time)',
@Vijaysinh
Vijaysinh / gemproducts.js
Last active May 11, 2022 11:27
gemproducts
var title = [];
var price = [];
for(i=1;i<=10;i++){
console.log(i);
$.ajax({
url: "https://mkp.gem.gov.in/home/search?q[]=gym&page="+i+"&_xhr=1",
type: 'POST',
async: false,
success: function(data) {
@Vijaysinh
Vijaysinh / insertGoogleAdsLocation.php
Created December 18, 2021 14:15
insertGoogleAdsLocation
<?php
$csv = "geotargets-2021-11-01.csv";
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB', 'adwords');
define('DB_HOST','localhost');
$bd = mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB) or die("Could not connect database");
$handle = fopen($csv, "r");
@Vijaysinh
Vijaysinh / RecursiveParentChild.php
Created October 21, 2021 09:23
RecursiveParentChild.php
<?php
$arr = '[{"id":8,"parent":4,"name":"Food & Lifestyle"},{"id":2,"parent":1,"name":"Mobile Phones"},{"id":1,"parent":0,"name":"Electronics"},{"id":3,"parent":1,"name":"Laptops"},{"id":5,"parent":4,"name":"Fiction"},{"id":4,"parent":0,"name":"Books"},{"id":6,"parent":4,"name":"Non-fiction"},{"id":7,"parent":1,"name":"Storage"}]';
$t = buildTree($arr);
print_r($t);
function buildTree(array $flatList)
{
@Vijaysinh
Vijaysinh / InterfaceSegregationPrinciple.php
Last active September 16, 2021 13:15
SOLID - InterfaceSegregationPrinciple PHP
<?php
interface VehicleInterface {
public function drive();
public function fly();
}
class FutureCar implements VehicleInterface {
public function drive() {
echo 'Driving a future car!';
}
public function fly() {
<?php
//Dependency Inversion SOLID Principle
interface DBConnectionInterface {
public function connect();
}
class MySQLConnection implements DBConnectionInterface {
public function connect() {
@Vijaysinh
Vijaysinh / jenkins.template
Created September 3, 2021 02:39 — forked from JosephMaxwell/jenkins.template
Jenkins CloudFormation Template (more information and tutorial videos at https://swiftotter.com/technical/running-jenkins-on-amazon-ec2-with-cloudformation)
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Launches a Jenkins server.",
"Parameters": {
"InstanceType": {
"Description": "EC2 instance type",
"Type": "String",
"Default": "t2.small",
"AllowedValues": [
"t1.micro",
@Vijaysinh
Vijaysinh / RDS-Aurora-CloudFormation-Example.yaml
Created August 27, 2021 10:01 — forked from sjparkinson/RDS-Aurora-CloudFormation-Example.yaml
A basic CloudFormation template for an RDS Aurora cluster.
---
AWSTemplateFormatVersion: 2010-09-09
Description: >
A basic CloudFormation template for an RDS Aurora cluster.
Parameters:
DatabaseUsername:
AllowedPattern: "[a-zA-Z0-9]+"
ConstraintDescription: must be between 1 to 16 alphanumeric characters.
@Vijaysinh
Vijaysinh / myclass.php
Created August 25, 2021 12:42
Count How many time class instance got created
<?php
// Count How many time class instance got created
class classA {
public static $counter = 0;
function __construct(){
self::$counter++;
}
@Vijaysinh
Vijaysinh / AWS_S3_Presign_Download.php
Created August 6, 2021 07:16 — forked from anthonyeden/AWS_S3_Presign_Download.php
AWS S3: Pre-sign Upload & Download Requests [PHP]
<?php
function AWS_S3_PresignDownload($AWSAccessKeyId, $AWSSecretAccessKey, $BucketName, $AWSRegion, $canonical_uri, $expires = 8400) {
// Creates a signed download link for an AWS S3 file
// Based on https://gist.github.com/kelvinmo/d78be66c4f36415a6b80
$encoded_uri = str_replace('%2F', '/', rawurlencode($canonical_uri));
// Specify the hostname for the S3 endpoint
if($AWSRegion == 'us-east-1') {