Skip to content

Instantly share code, notes, and snippets.

Matt Freer mattfreer

  • Birmingham, UK
Block or report user

Report or block mattfreer

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
@mattfreer
mattfreer / width-by-sibling-count.scss
Created Dec 12, 2012
Applies width property to siblings conditionally. Width is applied if the number of siblings matches the supplied sibling-count. This allows developers to set different widths based on the number of siblings. If $sibling-count matches the number-of-siblings then all siblings will be set to an equal percentage width, with a combinded total width …
View width-by-sibling-count.scss
// @param $sibling-selector: selector to target siblings (e.g. h5 | ".simple-filed")
// @param $sibling-count: the number of siblings that must exist in order for these widths to be applied
// @param $fixed-widths: optional keyword argument, list of fixed (percentage) widths to be applied to
// the first-n siblings (e.g. $fixed-widths: 40 30)
//
// Usage:
// h5 {
// @include width-by-sibling-count(h5, 4, $fixed-widths: 55);
// @include width-by-sibling-count(h5, 5, $fixed-widths: 40);
//}
@mattfreer
mattfreer / bad_template.eex
Last active Oct 12, 2015
Since upgrading to Elixir 1.1 and Eralang 18, I'm noticing that Dialyzer has some issues with String interpolation. This Gist demonstrates an issue with EEx templates that map over a list of Strings
View bad_template.eex
<%= Enum.map arbitrary_list, fn(item) -> %>
<%= item %>
<%= end %>
View db_terminate_backend.rake
# http://stackoverflow.com/questions/5108876/kill-a-postgresql-session-connection
namespace :db do
desc "Fix 'database is being accessed by other users'"
task :terminate => :environment do
ActiveRecord::Base.connection.execute <<-SQL
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
View docker-ssh-forward.bash
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
You can’t perform that action at this time.