Skip to content

Instantly share code, notes, and snippets.

Chris Roos chrisroos

Block or report user

Report or block chrisroos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chrisroos
chrisroos / gpg-import-and-export-instructions.md
Created Sep 9, 2011
Instructions for exporting/importing (backup/restore) GPG keys
View gpg-import-and-export-instructions.md

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/
# or, instead of backing up trustdb...
@chrisroos
chrisroos / README.md
Last active Nov 13, 2018
Example of using bundler/inline
View README.md

I came across 'bundler/inline' in Bundler pull request 3440, which I'd found from Rails pull request 20429. This now has a little snippet on the What's new page of the Bundler site.

This little example demonstrates how I might use it to create a single file using minitest.

I've just noticed that this script was working for me because I already had minitest installed as a system gem. If I uninstall the gem then the script fails because it can't find minitest. The source code documents an option to install gems if they don't exist (gemfile(true) do) but that doesn't seem to work for me. I see the following error:

Fetching gem metadata from https://rubygems.org/...
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Using metaclass 0.0.4
@chrisroos
chrisroos / README.md
Last active Nov 11, 2018
Bookmarklet that allows me to add a link to more information for specific emails I receive
View README.md

I receive a number of periodic emails that prompt me to do something (e.g. take an electricity meter reading). I wanted to be able to add information to those emails to remind me how to perform the task.

This JavaScript allows me to configure rules so that I can display a link to a web page when I'm viewing an email with a specific subject in Gmail.

I'm currently hosting the JavaScript and installer web page using rawgit.com.

Visit this page to install the bookmarklet.

@chrisroos
chrisroos / README.md
Last active Nov 8, 2018
Exploring Todoist's API
View README.md

The todoist.rb script uses their API to print a list of all my completed tasks in CSV format.

The standard Todoist backup doesn't contain completed tasks.

@chrisroos
chrisroos / Gemfile
Last active Aug 19, 2018
Exploring how to run specific tests using minitest
View Gemfile
source 'https://rubygems.org'
gem 'shoulda'
View 2018-04-30-rails-and-aws-ses.md

Testing Rails ActionMailer and AWS SES

I added two verified email addresses to AWS SES so that I could send emails from/to them while in the SES Sandbox.

UserMailer

class UserMailer < ApplicationMailer
  default from: 'accounts+aws-ses@gofreerange.com'
View 2016-09-20-using-heroku-release-phase-to-run-rails-migrations.md

It looks as though using Release Phase commands (available as of 2 June 2016) is the preferred way of running things like migrations after the slug has been compiled and deployed.

The Buildpack API explicitly suggests avoiding side effects during the build:

Buildpack developers should avoid generating side effects during the build. For example, it is not recommended to perform database migrations in the compile script.

The following example creates a Rails app with a single migration and demonstrates that the migration is run after deployment.

# Create empty Rails app
View affected-ids.rb
# These were the IDs returned by the identify-affected-attachments.rb script when it was run in staging on 20 Mar 2018.
#
[3625, 6002, 6007, 7874, 7875, 12248, 12249, 16333, 16381, 16383, 27263, 27607, 28153, 28154, 48876, 65687, 69606, 97881, 118296, 137087, 137587, 151994, 151995, 151996, 152690, 156319, 163466, 163467, 163468, 163469, 163470, 163471, 167849, 167851, 172237, 172238, 172239, 176752, 176753, 179306, 180955, 182610, 182636, 184031, 190436, 190437, 190438, 190439, 198104, 198144, 203773, 203952, 206956, 210410, 210933, 211644, 211646, 212271, 222544, 222545, 226017, 226119, 230027, 232152, 245882, 246519, 249795, 249796, 251493, 255473, 256038, 256798, 257471, 259192, 259868, 260418, 260904, 263013, 263014, 263359, 266717, 266834, 268678, 268679, 268680, 268681, 268682, 268683, 268684, 268685, 268686, 268687, 270767, 271065, 273957, 273959, 276018, 276347,276696, 276698, 278305, 279330, 281943, 284025, 284200, 284202, 284203, 284204, 284205, 284208, 284962, 286668, 286670, 287941, 288107, 2881
View print-whitehall-attachments-without-files-but-with-redirects.rb
# See https://github.com/alphagov/asset-manager/issues/525 for more information
ids = [1, 2, 3, 4, 5, 6, 7, 11, 17, 33, 44, 47, 79, 80, 82, 88, 94, 98, 99, 101, 106, 108, 135, 136, 137, 138, 139, 140, 145, 146, 153, 154, 160, 168, 182, 187, 231, 350, 374, 378, 379, 382, 389, 413, 437, 636, 765, 773, 774, 776, 863, 876, 966, 1223, 1224, 1456, 1486, 1519, 1724, 1725, 1751, 1752, 1753, 1754, 1755, 1765, 1766, 1767, 1773, 1776, 1779, 1781, 1782, 1783, 1785, 1786, 1787, 1788, 1789, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1819, 1827, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1
View 2018-03-16-attachment-data-ids-from-staging.txt
[1, 2, 3, 4, 5, 6, 7, 11, 17, 33, 44, 47, 79, 80, 82, 88, 94, 98, 99, 101, 106, 108, 135, 136, 137, 138, 139, 140, 145, 146, 153, 154, 160, 168, 182, 187, 231, 350, 374, 378, 379, 382, 389, 413, 437, 636, 765, 773, 774, 776, 863, 876, 966, 1223, 1224, 1456, 1486, 1519, 1724, 1725, 1751, 1752, 1753, 1754, 1755, 1765, 1766, 1767, 1773, 1776, 1779, 1781, 1782, 1783, 1785, 1786, 1787, 1788, 1789, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1819, 1827, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916
You can’t perform that action at this time.