Skip to content

Instantly share code, notes, and snippets.

View pavinduLakshan's full-sized avatar
🎯
Focusing

Pavindu Lakshan pavinduLakshan

🎯
Focusing
View GitHub Profile
<!--
This HTML page provides a simple button that initiates a social login flow using Google as the federated identity provider
via WSO2 Identity Server.
Supported WSO2 Identity Server versions: tested on 6.0, 6.1, 7.0, 7.1
When the "Login with Google" button is clicked, the `redirectToGoogle()` function constructs an OAuth2 authorization URL
with the required parameters:
- client_id: The application's client ID registered in Asgardeo.
- redirect_uri: The callback URL where the authorization code will be sent.
@pavinduLakshan
pavinduLakshan / user_bulk_create.js
Created August 22, 2024 06:37
Node.js script to register users in bulk in WSO2 Identity Server
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
const axios = require('axios');
const https = require('https');
const NUMBER_OF_USERS = 500
// Create an https.Agent instance to ignore SSL certificate errors
const agent = new https.Agent({
rejectUnauthorized: false
@pavinduLakshan
pavinduLakshan / CovidVaccineDailyCount.java
Created March 12, 2021 15:29
Hadoop Mapreduce Program for Covid Vaccine Dataset
package covidvaccinecount;
import java.io.*;
import java.util.TreeMap;
import java.util.Map.Entry;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.*;
@pavinduLakshan
pavinduLakshan / VideoSales.java
Created March 12, 2021 12:57
Hadoop Mapreduce Program for Video Games Sales Problem
package wordcount;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import React from 'react'
const FirstComponent = ({onBtnPress}) => {
return (
// will alert "Hello Sam, from second"
<button onClick={() => onBtnPress("Sam")}></button>
)
}
const SecondComponent = ({}) => {
const multer = require('multer');
// Create a directory '/uploads' in your project root, Uploaded images are stored there.
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'uploads')
},
filename: function (req, file, cb) {
cb(null, Date.now() + '-' +file.originalname )
}
var express = require("express");
var router = express.Router();
const multer = require("multer");
var upload = require("../upload");
router.post("/upload-image", (req, res, next) => {
let final_status = 200
upload(req, res, function(err) {
if (err instanceof multer.MulterError) {
console.log(err)
import React, { useState, useRef } from 'react';
import axios from 'axios'
const ImgUpExample = ({mode,btnText,handleSubmit}) => {
const imgUp = useRef(null);
const [image, setImage] = useState();
const [imageName, setImageName] = useState();
function handleImage(e) {
setImage(e.target.files[0]);
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
public class UDPClient{
/* The server port to which
the client socket is going to connect */
public final static int SERVICE_PORT = 50001;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
public class UDPServer{
// Server UDP socket runs at this port
public final static int SERVICE_PORT=50001;