This file contains hidden or 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 contextlib | |
| @contextlib.contextmanager | |
| def cm(): | |
| info = {} | |
| print 'start' | |
| yield info | |
| print 'end', info |
This file contains hidden or 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 fibonaci_recursive(n): | |
| if n <= 2: | |
| return 1 | |
| return fibonaci_recursive(n-1) + fibonaci_recursive(n-2) | |
| def fibonaci_dp_1(n): | |
| memo = {} | |
| for i in range(1, n + 1): |
This file contains hidden or 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
| """Maximum Subarray Problem | |
| The maximum subarray problem is the task of finding the largest | |
| possible sum of a contiguous subarray, within a given one-dimensional | |
| array A[1…n] of numbers. | |
| https://link.medium.com/MPXDJMtDMU | |
| """ | |
| def maxsubarray(array): |
This file contains hidden or 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
| """Binary Tree: Longest path | |
| https://link.medium.com/tHhd8C0KOU | |
| """ | |
| class Node(object): | |
| def __init__(self, value): | |
| self.value = value | |
| self.left = | |
| self.right = None |
This file contains hidden or 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 functools | |
| def merge_or_append(ranges, element): | |
| if ranges and ranges[-1][0] <= element[0] <= ranges[-1][1]: | |
| ranges[-1] = (ranges[-1][0], max(ranges[-1][1], element[1])) | |
| else: | |
| ranges.append(element) | |
| return ranges |
This file contains hidden or 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
| @font-face { | |
| font-family: "Fura Code Nerd"; | |
| font-weight: normal; | |
| src: url("https://cdn.jsdelivr.net/gh/ryanoasis/[email protected]/patched-fonts/FiraCode/Light/complete/Fura%20Code%20Light%20Nerd%20Font%20Complete%20Mono.otf") format('opentype'); | |
| } | |
| @font-face { | |
| font-family: "Fura Code Nerd"; | |
| font-weight: bold; | |
| src: url("https://cdn.jsdelivr.net/gh/ryanoasis/[email protected]/patched-fonts/FiraCode/Medium/complete/Fura%20Code%20Medium%20Nerd%20Font%20Complete%20Mono.otf?raw=true") format('opentype'); | |
| } |
This file contains hidden or 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
| @font-face { | |
| font-family: "Iosevka Nerd"; | |
| font-weight: normal; | |
| font-style: normal; | |
| src: url("https://cdn.jsdelivr.net/gh/ryanoasis/[email protected]/patched-fonts/Iosevka/Extra-Light/complete/Iosevka%20Term%20Extralight%20Nerd%20Font%20Complete%20Mono.ttf") format('truetype'); | |
| } | |
| @font-face { | |
| font-family: "Iosevka Nerd"; | |
| font-weight: normal; | |
| font-style: italic; |
This file contains hidden or 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
| MAPPING = { | |
| '{': '}', | |
| '(': ')', | |
| '[': ']', | |
| } | |
| def is_open(c): | |
| return c in MAPPING | |
This file contains hidden or 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
| /* Extracted from https://www.youtube.com/watch?v=xF0rupA848E */ | |
| class Resource { | |
| public Resource() { | |
| System.out.println("created..."); | |
| } | |
| public Resource op1() { | |
| System.out.println("op1..."); | |
| return this; |
This file contains hidden or 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
| term_.prefs_.set('font-family', '"Iosevka Nerd", monospace'); | |
| term_.prefs_.set('user-css', 'https://cdn.jsdelivr.net/gh/gchiam/[email protected]/css/iosevka/iosevka-light-nerd-font.css'); |