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
<?php
add_action("wp_enqueue_scripts", "my_enqueue", 11);
function my_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
wp_enqueue_script( 'function', get_stylesheet_directory_uri().'/js/gallery_script.js', 'jquery', true);
}
// add actions to respond to get_gallery_data
@scottpdawson
scottpdawson / crowdfire.js
Last active October 7, 2017 11:48
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?
$(document).on("click", function() {
$(".js-done-button:visible").closest(".row").hide();
});
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 / 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,
@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 / strava.js
Last active October 26, 2023 09:36
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 / 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": {
eleventyConfig.addCollection("events", (collection) =>
collection.getFilteredByGlob("posts/*.md").filter( post => {
return ( item.data.location ? post : false );
})
);