Skip to content

Instantly share code, notes, and snippets.

View kaizer1v's full-sized avatar
👷‍♀️
One day at a time.

Vivek S kaizer1v

👷‍♀️
One day at a time.
View GitHub Profile
@kaizer1v
kaizer1v / trail_2013-08-15.json
Created May 2, 2022 07:42
Spotify stream trail for a single date
[{"ts":1376547924000,"level_0":1175,"index":1175,"Unnamed: 0":1175,"username":"kaizer1v","platform":"Windows 7 (6.1.7601; x64; SP1; S)","ms_played":264880,"conn_country":"IN","ip_addr_decrypted":"115.240.80.29","user_agent_decrypted":"unknown","master_metadata_track_name":"Standing On The Shore","master_metadata_album_artist_name":"Empire of the Sun","master_metadata_album_album_name":"Walking On A Dream","spotify_track_uri":"spotify:track:7wME8torEQ606m3fj2XERm","episode_name":null,"episode_show_name":null,"spotify_episode_uri":null,"reason_start":"popup","reason_end":"trackdone","shuffle":false,"skipped":0.0,"offline":0.0,"offline_timestamp":0.0,"incognito_mode":0.0,"city":null,"region":null,"metro_code":0.0,"longitude":0.0,"latitude":0.0,"year":2013,"month":8,"day":15,"hour":6,"minute":25,"seconds":24,"time":"06:25:24"},{"ts":1376548200000,"level_0":3643,"index":3643,"Unnamed: 0":3643,"username":"kaizer1v","platform":"Windows 7 (6.1.7601; x64; SP1; S)","ms_played":275906,"conn_country":"IN","ip_addr_decryp
@kaizer1v
kaizer1v / top_5_groupby.py
Last active July 19, 2021 03:56
Top 5 in every group - Pandas
# Data Columns available are = ['track', 'year', 'minutes_streamed']
# GOAL: Top 5 tracks for every year from 2010 to 2020 based on the number of minutes streamed
group_1 = df.groupby(['year', 'track']).agg({'minutes_streamed': sum})
group_1['minutes_streamed'].groupby(['year'], group_keys=False).nlargest(5)
@kaizer1v
kaizer1v / emulate_inheritance.js
Last active November 14, 2018 17:40
Emulate Prototype Inheritance
/* ===============
* This snippet shows you how to inherit from one object into another,
* without using the `new` keyword or using any functions.
* ===============
*/
// create a class object which we will use to emulate inheritance
var Person = {
firstname: 'John',
lastname: 'Doe'
@kaizer1v
kaizer1v / import-html.html
Created October 5, 2018 04:03
Insert one html to another
<!DOCTYPE html>
<html>
<head>
<title>Import External HTML</title>
</head>
<body>
<h1>Importing External HTML Files</h1>
<p>View the code to see how to import another html</p>
<hr>
@kaizer1v
kaizer1v / jquery-template.html
Created October 4, 2018 06:43
jQuery template plugin using lodash
<!doctype html>
<html lang="en">
<head>
<title>jQuery Templating</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>
<body>
<h1 class="h">
@kaizer1v
kaizer1v / onlytrue.js
Created September 21, 2018 07:32
filterBoolean
// filters out all the falsey values and returns only valid ones
let arr = [7, "ate", "", false, 9];
arr.filter(Boolean); // [7, 'ate', 9]
@kaizer1v
kaizer1v / trim.js
Created September 5, 2018 09:08
Trimming
function trimLeft(val) {
// Adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
return val.replace(/^[\s\uFEFF\xA0]+/g, '');
}
@kaizer1v
kaizer1v / cycle.js
Created August 27, 2018 06:28
Cycle through Array in Javascript
let arr = [1, 2, 3];
// cycle the `arr` by
arr.unshift(arr.pop());
@kaizer1v
kaizer1v / generate_dates.py
Last active May 22, 2019 02:59
Pandas - Generate a list of Date Range
import pandas as pd
# will generate dates between the two dates, every 4 years
pd.date_range('01/01/1930', '01/01/2018', freq=pd.DateOffset(years=4))
@kaizer1v
kaizer1v / change_version.sh
Last active May 22, 2019 03:00
Using a different version of python (linux)
# Check versions of python installed
ls /usr/bin/python*
# Check your current python version
python --version
# Python 2.7.8
# Change alias of Python
alias python='/usr/bin/python3.5'
# or whatever version you have installed and want to switch to