Skip to content

Instantly share code, notes, and snippets.

View svkrclg's full-sized avatar
🏠
Working from home

Sk svkrclg

🏠
Working from home
View GitHub Profile
@svkrclg
svkrclg / throttle_run_time.js
Last active September 29, 2020 13:41
Lighthouse Throttle run
/*Need to change fetch different value from url array manually.
Because performance degrades with continous run.
*/
//Tested for regular 3G
const fs = require('fs');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
const url = ["https://www.amazon.in/", "https://twitter.com/", "https://www.snapdeal.com/", "https://abc.com/", "https://www.ticket.at/de/home" ];
const DEVTOOLS_RTT_ADJUSTMENT_FACTOR = 3.75;
@svkrclg
svkrclg / unthrottle_run_time.js
Created September 29, 2020 13:42
Lighthouse Unthrottle run
/*Need to change fetch different value from url array manually.
Because performance degrades with continous run.
*/
const fs = require('fs');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
const url = ["https://www.amazon.in/", "https://twitter.com/", "https://www.snapdeal.com/", "https://abc.com/", "https://www.ticket.at/de/home" ];
(async () => {
element = url[1]
const chrome = await chromeLauncher.launch();
@svkrclg
svkrclg / throttle_effect_on_score.js
Last active September 29, 2020 14:22
Lighthouse score for different network throttling
const fs = require('fs');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
(async () => {
const chrome = await chromeLauncher.launch();
const options = {logLevel: 'info', output: 'json', onlyCategories: ['performance'], port: chrome.port};
const DEVTOOLS_RTT_ADJUSTMENT_FACTOR = 3.75;
const DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR = 0.9;
const mobileRegular3g = {
@svkrclg
svkrclg / script.rb
Last active October 15, 2020 14:02
CIU script to run on prod
# To set available for CIU user
RedisUtils.ciu_live_set_availability_status(true)
#To disable ciu user
# RedisUtils.ciu_live_set_availability_status(false)
#To set desktop support
RedisUtils.ciu_live_set_platform_support("desktop", true)
#To disable desktop support
@svkrclg
svkrclg / urls.txt
Last active February 19, 2021 08:49
let url = [
"csdn.net",
"github.com",
"canva.com",
"yahoo.co.jp",
"naver.com",
"bongacams.com",
"bing.com",
"ebay.com",
"yy.com",
@svkrclg
svkrclg / server.java
Created November 7, 2021 16:23
A Java program to liste TCP connection
ServerSocket server = new ServerSocket(80); // Listen for connection on port 89
System.out.println("Server started");
Socket socket = server.accept(); //Wait for client
System.out.println("Client accepted");
@svkrclg
svkrclg / read_get_packet_snippet.txt
Last active December 18, 2021 15:56
Parse Get endpoint
socket = server.accept();
System.out.println("Client accepted");
DataInputStream in = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
byte[] messageByte = new byte[1000];
String dataString = "";
while(true)
{
int bytesRead = in.read(messageByte);
@svkrclg
svkrclg / send_response.txt
Last active December 19, 2021 16:58
frame HTTP response
// Get output stream
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
String message = "HTTP/1.1 200 OK\r\n" +
"Server: noob-server\r\n" +
"Date: 14 March, 1977\r\n" +
"\r\n" +
"Hello world - noob server";
out.write(message.getBytes());
@svkrclg
svkrclg / post_endpoint.txt
Last active December 19, 2021 17:27
POST read and send response
String dataString = "";
String body = "";
try
{
while(true)
{
int bytesRead = in.read(messageByte);
if (bytesRead == -1)
break;
dataString += new String(messageByte, 0, bytesRead);
@svkrclg
svkrclg / process_post.txt
Last active December 19, 2021 17:37
procees POST packet
public String[] processData(String request) {
String lines[] = request.split("\r\n");
int cl = -1;
for(String line : lines) {
System.out.println(line);
if(line.contains("Content-Length")) {
String x = line.substring(16);
cl = Integer.parseInt(x);
break;
}