Skip to content

Instantly share code, notes, and snippets.

View LhrSupun's full-sized avatar
🎯
Focusing

Lahiru Supun LhrSupun

🎯
Focusing
View GitHub Profile
@LhrSupun
LhrSupun / net-install.sh
Created October 9, 2025 16:29
.NET installation
#!/bin/bash
# Download the .NET install script
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
# Make it executable
chmod +x ./dotnet-install.sh
# Install .NET 8 (change channel to 8.0)
./dotnet-install.sh --channel 8.0
@LhrSupun
LhrSupun / package-lock.json
Last active December 19, 2024 06:09
Cloudflare twitter login
{
"name": "worker-name-placeholder",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "worker-name-placeholder",
"version": "1.0.0",
"license": "ISC"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebSocket Example</title>
<script>
// Appending the Content-Security-Policy meta tag dynamically
$('head').append('<meta http-equiv="Content-Security-Policy" content="connect-src chrome://resources chrome://theme \'self\' ws://10.40.9.120:23">');
  1. Read data from file appropriately (20 marks)

The read_matrices function handles file reading:

void read_matrices(const char *filename, Matrix **A, Matrix **B) {
    FILE *file = fopen(filename, "r");
    if (file == NULL) {
 fprintf(stderr, "Error: Cannot open file %s\n", filename);
@LhrSupun
LhrSupun / .gitattributes
Created August 6, 2024 06:37
Add these files in your Unity projects
# text files
*.meta text eol=lf
ProjectSettings/*.asset text
# model files
*.fbx filter=lfs diff=lfs merge=lfs -text
*.FBX filter=lfs diff=lfs merge=lfs -text
*.max filter=lfs diff=lfs merge=lfs -text
*.MAX filter=lfs diff=lfs merge=lfs -text
*.ma filter=lfs diff=lfs merge=lfs -text
@LhrSupun
LhrSupun / mongodb.ts
Created January 19, 2024 12:25
nextjs mongoose connect
// @/utils/mongodb.ts
import mongoose from 'mongoose';
const { MONGODB_URI, MONGODB_DB } = process.env;
if (!MONGODB_URI) throw new Error('MONGODB_URI not defined');
if (!MONGODB_DB) throw new Error('MONGODB_DB not defined');
const connect = async () => {
const soap = require('soap');
const bcrypt = require('bcryptjs');
const url = 'http://digitalservicessms.mobitel.lk/DigitalServicesSMSAPI/DigitalServicesSMSWS.wsdl';
const args = { arg0: { username: 'username', password: 'passwd' } };
const getClient = () => {
return new Promise((resolve, reject) => {
soap.createClient(url, (err, client) => {
if (err) return reject(err);
@LhrSupun
LhrSupun / countdown-timer.markdown
Created February 23, 2023 08:25
Countdown Timer
// Q 82
function primeFactors(num, prime) {
if(prime > num || prime === 0 || prime === 1) return false;
let factors = [];
let divisor = 2;
while (num > 2) {
if (num % divisor === 0) {
factors.push(divisor);
num = num / divisor;
#!/bin/bash
if [ $# -eq 0 ]
then
echo "\$0 charge/thermal"
echo "\$1 value"
exit 1
fi