Skip to content

Instantly share code, notes, and snippets.

@NirmalAriyathilake
NirmalAriyathilake / analysis_options.yaml
Created February 5, 2023 02:28
Flutter custom analysis options using flutter_lints
include: package:flutter_lints/flutter.yaml
analyzer:
errors:
todo: ignore
exclude:
- generated_plugin_registrant.dart
- "**/*.freezed.dart"
- "**/*.g.dart"
- "**/*.config.dart"
@NirmalAriyathilake
NirmalAriyathilake / launch.json
Last active October 27, 2022 19:20
Flutter vscode launch file - launch flutter app with verbose in debug mode
{
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"args": [
"--verbose"
]
@NirmalAriyathilake
NirmalAriyathilake / server.php
Last active October 27, 2018 03:43
OAuth And Social Login - server.php
<?php
require_once 'vendor/autoload.php';
session_start();
if(isset($_POST['idtoken'])){
// Get $id_token via HTTPS POST.
$id_token = $_POST['idtoken'];
$CLIENT_ID = "57064433868-ebkvuv5druld2jah3h8hmt5l71ennfqb.apps.googleusercontent.com";
$client = new Google_Client(['client_id' => $CLIENT_ID]); // Specify the CLIENT_ID of the app that accesses the backend
@NirmalAriyathilake
NirmalAriyathilake / logout.php
Created October 27, 2018 03:22
OAuth And Social Login - logout.php
<?php
session_start();
//remove PHPSESSID from browser
if ( isset( $_COOKIE[session_name()] ) )
setcookie( session_name(), null, time()-3600, '/' );
//clear session from globals
$_SESSION = array();
//clear session from disk
session_destroy();
@NirmalAriyathilake
NirmalAriyathilake / index.php
Last active October 27, 2018 03:42
OAuth And Social Login - index.php
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>OAuth And Social Login</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://apis.google.com/js/platform.js?onload=init" async defer></script>
@NirmalAriyathilake
NirmalAriyathilake / client.php
Created October 26, 2018 12:23
Double Submit Cookies Pattern - client.php
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Double Submit Cookies Pattern</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
@NirmalAriyathilake
NirmalAriyathilake / index.php
Created October 26, 2018 12:23
Double Submit Cookies Pattern - index.php
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Double Submit Cookies Pattern</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
@NirmalAriyathilake
NirmalAriyathilake / logout.php
Created October 26, 2018 12:23
Double Submit Cookies Pattern - logout.php
<?php
session_start();
//remove PHPSESSID from browser
if ( isset( $_COOKIE[session_name()] ) )
setcookie( session_name(), null, time()-3600, '/' );
//clear session from globals
$_SESSION = array();
//clear session from disk
session_destroy();
@NirmalAriyathilake
NirmalAriyathilake / server.php
Created October 26, 2018 12:23
Double Submit Cookies Pattern - server.php
<?php
session_start();
// validate login
if(isset($_POST['submit'])){
ob_end_clean(); // buffer clean
validate($_POST['username'],$_POST['password']);
}
@NirmalAriyathilake
NirmalAriyathilake / client.php
Last active October 26, 2018 12:06
Synchronizer Token Pattern - client.php
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Synchronizer Token Pattern</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script>