Skip to content

Instantly share code, notes, and snippets.

View fivejjs's full-sized avatar
🏠
Working from home

vfive fivejjs

🏠
Working from home
  • Data scientist and engineer
  • Sydney Australia
View GitHub Profile
@fivejjs
fivejjs / Different_style_guide_python.md
Created March 20, 2024 22:39 — forked from nipunsadvilkar/Different_style_guide_python.md
What is the standard Python docstring format?

Formats

Python docstrings can be written following several formats as the other posts showed. However the default Sphinx docstring format was not mentioned and is based on reStructuredText (reST). You can get some information about the main formats in that tuto.

Note that the reST is recommended by the PEP 287

There follows the main used formats for docstrings.

- Epytext

@fivejjs
fivejjs / bbox_iou_evaluation.py
Created October 5, 2023 09:37 — forked from AruniRC/bbox_iou_evaluation.py
Object detector util: match a set of detected bounding boxes and a set of ground-truth bounding boxes
from __future__ import division
import scipy.optimize
import numpy as np
def bbox_iou(boxA, boxB):
# https://www.pyimagesearch.com/2016/11/07/intersection-over-union-iou-for-object-detection/
# ^^ corrected.
# Determine the (x, y)-coordinates of the intersection rectangle
xA = max(boxA[0], boxB[0])

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

@fivejjs
fivejjs / ParseRSAKeys.java
Created October 4, 2022 23:15 — forked from destan/ParseRSAKeys.java
Parse RSA public and private key pair from string in Java
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
@fivejjs
fivejjs / upsert.clj
Created June 9, 2022 23:42 — forked from apeckham/upsert.clj
clojure jdbc copy into temporary table with upsert
(def t (java.io.File/createTempFile "filename" ".txt"))
(println (.getPath t))
(defn row [n]
[(+ n 500000) (rand-int 10000) (rand-int 10000) (rand-int 10000) (rand-int 10000) 5550555 (rand) "hello world"])
(with-open [w (io/writer t)]
(csv/write-csv w (map row (range 1000000))))
(j/with-db-transaction [tx db-spec]
(defn decode-key
"Converts a train case string into a snake case keyword."
[s]
(keyword (str/replace s "_" "-")))
(defn encode-key
"Converts a snake case keyword into a train case string."
[k]
(str/replace (name k) "-" "_"))
@fivejjs
fivejjs / user.clj
Created March 24, 2022 12:16 — forked from spacegangster/user.clj
Getting call graph (vars structure) in Clojure
(ns user)
; Hey, I've been playing a bit with graphing out the structure of a module for Lightpad.
; It worked well, I've found the target function that I'll need change to add a new feature.
; Tweet with a screenshot https://twitter.com/spacegangster/status/1324760381735272450
; lein coordinate
; [com.gfredericks/clj-usage-graph "0.3.0"]
; https://github.com/gfredericks/clj-usage-graph
@fivejjs
fivejjs / rich4clojure_hard_problem_053.clj
Created February 22, 2022 11:48 — forked from PEZ/rich4clojure_hard_problem_053.clj
Longest Increasing Sub-Seq – Rich 4Clojure Problem 53 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.hard.problem-053
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Longest Increasing Sub-Seq =
;; By 4Clojure user: dbyrne
;; Difficulty: Hard
;; Tags: [seqs]
;;
;; Given a vector of integers, find the longest
;; consecutive sub-sequence of increasing numbers. If two
@fivejjs
fivejjs / dijkstra.clj
Created December 18, 2021 11:13 — forked from loganlinn/dijkstra.clj
Dijkstra's Algorithm in Clojure
(def ^:private inf (Long/MAX_VALUE))
(defn neighbors
"Returns n's neighbors, optionally filtered if unvisited"
([g n] (get g n {}))
([g n uv] (select-keys (neighbors g n) uv)))
(defn update-costs
"Returns costs updated with any shorter paths found to curr's unvisisted
neighbors by using curr's shortest path"