Skip to content

Instantly share code, notes, and snippets.

@pycckuu
pycckuu / gist:576fefd979db2c5cafc60553ceec08a1
Created May 4, 2023 19:34
This script defines two functions that allow a user to interact with OpenAI's GPT models via the command line: gpt(): This function takes a query as an argument, sends it to the GPT-3.5 model, and returns a response. It uses the API key stored in the environment variable OPENAI_API_KEY to authenticate the request. The response is printed in the …
export OPENAI_API_KEY=sk-...
# ask gpt anything in the terminal and get a response
function gpt() {
local url="https://api.openai.com/v1/chat/completions"
local model="gpt-3.5-turbo"
local system="Offer a brief reply to the question. Format everything using ANSI escape codes for color, bold, and underline. Do not use backticks."
echo using $model model "\n"
local body="{\"model\":\"$model\", \"messages\":[{\"role\": \"system\", \"content\": \"$system\"}, {\"role\": \"user\", \"content\": \" Answer the query: $1\"}]}"
local headers="Content-Type: application/json"
local auth="Authorization: Bearer ${OPENAI_API_KEY}"
@pycckuu
pycckuu / pass.md
Last active April 24, 2023 15:51 — forked from abtrout/pass.md
Using password-store with git repository synching

Password-store keeps your passwords (or any other sensitive information) saved in GnuPG encrypted files organized in ~/.password-store. For more information about GPG, consult the GNU Privacy Handbook.

Getting started

To get started, install pass and generate a keypair.

$ brew install pass
$ gpg --gen-key
$ gpg --list-keys
@pycckuu
pycckuu / passgitgpg.md
Created May 29, 2022 20:45 — forked from flbuddymooreiv/passgitgpg.md
Setting up pass on git with a gpg key

The following shell transcript shows how to:

  • Create a GPG key
  • Create a pass database
  • Add git support to the pass database
  • Create a remote git repository
  • Push the pass database to the remote git repository
  • Fetch and display your passwords from another host

It is assumed that the pass package has been installed on both the first and second computers.

@pycckuu
pycckuu / golang-tls.md
Created June 15, 2020 13:50 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@pycckuu
pycckuu / ERC20 with Emit functionality
Created October 2, 2019 19:30
ERC20 with Emit functionality
pragma solidity ^0.4.24;
// ----------------------------------------------------------------------------
// '0Fucks' token contract
//
// Deployed to : 0x5A86f0cafD4ef3ba4f0344C138afcC84bd1ED222
// Symbol : 0FUCKS
// Name : 0 Fucks Token
// Total supply: 100000000
// Decimals : 18
@pycckuu
pycckuu / erc20 contract
Created August 30, 2019 08:27
simple erc 20 that shows balance in metamask
pragma solidity ^0.4.24;
// ----------------------------------------------------------------------------
// '0Fucks' token contract
//
// Deployed to : 0x5A86f0cafD4ef3ba4f0344C138afcC84bd1ED222
// Symbol : 0FUCKS
// Name : 0 Fucks Token
// Total supply: 100000000
// Decimals : 18
absl-py==0.7.1
appnope==0.1.0
astor==0.8.0
awscli==1.16.132
backcall==0.1.0
botocore==1.12.122
certifi==2019.6.16
decorator==4.4.0
gast==0.2.2
grpcio==1.16.1
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <fstream>
#include <sstream>
using std::string;
using std::vector;
using std::ifstream;
using std::stringstream;
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <fstream>
#include <sstream>
using std::string;
using std::vector;
using std::ifstream;
using std::stringstream;
@pycckuu
pycckuu / graph_lenght.cpp
Created March 31, 2016 03:45
method const vs non-const
friend void get_edge_value(const Graph &g, int node_x, int node_y){
if (g.mapping[node_x][node_y]==1) {
list<Edge>::iterator it;
for (it = g.list_of_edges.begin(); it != g.list_of_edges.end(); it++) {
if ( (it->begin == node_y && it->end == node_x) || (it->begin == node_x && it->end == node_y)){
cout << it->distance;
}
}
}
}