Skip to content

Instantly share code, notes, and snippets.

View retraigo's full-sized avatar
⚜️
I fancy attention

Pranev (NeTT) retraigo

⚜️
I fancy attention
View GitHub Profile
@retraigo
retraigo / esm.md
Created March 5, 2022 05:45
Why are all my packages in ESM?
  • I don't really want to add exports for require() due to potential unwanted behavior.
  • I am writing packages that could run in multiple runtimes, whether it's a browser, node or deno. Using CommonJS limits this.
@retraigo
retraigo / js-ts-projects.md
Last active June 12, 2022 10:28
A list of public JavaScript/TypeScript projects I maintain.

The List

A list of public JavaScript/TypeScript projects I maintain.

Packages and stuff

BetterMap

An extension of the JavaScript Map class with Array-like methods.

#include <stdio.h>
char queue[256];
int last = -1;
int limit = 256;
void enqueue(char itemToInsert) {
if (last == limit - 1) {
printf("Queue Overflow");
@retraigo
retraigo / double_linked_list.c
Last active September 21, 2022 16:05
Linked list
// Doubl Linked-List
#include <stdio.h>
#include <stdlib.h>
struct Element {
char value;
struct Element *next;
struct Element *previous;
};
@retraigo
retraigo / POSTULATES.md
Created August 29, 2022 09:35
The postulates of NeTT

Postulates of NeTT

  • If you have an opinion, share it or suggest it. Don't force it on others.
  • If you have a personal belief, be it religious or ethical, don't force it on others.
  • If you have a personal problem with someone, take it to where it belongs. Bringing it to unrelated online platforms wouldn't give you justice.
  • If you need help with something, describe what you need help with instead of asking if you can get help without describing the matter.
  • If you are asking for help, be clear with what you exactly need. You might end up wasting the time of the person trying to help you as well as that of yourself.
  • If someone asks for help and you don't want to help them, just don't help them. Instead, don't blame their ignorance on the matter.
  • If someone doesn't like something, don't do it just to piss them off.
  • If someone starts complaining about everything for no reason, just don't mind them. There is no cure for stupidity.
  • If you have a sense of justice, it makes sense that the other person
@retraigo
retraigo / EX_10_2.scala
Last active December 13, 2022 04:56
AI DS SEM 3 OOPS LAB
import scala.io.StdIn.{readInt};
import scala.collection.mutable.ArrayBuffer;
import scala.collection.immutable.List;
object Triplicate {
def main(args: Array[String]) = {
val arr = new ArrayBuffer[Int]();
println("Enter the numbers followed by a return after each number. Enter a non-number to stop.");
var continue = 1;
while(continue == 1) {
try {
@retraigo
retraigo / assignment_1.md
Created September 4, 2022 07:48
Scala assignments

1. Write a Scala program to sum values of a given array.

import scala.io.StdIn.{readDouble};
import scala.collection.mutable.ArrayBuffer;
object SumArray {
  def main(args: Array[String]) = {
    var listOfNumbers = new ArrayBuffer[Double]();
    println("Enter numbers to add. Enter 0 to stop.");
    var current = 1.0;
    while (current != 0.0) {
@retraigo
retraigo / linear_regression.rs
Created September 20, 2022 15:38
I hope this is actually linear regression
#[derive(Debug)]
pub struct LinearRegressionResult {
pub slope: f64,
pub intercept: f64,
pub r2: f64,
}
impl LinearRegressionResult {
pub fn predict(&self, x: f64) -> f64 {
self.intercept + (self.slope * x)
}
// Weighted random selection in Scala 2
// You have an array of items. Each item is an unsigned integer.
// The value of each item determines its weight.
// Higher the weight, higher the chance of rolling it.
class Fortuna(items: Array[Double]) {
private val weights = items;
private val cumulativeWeights: Array[Double] = new Array(items.length);
private var totalChance: Double = 0;
for (i <- 0 until items.length) {
use rand::Rng;
/// You have an array of items. Each item is an unsigned 32-bit integer.
/// The value of each item determines its weight.
/// Higher the weight, higher the chance of rolling it.
/// This algorithm uses a simple approach.
/// Keep moving in a straight line till your weights sum up to (or get reduced to)
/// a weight less than a single item's weight. Return the index of the result.