Skip to content

Instantly share code, notes, and snippets.

View scottpdawson's full-sized avatar
🏠
Writing, designing, and coding from home since 1998

Scott Dawson scottpdawson

🏠
Writing, designing, and coding from home since 1998
View GitHub Profile
function findRow(searchVal) {
// find row containing the event's timestamp
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
var searchDate = new Date(searchVal);
for (x = 0; x < data.length; x++) {
var thisDate = new Date(data[x][0]);
if (thisDate.getTime() === searchDate.getTime()) {
return x + 1;
}
const calendarId = "ENTER_CALENDAR_ID";
const uniqueEventSuffix = "[MOONCAL]";
const dataRange = "A2:C";
function deleteAutoCreatedEvents() {
var eventCal = CalendarApp.getCalendarById(calendarId);
var startOfCurrentYear = new Date(new Date().getFullYear(), 0, 1);
var endOfCurrentYear = new Date(new Date().getFullYear(), 11, 31)
var events = eventCal.getEvents(startOfCurrentYear, endOfCurrentYear);
for(var i=0; i < events.length; i++) {
//
// 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
//
{% if (hero) %}
<img class="page-hero" src="{{ hero }}" alt="Hero image for {{ title }}" />
{% endif %}
<table>
<thead>
<tr>
<th>Date</th>
<th>Title</th>
<th>Location</th>
</tr>
</thead>
<tbody>
{%- for post in collections.events -%}
eleventyConfig.addCollection("events", (collection) =>
collection.getFilteredByGlob("posts/*.md").filter( post => {
return ( item.data.location ? post : false );
})
);
@scottpdawson
scottpdawson / markdown.json
Created October 25, 2020 18:02
Snippets for Visual Studio Code to help generate markdown
{
"pic": {
"prefix": "pic",
"body": "{% picture \"/images/.jpg\", \"Caption\" %}"
},
"picrt": {
"prefix": "picrt",
"body": "{% pictureRt \"/images/.jpg\", \"Caption\" %}"
},
"lb": {
@scottpdawson
scottpdawson / strava.js
Last active October 31, 2024 14:54
Bulk download Strava activities
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 23:51
Map, CircleMarker, and Popup
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 12:55
Fetching ski resort data
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,