Skip to content

Instantly share code, notes, and snippets.

View TheAlchemistKE's full-sized avatar
🤩
Always Be Coding, Always Be Learning

Kelyn Paul Njeri TheAlchemistKE

🤩
Always Be Coding, Always Be Learning
View GitHub Profile
> Task :react-native-gradle-plugin:compileKotlin FAILED
1 actionable task: 1 executed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-gradle-plugin:compileKotlin'.
> java.io.IOException: Unable to delete directory '/Users/kelyn_njeri/Desktop/Work/promo-customer/node_modules/react-native-gradle-plugin/build/classes/kotlin/main'
Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
- /Users/kelyn_njeri/Desktop/Work/promo-customer/node_modules/react-native-gradle-plugin/build/classes/kotlin/main/META-INF/react-native-gradle-plugin.kotlin_module
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
#include <errno.h>
#define BUFFER_SIZE 256
#define MAX_COMMAND_LENGTH 100
"use client";
import React, { useEffect, useRef, useState } from "react";
import ReactToPrint from "react-to-print";
import { Button } from "./ui/button";
import Receipt from "./receipt";
import { scanCard } from "@/lib/client";
import { useToast } from "./ui/use-toast";
export default function PrintComponent() {
let componentRef = useRef();
@TheAlchemistKE
TheAlchemistKE / bellman_ford.ts
Created October 22, 2023 12:24
Bellman Ford Implementation in TypeScript.
class BellmanFord {
// Graph represented as an adjacency list
graph: Record<string, Record<string, number>>;
constructor(graph: Record<string, Record<string, number>>) {
this.graph = graph;
}
bellmanFord(source: string) {
// Initialize distances and predecessors
package main
import (
"fmt"
"math"
)
func bellmanFord(graph map[string]map[string]float64, source string) (map[string]float64, map[string]string) {
distances := make(map[string]float64)
predecessors := make(map[string]string)
def bellman_ford(graph, source):
# Initialize distances and predecessors
distances = {vertex: float('infinity') for vertex in graph}
predecessors = {vertex: None for vertex in graph}
distances[source] = 0
# Relax edges repeatedly
for _ in range(len(graph) - 1):
for vertex in graph:
for neighbor in graph[vertex]:
package main
import (
"fmt"
"math"
)
type Edge struct {
to int
cap int
package main
import (
"fmt"
"math"
)
func hungarianAlgorithm(costMatrix [][]int) ([]int, int) {
rows := len(costMatrix)
cols := len(costMatrix[0])
import numpy as np
from scipy.optimize import linear_sum_assignment
def hungarian_method(cost_matrix):
row_indices, col_indices = linear_sum_assignment(cost_matrix)
return list(zip(row_indices, col_indices))
# Example usage:
cost_matrix = np.array([
[3, 2, 7],
package main
import (
"fmt"
)
type HopcroftKarp struct {
graph map[string][]string
matching map[string]string
visited map[string]bool