Skip to content

Instantly share code, notes, and snippets.

View kelvingakuo's full-sized avatar

Kelvin Gakuo kelvingakuo

View GitHub Profile
##### Testing the different components separately before building the whole system
## THINGS YOU NEED TO SET UP
1. On the Raspberry Pi
```bash
pip install nanpy
pip install pygame
```
Testing the different components separately before building the whole system

THINGS YOU NEED TO SET UP

  1. On the Raspberry Pi
pip install nanpy
pip install pygame
@kelvingakuo
kelvingakuo / 0-README.md
Last active July 21, 2019 12:02 — forked from andineck/0-README.md
retropie bluez sixaxis shanwan PS3 controller bluetooth connection

shawnwan ps3 controller bluetooth connection problem fix

if your ps3 controller just vibrates when connecting to the retropie, or when your ps3 controller does not connect via bluetooth, this writedown might help you.

Since no exact description did work for me, I decided to write it down, what I did based on other descriptions, in order to get it to work.

links

version: '3.1'
services:
database:
image: "postgres"
restart: "always"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=db
CREATE TABLE IF NOT EXISTS public.persons(
person_id INT PRIMARY KEY,
first_name VARCHAR,
last_name VARCHAR
);
CREATE TABLE IF NOT EXISTS public.transactions(
transaction_id INT PRIMARY KEY,
transaction_amount INT,
def nested_loop_join(left: List[dict], right: List[dict], on: str, how: str) -> List[dict]:
""" Nested loop JOIN strategy: For every row in outer, find matching one in inner
If left/right JOIN and there's no match on inner, return outer. Else, skip
Params:
left (list<dict>) - List of dicts representing one relation
right (list<dict>) - List of dicts representing the other relation
on (string) - The key in the relations to JOIN on
how (string) - The JOIN (left, right, inner)
def hash_func(ind: int, mp_size: int):
""" A simple hash function (uses a version of the mid-square method and modulus)
Params:
ind (int) - The index to hash
mp_size (int) - The size of the hash map
Returns:
key (int) - The hashed output
"""
def inner_merge_join(left: List[dict], right: List[dict], on: str) -> List[dict]:
""" (Sort) Merge JOIN: Sort both by JOIN key. Loop through both simulateneously.
If matching, advance inner till no match. If no match, advance the smaller attr
INNER JOIN only implemented
"""
output = []
sorted_left = sorted(left, key = lambda dic: dic[on])
import re
keywords = r"(SELECT|WHERE|FROM|AND|OR|NOT)"
patterns = [
(keywords, lambda scanner, token: {"token_type": "keyword", "token": token}),
(r"[a-zA-Z_][a-zA-Z_0-9]*", lambda s, t: {"token_type": "name", "token": t}),
(r"\*", lambda s, t: {"token_type": "all_cols","token": t}),
(r">=|>|<=|<|=", lambda s, t: {"token_type": "operator","token": t}),
(r"[-+]?\d*\.\d+", lambda s, t: {"token_type": "float","token": t}),
(r"\d+", lambda s, t: {"token_type": "integer","token": t}),