Skip to content

Instantly share code, notes, and snippets.

View paramsingh's full-sized avatar

param paramsingh

View GitHub Profile
#include<iostream>
#include<fstream>
#include<bitset>
#include<cstdlib>
#include<cstdio>
#include<limits>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
This week I worked on making the alpha-importer and influx-writer a bit more intelligent in handling bad data. Also, did some rebases on old PRs, nothing much else
Kinda off topic but I also went to see a cricket match this weekend in what has to be one of the most beautiful cricket grounds in the world. Was a great day!
https://usercontent.irccloud-cdn.com/file/LRYPh6Oi/PANO_20170326_134245.jpg
import requests
import json
url = 'http://0.0.0.0:3031/1/user/iliekcomputers/listens'
server = 'http://listenbrainz.org/1/user/iliekcomputers/listens'
r = requests.get(url, params = {'count': 2})
print json.dumps(json.loads(r.text), indent = 4)
"""
r = requests.get(server, params = {'count': 5})
print json.dumps(json.loads(r.text), indent = 4)
def fetch_listens_from_storage(self, user_name, from_ts, to_ts, limit, order):
""" The timestamps are stored as UTC in the postgres datebase while on retrieving
the value they are converted to the local server's timezone. So to compare
datetime object we need to create a object in the same timezone as the server.
from_ts: seconds since epoch, in float
to_ts: seconds since epoch, in float
"""
# Quote single quote characters which could be used to mount an injection attack.
@paramsingh
paramsingh / save.md
Last active March 6, 2017 18:48
Saving stats in Postgresql.

The data we get from BigQuery needs to be saved on our server. The thing I've come up with is one table for each stat that needs to be saved, with foreign keys to the user table, and msids.

table columns notes
user_top_artists (user_id, artist_msid, listen_count) This table can be used for top artists of a user, user_id is FK to "user"
user_top_releases (user_id, release_msid, listen_count) This table can be used for top releases of a user
user_top_recordings (user_id, recording_msid, listen_count) This table can be used for top recordings of a user.
artist_top_releases (artist_msid, release_msid, listen_count) This table will be used for getting top releases of an artist.
artist_top_recordings (artist_msid, recording_msid, listen_count) This table will be used for getting top recordings of an artist.
@paramsingh
paramsingh / get_scrobbles.py
Created March 5, 2017 06:15
send and get listens
import requests
import json
url = 'http://0.0.0.0:3031/1/user/<user_name>/listens'
server = 'http://listenbrainz.org/1/user/iliekcomputers/listens'
r = requests.get(url, params = {'count': 5})
print json.dumps(json.loads(r.text), indent = 4)
"""
r = requests.get(server, params = {'count': 5})
print json.dumps(json.loads(r.text), indent = 4)
@paramsingh
paramsingh / dbms.md
Last active February 28, 2017 18:23
DBMS notes

Transactions

A transaction is a unit of program execution that accesses and possibly updates various data items.

Must be:

  • Atomic: Either executed in entirety or not.
  • Consistent: If run on a consistent db, the db should be consistent after the transaction is run.
  • Isolated: Should operate properly without interference from concurrent statements.
  • Durable: System should not "forget" about the execution of a transaction.
@paramsingh
paramsingh / networks.md
Created February 26, 2017 16:44
Computer networks notes

Computer Networks

Disclaimer: These notes are not for anything other than passing the Computer Networks class at NITH. Trying to study Networks from here for actually understanding Networks will lead to incompetency and certain failure. Try the Tanenbaum book instead.

Introduction

WIP

@paramsingh
paramsingh / proposal.md
Last active March 24, 2017 07:02
Listenbrainz GSoC Proposal
@paramsingh
paramsingh / what.md
Last active February 14, 2017 18:17
ListenBrainz Graph deets.

Visualization of data submitted to ListenBrainz is a big feature that will probably make it much more popular among users. With this in mind, we should try to show lots of pretty stats that users find interesting.

We have divided graphs into three categories:

  • User graphs: graphs which tell the user about her own listening history.
  • Entity graphs: graphs which show details about entities like artists,
  • Miscellaneous graphs: graphs which don't fit into the above categories, like a sitewide listen-count graph

What graphs should ListenBrainz show