Skip to content

Instantly share code, notes, and snippets.

View anjanesh's full-sized avatar

Anjanesh Lekshminarayanan anjanesh

View GitHub Profile
@anjanesh
anjanesh / IFSC.php
Last active February 6, 2020 02:36
multi-query select via mysqli
<?php
$mysqli = new mysqli("localhost", "username", "password", "data");
if (mysqli_connect_errno())
die("Connect failed: ".mysqli_connect_error());
$sql1 = "SELECT i1.`Name`, i1.`Branch`, i1.`IFSC`, i1.`Address`, i1.`Contact`
FROM `ifsc1` i1
WHERE i1.`Branch` LIKE '%sreekariyam%' OR i1.`Address` LIKE '%sreekariyam%'
;";
@anjanesh
anjanesh / find-intersection-among-arrays.js
Created October 13, 2011 08:39
Find Intersection Among Arrays
/*
ar : can be an array of arrays or an asssociative array
Examples:
================
intersect([[76,80,11,31,34,82,100], [13,31,66,43,73,100,73,10]])
will give [31,100]
intersect(
@anjanesh
anjanesh / csv-json.py
Last active April 28, 2019 04:21
Convert CSV to JSON
import sys, csv, json
if len(sys.argv) == 1:
print "1 argument for filename required"
sys.exit()
gdoc = csv.reader(open(sys.argv[1]))
# Get the 1st line, assuming it contains the column titles
fieldnames = gdoc.next()
@anjanesh
anjanesh / getter-setter
Created January 5, 2013 11:59
StackOverflow closed my question http://anjane.sh/Z6G4YX while I got it answered at devnetwork http://anjane.sh/RxY6Vh
<?php
class A
{
protected $_data;
public function __get($name)
{
if (in_array($name, ['Firstname', 'Lastname']))
return $this->_data[$name];
}
@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>
<?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] == '(')
{
/*
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
#$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
@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)
@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; }