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_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 / 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 / custom_binary_test.js
Created September 29, 2020 14:19
Run specific chrome binary
const fs = require('fs');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
(async () => {
const chrome = await chromeLauncher.launch({chromePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"}); //Specify chrome binary path to run lighthouse.
const options = {logLevel: 'info', output: 'html', onlyCategories: ['performance'], port: chrome.port};
const runnerResult = await lighthouse('https://example.com', options);
// `.report` is the HTML report as a string
@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);