Showing posts with label interview. Show all posts
Showing posts with label interview. Show all posts

task by hasone testdome

==


vuejs task
write the reoraderable list component . the component should recieve an array of elements as items prop and should displa the elements as list items in an unorderseed list
when the user click on a list item it should be sent to the first positionin the unordered list
for example if the component has the item prop ["A","B","C"], the list should look like:

<!DOCTYPE html> <html> <head> <title>Reorderable List</title> <script src="https://cdn.jsdelivr.net/npm/vue@2"></script> </head> <body> <div id="app"> <reorderable-list :items="['A', 'B', 'C']"></reorderable-list> </div> <script> Vue.component('reorderable-list', { props: ['items'], data() { return { list: [...this.items] }; }, methods: { moveToFirst(index) { const item = this.list.splice(index, 1)[0]; this.list.unshift(item); } }, template: ` <ul> <li v-for="(item, index) in list" :key="index" @click="moveToFirst(index)"> {{ item }} </li> </ul> ` }); new Vue({ el: '#app' }); </script> </body> </html>


== 

second task

convert a string of numbers to a sentnce .e ach number represents a aletter. numbers in  the string are seperated by  aspace. and words in the sentence are seperated by a plus characterf/

conversion table:

1 = A

2 =B

--

26 = Z


example numbe to letters (`20 15 19 20+4 15 13 5) should return 'test dome'


<?php function numberToLetters($string) { $conversionTable = [ 1 => 'A', 2 => 'B', 3 => 'C', 4 => 'D', 5 => 'E', 6 => 'F', 7 => 'G', 8 => 'H', 9 => 'I', 10 => 'J', 11 => 'K', 12 => 'L', 13 => 'M', 14 => 'N', 15 => 'O', 16 => 'P', 17 => 'Q', 18 => 'R', 19 => 'S', 20 => 'T', 21 => 'U', 22 => 'V', 23 => 'W', 24 => 'X', 25 => 'Y', 26 => 'Z' ]; $words = explode('+', $string); // Split string into words separated by '+' $result = []; foreach ($words as $word) { $letters = explode(' ', $word); // Split each word into numbers separated by spaces $wordResult = ''; foreach ($letters as $number) { if (isset($conversionTable[$number])) { $wordResult .= $conversionTable[$number]; } } $result[] = $wordResult; } return strtolower(implode(' ', $result)); // Convert result to a sentence in lowercase } // Example usage echo numberToLetters('20 5 19 20+4 15 13 5'); // Outputs: test dome ?>


echo numberToLetters('20 5 19 10+4 15 13 5');

===============================

implement the get view count method .it should accept a json 

a string and sum all vie wcount fields inside the json will alwyas hav ethe same structure as int he example case 

for example calling get view count should return 88270796 for the following $jsonstring 

{

  "apiVersion": "2.1",

  "videos": [

    {

      "id": "253",

      "category": "music",

      "title": "Jingle Bells",

      "duration": 457,

      "viewCount": 88270796

    }

  ]

}

==

<?php function getViewCount(string $jsonString): int { $data = json_decode($jsonString, true); $totalViewCount = 0; if (isset($data['videos']) && is_array($data['videos'])) { foreach ($data['videos'] as $video) { if (isset($video['viewCount'])) { $totalViewCount += $video['viewCount']; } } } return $totalViewCount; } $jsonString = ' { "apiVersion": "2.1", "videos": [ { "id": "253", "category": "music", "title": "Jingle Bells", "duration": 457, "viewCount": 88270796 } ] } '; echo getViewCount($jsonString); ?>


===

writea a function that removes all items that are not integers from the array the function should modify the existing aarray,nmot create a nbew one.

for example, if the input array containes values [1,'a,'b',2], after processing, the array will contain only values [1,2]

<?php function filterNumbersFromArray(array &$arr): void { foreach ($arr as $key => $value) { if (!is_int($value)) { unset($arr[$key]); } } } $arr = [1, 'a', 'b', 2]; filterNumbersFromArray($arr); print_r(array_values($arr)); ?>

==============


an education magazine pulbishee rankings of strudnetns and theire colleges in a acompetitoion in building unmmaned aerial vehical dornes. students whoi participated in the competion in different yeres, their ranking in the competion, and their colleges are contained inthe following tables;

table colleges 

id integer primary key

name varchar(50) not null


table students 

id integer primary key 

name varchar(50) not null 

collegeid integer

foreighn key (collegeid) references colleges(id)


table rankings 

studentid integer 

ranking integer not null

year integer not null

foreign key (studentid) references students(id)


write a query that lists all collges that have atleast one student with a ranking between 1 and 3 ( both inclusive) for the year 2015. the query should return 

the college name,

the rank of their best rnaking studnet for 21015.;

the numer of students who had rankings between 1 and 3 ( both inclusive) for the year 2015

rank 1 is the best rank, rank 2 is the second best an dso on . more than one student can tie for a rank in a ayear


SELECT
c.name AS college_name,
MIN(r.ranking) AS best_rank_2015,
COUNT(*) AS num_students_rank_1_to_3
FROM
rankings r
JOIN
students s ON r.studentid = s.id
JOIN
colleges c ON s.collegeid = c.id
WHERE
r.year = 2015
AND r.ranking BETWEEN 1 AND 3
GROUP BY
c.name;


=



=


As part of a data processing pipeline, complete the implementation of the make_pipeline method:

  • The make_pipeline method should accept a variable number of functions, and it should return a new function that accepts one parameter $arg.
  • The returned function should call the first function in make_pipeline with the parameter $arg, and call the second function with the result of the first function.
  • The returned function should continue calling each function in make_pipeline in order, following the same pattern, and return the value from the last function.

For example, calling make_pipeline(function($x) { return $x * 3; }, function($x) { return $x + 1; }, function($x) { return $x / 2; }), and then calling the returned function with 3 should return 5.

<?php

function make_pipeline(...$funcs)
{
return function ($arg) use ($funcs) {
$result =$arg;
foreach ($funcs as $func){
$result = $func($result);
}
return $result;
};
}

$fun = make_pipeline(
function ($x) {
return $x * 3;
},
function ($x) {
return $x + 1;
},
function ($x) {
return $x / 2;
}
);
echo $fun(3); # should print 5

===

App usage data are kept in the following table:

TABLE sessions
  id INTEGER PRIMARY KEY,
  userId INTEGER NOT NULL,
  duration DECIMAL NOT NULL

Write a query that selects userId and average session duration for each user who has more than one session.


SELECT userid, AVG(duration) AS avg_duration
FROM sessions
GROUP BY userid
HAVING COUNT(id) > 1;

=

questions:

what is abstract and what is interface

why we use abstaract

what is difference

why do we interface

wht is static method


where can use static, where can we declare static

solid principles

design pattern 

whtis service container and service provider

array methods 

what type of array in php supports

session and cookie

what is http only cookie

what is break and continue 

how can we handle exceptions

what is finally in php

whatr is composer

what is composer.lock

how to update the pacakge 

how can we update teh specific pakage

life cycke method in vuejs

how to bind the data 

what is v-model

event emitters

what is props and data functions 

hwo can we declare a method in vuejs

what is pure function in javascript


set time out and set interval

how to stop the setinterval

hosting in javascript

waht is closure in javacript

sql

what are join in sql

what is self join

what is inner  join

what is group by

what is indexing mechanism

what is composite index

aany experience in version control system and what is the workf low








task by vying softwares

i completed task for below questions, please check zip file
1, Create a script to import the csv file having the employee details into the DB and show them up in a web page.

2. Create programs to add/modify/delete of employee details with employee's manager into the DB and show them onto web page. Add csv export for employee details]

task by aqua web

 Test Project Description: You are tasked with building a job board application using Laravel. The application should allow users to post job listings, search for jobs, and apply for them. Requirements: 1. Job Listings: • Users should be able to create, read, update, and delete job listings. • Each job listing should have a title, description, company name, location, and job type (e.g., full-time, part-time, contract). • Implement pagination for displaying job listings. 2. User Authentication: • Users should be able to register, login, and logout. • Authentication should be implemented using Laravel's built-in authentication system. 3. Job Search: • Implement a search functionality that allows users to search for jobs based on keywords, location, or job type. • Display search results with relevant job listings. 4. Job Applications: • Users should be able to apply for job listings. • Upon applying, the user's application details (e.g., resume, cover letter) should be stored. 5. Email Notifications: • Send email notifications to users when they successfully post a job listing and when someone applies for their job listing. • Use Laravel's built-in mail functionality for sending emails. 6. Admin Panel: • Implement an admin panel where administrators can manage job listings and user applications. • Administrators should be able to view all job listings, approve/ delete job listings, and view job applications. Instructions: 1. Set up a new Laravel project. 2. Implement the necessary database tables, models, and relationships for job listings, users, and job applications. 3. Implement user authentication using Laravel's built-in authentication system. 4. Push your code to a public Git repository (e.g., GitHub) and provide the link to the repository. 5. Include clear instructions on how to run the project locally and any necessary setup steps in the README file. 6. Document any assumptions you made during development and any additional features or improvements you would make given more time.

task by momentum

 Please complete the below requirements

  1. The user has a company and the company has multiple fields
    1. Name
    2. Business Category
    3. Link
    4. Phone
    5. Email
    6. Website
    7. Country
    8. Address
    9. Postal code
  2. The task is adding 5 extra dynamic fields in the form
  3. Label and values can be editable in dynamic and static fields
  4. Save values in the company table in Laravel
  5. After saving labels, values and new extra fields show on the company update page

most frequently asked sql interview questions

 


























interview questions in sql

 what is ht ebasic tstructure osf a select statement in sql

how can you prevent sql injection attacks

can you write a sql query to find the top 5 cutomers based on their purchase history

list two common aggretgte functioions used ins qsl

differentiate between union and union all for combining datasets

what are subqueries and how canyou use them in sql statements

how to sort data in asecnding order and decending order using order by

how to group data and aply aggregate functions (count, sum, avg) using group by

how do you filter data based on specifi condtions using where clause

how do you join multiple tables in sql,explain different data types

what is the basic structure of a select statemen in sql


service providers and service containers

 Hello artisan, PHP is the most used server-side programming language on the web. In fact, 75 to 77% of all websites rely on PHP to some degree. And Laravel is one of the most popular framework based on PHP language.

Laravel provides lots of pre build features that user can use easily, Today in this article I’ll explain main difference between Service Container and Service Provider.

As per official definition from Laravel,

  • Service Container is a powerful tool for managing class dependencies and performing dependency injection.
  • Service Providers are the central place of all Laravel application bootstrapping. Your own application, as well as all of Laravel’s core services, are bootstrapped via service providers.

Now let’s understand both in detail,

  1. Service Container:

Service container is the place where your services are registered.

Laravel comes with a powerful IoC container, known as the service container. In Laravel application, the app instance is the container. The app() helper also returns an instance of the container.

It has basically three methods bind(), make() and singleton() used for binding servicesretrieving services and binding class as a singleton respectively.

Let’s understand this methods by example:

app()->bind('App\Interfaces\NewPostMailService', function() {
return new App\Services\NewPostMailService();
});
dd(app()->make('App\Interfaces\NewPostMailService'), app()->make('App\Interfaces\NewPostMailService'));==> Above line will return you two different instances.
--------------------------------------------------------------------
app()->singleton('App\Interfaces\NewPostMailService', function() {
return new App\Services\NewPostMailService();
});
dd(app()->make('App\Interfaces\NewPostMailService'), app()->make('App\Interfaces\NewPostMailService'));==> Above line will return you same instance because it is registered as singleton.

You can bind any custom services you want in container.

Now where will you put all of these method calls or bindings? The solution is the Service Provider. Let’s understand what is Service Provider.

2. Service Provider:

Service providers provide services by adding them to the container.

In Laravel Service Providers are located in app/Providers Directory.

By default every Laravel project comes with 5 Service Provider, out of them AppServiceProvider is empty class where you can register you binding in register() method.

Each Service Provider has 2 default method register() and boot().

register() method is used for registering new services to the application.

Best custom use of register method is implementation of Repository pattern.

public function register() 
{
$this->app->bind(OrderRepositoryInterface::class, OrderRepository::class);
}

boot() method is used for the bootstrapping the registered service, This method is called after all other service providers have been registered.

Best use case of boot() method is View Composers.

public function boot()
{
View::composer('view', function () {
// Add data here
});
}

That’s it! If you have any other questions, please feel free to leave your thoughts in the comments below and don’t forget to clap if you liked it!

17

The Service container is the place our application bindings are stored. And service providers are the classes where we register our bindings to the service container. In older releases of Laravel, we didn't have these providers and developers were always asking where to put the bindings. And the answer was confusing: "Where it makes the most sense."(!) Then, Laravel introduced these service providers and the Providers directory to make things more consistent.

Here is a basic example:

interface AcmeInterface {
    public function sayHi();
}

class AcmeImplementation implements AcmeInterface {
    public function sayHi() {
        echo 'Hi!';
    }
}

// Service Container
$app = new \Illuminate\Database\Container;

// Some required stuff that are also service providing lines 
// for app config and app itself.

$app->singleton('app', 'Illuminate\Container\Container');
$app->singleton('config', 'Illuminate\Config\Repository');

// Our Example Service Provider
$app->bind(AcmeInterface::class, AcmeImplementation::class);

// Example Usage:
$implementation = $app->make(AcmeInterface::class);
$implementation->sayHi();

As you can see:

  • first, we create the container (in real life, Laravel does this for us inside bootstrap/app.php),
  • then, we register our service (inside our Service Provider classes, and config/app.php),
  • and finally, we get and use our registered service. (inside controllers, models, services, etc.)


Service container is where your services are registered.

Service providers provide services by adding them to the container.


 

By reference of Laracast. Watch out to get understand.

Service containerhttps://laracasts.com/series/laravel-from-scratch-2017/episodes/24

Service providershttps://laracasts.com/series/laravel-from-scratch-2017/episodes/25



vel, the Service Container is a powerful tool for managing class dependencies and performing dependency injection. It's essentially a registry for all the services (dependencies) used within your application. Let's walk through an example to understand how the Service Container works and how dependencies are registered and resolved.

Let's say we have a simple Laravel application where we want to create a service that calculates the area of a rectangle. We'll create a service provider to register this service and use the Service Container to resolve and use it.

  1. Create a Service Provider:

    First, let's create a service provider using Artisan:

    bash
    php artisan make:provider RectangleAreaServiceProvider

    This will generate a new service provider file RectangleAreaServiceProvider.php in the app/Providers directory.

  2. Define the Service:

    In the RectangleAreaServiceProvider.php file, define the service and register it in the register method of the provider:

    php
    <?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use App\Services\RectangleAreaCalculator; class RectangleAreaServiceProvider extends ServiceProvider { public function register() { $this->app->bind('rectangleArea', function ($app) { return new RectangleAreaCalculator(); }); } }

    Here, we're binding the rectangleArea key to an instance of RectangleAreaCalculator in the Service Container.

  3. Create the Service Class:

    Next, create the RectangleAreaCalculator class in the app/Services directory:

    php
    <?php namespace App\Services; class RectangleAreaCalculator { public function calculate($length, $width) { return $length * $width; } }

    This class contains a calculate method that calculates the area of a rectangle based on its length and width.

  4. Use the Service:

    Now, you can use the rectangleArea service anywhere in your application. For example, in a controller:

    php
    <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Services\RectangleAreaCalculator; class RectangleController extends Controller { public function calculateArea(Request $request, RectangleAreaCalculator $rectangleArea) { $length = $request->input('length'); $width = $request->input('width'); $area = $rectangleArea->calculate($length, $width); return response()->json(['area' => $area]); } }

    In this controller method, we inject the RectangleAreaCalculator service using Laravel's automatic dependency injection. The calculateArea method takes the length and width of a rectangle from the request and calculates its area using the injected service.

  5. Register the Service Provider:

    Finally, register the RectangleAreaServiceProvider in the config/app.php file under the providers array:

    php
    'providers' => [ // Other providers... App\Providers\RectangleAreaServiceProvider::class, ],

    This tells Laravel to load and use our custom service provider.

Now, when you call the calculateArea endpoint in your application, Laravel will automatically resolve the RectangleAreaCalculator service from the Service Container and use it to calculate the area of a rectangle.

AI Tools

 Midjourney oter.ai aiva googlegemin dall-e copilot jasper copilot openaiplayground