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
WITH geodata AS ( | |
SELECT | |
ROW_NUMBER() OVER () AS OBJECTID, | |
* | |
FROM | |
read_parquet('~/Downloads/IRL.parquet') LIMIT 1000) | |
select json_object( | |
'type', 'FeatureCollection', | |
'features', array_agg( | |
json_object( |
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 requests | |
import openai | |
import urllib | |
import json | |
from duckduckgo_search import DDGS | |
# Set your OpenAI API key here | |
openai.api_key = "your-openai-api-key" | |
def search_duckduckgo(query): |
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
-- public.image_embeddings definition | |
-- Drop table | |
-- DROP TABLE public.image_embeddings; | |
CREATE TABLE public.image_embeddings ( | |
id serial4 NOT NULL, | |
image_path text NULL, | |
embedding public.vector NULL, |
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 | |
import psycopg2 | |
import numpy as np | |
from PIL import Image | |
from scipy.spatial.distance import cosine | |
import torch | |
from torchvision import models, transforms | |
# Database configuration | |
DB_NAME = "database" |
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 | |
import psycopg2 | |
from PIL import Image | |
import torch | |
from torchvision import models, transforms | |
# Database configuration | |
DB_NAME = "database" | |
DB_USER = "user" | |
DB_PASSWORD = "password" |
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 requests | |
from bs4 import BeautifulSoup | |
import os | |
qry = "glacier" #wikimedia commons query | |
# Define the search URL | |
search_url = f"https://commons.wikimedia.org/w/index.php?search={qry}&title=Special:MediaSearch&go=Go&type=image" | |
headers = { | |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" |
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 pdfkit | |
import requests | |
''' | |
The current theme will be applied to outputs, so it is recommended to switch to a simple theme before exporting. | |
''' | |
#Generate PDF from individual post URL | |
def url_to_pdf(url, output_filename): | |
try: |
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
SELECT | |
ARRAY_TO_STRING(ARRAY_AGG(CONCAT(st_x(q.loc),',',st_y(q.loc))), ';') AS coords | |
FROM ( | |
WITH | |
DATA AS ( | |
SELECT | |
loc, | |
resource_id, | |
wkt, | |
capture_date, |
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
WITH data AS ( | |
SELECT name, loc, resource_id, wkt, capture_date, (LAG(capture_date) OVER (PARTITION BY resource_id ORDER BY capture_date ASC)) AS prev_date, | |
(LAG(wkt) OVER (PARTITION BY resource_id ORDER BY capture_date ASC)) AS prev_loc | |
FROM | |
(SELECT name, resource_id, loc, st_astext(loc) as wkt, capture_date FROM `my_project.my_dataset.geo_sample` | |
order by capture_date desc) q | |
ORDER BY capture_date | |
) | |
SELECT name, resource_id, loc, capture_date FROM data | |
WHERE |
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
var PGPubsub = require('pg-pubsub'); | |
var nodemailer = require('nodemailer'); | |
var pubsubInstance = new PGPubsub('postgres://password:user@host:port/database'); // don't hard code this in real life. get it from a config or environment variable | |
var transporter = nodemailer.createTransport({ | |
service: 'gmail', | |
auth: { | |
user: "email@gmail.com", // don't hard code this in real life. get it from a config or environment variable | |
pass: "complex_gmail_password" // don't hard code this in real life. get it from a config or environment variable |
NewerOlder