This gist is updated daily via cron job and lists stats for npm packages:
- Top 1,000 most depended-upon packages
- Top 1,000 packages with largest number of dependencies
- Top 1,000 packages with highest PageRank score
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 |
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]) |
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() |
Source: https://medium.com/@Mahmoud_Zalt/eloquent-relationships-cheat-sheet-5155498c209
One to one ( 1-1 ) |
One to many ( 1-n ) |
Poly one to many ( 1x-n ) |
Many to many ( n-n ) |
Poly many to many ( nx-n ) |
|
---|---|---|---|---|---|
Number of models | 2 only | 2 only | 3 and above | 2 only | 3 and above |
Number of tables | 2 (1/model) | 2 (1/model) | 3+ (1/model) | 3 (1/model + pivot) | 4+ (1/model + pivot) |
Pivot table | - | - | - | required |
This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/
the command zig run my_code.zig
will compile and immediately run your Zig
program. Each of these cells contains a zig program that you can try to run
(some of them contain compile-time errors that you can comment out to play
with)
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
// Spec http://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify | |
const replacer = (key, value) => | |
value instanceof Object && !(value instanceof Array) ? | |
Object.keys(value) | |
.sort() | |
.reduce((sorted, key) => { | |
sorted[key] = value[key]; | |
return sorted | |
}, {}) : | |
value; |
Model:: | |
/*Select*/ | |
select('col1','col2') | |
->select(array('col1','col2')) | |
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating')) | |
->addSelect('col3','col4') | |
->distinct() // distinct select | |
/*From*/ |