Skip to content

Instantly share code, notes, and snippets.

View anjanesh's full-sized avatar

Anjanesh Lekshminarayanan anjanesh

View GitHub Profile
@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 / 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 / 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 / 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%'
;";