Skip to content

Instantly share code, notes, and snippets.

View anjanesh's full-sized avatar

Anjanesh Lekshminarayanan anjanesh

View GitHub Profile
@anjanesh
anjanesh / toxicity-webserver.ts
Last active February 28, 2023 07:40
deno webserver returning JSON for tensorflowJS for toxicity model
import tfjs from "npm:@tensorflow/tfjs@4.2.0";
import * as toxicity from "npm:@tensorflow-models/toxicity@1.2.2";
const server = Deno.listen({ port: 8080 });
console.log(`HTTP webserver running. Access it at: http://localhost:8080/`);
const threshold = 0.5;
let t0 = performance.now();
let arrToxicity = {};
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>AutoSave TextArea Contents</title>
<script src="https://unpkg.com/alpinejs@3.10.5/dist/cdn.min.js" defer></script>
</head>
<body>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>AlpineJS - Indian Number System for Amount in Rupees</title>
<script src="https://unpkg.com/alpinejs@3.10.3/dist/cdn.min.js" defer></script>
<script>
const INR_THOUSAND = 1000;
@anjanesh
anjanesh / rallycoding.201.js
Last active January 28, 2021 05:29
Longest Increasing Sequence
// https://www.rallycoding.com/problems/201
const solve = (intArray) =>
{
let a = [], l;
let b = [], m = 0;
let i, j;
for (i = 0; i < intArray.length - 1; i++)
{
@anjanesh
anjanesh / mega-menu.html
Created January 9, 2021 12:27
Mega Menu using CSS only
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap" rel="stylesheet">
<title>Mega Menu using CSS only</title>
<style type="text/css">
body { font-family: Roboto; font-weight: normal; }
@anjanesh
anjanesh / number2words.js
Created October 20, 2020 00:58
Number to words (crore and lakh)
const HUNDRED = 100;
const THOUSAND = HUNDRED * 10;
const LAKH = THOUSAND * 100;
const CRORE = LAKH * 100;
const TN = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
const TY = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'sixteen', 'eighty', 'ninety'];
const O = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
function number2words(num)
<?php
#$nums = [-2,1,-3,4,-1,2,1,-5,4];
$nums = [84,38,65,52,-9,70,81,58,-33,87,-47,48,23,-53,86,-2,45,56,35,5,90,47,-84,-21,55,-8,37,0,-3,-60,-11,-42,54,-68,-89,-54,-98,68,80,-31,55,-67,93,-45,-21,79,52,-75,12,-12,29,-21,-88,21,57,67,-87,-6,-33,-14,10,32,44,-35,63,54,-13,65,22,-33,-66,-46,0,-73,8,78,82,-62,79,-6,2,-15,72,13,83,30,-20,72,-99,46,-41,11,-21,-97,52,-81,33,-61,83,-45,-18,-83,-15,81,-80,69,37,-98,-93,-7,-28,8,55,-55,-78,38,51,-22,-13,51,-75,45,-61,-20,24,90,-2,-43,-94,-41,-12,-12,-25,72,-54,-28,42,59,-27,25,-70,22,-89,84,66,-91,-1,-6,-14,85,-78,-13,8,-39,66,-68,-72,-58,-11,-89,0,53,-25,51,26,20,-77,-55,-43,-27,46,-14,94,33,-53,37,41,45,-69,-72,7,-48,14,-85,-11,-42,-76,-6,-1,-11,4,98,-58,78,49,44,-25,49,65,31,-78,12,93,-84,-55,-83,52,86,61,59,90,-54,-89,-19,-63,-23,38,-40,47,-86,48,-49,-88,67,-94,38,11,-43,-36,-23,65,-15,65,58,-23,-90,75,-94,72,13,64,62,35,51,-79,72,-72,58,-91,74,72,34,-98,60,1,83,-25,-88,-59,38,-35,-94,99,-70,40,-47,-83,15,-42,88,-94,-78,28,40,73,48,-11,77,-17,-2,29,-68,-68,7,69,9
/*
Usage :
node brackets.js
((a+b*d)*(x/2))*(1+(y+(x-2)/10))
[ '(a+b*d)',
'(x/2)',
'((a+b*d)*(x/2))',
'(x-2)',
'(y+(x-2)/10)',
<?php
$s = "((a+b*d)*(x/2))*(1+(y+(x-2)/10))";
$b = [];
$j = 0;
$stack = [];
for ($i = 0; $i < strlen($s); $i++)
{
if ($s[$i] == '(')
{
@anjanesh
anjanesh / commas.html
Created April 28, 2019 04:18
Commas in INPUT textfields
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
</head>
<body>
<div id="container">
<form id="frm" class="form" action="" method="post">
<div>
<div>