Skip to content

Instantly share code, notes, and snippets.

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

@neelabalan
neelabalan / aproducer.py
Created July 23, 2023 07:58 — forked from dabeaz/aproducer.py
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@neelabalan
neelabalan / normcore-llm.md
Created September 15, 2023 12:45 — forked from veekaybee/normcore-llm.md
Normcore LLM Reads
@neelabalan
neelabalan / settings.json
Created September 17, 2023 15:19
vscode file explorer indentation
"workbench.tree.indent": 15,
"workbench.tree.renderIndentGuides": "always",
"workbench.colorCustomizations": {
"tree.indentGuidesStroke": "#05ef3c"
}
from langchain.document_loaders import WebBaseLoader
from langchain.indexes import VectorstoreIndexCreator
loader = WebBaseLoader('https://jj09.net/simple-path-to-weight-loss/')
index = VectorstoreIndexCreator().from_loaders([loader])
print(index.query('how many colories should I consume to lose weight'))
@neelabalan
neelabalan / command
Created November 1, 2023 12:32
list resource cloudformation
aws cloudformation list-types --visibility PUBLIC --query "TypeSummaries[].TypeName" --output json > result.json
@neelabalan
neelabalan / r_file.r
Created November 3, 2023 12:31
R functions - backup
add_numbers <- function(x, y) {
result <- x + y
return(result)
}
sumArray = function(arrayOfNumbers) {
result = 0
if(typeof(arrayOfNumbers)=="double") {
for(i in c(1:length(arrayOfNumbers))) {
result = result + arrayOfNumbers[i]
from typing import Optional
from pydantic import Field, BaseModel
import openai
import instructor
instructor.patch()
class ContentSummary(BaseModel):
title: str
@neelabalan
neelabalan / prompt
Created November 6, 2023 17:05
Philosophy prompt
In our philosophical discussions, I ask you to channel the spirit of Jiddu Krishnamurti's dialogues. Approach each topic with depth, inviting further thought and reflection. Challenge assumptions, provoke deeper inquiry, and offer insights that encourage a profound examination of the subject. Do this across the breadth of philosophical inquiry, touching upon various themes and ideas as they arise. Engage with the content in a manner that promotes a rich and expansive exploration of philosophy.
@neelabalan
neelabalan / util.py
Created November 20, 2023 13:32
Stitch the response (to be used with ollama)
import requests
def stitch_response(response: requests.Response) -> str:
if not response.status_code == 200:
return ""
actual_response = ""
for res_chunk in response.text.split("\n")[:-1]:
actual_response += json.loads(res_chunk)["response"]
return actual_response