Skip to content

Instantly share code, notes, and snippets.

@rollue
rollue / refactored_merge_two_ordered_lists.py
Created March 4, 2018 09:01
Refactored merge two ordered lists
def refactored_merge_two_sorted_lists(L1, L2):
dummy_head = tail = Node()
cur1 = L1
cur2 = L2
while cur1 and cur2:
if cur1.data < cur2.data:
tail.next, cur1 = cur1, cur1.next
else:
tail.next, cur2 = cur2, cur2.next
@rollue
rollue / doubly_linked_list.py
Created March 4, 2018 10:57
implement doubly linked list
# -*- coding: utf-8 -*-
__author__ = "Myong-Hoon Jeon"
from unittest import main, TestCase
class Node:
""" 연결리스트의 Node. """
# -*- coding: utf-8 -*-
__author__ = "MH Jeon"
import os
from unittest import main, TestCase
import sys
""" Solution for EPI 8.1: Implement stack with max API """
from unittest import main, TestCase
class Node:
def __init__(self, data, next):
self._data = data
self._next = next
def __repr__(self):
@rollue
rollue / queue.py
Created March 5, 2018 16:45
Simple implementatin of queue
from unittest import main, TestCase
class Node:
def __init__(self, data, next):
self._data = data
self._next = next
def __repr__(self):
@rollue
rollue / binary_search_tree.py
Created March 9, 2018 04:17
Python implementation of binary search tree; add, search, delete
# -*- coding: utf-8 -*-
from unittest import TestCase, main
__author__ = 'MH Jeon'
class Node:
def __init__(self, data):
@rollue
rollue / Q1-find-nearest-two-points.py
Created March 24, 2018 02:17
Q1-find-nearest-two-points.py
"""
# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
num_of_lines = 2
for i in range(num_of_lines):
if i == 0:
total_num = int(input())
else:
num_list = [int(x) for x in input().split()]
@rollue
rollue / vim_cheatsheet.md
Created March 25, 2018 00:38 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@rollue
rollue / cognito-developer-authenticated-client-example.py
Created May 1, 2019 03:23 — forked from dkarchmer/cognito-developer-authenticated-client-example.py
django-boto3-cognito: AWS' Cognito Developer Authenticated Identities Authflow using Django/Python/Boto3 (For building stand-alone clients)
__author__ = 'dkarchmer'
'''
This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but
requires your Django server to have an API for your user to access Cognito based credentials
Because of Cognito, the client (this script) will only get temporary AWS credentials associated
to your user and only your user, and based on whatever you configure your AIM Policy to be.
Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate
how to create a stand-alone Python script but operating similarly to these apps.
@rollue
rollue / SignS3RequestAPIView.py
Created May 3, 2019 03:35 — forked from ergusto/SignS3RequestAPIView.py
For signing direct to S3 file uploads with Django Rest Framework
import os, boto3
from botocore.client import Config
from django.conf import settings
from rest_framework import parsers
from rest_framework.permissions import IsAuthenticated
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.renderers import JSONRenderer