Skip to content

Instantly share code, notes, and snippets.

View dabajabaza's full-sized avatar

Carbon-Based Lifeform dabajabaza

  • Moscow
View GitHub Profile
@dabajabaza
dabajabaza / btree_traversal.py
Last active July 23, 2023 14:00
Binary Tree Traversal
# IN-ORDER
def in_order_iterative(root):
stack = []
visited = []
while root or stack:
while root:
stack.append(root)
root = root->left
root = stack.pop()
visited.append(root->val)
@dabajabaza
dabajabaza / 0.md
Created September 8, 2016 22:23 — forked from max-mapper/0.md
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)

@dabajabaza
dabajabaza / reddit_api_requests
Last active August 20, 2016 14:39
Examples of requests to reddit api
{} - necessary
[] - optional
#reddit front page
reddit.com/.json
#subreddit's posts
reddit.com/r/{subreddit}.json
#thread's comments
@dabajabaza
dabajabaza / mysql2sqlite.sh
Created June 4, 2016 15:11 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite