Skip to content

Instantly share code, notes, and snippets.

View shark8me's full-sized avatar

Kiran Karkera shark8me

View GitHub Profile
@shark8me
shark8me / create-job.clj
Created September 15, 2020 11:24
Create a k8s job
;;set the REST endpoint for K8S
(core/set-api-context {:base-url "http://localhost:8080"})
;;create a job with the given spec.
;;we'll use the default K8s namespace.
(create-namespaced-job "default" pi-job-spec)
@shark8me
shark8me / get-job-status.clj
Created September 15, 2020 11:26
Get the job status
(get-job-status "pi")
;;{:startTime "2020-09-15T08:33:44Z", :active 1}
;;wait for a few seconds
(get-job-status "pi")
;;{:conditions [{:type "Complete", :status "True", :lastProbeTime "2020-09-15T08:33:55Z",
;;:lastTransitionTime "2020-09-15T08:33:55Z"}], :startTime "2020-09-15T08:33:44Z",
;;:completionTime "2020-09-15T08:33:55Z", :succeeded 1}
@shark8me
shark8me / get-job-result.clj
Created September 15, 2020 11:36
Get the Kubernetes job result
(->
;;this is a utility API to get the name of the pods
;;used by the job named pi.
(get-job-pods "pi")
first
(read-namespaced-pod-log "default"))
;;the result is the first 50 digits of pi.
;;"3.1415926535897932384626433832795028841971693993751\n"
@shark8me
shark8me / delete-job.clj
Created September 15, 2020 11:41
Delete the Kubernetes Job
(delete-namespaced-job "pi" "default"
{:kind :DeleteOptions
:propagationPolicy "Foreground"})
;;all dependents are deleted when this command returns
@shark8me
shark8me / k8s-pi-job-full.clj
Created September 15, 2020 11:49
Running the K8S Pi job via the Clojure Repl
(ns clj-k8s-job.core
(:require
[clojure-kubernetes-client.core :as core]
[clojure-kubernetes-client.api.core-v1 :refer [read-namespaced-pod-log
list-pod-for-all-namespaces]]
[clojure-kubernetes-client.api.batch-v1 :refer [create-namespaced-job
read-namespaced-job-status
delete-namespaced-job]]))
(def pi-job-spec
@shark8me
shark8me / deploy.yaml
Last active September 15, 2021 13:57
Deploy Clojure jars to Github packages
name: Publish package to GitHub Packages
on: [push]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
@shark8me
shark8me / project.clj
Created September 15, 2021 14:57
project.clj definition for deploying to Github packages
(defproject group-id/artifact-id "version"
:repositories [["github" {:url "https://maven.pkg.github.com/<githubusername>/<repo>"
:username <github-username> :password [:env/GITHUB_TOKEN]}]]
;;other bits
)
@shark8me
shark8me / settings.xml
Last active September 15, 2021 15:21
Maven settings.xml entry to allow for download of jars from Github registry
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
@shark8me
shark8me / timidity.cfg
Created July 10, 2022 09:12
Configuring timidity to use multiple soundfonts
dir /soundfont
bank 0
74 %font ExpressiveFluteSSO-v1.2.sf2 0 0
40 %font Strings-4U-v1.0.sf2 0 0
54 %font KBH-Real-Choir-V2.5.sf2 0 1
@shark8me
shark8me / convstack2d.py
Created September 16, 2022 13:45
Default convolution stack for AMT
class ConvStack2d(nn.Module):
def __init__(self, input_features, output_features):
super().__init__()
# input is batch_size * 1 channel * frames * input_features
self.cnn = nn.Sequential(
# layer 0
nn.Conv2d(1, output_features // 16, (3, 3), padding=1),
nn.BatchNorm2d(output_features // 16),
nn.ReLU(),