Skip to content

Instantly share code, notes, and snippets.

View garethpaul's full-sized avatar
:octocat:

Gareth Paul Jones (GPJ) garethpaul

:octocat:
View GitHub Profile
@garethpaul
garethpaul / beatles.txt
Created March 13, 2024 04:18
beatles.txt
I read the news today, oh boy
About a lucky man who made the grade
And though the news was rather sad
Well, I just had to laugh
I saw the photograph
He blew his mind out in a car
He didn't notice that the lights had changed
A crowd of people stood and stared
They'd seen his face before
Nobody was really sure if he was from the House of Lords
@garethpaul
garethpaul / prompts.txt
Created May 2, 2023 23:59
Prompt Examples
# GPT-3 examples (using mostly text-davinci-003)
## Information extraction from claim phone conversations
* Engine: text-davinci-003 (also works in text-davinci-002, but might require more instructions to get a correct JSON back)
* Temperature: 0.7
```
You must extract the following information from the phone conversation below:
@garethpaul
garethpaul / chrome_history_with_meta.sql
Created October 16, 2022 17:04
Chrome History with Day/Hour etc
DROP TABLE chrome_history;
CREATE TABLE IF NOT EXISTS chrome_history AS
SELECT
strftime('%Y-%m-%d', datetime((last_visit_time / 1000000) - 11644473600, 'unixepoch', 'localtime')) AS visit_date,
case cast (strftime('%w', datetime((last_visit_time / 1000000) - 11644473600, 'unixepoch', 'localtime')) as integer)
when 0 then 'Sunday'
when 1 then 'Monday'
when 2 then 'Tuesday'
when 3 then 'Wednesday'
when 4 then 'Thursday'
@garethpaul
garethpaul / chrome_history_postgres.sql
Created October 15, 2022 18:21
Chrome Browser History SQL
CREATE TABLE meta(key VARCHAR NOT NULL UNIQUE PRIMARY KEY, value VARCHAR);
CREATE TABLE downloads (id INTEGER PRIMARY KEY,guid VARCHAR NOT NULL,current_path VARCHAR NOT NULL,target_path VARCHAR NOT NULL,start_time INTEGER NOT NULL,received_bytes INTEGER NOT NULL,total_bytes INTEGER NOT NULL,state INTEGER NOT NULL,danger_type INTEGER NOT NULL,interrupt_reason INTEGER NOT NULL,hash bytea NOT NULL,end_time INTEGER NOT NULL,opened INTEGER NOT NULL,last_access_time INTEGER NOT NULL,transient INTEGER NOT NULL,referrer VARCHAR NOT NULL,site_url VARCHAR NOT NULL,tab_url VARCHAR NOT NULL,tab_referrer_url VARCHAR NOT NULL,http_method VARCHAR NOT NULL,by_ext_id VARCHAR NOT NULL,by_ext_name VARCHAR NOT NULL,etag VARCHAR NOT NULL,last_modified VARCHAR NOT NULL,mime_type VARCHAR(255) NOT NULL,original_mime_type VARCHAR(255) NOT NULL, embedder_download_data VARCHAR NOT NULL DEFAULT '');
CREATE TABLE downloads_url_chains (id INTEGER NOT NULL,chain_index INTEGER NOT NULL,url VARCHAR NOT NULL, PRIMARY KEY (id, chain_index) );
#initialize dataframe
df_temp = pd.DataFrame()
#populate date and average temperature fields (cast string date to datetime and convert temperature from tenths of Celsius to Fahrenheit)
df_temp['date'] = [datetime.strptime(d, "%Y-%m-%dT%H:%M:%S") for d in dates_temp]
df_temp['avgTemp'] = [float(v)/10.0*1.8 + 32 for v in temps]
df_temp['minTemp'] = [float(v)/10.0*1.8 + 32 for v in minT]
df_temp['maxTemp'] = [float(v)/10.0*1.8 + 32 for v in maxT]
# Convert mm/day to inch/day
df_temp['prcp'] = [float(v)/25.54 for v in prcp]
#for each year from 2018-2019 ...
for year in range(2018, 2019):
year = str(year)
print('working on year '+year)
#make the api call
r = requests.get('https://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GHCND&datatypeid=TAVG&datatypeid=TMAX&limit=1000&stationid='+station_id+'&startdate='+year+'-01-01&enddate='+year+'-12-31', headers={'token':token})
r2 = requests.get('https://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GHCND&datatypeid=TMIN&datatypeid=PRCP&limit=1000&stationid='+station_id+'&startdate='+year+'-01-01&enddate='+year+'-12-31', headers={'token':token})
#load the api response as a json
#initialize lists to store data
dates_temp = []
dates_prcp = []
temps = []
minT = []
maxT = []
prcp = []
// Power Lines
var url = 'geojson/power_lines.geojson';
map.addLayer({
'id': 'power_lines',
'type': 'line',
'source': {
'type': 'geojson',
'data': url
},
'paint': {
// Setup a line animation for the power to run through e.g. like a strobe..
var animationStep = 30;
function enableLineAnimation(layerId) {
var step = 0;
let dashArraySeq = [
[0, 4, 3],
[1, 4, 2],
[2, 4, 1],
[3, 4, 0],
[0, 1, 3, 3],
// Once the map loads we push the geoJson over the top.
map.on('load', function() {
// Power Lines
var url = 'geojson/power_lines.geojson';
map.addLayer({
'id': 'power_lines',
'type': 'line',
'source': {
'type': 'geojson',
'data': url