Skip to content

Instantly share code, notes, and snippets.

@zakiindra
zakiindra / game_of_life.txt
Last active August 24, 2018 03:01
Game Of Life
Duration
45 minutes
Problem Description
This game is about calculating the next generation of Conway’s game of life, given any starting position. See http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life for background.
You start with a two dimensional grid of cells, where each cell is either alive or dead. In this version of the problem, the grid is finite, and no life can exist off the edges.
When calculating the next generation of the grid, follow these rules:
1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
2. Any live cell with more than three live neighbours dies, as if by overcrowding.
3. Any live cell with two or three live neighbours lives on to the next generation.
@zakiindra
zakiindra / avro_to_dataframe.py
Last active November 5, 2019 04:35 — forked from LouisAmon/avro_to_dataframe.py
Read Avro file from Pandas
import pandas
import fastavro
def avro_df(filepath, encoding):
# Open file stream
with open(filepath, encoding) as fp:
# Configure Avro reader
reader = fastavro.reader(fp)
# Load records in memory
records = [r for r in reader]
@zakiindra
zakiindra / spark_read_parquet
Created November 5, 2019 04:35
Read from Parquet using Spark
//
val prop=new java.util.Properties()
prop.put("user","username")
prop.put("password","yourpassword")
val url="jdbc:mysql://host:port/db_name"
val df=spark.read.jdbc(url,"table_name",prop)
df.show()
//
x = dict()
def update(x, id, location, time):
locs = x.get(id)
if (locs is None):
locs = dict()
locs[location] = [time]
x[id] = locs
else:
times = locs.get(location)
@zakiindra
zakiindra / perceptron.py
Last active April 25, 2022 22:58
Perceptron from Scratch with PyTorch
import numpy as np
import torch
# 9 data points: one x1 x2 y
xy = np.matrix ([
[1.0, 0.0, 0.0, 0.5],
[1.0, 0.0, 0.5, 0.3],
[1.0, 0.0, 1.0, 0.2],
[1.0, 0.5, 0.0, 0.8],
[1.0, 0.5, 0.5, 0.5],
@zakiindra
zakiindra / anime-recommendation-system.ipynb
Created May 8, 2022 01:33
Anime Recommendation System
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

SSRLCV Compile and Run in CUDA Cluster

  1. Connect to any cluster with GPU.

  2. Clone SSRLCV and SSRLCV-Sample-Data repo.

    git clone https://github.com/uga-ssrl/SSRLCV.git
    git clone https://github.com/uga-ssrl/SSRLCV-Sample-Data.git

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: