Skip to content

Instantly share code, notes, and snippets.

View mtodd's full-sized avatar
🔐
[redacted]

Matt Todd mtodd

🔐
[redacted]
View GitHub Profile
@staltz
staltz / introrx.md
Last active April 24, 2025 06:10
The introduction to Reactive Programming you've been missing
@coliver
coliver / jameswhitemanifesto.txt
Created May 22, 2014 14:58
James White Manifesto
== Rules ==
On Infrastructure
-----------------
There is one system, not a collection of systems.
The desired state of the system should be a known quantity.
The "known quantity" must be machine parseable.
The actual state of the system must self-correct to the desired state.
The only authoritative source for the actual state of the system is the system.
The entire system must be deployable using source media and text files.
@phurni
phurni / application.rb
Created May 16, 2014 21:22
override active_record.initialize_database in rails (rails4)
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if ar_initdb = ActiveRecord::Railtie.initializers.find {|item| item.name == 'active_record.initialize_database'}
ActiveRecord::Railtie.initializers.delete(ar_initdb)
ActiveRecord::Railtie.initializer :after => ar_initdb.after do
ActiveSupport.on_load(:active_record) do
self.configurations = Rails.application.config.database_configuration
@schaary
schaary / ldapsearch.rb
Last active August 29, 2015 13:58
shows an example ldapsearch call with net/ldap gem, when you have the dn of the entry
basedn = "uid=foo,ou=bar,c=baz"
attrs = ["mail", "cn", "sn", "objectclass"]
ldap.search(:base => basedn, :attributes => attrs) do |entry|
puts "DN: #{entry.dn}"
entry.each do |attr, values|
puts "#{attr}:"
values.each do |value|
puts "#{value}"
end
end
@mintuhouse
mintuhouse / net_ldap_overrides.rb
Created April 2, 2014 10:51
Verify the certificate of secure LDAP server using net-ldap ruby gem
class Net::LDAP
def initialize(args = {})
@host = args[:host] || DefaultHost
@port = args[:port] || DefaultPort
@verbose = false # Make this configurable with a switch on the class.
@auth = args[:auth] || DefaultAuth
@base = args[:base] || DefaultTreebase
encryption args[:encryption] # may be nil
@zerowidth
zerowidth / sql.md
Last active April 11, 2017 18:31
GitHub::SQL - a helping hand for SQL in a rails app

DEPRECATED

GitHub::SQL has been released as an officially-maintained project and ruby gem: github/github-ds.

BEFORE:
sam@ubuntu discourse % rm -fr tmp/cache
sam@ubuntu discourse % rm -fr public/assets
sam@ubuntu discourse % time RAILS_ENV=production bin/rake assets:precompile
58.55s user 1.79s system 100% cpu 1:00.02 total
AFTER:
@matsimon
matsimon / ad_authorized_keys.sh
Last active February 26, 2021 20:34
Script used by 'AuthorizedKeysCommand' to retrieve SSH keys in an Active Directory (OpenSSH >= 6.2)
#!/bin/bash
username=`echo $1`
# AD needs authenticated binds, it's an unprivileged user
# use the UPN to write little less
ldapsearch \
-o ldif-wrap=no \
-D "srv-sshkeylookup@mydomain" \
-w "PlaintextPassword" \
@wojtha
wojtha / Locales.yaml
Created January 15, 2014 10:13 — forked from s-andringa/Locales.yml
config.exceptions_app and ExceptionController
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
@rick
rick / github.com.js
Created September 19, 2013 22:04
dotjs file to mute unread github notifications on a repo
$("button.mark-all-as-read").parent().prepend('<button class="box-action mute-all-unread css-truncate tooltipped upwards" original-title="mute all unread notifications"> <span class="octicon octicon-mute"></span> </button>');
$('button.mute-all-unread').click(function(event) {
// mute all unread notifications
$(this).parent().parent().parent().find('li.unread').find('.js-mute-notification button').click();
return false;
});