Skip to content

Instantly share code, notes, and snippets.

View shiny-eel's full-sized avatar

shiny-eel

View GitHub Profile
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
@shiny-eel
shiny-eel / .p10k.zsh
Created May 6, 2021 01:28
powerlevel10k
# Generated by Powerlevel10k configuration wizard on 2021-03-20 at 16:57 AEDT.
# Based on romkatv/powerlevel10k/config/p10k-classic.zsh, checksum 40036.
# Wizard options: nerdfont-complete + powerline, small icons, classic, unicode,
# lightest, angled separators, sharp heads, flat tails, 1 line, compact, few icons,
# concise, transient_prompt, instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate
# your own config based on it.
#
@shiny-eel
shiny-eel / answers.txt
Last active August 27, 2020 09:44
[TWU Biblioteca SQL] Queries and answers for the Biblioteca SQL assignment #sql
-- Queries and Answers for TWU Biblioteca SQL Assignment
-- Author: Lu Shien Lee
-- Question 1
SELECT member.name
FROM book, member, checkout_item
WHERE book.title = "The Hobbit"
AND member.id = checkout_item.member_id
AND book_id = book.id;
@shiny-eel
shiny-eel / snippet.sh
Created August 26, 2020 04:21
[Fast git squash] Unsafe but efficient way of moving multiple commit changes into the a previous commit #git
git branch featureBranch
# where n is the number of commits to squash
git reset --soft HEAD~[n]
git commit --amend
@shiny-eel
shiny-eel / minTimeRequired.py
Last active August 18, 2019 05:19
[Minimum Time Required] Find the minimum of days taken to produce G units given array M where M(i) = days needed for machine i to produce 1 unit. #hackerrank #python #search
# Complete the minTime function below.
def minTime(machines, goal):
average = 0
big = 0
for mach in machines:
average += 1/mach
big = max(mach, big)
approx = round(goal / average) - 1
@shiny-eel
shiny-eel / allPossibleLeaders.py
Last active August 17, 2019 07:59
[All Possible Leaders] Given an array, find all its elements that can become a leader, after increasing by 1 all of the numbers in some segment of a given length. #codility #python
def solution(K, M, A):
freqs = [0] * (M+1) # freqs[i] = frequency of int i+1, ie from 1-(M+1)
# increments[i] = int to have freq incremented when enters window at ind i (range should be 1-M)
increments = [0] * len(A)
threshold = (len(A) // 2) + 1
leaders = [0] * (M+1) # once leader found, place in matching position in array
for i in range(len(A)):
num = A[i]
increments[i] = num + 1
@shiny-eel
shiny-eel / readme.md
Created August 15, 2019 07:27
[Minimum Rectangles] Cover "Manhattan skyline" using the minimum number of rectangles. #codility #python #stack

What I learned

@shiny-eel
shiny-eel / readme.md
Created August 14, 2019 23:17
[Number of Intersections] Compute the number of intersections in a sequence of discs. #codility #python
@shiny-eel
shiny-eel / digraph-color.py
Created August 12, 2019 20:08
[Coloring a digraph] Given an undirected graph with maximum degree D, find a graph coloring using at most D+1 colors. #interviewcake
def color_graph(graph, colors):
# Create a valid coloring for the graph
# BFS
to_visit = []
to_visit.append(graph[0])
while to_visit:
node = to_visit.pop(0)
@shiny-eel
shiny-eel / Solution.java
Last active May 10, 2019 16:50
[Minimum absolute sum of any pair] Minimum absolute sum of any pair of integers in an array. #codility #queues #sorting #java
class Solution {
public int solution(int[] A) {
Arrays.sort(A);
// Split into -ve queue and +ve queue
ArrayDeque<Integer> negs = new ArrayDeque<>();
ArrayDeque<Integer> pos = new ArrayDeque<>();
for (int i = 0; i<A.length; i++) {
int el = A[i];
if (el >= 0) {