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
rajiv.shah@C02FK16KMD6V vh1 % git push heroku master | |
Enumerating objects: 7, done. | |
Counting objects: 100% (7/7), done. | |
Delta compression using up to 16 threads | |
Compressing objects: 100% (4/4), done. | |
Writing objects: 100% (4/4), 4.30 KiB | 244.00 KiB/s, done. | |
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0 | |
remote: Compressing source files... done. | |
remote: Building source: | |
remote: |
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
{"feed":{"title":"Top Music Videos","id":"https://rss.itunes.apple.com/api/v1/us/music-videos/top-music-videos/all/200/explicit.json","author":{"name":"iTunes Store","uri":"http://wwww.apple.com/us/itunes/"},"links":[{"self":"https://rss.itunes.apple.com/api/v1/us/music-videos/top-music-videos/all/200/explicit.json"},{"alternate":"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?genreId=34\u0026popId=5"}],"copyright":"Copyright © 2018 Apple Inc. Все права защищены.","country":"us","icon":"http://itunes.apple.com/favicon.ico","updated":"2021-05-25T17:11:53.000-07:00","results":[{"artistName":"BTS","id":"1568538211","releaseDate":"2021-05-21","name":"Butter","kind":"musicVideo","copyright":"℗ 2021 BIGHIT MUSIC / HYBE","artistId":"883131348","artistUrl":"https://music.apple.com/us/artist/bts/883131348","artworkUrl100":"https://is5-ssl.mzstatic.com/image/thumb/Features125/v4/10/e1/ca/10e1ca24-34f4-d46b-55c8-ad02684af94d/mza_10814629250342140759.jpg/200x200mv.png","genres":[{"genreId":"1686","name":"K-Po |
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 collections | |
def flatten(dict_, *, separator='.', raise_on_collision=True): | |
flattened = {} | |
for key, value in dict_.items(): | |
if isinstance(value, collections.abc.Mapping): | |
tmp_dict = flatten(value) | |
for tmp_key, tmp_value in tmp_dict.items(): | |
tmp_key = separator.join((key, tmp_key)) |
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
# https://twitter.com/brainix/status/1358343863354552324 | |
def runlength_encoding(s): | |
if s: | |
count = 1 | |
for c1, c2 in zip(s[:-1], s[1:]): | |
if c1 == c2: | |
count += 1 | |
else: | |
yield c1, count |
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
>>> def hanoi(num, from_, using, to): | |
... if num: | |
... yield from hanoi(num-1, from_, to, using) | |
... yield f'move disc {num} from peg {from_} to peg {to}' | |
... yield from hanoi(num-1, using, from_, to) | |
... | |
>>> for move in hanoi(4, 1, 2, 3): | |
... print(move) | |
... | |
move disc 1 from peg 1 to peg 2 |
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
>>> def naturals(start): | |
... yield start | |
... yield from naturals(start+1) | |
... | |
>>> def sieve(prev_sieve): | |
... prime = next(prev_sieve) | |
... yield prime | |
... yield from (num for num in prev_sieve if num % prime != 0) | |
... | |
>>> s = sieve(naturals(2)) |
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
>>> j = 256 | |
>>> k = 256 | |
>>> j is k | |
True | |
>>> j = 257 | |
>>> k = 257 | |
>>> j is k | |
False | |
>>> j, k = 257, 257 | |
>>> j is k |
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 random | |
def assertion_sort(list_): | |
try: | |
assert all(x <= y for x, y in zip(list_, list_[1:])) | |
except AssertionError: | |
random.shuffle(list_) | |
assertion_sort(list_) |
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
#!/usr/bin/env python3 | |
import sys | |
# Map the uppercase letters forwards: | |
_MAPPING = { | |
'Q': 'P', | |
'W': 'O', |
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
<?xml version="1.0" encoding="utf-8"?> | |
<feed xmlns:im="http://itunes.apple.com/rss" xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> | |
<id>https://itunes.apple.com/us/rss/topmusicvideos/limit=200/explicit=true/xml</id><title>iTunes Store: Top Music Videos</title><updated>2016-06-22T20:09:58-07:00</updated><link rel="alternate" type="text/html" href="https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?cc=us&id=1&popId=5"/><link rel="self" href="https://itunes.apple.com/us/rss/topmusicvideos/limit=200/explicit=true/xml"/><icon>http://itunes.apple.com/favicon.ico</icon><author><name>iTunes Store</name><uri>http://www.apple.com/itunes/</uri></author><rights>Copyright 2008 Apple Inc.</rights> | |
<entry> | |
<updated>2016-06-22T20:09:58-07:00</updated> | |
<id im:id="1125405366">https://itunes.apple.com/us/music-video/this-is-what-you-came-for/id1125405366?uo=2</id> | |
NewerOlder