Skip to content

Instantly share code, notes, and snippets.

View webmat's full-sized avatar

Mathieu Martin webmat

View GitHub Profile
@webmat
webmat / readme.md
Last active August 29, 2015 13:55
Disk representation of the different MySQL engines

I recently had to detect whether a MySQL server had any tables that didn't support transactions (mainly MyISAM).

The only problem is that this server had close to 5000 indivitual databases, and my usual query didn't cut it:

SELECT  information_schema.TABLES.TABLE_SCHEMA,
        information_schema.TABLES.TABLE_NAME,
        information_schema.TABLES.ENGINE,
FROM information_schema.TABLES
WHERE information_schema.TABLES.TABLE_SCHEMA not in ('performance_schema', 'mysql', 'information_schema')
@webmat
webmat / gist:4b8a65cf865fd69fafc8
Created May 6, 2014 17:11
Git lightning talk
Understanding the concepts
- The Git Parable, but Tom Preston-Werner
http://tom.preston-werner.com/2009/05/19/the-git-parable.html
- git is a bucket of commits
- most commits have one parent, and a blob
- some commits have 2 parents (merges)
- some commits have 1 parents (first commit!)
- refs
- branches: pointers to a commit - moves over time
@webmat
webmat / gist:15920
Created October 9, 2008 22:15
Check out the values of all instance variables in object 'o'
# Check out the values of all instance variables in object 'o':
o.instance_variables.inject({}) {|memo,v|
memo.merge!(v=>s.instance_eval(v))
}
#!/usr/bin/env ruby
# An improved GitHub gemspec checker.
# GitHub accepts YAML dumps for the gemspecs, which helps keep your gem generation tasks DRY
if ARGV.size < 1
puts "Usage: github-test.rb my-project.gemspec"
exit
end
membership_of_favourite_club:
joined_on: <%= 3.weeks.ago.to_s(:db) %>
club: moustache_club
member: groucho
favourite: true
type: Membership
# For the queasy, this is MIT licensed. See comment at the end.
module ExceptionMacros
# Make sure a block raises an exception.
# Call with optional arguments :instance_of/:kind_of and :message
# If :instance_of or :kind_of is specified, assert on the given type.
# Otherwise only assert that an exception is raised.
# Note: The shorthand should_raise(LoadError) is equivalent to should_raise(:instance_of => LoadError)
# If :message is specified, will assert that exception.message =~ :message.
#
#!/usr/bin/env ruby
# Filename: mdc
# You put it in your path, then install Maruku, the awesome markdown gem.
# Maruku has awesome warning and isn't buggy.
# Usage:
# mdc article.md
# #=> article.html
#
#console
sudo gem install ruby_parser
#irb
require 'rubygems' ; require 'ruby_parser' ; require 'pp'
pp RubyParser.new.parse "class C
def meth(arg)
arg * 2
end
# Rubygems 1.3.1 incompatible with rbx. Missing constant EACCESS
# Either with the dev's bin/ in the path or rbx symlinked in the path,
# I get the following error:
$ rbx gem install rack --no-rdoc --no-ri
ERROR: While executing gem ... (NameError)
Missing or uninitialized constant: EACCESS
# Note: Yeah, I should SUDO
# IRB prompt that looks like code samples
IRB.conf[:USE_READLINE] = true
IRB.conf[:AUTO_INDENT] = false
my_conf = IRB.conf[:PROMPT][:COPY] = {}
my_conf[:PROMPT_N] = ""
my_conf[:PROMPT_S] = ""
my_conf[:PROMPT_I] = ""
my_conf[:PROMPT_C] = ""
my_conf[:RETURN] = "#=> %s\n\n"