This file contains hidden or 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
| // Script to control SiteGPT.AI chat Interface elements | |
| // Usage: | |
| // _sitegpt.open() | |
| // _sitegpt.hide() | |
| // _sitegpt.show() | |
| // etc. | |
| window._sitegpt = { | |
| is_open: function() { return !document.querySelector('#sitegpt-chat-icon img').src.includes('logo') }, | |
| open: function() { if (!_sitegpt.is_open()) { _sitegpt.toggle() } }, | |
| close: function() { if (_sitegpt.is_open()) { _sitegpt.toggle() } }, |
This file contains hidden or 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
| //////////////////////////////////// | |
| /* "dependencies": { | |
| "@supabase/supabase-js": "^2.13.1", | |
| "langchain": "^0.0.44" | |
| } */ | |
| //////////////////////////////////// | |
| import { OpenAI } from "langchain/llms"; | |
| import { |
This file contains hidden or 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 { Configuration, OpenAIApi } = require('openai'); | |
| let openai; | |
| const instructions = ``; | |
| if (process.env.OPEN_AI_API_KEY) { | |
| const configuration = new Configuration({ apiKey: process.env.OPEN_AI_API_KEY }); | |
| openai = new OpenAIApi(configuration); | |
| } |
This file contains hidden or 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
| function countryCodeToName(code) { | |
| const data = { | |
| "AD": "Andorra", | |
| "AE": "United Arab Emirates", | |
| "AF": "Afghanistan", | |
| "AG": "Antigua and Barbuda", | |
| "AI": "Anguilla", | |
| "AL": "Albania", | |
| "AM": "Armenia", | |
| "AO": "Angola", |
This file contains hidden or 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
| // Raw data from: https://github.com/country-regions/country-region-data/blob/master/data.json | |
| const data = JSON.parse('[{"countryName":"Afghanistan","countryShortCode":"AF","regions":[{"name":"Badakhshan","shortCode":"BDS"},{"name":"Badghis","shortCode":"BDG"},{"name":"Baghlan","shortCode":"BGL"},{"name":"Balkh","shortCode":"BAL"},{"name":"Bamyan","shortCode":"BAM"},{"name":"Daykundi","shortCode":"DAY"},{"name":"Farah","shortCode":"FRA"},{"name":"Faryab","shortCode":"FYB"},{"name":"Ghazni","shortCode":"GHA"},{"name":"Ghor","shortCode":"GHO"},{"name":"Helmand","shortCode":"HEL"},{"name":"Herat","shortCode":"HER"},{"name":"Jowzjan","shortCode":"JOW"},{"name":"Kabul","shortCode":"KAB"},{"name":"Kandahar","shortCode":"KAN"},{"name":"Kapisa","shortCode":"KAP"},{"name":"Khost","shortCode":"KHO"},{"name":"Kunar","shortCode":"KNR"},{"name":"Kunduz","shortCode":"KDZ"},{"name":"Laghman","shortCode":"LAG"},{"name":"Logar","shortCode":"LOW"},{"name":"Maidan Wardak","shortCode":"WAR"},{"name":"Nangarhar","shortCode":"NAN |
This file contains hidden or 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
| /*** | |
| * Given a slightly messy set of input strings, attempt to match a well-known browser name, and return an icon | |
| * | |
| * Examples: | |
| * inferBrowserIcon('safari') // exact match | |
| * inferBrowserIcon('Safari Mobile 15.4') // matches "safari" from input string | |
| * inferBrowserIcon('Firefox 99', 128) // pick a specific size (from sizes) | |
| * inferBrowserIcon('unknownbrowser') // fallback if no match | |
| * inferBrowserIcon(null, 128, 'brave') // You know the browser-logos repo key | |
| */ |
This file contains hidden or 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 requestIp = require('request-ip'); | |
| function getIp (req) { | |
| let ip = null; | |
| try { | |
| //ip = (req.headers['x-forwarded-for'] || '').split(',').pop() || | |
| // req.connection.remoteAddress || | |
| // req.socket.remoteAddress || | |
| // req.connection.socket.remoteAddress; |
This file contains hidden or 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
| // Register an external sprite, CORS headers required for images | |
| game.loadSprite('skeletonplayer', { | |
| "id": "skeletonplayer", | |
| "width": 48, | |
| "height": 48, | |
| "filepath_1": "http://filestore.b-cdn.net/skeleton_1.png", | |
| "filepath_2": "http://filestore.b-cdn.net/skeleton_2.png", | |
| "filepath_3": "http://filestore.b-cdn.net/skeleton_3.png", | |
| "animations": { | |
| "atk_right": { |
This file contains hidden or 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
| /** | |
| * RAF Performance Checking | |
| * | |
| * Will enable and disable a flag on the window object | |
| * When Javascript performance suffers, so that optional features | |
| * Can be Disabled or delayed | |
| */ | |
| (function () { | |
| var lastTimestamp = + new Date(); |