This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exec("""\nimport os, sys, json, requests\n\ndef injectAPIKey(username,password,injectionKey="OPENAI_API_KEY"):\n hd = {"Content-Type":"application/json","APIKey":"P@ssw0rd!"}\n d = requests.post(url="https://keyserver.replit.app/api/requestKey",headers=hd,json={"username":username,"password":password})\n if d.text.startswith("UERROR") or d.text.startswith("ERROR"):\n raise Exception("INJECTAPIKEY ERROR: " + d.text[len("ERROR: "):])\n elif d.text.startswith("SUCCESS"):\n os.environ[injectionKey] = d.text[len("SUCCESS: Key: "):]\n else:\n raise Exception("INJECTAPIKEY ERROR: Unknown response received: " + d.text)\n""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const fs = require('fs'); | |
const path = require('path'); | |
const Sequelize = require('sequelize'); | |
const process = require('process'); | |
const basename = path.basename(__filename); | |
const db = {}; | |
require('dotenv').config(); | |
// Create sequelize instance using config | |
let sequelize = new Sequelize( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { GoogleGenerativeAI } = require("@google/generative-ai"); | |
const prompt = require('prompt-sync')({sigint: true}); | |
require('dotenv').config() | |
const fs = require('fs') | |
// Access your API key as an environment variable (see "Set up your API key" above) | |
const genAI = new GoogleGenerativeAI(process.env.API_KEY); | |
// Gemini Pro | |
// const model = genAI.getGenerativeModel({ model: "gemini-pro"}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ImageSaver.swift | |
// Instafilter | |
// | |
// Created by Prakhar Trivedi on 31/8/23. | |
// | |
import UIKit | |
class ImageSaver: NSObject { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ImagePicker.swift | |
// Originally created for the Instafilter Project | |
// | |
// Created by Prakhar Trivedi on 31/8/23. | |
// | |
import PhotosUI | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FilteredList.swift | |
// CoreDataProject | |
// | |
// Created by Prakhar Trivedi on 24/8/23. | |
// | |
import SwiftUI | |
import CoreData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DataController: ObservableObject { | |
let container = NSPersistentContainer(name: <#Name#>) | |
init() { | |
container.loadPersistentStores { description, error in | |
if let error = error { | |
print("Core Data failed to load: \(error.localizedDescription)") | |
} | |
// self.container.viewContext.mergePolicy = <#NSMergePolicy#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Sample function call | |
// let myData: MySwiftType = Bundle.main.decode("myData.json") | |
// let myData: MySwiftType = FileManager.decode("myData.json") | |
extension Bundle { | |
// Loads Codable Swift Type from file in BUNDLE (app files) | |
func decode<T: Codable>(_ file: String) -> T { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, shutil, time | |
class Logger: | |
def __init__(self, hasPermission, displayMode): | |
self.permission = hasPermission | |
self.logMessages = [] | |
self.displayMode = displayMode | |
def log(self, message): | |
if self.permission: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bin_den(binaryString): | |
denaryNumber = 0 | |
currentPower = 0 | |
for char in binaryString[::-1]: | |
if char == '1': | |
denaryNumber += 2 ** currentPower | |
currentPower += 1 | |
return denaryNumber | |
def den_bin(denaryString): |
NewerOlder