Skip to content

Instantly share code, notes, and snippets.

[
{
"name": "Amaranth (also Love-lies-bleeding)",
"care": {
"q1": "Plant in garden."
}
},
{
"name": "Asparagus",
"care": {
{
"attachments": [
{
"fallback": "users",
"callback_id": "b75e3599-b12b-412a-88ff-65d0cad93864",
"actions": [
{
"name": "foo",
"type": "select",
"text": "assign to",
// 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 June 22, 2016 23:24
karma.config.js snippet for storing coverage in artifacts of CircleCI build
coverageReporter: {
reporters: [
{type: 'text'},
{
type: 'lcov',
dir: process.env.CIRCLE_ARTIFACTS || '.',
subdir: 'coverage'
}
]
},
@m5rk
m5rk / sessions_controller.rb
Last active April 30, 2020 07:37
Slack Sessions Controller
# 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 March 5, 2015 04:30
functional flatten_hash
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 September 16, 2014 14:24
Migration to update timestamps to null: false
# 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
# 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 December 27, 2015 01:09
rails template
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'
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
HEAD is now at 41621a2 QLocale: Update Portuguese and Greek locales data