Snippets Collections
#include<iostream>
using namespace std;
int main()
{
    float gross ,basic,hra,da;
    cout<<"enter basic salary of an employee:";
    cin>>basic;
    
        if(basic<25000)
    {
        da=basic*80/100;
        hra=basic*20/100;
    }    
    else if(basic>=25000&&basic<40000)
    {
        da=basic*90/100;
        hra=basic*25/100;
    }
    else if (basic>40000)
    {
        da=basic*95/100;
        hra=basic*30/100;
    }
    gross=basic+hra+da;
    cout<<"\n\tbasic pay..........."<<basic<<endl;
    cout<<"\tdearness allowance........."<<da<<endl;
    cout<<"\thouse rent allowance..........."<<hra<<endl;
    cout<<"\t----------------------------------"<<endl;
    cout<<"\tgross salary.................."<<gross<<endl;
    cout<<"\t-------------------------------------"<<endl;
    return 0;
    
    
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    <TextView
        android:id="@+id/text_view_id"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="hello" />
</LinearLayout>
---------------------------------------------------------------------------------
// With Vertical Orientation
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:layout_weight="1">
        <Button
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="One" />
        <Button
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="TWO" />
        <Button
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Three" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="One"
            android:textSize="20pt"
            android:background="#aaaa00"
            />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Two"
            android:textSize="20pt"
            android:background="#aa0000"
            />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Three"
            android:textSize="20pt"
            android:background="#00aa00" 
            />
    </LinearLayout>
    </LinearLayout>
------------------------------------------------------------------------------------------------------------
// With Horizontal Orientation
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
        <TextView
            android:layout_width="105px"
            android:layout_height="fill_parent"
            android:text="Red"
            android:background="#aa0000"
            />
        <TextView
            android:layout_width="95px"
            android:layout_height="450px"
            android:text="Green"
            android:background="#00aa00"
            />
        <TextView
            android:layout_width="85px"
            android:layout_height="350px"
            android:text="Yellow"
            android:background="#ffff00"
            />
        <TextView
            android:layout_width="75px"
            android:layout_height="250px"
            android:text="Light Yellow"
            android:background="#aaaa00"
            />
    </LinearLayout>

----------------------------------------------------------------------------------------------------------
Example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
    <Button
        android:id="@+id/backbutton"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Back" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="First Name"
            />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="100px"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Last Name"
            />
        <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="100px"
        />
    </LinearLayout>

------------------------------------------------------------------------------------
Example_2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <Button
        android:id="@+id/backbutton"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Back" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="First Name" />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="100px" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Last Name"
            />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="100px"
            />
    </LinearLayout>
</LinearLayout>
------------------------------------------------------------------------------------
Absolute Layout 

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:layout_x="110px"
        android:layout_y="110px"
        android:text="User Name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <EditText
        android:layout_x="250px"
        android:layout_y="80px"
        android:width="100px"
        android:layout_width="200dp"
        android:layout_height="wrap_content" />
    <TextView
        android:layout_x="110px"
        android:layout_y="200px"
        android:text="Password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <EditText
        android:layout_x="250px"
        android:layout_y="150px"
        android:width="100px"
        android:layout_width="200dp"
        android:layout_height="wrap_content" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Log In"
        android:layout_x="300px"
        android:layout_y="300px"/>
</AbsoluteLayout>

---------------------------------------------------------------------------------------------------------------------------

Frame_Layout without gravity attribute

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
    <TextView android:text="LeftTop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="RightTop" />
    <TextView android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="CentreTop" />
</FrameLayout>


Frame_Layout with gravity attribute

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
    <TextView android:text="LeftTop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="RightTop"
        android:layout_gravity="top|right" />
    <TextView android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="CentreTop"
        android:layout_gravity="top|center_horizontal" />
</FrameLayout>

--------------------------------------------------------------------------------------
Relative Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!--Text View for Displaying SIGN IN Text At Top of UI-->
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="SIGN IN"
        android:id="@+id/textView3"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />
    <!--Text View for Displaying Username-->
    <TextView
        android:id="@+id/userName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="110dp"
        android:text="UserName:"
        android:textColor="#000000"
        android:textSize="20sp" />
    <!--Text View for Displaying Password-->
    <TextView
        android:id="@+id/password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/userName"
        android:text="Password:"
        android:textColor="#000000"
        android:textSize="20sp" />
    <!--Edit Text for Filling Username-->
    <EditText
        android:id="@+id/edt_userName"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_marginTop="100dp"
        android:layout_toRightOf="@+id/userName"
        android:hint="User Name" />
    <!--Edit Text for Filling Password-->
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_below="@+id/edt_userName"
        android:layout_toRightOf="@+id/password"
        android:hint="Password" />
    <!--Button for Clicking after filling details-->
    <Button
        android:id="@+id/btnLogin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/password"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:background="#03B424"
        android:text="Login"
        android:textColor="#ffffff"
        android:textStyle="bold" />
</RelativeLayout>
-------------------------------------------------------------------------------------------------
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1">
    <TableRow
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="USER_NAME" />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
    </TableRow>
    <TableRow
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="PASSWORD" />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </TableRow>
    <TableRow
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <CheckBox
            android:id="@+id/checkBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Pizza" />
        <RadioButton
            android:id="@+id/radioButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </TableRow>
    <TableRow >
        <Button
            android:id="@+id/loginBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="login"
            android:textStyle="bold" />
    </TableRow>
</TableLayout>
----------------------------------------------------------------------------------------------------------------------------------------
 function marks(a,b)
    {
        return a+b;
    }
    c=marks(2,3)
    console.log(c)
In controller
1. $customers= Customer::paginate(10);

Then after foreach and table
 <div class="d-flex justify-content-center">
        {{ $customers->links() }}
 </div>
2. Then youcan view pagination but unable to properly format
3. Then execute the following command
php artisan vendor:publish
tyhen select the laravel pagination
4. Then in AppServiceProvider.php enter the following code in the header
use Illuminate\Pagination\Paginator;

and in the metod boot(): void enter the following code
Paginator::useBootstrap();
#include <iostream>
using namespace std;

int main()
{
    int *p;
    p= new int[5];  
    //will allocate memory for 5 integers, so it is an array of integers and it is assigned to p
    
    //initializing the values
    p[0] = 10;
    p[1] = 20;
    p[2] = 30;
    p[3] = 40;
    p[4] = 50;

    
    for(int i=0; i<5; i++)
      cout << p[i] << endl;
   
  	delete [] p;   //to delete an array, first use square brackets and the the name of the variable 		to be deleted
  return 0;
}
#include <iostream>
using namespace std;

int main()
{
    int *p;
    p= (int *)malloc(5*sizeof(int));  
    //will allocate memory for 5 integers, so it is an array of integers and it is assigned to p
    
    //initializing the values
    p[0] = 10;
    p[1] = 20;
    p[2] = 30;
    p[3] = 40;
    p[4] = 50;

    
    for(int i=0; i<5; i++)
    {
        cout << p[i] << endl;
    }
    
    return 0;
}
 var mark={
        ravi:30,rahuk:90
    }
    console.log(mark);
1. First of all enter a attribute in the form tag to upload/save image or file
<form enctype="multipart/form-data">
</form>
2. Now to store image in blade write the following input
<input type="file" name="myImage">
3. Then in the controller in store method write the followinig code
if ($request->hasFile('myImage')) {
            $imageName = time().'.'.$request->file('myImage')->getClientOriginalExtension(); 
  ////////////////////It store the image/file to the storage/app/public folder//////////////
            $request->file('myImage')->storeAs('public', $imageName);
            $customer->image = $imageName;
        }

///////////////////Unable to file from storage/app/public folder./////////////////////////
#include <iostream>
using namespace std;

int main()
{
  int A[5] = {10,20,30,40,50};
  int *p , *ptr;
  p = A; 
  ptr = &A[0];
/*
no need to give the ampersand(&) when we are giving array name to the pointer, because name of an array A itself is the starting address of this array. So, p is the pointer so, it can store the address.
If we want to use ampersand(&) then we should say A of zero, A[0] means this to 10, A[0] is 2 and its address, then you should write the address.
*/
  
for (int i=0; i<5; i++)
{
    cout << A[i] << endl;
    //To access the values using pointer instead of array name:
    // cout << p[i] << endl;
}
  
  return 0;
}
1. Make resource controller with the following command
php artisan make:controller CustomerController -r
2. There are now following routes generated
3. Then in web.php file make a base route for CustomerController with
  Route::resource('/customers', CustomerController::class);
route('customers.index')
route('customers.store')
route('customers.edit')
route('customers.update')
route('customers.destroy')
4. Now First of all show data in index by click the route button
<a href="{{route('customers.index')}}">Cutomer List</a>
5. Now create a button to create a new customer
<a href="{{{{route('customers.create')}}}}"></a>
6. now create page of new cutomer form
<form method="post" action= "{{route('customers.create')}}" enctype="multipart/form-data">
  @csrf
  <label for="name">Name</label>
  <input type="text" name="name">
    
    <input type="submit">
</form>
7. Now in controller enter the following code in store method in CustomerController
$customer = new Customer;
$customer->name = $customer->name;
$result = $customer->save();
if($result)
  {
    return redirect()->route('customers.index')->with('success', 'Record Saved Successfully');
  }
else
  {
    return redirect()->route('customers.index')->with('success', 'Unable to Save');
  }
8. Now create a button to edit the data
<a href="{{route('customers.edit')}}">Edit Customer</a>
9. Now in the edit blade file enter the following code
<form method="post" action= "{{route('customers.update', $customer->id)}}" enctype="multipart/form-data">
  @csrf
  @method('put')
  <label for="name">Name</label>
  <input type="text" name="name" value="{{$customer->name}}">
  <input type="submit">
</form>
10. Now enter the following code in update method of CustomerController
$customer = Customer::find($id);
$customer->name = $customer->name;
$result = $customer->update();
if($result)
  {
    return redirect()->route('customers.index')->with('success', 'Record Saved Successfully');
  }
else
  {
    return redirect()->route('customers.index')->with('success', 'Unable to Save');
  }
10. Now create a delete button on the index view
<form method="post" action="{{route('customers.destroy', $customer->id)}}">
 <button onclick="return confirm('Are you sure to Delete?')" type="submit">Delete</button>
</form>
11. Now in the destroy method enter the following code
	$customer = Customer::find($id);
        $result = $customer->delete();
        if($result)
        {
            return redirect()->route('customers.index')->with('success', 'Record deleted Successfully');
        }
        else
        {
            return redirect()->route('customers.index')->with('success', 'Unable to Delete Record');
        }
<html>
<head>
<style>
* {
  box-sizing: border-box;
}

.column {
  float: left;
  width: 50%;
  padding: 10px;
  text-align:center;
}

.row:after {
  content: "";
  display: table;
  clear: both;
}
a{
  text-decoration: none;
  }
</style>
</head>
<body>

<div class="row">
  <div class="column" >

    <h2>Reserve from Dun Laogharie</h2>
 <a href="#">Reservation</a>
  

  </div>
  <div class="column">
   <h2>Reserve from Kimmage</h2>
 <a href="#">Reservation</a>
  </div>
</div>

</body>
</html>
#include <iostream>
using namespace std;

int main()
{
  int a = 10;
  int *p;
  p = &a;
  
  cout << "value of a : " << a << endl;
  cout << "using pointer : " << *p << endl;
  cout << "address of a : " << &a << endl;
  cout << "address of a using pointer: " << p << endl;
  
  return 0;
}
    backdrop-filter: blur(5px);
https://www.canvasartbar.ca/artists
Console.WriteLine("Välkommen till min meny!");

bool minBool = true;
while (minBool)
{
    Console.WriteLine("[1] Spara din siffra");
    Console.WriteLine("[2] Skriv ut din sparade siffra");
    Console.WriteLine("[3] Nollställ din siffra");
    Console.WriteLine("[4] Avsluta programmet");

    int input = Convert.ToInt32(Console.ReadLine());
    int sparadSiffra = 0;
    if (input == 1)
    {
        Console.WriteLine("Skriv siffran du vill spara");
        sparadSiffra = Convert.ToInt32(Console.ReadLine());
    }
    if (input == 2)
    {
        Console.WriteLine("Din sparade siffra är: " + sparadSiffra);
    }
    if (input == 3)
    {
        sparadSiffra = 0;
        Console.WriteLine("Din siffra är nollställd!");
    }
    else if (input == 4)
    {
        Console.WriteLine("Avslutar programmet");
        minBool = false;
    }
<select name="company_id" id="" class="form-control">
                    <option value="">Select Company</option>
                    @foreach ($companies as $company)
                        <option value="{{$company->id}}" {{($company->id == $employee->company_id) ? 'selected': ''}}>{{$company->name}}</option>
                    @endforeach
                </select>
import { catchError, EMPTY, Observable, switchMap, throwError } from 'rxjs';
import { AuthenticationService } from '../authentication.service';
import { UserService } from '../user.service';

@Injectable({
  providedIn: 'root',
})
export class AuthInterceptorService implements HttpInterceptor {
  constructor(private injector: Injector) {}
  intercept(
    req: HttpRequest<any>,
    next: HttpHandler
  ): Observable<HttpEvent<any>> {
    //this request should handle request if token is expired:
    //use a flag like "retry" if i should retry

    const reqClone = req.clone({ headers: req.headers.delete('skip', 'true') });

    return next.handle(reqClone).pipe(
      catchError((err) => {
        if (err.status === 401) {
          return this.handleRefreshToken(req, next);
        }
        return EMPTY;
      })
    );
  }

  handleRefreshToken(
    req: HttpRequest<any>,
    next: HttpHandler
  ): Observable<HttpEvent<any>> {
    const authService = this.injector.get(AuthenticationService); // approfondisci sta cosa
    return authService.refresh().pipe(
      switchMap((resp) => {
        return next.handle(req); // ripeto la richiesta con il sessiontoken fresco
      })
    );
  }
}

import { Injectable } from '@angular/core';
import {
  BehaviorSubject,
  catchError,
  EMPTY,
  filter,
  map,
  shareReplay,
  tap,
} from 'rxjs';
import { HttpClient } from '@angular/common/http';

import { IUser, IUserSignup } from '../models/user/user';
import { environment } from 'src/environments/environment';
import { LoginRequest } from '../models/login/login.request';
import { LoginResponse } from '../models/login/login.response';

const anonimous_USER: IUser = {
  email: '',
  username: '',
  id: '',
  roles: [],
};

@Injectable({
  providedIn: 'root',
})
export class AuthenticationService {
  private BASE = environment.base;
  private SIGNUP_URL = `${this.BASE}${environment.signupURL}`;
  private LOGOUT_URL = `${this.BASE}${environment.logout}`;
  private LOGIN_URL = `${this.BASE}${environment.login}`;
  private USER_URL = `${this.BASE}${environment.user}`;
  private REFRESH_URL = `${this.BASE}${environment.refresh}`;

  private ADMIN_AS_USER_URL = `${this.BASE}${environment.admin}${environment.loginAsUser}`;
  private subject = new BehaviorSubject<IUser | undefined>(anonimous_USER);
  public user$ = this.subject.pipe(filter((user) => Boolean(user)));
  public isLoggedIn$ = this.user$.pipe(map((user) => Boolean(user?.id)));
  public isLoggedOut$ = this.isLoggedIn$.pipe(map((loggedIn) => !loggedIn));

  constructor(private http: HttpClient) {
    this.getUserSession().subscribe((user) => this.subject.next(user));
  }

  signup(user: IUserSignup) {
    return this.http
      .post<IUser>(this.SIGNUP_URL, user, {
        headers: { skip: 'true' },
      })
      .pipe(
        shareReplay(),
        tap((user) => {
          console.log(user);
          this.subject.next(user);
        })
      );
  }
  getUserSession() {
    return this.http
      .get<IUser | undefined>(this.USER_URL, {
        headers: { skip: 'true' },
      })
      .pipe(shareReplay());
  }

  logout() {
    return this.http
      .post(this.LOGOUT_URL, null, { headers: { skip: 'true' } })
      .pipe(
        shareReplay(),
        tap(() => {
          this.subject.next(anonimous_USER); // emetto un utente nullo
        })
      );
  }

  login(loginRequest: LoginRequest) {
    return this.http
      .post<LoginResponse>(this.LOGIN_URL, loginRequest, {
        headers: { skip: 'true' },
      })
      .pipe(
        shareReplay(),
        tap((user) => {
          this.subject.next(user);
        })
      );
  }

  loginAsUser(userEmail: string) {
    return this.http
      .post<LoginResponse>(
        this.ADMIN_AS_USER_URL,
        { email: userEmail },
        {
          headers: { skip: 'true' },
        }
      )
      .pipe(
        shareReplay(),
        tap((user) => {
          this.subject.next(user);
        })
      );
  }

  refresh() {
    const email = this.subject.value?.email;
    return this.http.post(this.REFRESH_URL, { email: email || '' }).pipe(
      tap({
        error: (err) => {
          console.log(err);
        },
      }),
      shareReplay(),
      catchError(() => {
        return EMPTY; // non voglio che fa nulla se c'è un errore
      })
    );
  }
}
function reverseWords(str) {
let reverseWords = str.split(" ")
.map(word => word.split("").reverse().join(""))
return reverseWords.join(" ")
}
spl = "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon"
print(spl.split(","))
str = "Ai For All"
print(str.capitalize())
print(str.title())
print(str.swapcase())
str1 = "Thirty "
str2 = "Days "
str3 = "Of "
str4 = "Code "
concatenate_str = str1 + str2 + str3 + str4
print(concatenate_str)
@Injectable({ providedIn: 'root' })
export class PermissionsService {
  isAdmin(isAdmin: boolean) {
    return isAdmin;
  }
}

export const canActivate = (isAdmin: boolean, permissionService = inject(PermissionsService)) => permissionService.isAdmin(isAdmin);

export const APP_ROUTES: [{
  path: 'dashboard',
  canActivate: [() => canActivate(true)],
  loadComponent: () => import('./dashboard/admin.component'),
 }]
<a href="[id-fiche]pagelibre;51449165;0[/id-fiche]#KLINK" _linktype="interne"><span class="button alert"><img src="/servlet/com.univ.utils.LectureImageToolbox?TAG=[id-image]4931[/id-image]" style="width:25px;height:25px;float:left;margin : 0px 10px;" alt="[legende-image]4931[/legende-image]" title="[title-image]4931[/title-image]" />INFORMATIONS CORONAVIRUS <span style="font-size:0.6em;color:black;">MAJ le 14/03/22 </span></span></a>
/*
First create your Service that you want to inject using the custom token
*/

import {tap, first, map} from 'rxjs/operators';

import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from "@angular/router";
import {Observable} from "rxjs";
import {AuthService} from "./auth.service";
import * as _ from 'lodash';
import {Injectable} from "@angular/core";

@Injectable()
export class AuthorizationGuard implements  CanActivate {


    constructor(private allowedRoles:string[],
                private authService:AuthService, private router:Router) {

    }


    canActivate(
        route: ActivatedRouteSnapshot,
        state: RouterStateSnapshot): Observable<boolean>  {

        return this.authService.user$.pipe(
            map(user => _.intersection(this.allowedRoles, user.roles).length > 0 ),
            first(),
            tap(allowed => {
                if (!allowed) {
                    this.router.navigateByUrl('/');
                }
            }),);


    }

}

/**as you can see the first argument is a string of roles*/
/** Inside the app.module:*/

import {BrowserModule} from '@angular/platform-browser';
import {NgModule, Provider} from '@angular/core';
import {HttpClientModule, HttpClientXsrfModule} from '@angular/common/http';
import {AuthService} from "./services/auth.service";
import {AuthorizationGuard} from "./services/authorization.guard";

//this is the factory function that returns the instance of the Guard:

export function createAdminOnlyGuard(authService:AuthService, router:Router) {
    return new AuthorizationGuard(['ADMIN'], authService, router);
}



@NgModule({
    declarations: [
        AppComponent,

    ],
    imports: [
        BrowserModule,
        HttpClientModule,

    ],
    providers: [
 
        AuthService,
        {
            provide: 'adminsOnlyGuard',
            useFactory: createAdminOnlyGuard,
            deps: [
                AuthService,
                Router
            ]

        }
    ],
    bootstrap: [AppComponent]
})
export class AppModule {

}

//usage :

import {Routes} from '@angular/router';
import {AdminComponent} from "./admin/admin.component";

export const routesConfig: Routes = [
    {
        path: 'admin',
        component: AdminComponent,
        canActivate: ["adminsOnlyGuard"]
    },
];




PI = 3.14
Radius = float(input(" Enter the value of radius : "))

Area = PI * Radius * Radius
circumference = 2 * PI * Radius
print("Area : ", Area)
print("Circumference : ",circumference )
Area = 0.5 * Base * Height
print("Area of triangle : ", Area)
Area = 0.5 * Base * Height
print("Area of triangle : ", Area)
Area = 0.5 * Base * Height
print("Area of triangle : ", Area)
Area = 0.5 * Base * Height
print("Area of triangle : ", Area)
Base = float(input("Enter the value of Base : "))
Height = float(input("Enter the value of Height : "))
print(" Data type of First_Name : " , type(First_Name))
print(" Data type of Last_Name : " , type(Last_Name))
print(" Data type of Country_Name : " , type(Country_Name))
print(" Data type of City_Name : " , type(City_Name))
print(" Data type of Age : " , type(Age))
print(" Data type of Dob : " , type(Dob))
print(" Data type of is_true : " , type(is_true))
First_Name = ' Dhruv' #You can assign your first name in the place of Dhruv
Last_Name = ' Makwana ' #You can assign your last name in the place of Makwana
Country_Name = ' India ' #You can assign your country name in the place of India.
City_Name = ' Ahmedabad ' #You can assign your city name in the place of Ahmedabad.
Age = 20 #You can assign your age in the place of 20.
Dob = ' 03-01-2003 ' #You can assign your dob in the place of 03-01-2003.
is_true = True
Assembly assembly = Assembly.LoadFrom("TestAssembly.dll");
Version ver = assembly.GetName().Version;
using System.Reflection;

infoFileVersionInfo versInfo = FileVersionInfo.GetVersionInfo("path.exe");
string version = $"v{versInfo.FileMajorPart}.{versInfo.FileMinorPart}.{versInfo.FileBuildPart}";
OpenFileDialog folderBrowser = new OpenFileDialog();
// Set validate names and check file exists to false otherwise windows will
// not let you select "Folder Selection."
folderBrowser.ValidateNames = false;
folderBrowser.CheckFileExists = false;
folderBrowser.CheckPathExists = true;
// Always default to Folder Selection.
folderBrowser.FileName = "Folder Selection.";
if (folderBrowser.ShowDialog() == DialogResult.OK)
{
    string folderPath = Path.GetDirectoryName(folderBrowser.FileName);
    // ...
}
.sp-eap-load-more:not(:has(button)) {
    display:none;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="TestNG">

    <test name="Example Test" preserve-order="false">
        <classes>
            <class name="LoginTests"/>
            <class name="BaseTest"/>
            <class name="RegistrationTests"/>
        </classes>
    </test>
</suite>
@Test
public static void RegistrationSuccessTest () {

  WebDriver driver = new ChromeDriver();
  driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

  String url = "https://bbb.testpro.io/";
  driver.get(url);
  Assert.assertEquals(driver.getCurrentUrl(), url);
  driver.quit();
}
const endpoint = 'https://gist.githubusercontent.com/Miserlou/c5cd8364bf9b2420bb29/raw/2bf258763cdddd704f8ffd3ea9a3e81d25e2c6f6/cities.json';
const cities = [];
const searchInput = document.querySelector('.search');
const suggestions = document.querySelector('.suggestions');

const fetchData = async(url) => {
    const response = await fetch(url)
    const data = await response.json();
    return data;
}


function displayItems(cities){
    const items = cities.map((place) => {
      return `
      <li>
        <span class="name">${place.city}</span>
        <span class="population">${place.population}</span>
      </li>
    `;
  }).join('');
  suggestions.innerHTML = items;

}



const startApp = async() => {

    const citiesData = await fetchData(endpoint);
    cities.push(...citiesData);  
    displayItems(cities)

    searchInput.addEventListener('keyup', function(e){
      const value = e.target.value;
      const regex = new RegExp(value, 'gi');
      const filteredCities = cities.filter((place) => {
       return place.city.match(regex);
      })

      displayItems(filteredCities);
    })

}


startApp();












Private Sub GetProjectReferences()
    Dim lines = New List(Of String)
    Dim path = "..\..\TestApp.vbproj"
    For Each line In File.ReadAllLines(path)
        If line.Contains("<ProjectReference") Then
            Dim projNameWithExtension = line.Substring(line.LastIndexOf("\") + 1)
            Dim projName = projNameWithExtension.Substring(0, projNameWithExtension.IndexOf(".vbproj"))
            lines.Add(projName)
        End If
    Next
End Sub
<!DOCTYPE html>
<html>
  <head>
	<title>Video Picker</title>
	<link rel="stylesheet" href="style.css">
  </head>
  <body>
	<h1>Video Picker</h1>
	<form>
	  <input type="text" id="videoUrl" placeholder="Enter video URL...">
	  <button type="button" id="addVideoBtn">Add Video</button>
	</form>
	<hr>
	
	<h3 id="videoCount"></h3>

	
	<div id="videoList"></div>
	
	<script src="script.js">
	alert("If you want you can modify the UI of this project, to adapt on your needs\n" + "\nhave a great and blessed day 🤝🏼😊");

alert("Enter as many YouTube video links as you want to, and see the magic")


window.onload = function() {
const videoList = document.getElementById('videoList');
const addVideoBtn = document.getElementById('addVideoBtn');

// Load videos from LocalStorage on page load
loadVideos();

addVideoBtn.addEventListener('click', addVideo);

function addVideo() {
  const videoUrl = document.getElementById('videoUrl').value;
  const videoId = getVideoId(videoUrl);

  if (videoId) {
	const videoItem = createVideoItem(videoId);
	videoList.appendChild(videoItem);
	
	// Save video to LocalStorage
	saveVideo(videoId);
  }

  document.getElementById('videoUrl').value = '';
}

function getVideoId(url) {
  const regex = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/;
  const match = url.match(regex);

  if (match && match[1]) {
	return match[1];
  } else {
	alert('Invalid video URL');
	return null;
  }
}

function createVideoItem(videoId) {
  const videoItem = document.createElement('div');
  videoItem.className = 'video-item';
  const thumbnailUrl = `https://img.youtube.com/vi/${videoId}/mqdefault.jpg`;
  const videoUrl = `https://www.youtube.com/watch?v=${videoId}`;
  videoItem.innerHTML = `
	<a href="${videoUrl}" target="_blank">
	  <img src="${thumbnailUrl}" alt="Video thumbnail">
	  <h2>${videoId}</h2>
	</a>
	<button class="remove-video-btn">Remove</button>
  `;

  // Add event listener to the 'Remove' button
  const removeBtn = videoItem.querySelector('.remove-video-btn');

  removeBtn.addEventListener('click', () => {
	removeVideo(videoId);
	videoItem.remove();
  });

  return videoItem;
}

function removeVideo(videoId) {
  let videos = [];
  if (localStorage.getItem('videos')) {
	videos = JSON.parse(localStorage.getItem('videos'));
  }
  const index = videos.indexOf(videoId);
  if (index !== -1) {
	// Display confirmation dialog box
	const confirmed = confirm("Are you sure you want to remove this video? 😥");
	if (confirmed) {
	  // Remove video from list
	  videos.splice(index, 1);
	  localStorage.setItem('videos', JSON.stringify(videos));
	  const videoItem = document.getElementById(videoId);
	  videoList.removeChild(videoItem);
	}
  }
}


function saveVideo(videoId) {
  let videos = [];
  if (localStorage.getItem('videos')) {
	videos = JSON.parse(localStorage.getItem('videos'));
  }
  if (!videos.includes(videoId)) {
	videos.push(videoId);
	localStorage.setItem('videos', JSON.stringify(videos));
  }
}

function loadVideos() {
  if (localStorage.getItem('videos')) {
	const videos = JSON.parse(localStorage.getItem('videos'));
	const videoCount = document.getElementById('videoCount');
	videoCount.textContent = `You have ${videos.length} videos in the list.`;
	videos.forEach(videoId => {
	  const videoItem = createVideoItem(videoId);
	  videoList.appendChild(videoItem);
	});
  }
}

}
/*
The saveVideo() function takes the video ID and saves it to an array in LocalStorage. The loadVideos() function is called on page load and loads the videos from LocalStorage, creating a videoItem for each one and appending it to the videoList. This way, the user's added videos will persist even if they close and reopen the page.*/
	
	</script>
  </body>
</html>
[/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		
		int x=add(1,2,3,4,5);
		System.out.println(x);
		// your code goes here
	}
	public static int add(int ...args)
	{
		int ans=0;
		for(int x:args)
		{
			ans+=x;
		}
		return ans;
	}
}]
/*
Inspired by Vera Molnár's Un, deux, trois
Based on a translation from Generative Artistry:
https://generativeartistry.com/tutorials/un-deux-trois/
*/



//stroke cap! never changed it before ><
function setup() {
  createCanvas(windowWidth, windowHeight);
  strokeCap(ROUND);
  strokeWeight(4);
}



function draw() {
  background(255);

  //chose a smaller one from height or width
  let step = min(width / 15, height / 15);

  // like grid, add one step for one times, 
  //in the for loop it will add until it reach to the height or width 

  for (let y = step; y < height - step; y += step) {
    for (let x = step; x < width - step; x += step) {

      // seperate it into three levels
      // and draw different lines

      //DrawLine function with 4 parameters

      if (y < height / 3) {
        drawLine(x, y, step, [0.5]);
      } else if (y < (height / 3) * 2) {
        drawLine(x, y, step, [0.2, 0.8]);
      } else {
        drawLine(x, y, step, [0.1, 0.5, 0.9]);
      }
    }
  }
  noLoop();
}

function drawLine(_x, _y, _step, positions) {

  push();
  

  //interesting! translate + half of step ,rotate, then translate back! 
  translate(   _x + _step / 2,    _y + _step / 2   );
  rotate(random(5));
  translate(-_step / 2, -_step / 2);


  // loop by it self!
  for (let i = 0; i <= positions.length; i++) {

    //x are the same-> horizontal
    //y 0 to step
    line( positions[i] * _step, 
          0, 
          positions[i] * _step, 
          _step);
  }
  
  
  

  pop();
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}
star

Mon Feb 27 2023 14:45:28 GMT+0000 (Coordinated Universal Time)

@kavishri

star

Mon Feb 27 2023 13:58:45 GMT+0000 (Coordinated Universal Time)

@Amit285

star

Mon Feb 27 2023 13:50:38 GMT+0000 (Coordinated Universal Time)

@solve_karbe12

star

Mon Feb 27 2023 13:47:24 GMT+0000 (Coordinated Universal Time)

@ahmad007

star

Mon Feb 27 2023 13:46:58 GMT+0000 (Coordinated Universal Time)

@saakshi #c++

star

Mon Feb 27 2023 13:43:19 GMT+0000 (Coordinated Universal Time)

@saakshi #c

star

Mon Feb 27 2023 13:43:18 GMT+0000 (Coordinated Universal Time)

@solve_karbe12

star

Mon Feb 27 2023 13:38:57 GMT+0000 (Coordinated Universal Time)

@ahmad007

star

Mon Feb 27 2023 13:31:40 GMT+0000 (Coordinated Universal Time)

@saakshi #c++

star

Mon Feb 27 2023 13:28:27 GMT+0000 (Coordinated Universal Time)

@ahmad007

star

Mon Feb 27 2023 13:18:56 GMT+0000 (Coordinated Universal Time)

@hollyhenaghan #undefined

star

Mon Feb 27 2023 13:14:04 GMT+0000 (Coordinated Universal Time)

@saakshi #c++

star

Mon Feb 27 2023 13:07:46 GMT+0000 (Coordinated Universal Time)

@hamzahanif192

star

Mon Feb 27 2023 13:05:44 GMT+0000 (Coordinated Universal Time)

@Goof3y #c#

star

Mon Feb 27 2023 12:58:45 GMT+0000 (Coordinated Universal Time)

@ahmad007

star

Mon Feb 27 2023 11:37:37 GMT+0000 (Coordinated Universal Time)

@mtommasi

star

Mon Feb 27 2023 11:33:53 GMT+0000 (Coordinated Universal Time) https://2captcha.com/

@10x

star

Mon Feb 27 2023 11:32:17 GMT+0000 (Coordinated Universal Time) https://selectolax.readthedocs.io/en/latest/parser.html

@10x

star

Mon Feb 27 2023 11:05:01 GMT+0000 (Coordinated Universal Time) https://www.opris.exchange/binance-clone-script/

@oprisexchange #binanceclonescript #binanceclonesoftware #binancecloneapp

star

Mon Feb 27 2023 10:52:33 GMT+0000 (Coordinated Universal Time)

@AlanaBF #javascript

star

Mon Feb 27 2023 10:51:14 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 10:50:03 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 10:47:31 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 10:03:50 GMT+0000 (Coordinated Universal Time)

@mtommasi

star

Mon Feb 27 2023 09:53:00 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/user/settings

@Egor

star

Mon Feb 27 2023 09:34:17 GMT+0000 (Coordinated Universal Time)

@webmasterUdL

star

Mon Feb 27 2023 09:31:13 GMT+0000 (Coordinated Universal Time)

@mtommasi

star

Mon Feb 27 2023 08:02:18 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 07:56:54 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 07:56:54 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 07:55:28 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 07:55:03 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 07:51:17 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 05:35:21 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 05:32:12 GMT+0000 (Coordinated Universal Time)

@infinityai

star

Mon Feb 27 2023 05:19:08 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/29772065/how-to-check-the-version-of-an-assembly-dll

@javicinhio #cs

star

Mon Feb 27 2023 05:14:51 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/11350008/how-to-get-exe-file-version-number-from-file-path

@javicinhio #cs

star

Mon Feb 27 2023 05:14:34 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/11624298/how-do-i-use-openfiledialog-to-select-a-folder

@javicinhio #cs

star

Mon Feb 27 2023 05:14:09 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/14305581/method-to-get-all-files-within-folder-and-subfolders-that-will-return-a-list

@javicinhio #cs

star

Mon Feb 27 2023 05:05:26 GMT+0000 (Coordinated Universal Time)

@Pulak

star

Mon Feb 27 2023 04:35:54 GMT+0000 (Coordinated Universal Time)

@Batmansbitch79

star

Mon Feb 27 2023 04:34:59 GMT+0000 (Coordinated Universal Time)

@Batmansbitch79

star

Mon Feb 27 2023 04:26:43 GMT+0000 (Coordinated Universal Time)

@davidmchale #intersection #observer

star

Mon Feb 27 2023 04:13:49 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/56055553/c-sharp-get-project-references-that-are-projects

@javicinhio #cs

star

Mon Feb 27 2023 04:02:01 GMT+0000 (Coordinated Universal Time) https://blog.csdn.net/Brendon_Tan/article/details/89854751?ops_request_misc

@marhap_

star

Mon Feb 27 2023 03:59:44 GMT+0000 (Coordinated Universal Time) https://viblo.asia/p/su-dung-jwt-voi-spring-security-oauth-Do754AOWKM6

@namnt

star

Mon Feb 27 2023 02:06:02 GMT+0000 (Coordinated Universal Time) https://github.com/malike/sso-auth/tree/master/auth-server/src/main/java/st/malike/auth/server/repository

@namnt

star

Mon Feb 27 2023 01:19:12 GMT+0000 (Coordinated Universal Time)

@swiftui_spanish #html #css #javascript

star

Mon Feb 27 2023 01:05:33 GMT+0000 (Coordinated Universal Time) Telusko

@void_harsh #java

star

Mon Feb 27 2023 00:59:50 GMT+0000 (Coordinated Universal Time)

@yc_lan

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension