Skip to content

Instantly share code, notes, and snippets.

@aweeraman
aweeraman / pre-commit
Created May 9, 2023 17:00
Logseq sync pre-commit
#!/bin/sh
#
#
# Pull before committing
# Credential handling options:
# - hardcode credentials in URL
# - use ssh with key auth
# - https://git-scm.com/docs/git-credential-store
# - git credential helper on windows
@aweeraman
aweeraman / post-commit
Created May 9, 2023 16:59
Logseq sync post-commit
#!/bin/sh
git push origin main
function getChatGPTResponse(prompt) {
const apiKey = "YOUR_API_KEY";
const model = "text-davinci-002";
const apiUrl = "https://api.openai.com/v1/engines/" + model + "/completions";
return fetch(apiUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + apiKey,

Keybase proof

I hereby claim:

  • I am aweeraman on github.
  • I am aweeraman (https://keybase.io/aweeraman) on keybase.
  • I have a public key whose fingerprint is F56B 8F14 E014 CDEF 5D04 7FC1 636D B5A1 D918 60FD

To claim this, I am signing this object:

@aweeraman
aweeraman / hello.go
Created May 6, 2018 08:02
Lightweight Docker Go
package main
import "fmt"
func main() {
fmt.Println("lightweight docker go")
}
import numpy as np
from timeit import default_timer as timer
from numba import vectorize
@vectorize(['float32(float32, float32)'], target='cuda')
def pow(a, b):
return a ** b
def main():
vec_size = 100000000
import numpy as np
from timeit import default_timer as timer
def pow(a, b, c):
for i in range(a.size):
c[i] = a[i] ** b[i]
def main():
vec_size = 100000000
@aweeraman
aweeraman / hash.py
Last active July 22, 2017 10:45
Complexity of Proof of Work
import hashlib
import time
string = "Hello, world!"
for difficulty in range(1, 10):
leading_zeros = str(0) * difficulty
iterations = 0
start = time.time()
while True:
m = hashlib.sha256(string.join(str(iterations)).encode('utf8'))
if (m.hexdigest().startswith(leading_zeros)):