Skip to content

Instantly share code, notes, and snippets.

View futhr's full-sized avatar
:octocat:

Tobias Bohwalli futhr

:octocat:
View GitHub Profile
@futhr
futhr / select2_capybara_helper.rb
Created March 6, 2014 20:15
Select2 Capybara helper for forms.
# compact version from: https://github.com/spree/spree/blob/master/core/lib/spree/testing_support/capybara_ext.rb
# just drop file in spec/support
module CapybaraHelper
def select2_select(value, options)
find("#s2id_#{options[:from]} a").click
within(:xpath, '//body') do
find('div.select2-result-label', text: %r{#{Regexp.escape(value)}}i).click
end
end
end
@futhr
futhr / memorandum.sh
Created April 1, 2014 02:39
Terminal memorandum --simple as that but easy forgot.
#!/bin/sh
# if cronjob junk .local mailbox
mail
delete 1-10
q
@futhr
futhr / version.rb
Created April 4, 2014 14:10
Nice style for Gem version - pick from a rails/rails pull request.
module YourGem
# Returns the version of the currently loaded YourGem as a <tt>Gem::Version</tt>
def self.version
Gem::Version.new VERSION::STRING
end
module VERSION
MAJOR = 1
MINOR = 1
@futhr
futhr / hard_worker_spec.rb
Created April 23, 2014 00:57
Test sidetiq -- coderwall.com/p/nqpa-w
class HardWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { hourly }
def perform
# Do some work
end
end
@futhr
futhr / timestamp.bash
Created September 10, 2014 18:24
OSX create timestamp for migrations (rails g migration is so slow).
date -n +%Y%m%d%H%M%S
@futhr
futhr / capybara.rb
Last active April 21, 2016 19:14 — forked from afn/gist:c04ccfe71d648763b306
Restart and retry when Poltergeist fails randomly.
# Borrowed from https://github.com/y310/rspec-retry/blob/master/lib/rspec/retry.rb
# Drop this script into spec/support
# To test snippet just set timeout to 1
RSpec.configure do |config|
Capybara.javascript_driver = :poltergeist
Capybara.register_driver(:poltergeist) do |app|
Capybara::Poltergeist::Driver.new app,
@futhr
futhr / example.sh
Created August 4, 2016 14:53
Search code in all gems (for rbenv).
cd /Users/<user>/.rbenv/versions/<version>/gemsets/<project>/gems/
grep -ir <search string> *
@futhr
futhr / main.js
Last active May 3, 2017 12:55
myDevices Cloud API sample code.
//----------------------------------
// myDevices Cloud API sample code
//----------------------------------
// Use rather request than https
const Http = require('https');
const Util = require('util');
const API_HOST = 'va-staging-corridor.mydevices.com';
const API_PORT = 443;
@futhr
futhr / uninstall_gems.sh
Created November 7, 2017 21:43
Convenient script to uninstall all global installed gems (..when using rbenv).
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
@futhr
futhr / vueforage.js
Created December 11, 2017 01:15
Vue: Forage Adapter
// -----------------------------------------------------------------------------
// Vue: Forage Adapter
//
// @example
//
// import VueForage from "services/vueforage"
//
// Vue.use(VueForage)
//
// this.$vueForage.creageInstance({