Skip to content

Instantly share code, notes, and snippets.

View PeterWaIIace's full-sized avatar
💘
In love with computational evolution

W4ltz PeterWaIIace

💘
In love with computational evolution
View GitHub Profile
@PeterWaIIace
PeterWaIIace / matrix_vis.py
Last active June 22, 2024 05:58
Simple visualisation for matrices Numpy/JAX
# Define color codes
colors = {
'red': '\033[91m',
'green': '\033[92m',
'yellow': '\033[93m',
'purple': '\033[95m',
'blue': '\033[34m',
'orange': '\033[33m', # Orange color
'reset': '\033[0m' # Reset color to default
}
@PeterWaIIace
PeterWaIIace / pbar.py
Last active March 24, 2024 21:07
Nice progress bar for python
import time
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
@PeterWaIIace
PeterWaIIace / android-ubuntu
Created December 20, 2023 18:26 — forked from mpaepper/android-ubuntu
How to debug your Android device under Ubuntu
When programming apps for Android, you usually want to test them on real Android devices.
This little gist describes how to do so using Ubuntu 14.
First, you need to download and install the Android development IDE (http://developer.android.com/sdk/index.html) and create an Android project which you want to debug.
Next, you need to setup the debugging mode on your Android device. Starting in Android 4.2 you need to enable the developer options first: 1) Go to settings 2) Go to About Phone 3) Tap the build number 10 times (or more, not sure ;)) and you will get the notification that you enabled it.
Then go to the developer settings and enable the debug mode for your phone.
Now you think you can just plug it into your USB mode? - Nope.
@PeterWaIIace
PeterWaIIace / toggle.html
Created December 16, 2023 14:38
simple informational toggle
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Toggle Switch with Calibrators</title>
<style>
body {
display: grid;
@PeterWaIIace
PeterWaIIace / DFS_find_cycle.py
Created December 7, 2023 23:41
Find cycles in graph with DFS
def has_cycle(graph):
visited = set()
recursion_stack = set()
def dfs(node):
visited.add(node)
recursion_stack.add(node)
@PeterWaIIace
PeterWaIIace / shortest_path.py
Created December 7, 2023 21:05
Find shortest path in unbalanced graph
from queue import Queue
def shortest_path(graph, start_node, end_node):
visited = set()
q = Queue()
# (current_node, path)
q.put((start_node,[start_node]))
while q.qsize():
curr_node, path = q.get()
print(curr_node, path)
@PeterWaIIace
PeterWaIIace / count_islands.py
Created December 7, 2023 20:12
[BFS] count islands
from collections import deque
def count_islands(matrix):
if not matrix:
return 0
visited = set()
islands = 0
@PeterWaIIace
PeterWaIIace / binary_search.c
Created November 27, 2023 01:29
binary search in C
int32_t binary_search(const uint8_t * array, const uint32_t length, uint8_t val)
{
uint8_t low = 0;
uint8_t high = length;
do
{
uint8_t index = floor((low + high)/2);
if(val == array[index])
{
@PeterWaIIace
PeterWaIIace / eye.css
Created November 26, 2023 19:32
eye.css
<!DOCTYPE html>
<html>
<head>
<style>
.eyeball {
width: 80px;
height: 80px;
background-color: white;
border-radius: 50%;
display: flex;
@PeterWaIIace
PeterWaIIace / conversions.elm
Created November 26, 2023 17:21
Elm multi-form for units conversions
module Main exposing (main)
import Browser
import Html exposing (Html, Attribute, p, span, input, text)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
-- MAIN