Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark McEahern m5rk

View GitHub Profile
View message.json
{
"attachments": [
{
"fallback": "users",
"callback_id": "b75e3599-b12b-412a-88ff-65d0cad93864",
"actions": [
{
"name": "foo",
"type": "select",
"text": "assign to",
View takePicture
// When Cordova is not present Camera.getPicture() will throw an exception.
// Catch that and use your fixture image...
public takePicture(): void {
Camera.getPicture(options)
.then((data) => {
let base64Image: string = 'data:image/jpeg;base64,' + data;
this.save(base64Image);
})
.catch(() => {
// openssl base64 -in small.png -out small.txt
@m5rk
m5rk / karma.config.js
Created Jun 22, 2016
karma.config.js snippet for storing coverage in artifacts of CircleCI build
View karma.config.js
coverageReporter: {
reporters: [
{type: 'text'},
{
type: 'lcov',
dir: process.env.CIRCLE_ARTIFACTS || '.',
subdir: 'coverage'
}
]
},
@m5rk
m5rk / sessions_controller.rb
Last active Apr 30, 2020
Slack Sessions Controller
View sessions_controller.rb
# app/controllers/slack/sessions_controller.rb
module Slack
class SessionsController < ApplicationController
before_action :ensure_no_error!
before_action :ensure_ok!
before_action :ensure_slack_token_valid!
before_action :ensure_account!
before_action :ensure_user!
expose(:slack_client) { Slack::Web::Client.new }
@m5rk
m5rk / gist:1ad633281debcebf93cc
Created Mar 5, 2015
functional flatten_hash
View gist:1ad633281debcebf93cc
def flatten_hash(hash)
hash.keys + hash.values.select do |value|
value.respond_to?(:keys)
end.map do |hash|
flatten_hash(hash)
end.flatten
end
@m5rk
m5rk / gist:4b5e47eed1da5510c1ab
Created Sep 16, 2014
Migration to update timestamps to null: false
View gist:4b5e47eed1da5510c1ab
# Rails 3.2 generated timestamps with null: false but then this was reverted before 4.0
# so if you migrated from 3.2 to 4.x, you'll always have this perpetual skew between your
# schema in source control and the schema in the database unless you correct it like
# this:
class SetTimestampsToNotNull < ActiveRecord::Migration
def change
tables = ActiveRecord::Base.connection.tables - ["schema_migrations"]
tables_with_timestamps = tables.select do |table|
ActiveRecord::Base.connection.columns(table).map(&:name).include?('created_at')
end
View Test for rails-rails#16684
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.0.3'
require 'active_record'
require 'minitest/autorun'
require 'logger'
require 'pry'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
@m5rk
m5rk / gist:7243018
Last active Dec 27, 2015
rails template
View gist:7243018
git :init
git add: "."
git commit: "-a -m 'Initial commit'"
gem_group :development, :test do
gem 'rspec-rails'
end
gem_group :test do
gem 'shoulda-matchers'
View gist:7236686
This file has been truncated, but you can view the full file.
/usr/bin/curl -f#LA Homebrew 0.9.5 (Ruby 1.8.7-358; Mac OS X 10.9) https://raw.github.com/cliffrowley/homebrew/patched_qt/Library/Formula/qt.rb -o /Library/Caches/Homebrew/Formula/qt.rb --silent
==> Cloning git://gitorious.org/qt/qt.git
git --git-dir /Library/Caches/Homebrew/qt--git/.git status -s
Updating /Library/Caches/Homebrew/qt--git
git config remote.origin.url git://gitorious.org/qt/qt.git
git config remote.origin.fetch +refs/heads/4.8:refs/remotes/origin/4.8
git fetch origin
git checkout -f 4.8
git reset --hard origin/4.8
View gist:7232391
⁙ brew install https://raw.github.com/cliffrowley/homebrew/patched_qt/Library/Formula/qt.rb --HEAD
######################################################################## 100.0%
==> Cloning git://gitorious.org/qt/qt.git
Updating /Library/Caches/Homebrew/qt--git
==> Checking out branch 4.8
==> Patching
patching file src/plugins/bearer/corewlan/qcorewlanengine.mm
patching file src/plugins/bearer/corewlan/qcorewlanengine_10_6.mm
patching file src/3rdparty/webkit/Source/WebKit/qt/QtWebKit.pro
patch unexpectedly ends in middle of line
You can’t perform that action at this time.