Skip to content

Instantly share code, notes, and snippets.

View mjc-gh's full-sized avatar
🎯
Open Sourcing

Michael Coyne mjc-gh

🎯
Open Sourcing
View GitHub Profile
@searls
searls / reset_fixtures
Created March 3, 2020 03:33
Manually your Rails test fixtures whenever you want
#!/usr/bin/env ruby
ENV["RAILS_ENV"] = "test"
require_relative "../config/environment"
ResetsFixtures.new.call
@mcattarinussi
mcattarinussi / gpg-ssh-setup.md
Last active April 9, 2024 02:09
A setup guide to use a personal gpg key for ssh authentication

GPG - SSH setup

Generating the master key

Here we create the master key. We want only Certify capability: we use the master key only to create the subkeys, Sign - Encrypt - Authenticate capabilities will be assigned to the subkeys.

Run the following command to start the master key generation process. Select the set your own capabilities creation process (type 8)

  ▶ gpg --full-generate-key --expert

gpg (GnuPG) 2.2.9; Copyright (C) 2018 Free Software Foundation, Inc.

@tbranyen
tbranyen / es-modules-diffhtml.html
Last active June 1, 2017 17:50
Loading some middleware and diffHTML with ES Modules in Chromium 60
<style>
body { display: flex; align-items: center; justify-content: center; }
h1 { font-size: 60px; font-family: Helvetica; }
</style>
<script type="module">
import { innerHTML, html, use } from 'https://diffhtml.org/master/diffhtml';
import createLogger from 'https://diffhtml.org/master/diffhtml-middleware-logger';
import inlineTransitions from 'https://diffhtml.org/master/diffhtml-middleware-inline-transitions';
@hejld
hejld / react-event-handling.md
Created November 22, 2015 19:36
React Event Handling

EVENT HANDLING

First source file you should be reading when trying to understand React Event System is ReactBrowserEventEmitter.js.

ReactEventListener

First the event is captured at the top-level ReactEventListener.

  • in the main thread

API

@hwine
hwine / decode_hosts.py
Created July 31, 2015 02:48
decode hashed known_hosts
#!/usr/bin/env python
"""
Find host - decode hashed known_hosts files
Using an unhashed known_hosts file as reference, compare by host
key.
"""
import logging
@jfairbank
jfairbank / app.js
Last active September 26, 2017 16:20
ES7 Class Decorators, Properties, and Angular
import angular from 'angular';
import MyService from './myService';
import myDirective from './myDirective';
angular.module('myApp', [])
.service('myService', MyService)
.directive('myDirective', myDirective);
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 16, 2024 12:16
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@masciugo
masciugo / secrets_management.md
Created September 26, 2014 16:48
secrets management in Rails

Rails secrets management with Figaro and Capistrano

Use of figaro gem (or something like dotenv) in all environments.

The Figaro config/application.yml file with all the secrets will be git-ignored. So on every deployment server I had to manually add the file shared/config/application.yml and then linked automatically on each deployment to the current version of the app by adding in config/deploy.rb:

set :linked_files, %w{config/application.yml}

For development config/application.yml is something like the following:

@afeld
afeld / gist:5704079
Last active November 27, 2023 15:43
Using Rails+Bower on Heroku
@mjc-gh
mjc-gh / test_helper.rb
Last active June 13, 2020 16:14
Minitest methods
require 'minitest/autorun'
class Minitest::Test
def self.test(name, &block)
define_method "test_#{name.gsub(/\s+/, '_')}", &block
end
def self.setup(&block)
define_method :setup, &block
end