Skip to content

Instantly share code, notes, and snippets.

View tirkarthi's full-sized avatar

Karthikeyan Singaravelan tirkarthi

View GitHub Profile
@tirkarthi
tirkarthi / biller.py
Created March 10, 2018 07:46
A sample bill program
from __future__ import print_function
def calculate_bill_amount(gem_list, price_list, reqd_gems, reqd_quantity):
bill_amount = -1
gem_dict = dict(zip(gem_list, price_list))
order_dict = dict(zip(reqd_gems, reqd_quantity))
for gem in reqd_gems:
if not gem_dict.get(gem):
return bill_amount
@tirkarthi
tirkarthi / core.async
Created March 18, 2018 06:47
core.async query
> use lein
switched to db lein
> db.clojars.distinct("url", {dependencies: {$elemMatch : {artifactId: "core.async"}}, "version": {$lt: "0.3.442"}}, {url: 1, '_id': false})
[
"http://github.com/pleasetrythisathome/tao",
"http://dsteurer.org",
"https://github.com/cncommerce/beetlejuice",
"https://github.com/tgetgood/lemonade",
"http://example.com/FIXME",
"https://github.com/luchiniatwork/contentql",
@tirkarthi
tirkarthi / build-top.py
Last active March 31, 2018 12:46
Dependants list for 49305 issue
import json
from collections import OrderedDict
from pymongo import MongoClient
deps = {}
connection = MongoClient()
database = connection.crates
collection = database.crates_data
@tirkarthi
tirkarthi / .travis.yml
Created June 8, 2018 06:50
Fix OpenJDK 9 and above certificate failures in Travis
language: clojure
lein: 2.8.1
jdk:
- openjdk8
- oraclejdk8
- oraclejdk9
matrix:
include:
@tirkarthi
tirkarthi / typos.txt
Created June 16, 2018 07:02
Output of the command : cd Docs && find . -iname '*rst' | xargs -I{} sh -c "aspell --master=en_US --extra-dicts=en_GB --ignore 3 list < {}" | sort | uniq > typos.txt
aaaa
AAAA
aaaaa
aaaaaa
aaaab
AAAABBBCCD
AAAABBBCCDAABBB
aaab
aahz
Aahz

Problems come in different forms

  • The website you use doesn't sort based on two or more fields.
  • You want to get an alert based on a particular condition.
  • You want to visualize the data in a different way to take a decision.

Data rich world and we can engineer solutions.

  • Most of the data you want to manipulate is structured.
  • Getting hold of the data helps you expand on the solution rather than being constrained on the current drawbacks.
from typing import List, Dict
import sys
def get_profile_a(user_id: int, likes: Dict[str, int]) -> Dict[str, int]:
return {'user_id': user_id, 'likes': len(likes)}
def get_profile_b(user_id, likes):
return {'user_id': user_id, 'likes': len(likes.keys())}
if len(sys.argv) > 1:
@tirkarthi
tirkarthi / redis_streams.go
Created August 27, 2018 11:10
A sample program using redis streams and goroutines
package main
import (
"fmt"
"github.com/go-redis/redis"
"sync"
"time"
)
func main() {
# Go to order history page
# In console see requests to https://www.swiggy.com/dapi/order/all?order_id= and hit show more to download more JSON data.
# Collect all the JSON responses in an array to form swiggy.json
from collections import defaultdict
import json
FORMAT_STRING = "{name:>30} | {price:<8} | {delivery:<10} | {gst:<5} | {discount:<5}"
orders_list = []
@tirkarthi
tirkarthi / python-bugs.org
Created September 23, 2018 15:55
An org file with some bugs while triaging