Skip to content

Instantly share code, notes, and snippets.

// ranker is a helper type for the rank function.
type ranker struct {
f []float64 // Data to be ranked.
r []int // A list of indexes into f that reflects rank order after sorting.
}
// ranker satisfies the sort.Interface without mutating the reference slice, f.
func (r ranker) Len() int { return len(r.f) }
func (r ranker) Less(i, j int) bool { return r.f[r.r[i]] < r.f[r.r[j]] }
func (r ranker) Swap(i, j int) { r.r[i], r.r[j] = r.r[j], r.r[i] }
@juanbrujo
juanbrujo / PlayStationBIOSFilesNAEUJP.md
Last active May 4, 2024 14:31
Files for PlayStation BIOS Files NA-EU-JP
@tykurtz
tykurtz / grokking_to_leetcode.md
Last active May 4, 2024 14:31
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

@shaundon
shaundon / WorkoutSplit.swift
Created February 21, 2021 17:34
Convert an array of HKQuantitySample into splits.
import Foundation
import HealthKit
struct WorkoutSplit: Hashable {
let label: String
let distance: HKQuantity
let duration: TimeInterval
}
extension WorkoutSplit {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Sohamsk
Sohamsk / djikstra.py
Last active May 4, 2024 14:26
This gist is meant to store code related to greedy algorithms
import heapq
from typing import List
def djikstra(graph_inner, starting, vertices) -> List:
pq = []
dist = [float('inf') for i in range(vertices)]
dist[starting] = 0
print(dist)
heapq.heappush(pq, [0, starting])
@L422Y
L422Y / osx_automount_nfs.md
Last active May 4, 2024 14:26
Automounting NFS share in OS X into /Volumes

I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:

/etc/auto_master (see last line):

#
# Automounter master map
#

+auto_master # Use directory service

@Sohamsk
Sohamsk / graph_colouring_backtracking.py
Last active May 4, 2024 14:26
Solving backtracking problem
def is_safe(graph, colours, colour, current):
neighbours = graph[current]
for neighbour in neighbours:
if colour == colours[neighbour - 1]:
return False
return True
def graph_traversal(graph, colours, vertices, current):
if current == vertices + 1:
return True
@Sohamsk
Sohamsk / Astar.py
Last active May 4, 2024 14:26
Solving 8 puzzle problem using A star algorithm.
class Node:
def __init__(self, data: list, level, f_val):
self.data = data
self.level = level
self.f_val = f_val
def generate_children(self):
children = []
values = [[0, 1], [1, 0], [-1, 0], [0, -1]]
row, col = self.find()
@indyfromoz
indyfromoz / aspnet-mvc.gitignore
Created November 19, 2012 06:44
.Gitignore for ASP.NET MVC
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache