{"id":16935580,"url":"https://github.com/virtadpt/exocortex-faas","last_synced_at":"2025-07-06T07:03:10.739Z","repository":{"id":144979548,"uuid":"192854618","full_name":"virtadpt/exocortex-faas","owner":"virtadpt","description":"OpenFaaS functions I've written to work with Huginn.","archived":false,"fork":false,"pushed_at":"2019-09-07T04:06:28.000Z","size":59,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T14:51:15.770Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/virtadpt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-20T05:31:53.000Z","updated_at":"2020-05-11T19:50:42.000Z","dependencies_parsed_at":"2023-04-11T01:31:16.013Z","dependency_job_id":null,"html_url":"https://github.com/virtadpt/exocortex-faas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtadpt%2Fexocortex-faas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtadpt%2Fexocortex-faas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtadpt%2Fexocortex-faas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtadpt%2Fexocortex-faas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virtadpt","download_url":"https://codeload.github.com/virtadpt/exocortex-faas/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248464656,"owners_count":21108238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T20:54:52.300Z","updated_at":"2025-04-11T18:54:01.518Z","avatar_url":"https://github.com/virtadpt.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# exocortex-faas\nSince discovering [OpenFaaS](https://www.openfaas.com/) I've been writing more and more special code for use with my [Huginn](https://github.com/huginn/huginn) installation.  It's surprisingly easy to set up and get running, and it makes it very easy to use some of the more specialized (usually, service-specific) modules for many programming languages as tools.  So, here are the FaaS (Function-as-a-Service) modules that I've been using.\n\nUnless otherwise stated, if you make an HTTP(S) request to one of these functions without any arguments, you will get the online help.\n\n## [8ball-tmr/](8ball-tmr/)\nA magick 8-ball of quotes from the [Modern Rogue](https://www.themodernrogue.com/) Discord server.  Every time you make a GET request, it returns another quote.\n\n### Building and deploying\n* `faas-cli build -f 8ball-tmr.yml`\n* `faas-cli deploy -f 8ball-tmr.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n## [calculator/](calculator/)\nA simple calculator.  Send it a math problem in a request and it'll solve it.  Operators and operands have to have spaces in between them, like this:\n\n`23 * 5`\n\n`16 + 18 / 2`\n\nFunctions supported:\n* add (+)\n* subtract (-)\n* multiply (*)\n* divide (/)\n* fmod - modulus (floating point output)\n* abs - absolute value\n* ceil - ceiling\n* fabs - absolute value (floating point)\n\n### Building and deploying\n* `faas-cli build -f calculator.yml`\n* `faas-cli deploy -f calculator.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n## [coordinate-converter/](coordinate-converter/)\nThis function takes map coordinates in one of the following formats and converts them into map coordinates in any of the other formats it supports:\n\n* degrees/minutes/seconds (dms)\n  * 48°53'10.18\"N 2°20'35.09\"E\n* decimal degrees (dd)\n  * -48.8866111111 -2.34330555556\n* [open location code](https://plus.codes/) (openlocationcode, pluscode)\n  * 8FVC9G8F+6X\n* [Military Grid Reference System](https://en.wikipedia.org/wiki/Military_Grid_Reference_System) (mgrs)\n  * 4QFJ1234567890\n\nInputs should look like this:\n\n```\n{\n  \"coordinates\": \"\u003cthe coordinates to convert\u003e\",\n  \"from\": \"\u003ctype of the coordinates to convert\u003e\",\n  \"to\": \"\u003ctype to convert the coordinates to\u003e\"\n}\n```\n\n### Building and deploying\nDue to the fact that one of the dependent modules is a wrapper around a C library, some additional flags need to be passed to `faas-cli` when building the container:\n\n* `faas-cli build -f coordinate-converter.yml  -b ADDITIONAL_PACKAGE=\"gcc libc-dev\"`\n* `faas-cli deploy -f coordinate-converter.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n## [geoplanet-db/](geoplanet-db/)\nThis function looks up the Yahoo! [Where On Earth ID](https://en.wikipedia.org/wiki/WOEID) value for the geographic locations looked up in it.  Relies upon having a copy of the WOEID database in the container because Yahoo! killed this service some time ago, and as such only three copies seem to exist anywhere:\n\n* https://archive.org/details/geoplanet_data_7.10.0.zip (needs to be loaded into a [SQLite](https://sqlite.org/) database)\n* https://drwho.virtadpt.net/files/geoplanet_data_7.10.0.zip (needs to be loaded into a [SQLite](https://sqlite.org/) database)\n* https://drwho.virtadpt.net/files/geoplanet.sqlite.zip (already loaded into a SQLite database, just uncompress)\n\n### Building and deploying\n\n### You already have a geoplanet.sqlite database:\n* Make sure that the 'geoplanet.sqlite' file exists in your exocortex-faas/geoplabnet-db/ directory.  Put it there if it's not.\n* `faas-cli build -f geoplanet-db.yml`\n* `faas-cli deploy -f geoplanet-db.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n### You need to build a geoplanet.sqlite database:\n```\nuser@host: sqlite3 geoplanet.sqlite\nsqlite\u003e .mode tabs\nsqlite\u003e PRAGMA foreign_keys=off;\n\nsqlite\u003e CREATE TABLE adjacencies (id INTEGER PRIMARY KEY, Place_WOE_ID TEXT, Place_ISO TEXT, Neighbour_WOE_ID TEXT, Neighbour_ISO TEXT);\nsqlite\u003e .import geoplanet_adjacencies_7.10.0.tsv temp_adjacencies\nsqlite\u003e INSERT INTO adjacencies(Place_WOE_ID, Place_ISO, Neighbour_WOE_ID, Neighbour_ISO) SELECT Place_WOE_ID, Place_ISO, Neighbour_WOE_ID, Neighbour_ISO from temp_adjacencies;\nsqlite\u003e drop table temp_adjacencies;\n\nsqlite\u003e CREATE TABLE admins (id INTEGER PRIMARY KEY, WOE_ID TEXT, iso TEXT, State TEXT, County TEXT, Local_Admin TEXT, Country TEXT, Continent TEXT);\nsqlite\u003e .import geoplanet_admins_7.10.0.tsv temp_admins\nsqlite\u003e INSERT INTO admins(WOE_ID, iso, State, County, Local_Admin, Country, Continent) SELECT WOE_ID, iso, State, County, Local_Admin, Country, Continent from temp_admins;\nsqlite\u003e drop table temp_admins;\n\nsqlite\u003e CREATE TABLE aliases (id INTEGER PRIMARY KEY, WOE_ID TEXT, Name TEXT, Name_Type TEXT, Language Text);\nsqlite\u003e .import geoplanet_aliases_7.10.0.tsv temp_aliases\nsqlite\u003e INSERT INTO aliases(WOE_ID, Name, Name_Type, Language) SELECT WOE_ID, Name, Name_Type, Language from temp_aliases;\nsqlite\u003e DROP TABLE temp_aliases;\n\nsqlite\u003e CREATE TABLE changes (id INTEGER PRIMARY KEY, Woe_id TEXT, Rep_id TEXT, Data_Version TEXT);\nsqlite\u003e .import geoplanet_changes_7.10.0.tsv temp_changes\nsqlite\u003e INSERT INTO changes (Woe_id, Rep_id, Data_Version) SELECT Woe_id, Rep_id, Data_Version from temp_changes;\nsqlite\u003e DROP TABLE temp_changes;\n\nsqlite\u003e CREATE TABLE places (id INTEGER PRIMARY KEY, WOE_ID TEXT, ISO TEXT, Name TEXT, Language TEXT, PlaceType TEXT, Parent_ID TEXT);\nsqlite\u003e .import geoplanet_places_7.10.0.tsv temp_places\nsqlite\u003e INSERT INTO places (WOE_ID, ISO, Name, Language, PlaceType, Parent_ID) SELECT WOE_ID, ISO, Name, Language, PlaceType, Parent_ID from temp_places;\nsqlite\u003e drop table temp_places;\n\nsqlite\u003e PRAGMA foreign_keys=on;\nsqlite\u003e VACUUM;\nsqlite\u003e .quit\n```\n\nNow follow the \"You already have a geoplanet.sqlite database:\" instructions above.\n\n### How to use the Geoplanet database to look up WOEIDs:\n`curl http://https://your.openfaas.gateway.here:8080/function/geoplanet-db/places/?Name=washington%20dc`\n\n## [hmac-a-tron/](hmac-a-tron/)\nThis function takes a JSON document and generates an [HMAC](https://en.wikipedia.org/wiki/Hash-based_message_authentication_code) of it, or a [Javascript Web Token](https://jwt.io/).\n\nSupported algorithms:\n\n* md5\n* sha1\n* sha224\n* sha256\n* sha384\n* sha512\n\nThe inputs to the HMAC feature should look like this:\n\n```\n{\n    \"data\": \"\u003cdata here\u003e\",\n    \"hash\": \"\u003chashing algorithm to use\u003e\",\n    \"secret\": \"\u003cauthentication secret\u003e\"\n}\n```\n\nSupported JWT algorithms:\n\n* HS256\n* HS386\n* HS512\n\nThe inputs to the JWT feature should look like this:\n\n```\n{\n    \"hash\": \"jwt\",\n    \"headers\": {\n        \"alg\": \"\u003cJWT algorithm to use\u003e\",\n        \"typ\": \"JWT\"\n    },\n    \"payload\": {\n        \"key\": \"value\",\n        \"another key\": \"another value\",\n        and so forth...\n    },\n    \"secret\": \"\u003cauthentication secret\u003e\"\n}\n```\n\n### Building and deploying\n* `faas-cli build -f hmac-a-tron.yml`\n* `faas-cli deploy -f hmac-a-tron.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n## [httpbin/](httpbin/)\nWhen I was learning how to use OpenFaaS, I wrote a simple function that interacts with https://httpbin.org/.  It's nothing special.\n\n### Building and deploying\n* `faas-cli build -f httpbin.yml`\n* `faas-cli deploy -f httpbin.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n## [i-ching/](i-ching/)\nA quick and dirty function that casts an [i ching](https://en.wikipedia.org/wiki/I_Ching) hexagram.  Each time you hit this function it'll toss the yarrow stalks again and return the hexagram as ASCII art, the name and number, and [a link to Wikipedia](https://en.wikipedia.org/wiki/List_of_hexagrams_of_the_I_Ching) which describes the hexagram.  Because everyone has their own take on things I leave it to you to determine what it may mean; there is no shortage of [i ching references](https://duckduckgo.com/?q=i+ching) out there, so pick the one you like.\n\n### Building and deploying\n* `faas-cli build -f i-ching.yml`\n* `faas-cli deploy -f i-ching.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n## [icanhazip/](icanhazip/)\nPings https://icanhazip.com/ and returns the IP address you're running this container on.  Nothing special.  Just me learning how to use CLI utilities (in this case, wget) as functions.\n\n### Building and deploying\n* `faas-cli build -f icanhazip.yml`\n* `faas-cli deploy -f icanhazip.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n## [testssl/](testssl/)\nInstalls the [testssl.sh](https://github.com/drwetter/testssl.sh) utility in a container and calls it as a function.\n\n### Building and deploying\n* `faas-cli build -f testssl.yml`\n* `faas-cli deploy -f testssl.yml --gateway https://your.openfaas.gateway.here:8080/`\n\n## [twitter-trends/](twitter-trends/)\nThis function uses the [Python Twitter module](https://pypi.org/project/twitter/) to call out to the [Twitter API](https://developer.twitter.com/) and list what's trending in a given geographic location.  Dependent upon the [geoplanet-db/](geoplanet-db/) function because Twitter, for reasons unknown, still uses Yahoo! Where On Earth IDs internally.\n\nTakes as its input a JSON document like this:\n\n```\n{\n    \"access_key\": \"Twitter access key\",\n    \"access_secret\": \"Twitter access secret\",\n    \"consumer_key\": \"Twitter app consumer key\",\n    \"consumer_secret\": \"Twitter app consumer secret\",\n    \"location_id\": \"woeid of the location you want information about\"\n}\n```\n\nReturns a JSON document containing terms trending on Twitter for that location.\n\n### Building and deploying\n* `faas-cli build -f testssl.yml`\n* `faas-cli deploy -f testssl.yml --gateway https://your.openfaas.gateway.here:8080/`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtadpt%2Fexocortex-faas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtadpt%2Fexocortex-faas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtadpt%2Fexocortex-faas/lists"}