Skip to content

Instantly share code, notes, and snippets.

View jdennes's full-sized avatar

James Dennes jdennes

View GitHub Profile
@jdennes
jdennes / LICENSE
Last active March 7, 2024 04:40
Subscribing to a Campaign Monitor list using AJAX
The MIT License (MIT)
Copyright (c) James Dennes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@jdennes
jdennes / README.md
Last active January 6, 2024 01:46
Convert a directory of .ogg files to .mp3 files
  • You need ffmpeg installed. If you have Homebrew installed on a Mac, you can do this by running:

    brew install ffmpeg
    
  • Put process.sh in directory containing .ogg files.

  • Ensure it's executable:

@jdennes
jdennes / controller-and-action-from-path.md
Last active April 3, 2023 15:03
Get the Rails controller and action given a path

Get the Rails controller and action from a given path/route

Given an application path like /github/github/issues, use the following to get the controller and action:

irb(main):001:0> Rails.application.routes.recognize_path "/github/github/issues", method: "GET"
=> {:controller=>"issues", :action=>"index", :user_id=>"github", :repository=>"github"}

The /github/github/issues path maps to issues#index (the index action on the IssuesController).

@jdennes
jdennes / get-site-admin-report.sh
Last active December 9, 2022 17:47
Shell script to get Site Admin reports on GitHub Enterprise
#!/bin/bash
# Export USERNAME, PASSWORD, and REPORT_URL
# REPORT_URL should look something like https://my.ghe/stafftools/reports/all_users.csv
# See: https://help.github.com/enterprise/admin/articles/site-admin-dashboard/#reports
set -e
for i in $(seq 1 5); do
echo "Trying to get report..."
result=$(curl -s -L -u $USERNAME:$PASSWORD $REPORT_URL)
@jdennes
jdennes / pre-commit.py
Created November 18, 2009 21:48
pre-commit svn hook in python
# pre-commit.py:
#
# Performs the following:
# - Makes sure the author has entered a log message.
# - Makes sure the author is only creating a tag, or if deleting a tag, author is a specific user
# - Makes sure the author is not committing to a particular set of paths in the repository
#
# Script based on http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/log-police.py
#
# usage: pre-commit.py -t TXN_NAME REPOS
@jdennes
jdennes / Gemfile
Last active September 22, 2022 16:31
Export a list of members from a GitHub organisation
source "https://rubygems.org"
gem "octokit"
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>animation test</title>
<style>
body {
text-align: center;
font-family: 'Courier New', Courier, monospace;
}
@jdennes
jdennes / buienalarm-scraper-details.md
Last active February 17, 2022 19:20
Documents how to scrape Buienalarm.nl (until their website changes)

Buienalarm.nl scraper details

A request to http://www.buienalarm.nl/location/rotterdam produces a chart that shows the projected rainfall for the next two hours in Rotterdam:

buienalarm

That page includes the following JavaScript that represents the data used to build the chart:

<script type="text/javascript">
@jdennes
jdennes / Procfile
Last active December 31, 2021 09:24
Flask application to demonstrate authenticating with the Campaign Monitor API using OAuth. Uses the createsend, Flask, and Flask-OAuth packages.
web: python app.py
@jdennes
jdennes / Gemfile
Last active October 14, 2021 05:17
Another example Rack application to demonstrate authenticating with the Campaign Monitor API using OAuth. This example only uses the sinatra and createsend gems.
source :rubygems
gem 'sinatra'
gem 'createsend'