Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Writing, designing, and coding from home since 1998

Scott Dawson scottpdawson

🏠
Writing, designing, and coding from home since 1998
View GitHub Profile
View downloadStravaGPX.js
//
// 1. Go to https://www.strava.com/athlete/training
//
// 2. Open the Chrome developer console
//
// 3. Paste into the console the code from
// https://github.com/eligrey/FileSaver.js/blob/master/src/FileSaver.js
//
// 4. Paste the two functions below into the console
//
View hero.njk
{% if (hero) %}
<img class="page-hero" src="{{ hero }}" alt="Hero image for {{ title }}" />
{% endif %}
View eventsTable.html
<table>
<thead>
<tr>
<th>Date</th>
<th>Title</th>
<th>Location</th>
</tr>
</thead>
<tbody>
{%- for post in collections.events -%}
View eventsCollection
eleventyConfig.addCollection("events", (collection) =>
collection.getFilteredByGlob("posts/*.md").filter( post => {
return ( item.data.location ? post : false );
})
);
@scottpdawson
scottpdawson / markdown.json
Created Oct 25, 2020
Snippets for Visual Studio Code to help generate markdown
View markdown.json
{
"pic": {
"prefix": "pic",
"body": "{% picture \"/images/.jpg\", \"Caption\" %}"
},
"picrt": {
"prefix": "picrt",
"body": "{% pictureRt \"/images/.jpg\", \"Caption\" %}"
},
"lb": {
@scottpdawson
scottpdawson / strava.js
Last active Apr 12, 2021
Bulk download Strava activities
View strava.js
var maxPage = 25; // calculate this using (activities/20 + 1)
var activityType = "Run"; // change to the workout type you want, or blank for all
var p = 1;
var done = 0;
var url;
var nw = window.open("workouts.html");
nw.document.write("[");
while (p <= maxPage) {
url = "https://www.strava.com/athlete/training_activities" +
"?keywords=&activity_type=" + activityType + "&workout_type=&commute=&private_activities=" +
@scottpdawson
scottpdawson / SkiMap.js
Last active May 27, 2020
Map, CircleMarker, and Popup
View SkiMap.js
export default class SkiMap extends Component {
state = defaultMapState;
render() {
return this.props.resorts ? (
<Map
center={[this.state.lat, this.state.lng]}
zoom={this.state.zoom}
style={{ width: "100%", position: "absolute", top: 0, bottom: 0, zIndex: 500, }}
updateWhenZooming={false}
updateWhenIdle={true}
@scottpdawson
scottpdawson / App.js
Created May 27, 2020
Fetching ski resort data
View App.js
async componentDidMount() {
// trigger data load from openskimap
axios
.get(`//tiles.skimap.org/geojson/ski_areas.geojson`)
.then((res) => {
const resorts =
res.data.features.map((resort) => ({
id: resort.properties.id,
point: getPointForResort(resort),
name: resort.properties.name,
View map-routes.R
library(plotKML)
# Find GPX files using a pattern
files <- dir(pattern = "\\.gpx")
# Consolidate routes in one drata frame
index <- c()
latitude <- c()
longitude <- c()
for (i in 1:length(files)) {
@scottpdawson
scottpdawson / crowdfire.js
Last active Oct 7, 2017
When Crowdfire updated their service to show a checkmark after you've taken action on a profile instead of just hiding the profile, they ruined the usability of their service. If you paste this in your browser console on each page load, it reverts the functionality back to what it was before. Is there a way to have this load automatically?
View crowdfire.js
$(document).on("click", function() {
$(".js-done-button:visible").closest(".row").hide();
});