Skip to content

Instantly share code, notes, and snippets.

View skarlekar's full-sized avatar

Srini Karlekar skarlekar

View GitHub Profile
@skarlekar
skarlekar / guess-the-prompt.txt
Last active May 19, 2024 02:38
Here is the prompt I used to generate the 'Guess the Prompt' game
You are a game designer, a prompt engineer and a excellent teacher. Your task is to teach effective prompting techniques through a game where you challenge the user to think like an artist or photographer. In each round you will generate a prompt to create and display one image without revealing the prompt that you used and ask the user to guess the prompt that you used to generate the image. It is important that you do not reveal the prompt you used.
Once the user enters the guess, you will generate an image based on the description provided by the user. You will then measure how closely the users guess matches the original prompt using cosine similarity. You will then generate a percentage score based on the cosine similarity score. A cosine similarity value of -1 will be 0% and a cosine similarity value of 1 will be 100%. A cosine similarity score of 0 will be 50%. The cosine similarity score ranges from -1 (completely dissimilar) to 1 (exactly the same), with values closer to 1 indicating higher simil
@skarlekar
skarlekar / prompt-compare.py
Created May 18, 2024 21:20
This Python script provides a utility to compute the cosine similarity between two text sentences. This script is useful for applications like plagiarism detection, semantic search, or text data preprocessing where understanding the degree of similarity between texts is crucial.
"""
This Python script provides a utility to compute the cosine similarity between two text sentences using the TF-IDF
(Term Frequency-Inverse Document Frequency) vectorization approach.
Key Components:
1. Import Statements: The script begins by importing necessary modules:
- TfidfVectorizer from sklearn.feature_extraction.text for converting text data into a matrix of TF-IDF features.
- cosine_similarity from sklearn.metrics.pairwise to compute the similarity between two vectors in the TF-IDF space.
- sys for accessing command-line arguments.
@skarlekar
skarlekar / reshape-mnist-image-data-from-csv.py
Last active January 23, 2023 06:56
Sign-language MNist Data CSV Conversion: Convert 28x28 pixel image data passed as a label plus 784 field CSV record file into a Numpy array of shape (length, 28, 28) and a label array of (length,) as output
import numpy as np
# You will need to write code that will read the file passed
# into this function. The first line contains the column headers
# so you should ignore it
# Each successive line contians 785 comma separated values between 0 and 255
# The first value is the label
# The rest are the pixel values for that picture
# The function will return 2 np.array types. One with all the labels
# One with all the images
@skarlekar
skarlekar / Start-minio.sh
Last active May 14, 2022 08:59
Raspberry Pi Commands
# Reference: https://github.com/christianbaun/ossperf/wiki/Minio-on-a-Raspberry-Pi-3-with-Raspbian-(Debian-Jessie-8.0)
wget https://dl.minio.io/server/minio/release/linux-arm/minio
chmod +x minio
./minio server --address ":8080" /media/ssd/minio-data/
@skarlekar
skarlekar / pretty-print-json.sh
Created April 15, 2019 03:36
Pretty Print JSON in Shell Script
python -m json.tool my_json.json
@skarlekar
skarlekar / install-prereqs.md
Last active July 20, 2018 19:44
Script to install common prerequisites for a Docker-Node or Docker-Python project on Ubuntu 16.04

Install the Pre-requisites for Ubuntu

Use the following commands or follow the installing pre-requisites guide to prep the environment for Hyperledger Fabric installation.

curl -O https://gist.githubusercontent.com/skarlekar/6cab70ee0d8cecf60d66f9beabd40acf/raw/fb976b2986e2d2e59aa4ea8caf8f10016e85af41/prereqs-ubuntu.sh

chmod u+x prereqs-ubuntu.sh

Next run the script to install the pre-requisites.

@skarlekar
skarlekar / secure-mongo.md
Last active July 20, 2018 20:05
Secure MongoDB

Secure MongoDB

Start MongoDB

docker run -d --name mongo -p 27017:27017 -v ~/mongo-data:/data/db mongo --auth

List containers and ensure mongodb is running:

docker ps
@skarlekar
skarlekar / trimContainers.sh
Created April 23, 2018 16:52
Hyperledger Fabric - Remove old container after upgrading BNA
#!/bin/sh
first=`docker ps | grep "dev-peer0" | cut -c1-12 | head -n 1`
echo "Latest container: $first"
rest=`docker ps | grep "dev-peer0" | cut -c1-12 | grep -v $first`
echo "Stopped containers: "
docker stop $rest
echo "Removed containers: "
docker rm $rest
@skarlekar
skarlekar / autostartfabric.sh
Created April 23, 2018 16:31
Auto Start Hyperledger Fabric, HLF REST Server and Composer Playground from Ubuntu. Script expects Unix command 'expect' to be installed.
#!/usr/bin/expect -f
spawn su - hyperuser
expect "Password:"
send "<hyperuser-password>\r";
expect "hyperuser$"
send "cd ~/fabric-tools; ls\r"
expect "hyperuser$"
send "/home/hyperuser/fabric-tools/fabricUtil.sh start\r"
expect "hyperuser$"
send "echo HLF Containers started\r"
@skarlekar
skarlekar / kill-rest.sh
Last active June 7, 2018 18:12
Hyperledger Composer Utilities
PID=`lsof -i :3000 | cut -c 8-13 | grep -v "PID" | head -n 1 | tr -d '[:space:]'`
[ -z "$PID" ] && echo "Composer REST Server not running on port 3000" || echo "Killing $PID"
[ -z "$PID" ] && echo "Nothing to kill!" || kill $PID