This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let us say you have the following data for all apartments in a locality inside a city. For this problem the city is assumed to be | |
Bangalore. | |
{ | |
"whitefield": { | |
"varthur": { | |
"Brigade_Harmony": { | |
"103": { | |
"person": { | |
"name": "Pranav Anand", |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
amd | |
amds | |
aol | |
aols | |
aws | |
awss | |
aachen | |
aachens | |
aaliyah | |
aaliyahs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generating new words from existing words | |
""" | |
fruits = ['grape', 'banana', 'apple', 'orange', 'litchi', 'pomegranate'] | |
'apple', 'grape' => 'leg' | |
'banana', 'apple' => 'bale' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
class APITest: | |
def __init__(self, api): | |
t1 = time.time() | |
requests.get(api) | |
t2 = time.time() | |
self.time_taken = t2 - t1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let us say you have a piece of JSON data as follows. | |
basket = {'grape': 160, | |
'banana': 80, | |
'pear': 320, | |
'orange': 120, | |
'red apple': 290, | |
'green apple': 380, | |
'papaya': 40} | |
And you have a price constraint as follows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shell commands to add "x" values | |
$ $ cat alerts.json | grep "x" | sed 's/"x"://g' | awk '{sum += $NF} END {print sum}' | |
50237 | |
$ cat alerts.json | grep "x" | sed 's/,//g' | awk -F ":" '{sum += $NF} END {print sum}' | |
50237 | |
$ cat alerts.json | grep "x" | cut -d ":" -f 2 | awk '{ sum += $0} END {print sum}' | |
50237 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ javac -cp ./json-simple-1.1.jar MonitorClass.java | |
MonitorClass.java:24: error: constructor JSONArray in class JSONArray cannot be applied to given types; | |
JSONArray ja = new JSONArray("[{\"x\":49,\"y\":22,\"z\":72,\"ts\":\"2022-02-0815:43:13\"},{\"x\":60,\"y\":17,\"z\":6,\"ts\":\"2022-02-0815:43:15\"},{\"x\":94,\"y\":36,\"z\":8,\"ts\":\"2022-02-0815:43:17\"},{\"x\":86,\"y\":40,\"z\":5,\"ts\":\"2022-02-0815:43:21\"},{\"x\":25,\"y\":85,\"z\":95,\"ts\":\"2022-02-0815:43:23\"},{\"x\":28,\"y\":71,\"z\":65,\"ts\":\"2022-02-0815:43:26\"},{\"x\":12,\"y\":46,\"z\":70,\"ts\":\"2022-02-0815:43:28\"},{\"x\":30,\"y\":45,\"z\":70,\"ts\":\"2022-02-0815:43:30\"},{\"x\":22,\"y\":74,\"z\":14,\"ts\":\"2022-02-0815:43:31\"},{\"x\":78,\"y\":5,\"z\":4,\"ts\":\"2022-02-0815:43:33\"},{\"x\":18,\"y\":78,\"z\":45,\"ts\":\"2022-02-0815:43:35\"},{\"x\":34,\"y\":7,\"z\":15,\"ts\":\"2022-02-0815:43:36\"},{\"x\":98,\"y\":53,\"z\":42,\"ts\":\"2022-02-0815:43:38\"},{\"x\":28,\"y\":33,\"z\":23,\"ts\":\"2022-02-0815:43:41\"},{\"x\": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ideally put this inside your ~/.bashrc file | |
function temp-venv() { | |
function cleanup_venv() { | |
echo "Cleaning up ${VIRTUAL_ENV} ..." | |
rm -rf ${VIRTUAL_ENV} | |
unalias deactivate | |
deactivate | |
} |