Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Andrei K akost

View GitHub Profile
@akost
akost / kids-20-inch-bike.md
Last active Apr 2, 2019
Kids 20" Bike Research
View kids-20-inch-bike.md

Kids' 20" inch bikes research (October 2018).

Requirements:

  • Good brand
  • Hand brakes (not a coaster brake)
  • Reasonable price
  • Multiple gears (except Cleary Bikes Owl)

Results:

@akost
akost / dfs-inorder.py
Created Jul 2, 2017
Depth-First Search for binary tree. In-order traversal
View dfs-inorder.py
"""
Depth-First Search for binary tree
In-order traversal
"""
import unittest
class Node(object):
def __init__(self, data = None, left = None, right = None):
self.data = data
@akost
akost / bfs.py
Last active Jul 2, 2017
Breadth-First Search
View bfs.py
"""
Breadth-First Search for binary tree
"""
import unittest
class Node(object):
def __init__(self, data = None, left = None, right = None):
self.data = data
self.left = left
@akost
akost / str_to_int.py
Last active Jul 2, 2017
Converts string to integer
View str_to_int.py
"""
Convert string to integer
"""
import unittest
class TestStringMethods(unittest.TestCase):
def test1(self):
self.assertEqual(myInt("123"), 123)
@akost
akost / str_to_int.py
Last active Jul 2, 2017
Convert string to signed integer
View str_to_int.py
"""
Convert string to integer
"""
import unittest
class TestStringMethods(unittest.TestCase):
def test1(self):
self.assertEqual(myInt("123"), 123)
View cycle_detection.py
"""
Detect a cycle in a linked list. Note that the head pointer may be 'None' if the list is empty.
A Node is defined as:
class Node(object):
def __init__(self, data = None, next_node = None):
self.data = data
self.next = next_node
"""
@akost
akost / hours.php
Created Mar 9, 2017
Ugly 12-hours formatting
View hours.php
<?php echo ($i <= 12) ? $i : (($i <= 24) ? ($i - 12) : ($i - 24)) ?><?php echo $i < 12 ? 'am' : ($i > 23) ? 'am' : 'pm' ?>
@akost
akost / gist:b1fc7189ea5dc291b79e
Created Sep 11, 2015
Bookmarklet to show all page headers
View gist:b1fc7189ea5dc291b79e
javascript:(function(){function%20read(url){var%20r=new%20XMLHttpRequest();r.open('HEAD',url,false);r.send(null);return%20r.getAllResponseHeaders();}alert(read(window.location))})();
View godaddy-ssl-howto
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
http://support.godaddy.com/help/article/3601/generating-a-certificate-signing-request-nginx
http://support.godaddy.com/help/article/4976/rekeying-an-ssl-certificate
# Be sure to remember to chain them!
cat gd_bundle-g2-g1.crt >> yourdomain.crt
# Move 'em
sudo mv yourdomain.crt /etc/ssl/certs/yourdomain.crt
@akost
akost / gist:6386238
Last active Dec 21, 2015
Сдача экзамена по вождению в WA, USA. Существенное отличие от сдачи в России. Цитата из Drivers Guide http://www.dol.wa.gov/driverslicense/guide.html
View gist:6386238
Экзаменатор не ставит перед собой задачу ввести в заблуждение,
запутать или потребовать от экзаменуемого совершить правонарушение.
You can’t perform that action at this time.