Skip to content

Instantly share code, notes, and snippets.

@shekibobo
shekibobo / capybara.rb
Created September 12, 2014 21:02
capybara.rb
require 'capybara/poltergeist'
Capybara.asset_host = 'http://localhost:3000'
Capybara.javascript_driver = :poltergeist
RSpec.configure do |config|
config.before(:each, touchy_js: true) do
Capybara.current_driver = :selenium
end
config.after(:each, touchy_js: true) do
@shekibobo
shekibobo / keybase.md
Created September 22, 2014 20:07
Keybase Identity

Keybase proof

I hereby claim:

  • I am shekibobo on github.
  • I am kovachjc (https://keybase.io/kovachjc) on keybase.
  • I have a public key whose fingerprint is 75C1 2506 FB58 4019 F849 4FA4 C82A 3DF4 1665 626E

To claim this, I am signing this object:

public List<String> getOptions() {
if (mOptions == null) {
FluentIterable<String> options = FluentIterable
.from(mAvailableThings)
.transform(Thing::getName);
mOptions = Lists.newArrayList(ImmutableSet.copyOf(options));
}
return mOptions;
}
@shekibobo
shekibobo / helpers.rb
Last active August 29, 2015 14:12
Attempt to send recovery email to alt_email
# in config/initializers/devise/mailers/helpers.rb (I think)
module Devise
module Mailers
module Helpers
def headers_for(action, opts)
headers = {
subject: subject_for(action),
# overriding this one using the one from the form
to: resource.notification_email,
from: mailer_sender(devise_mapping),
MyModel newModel = getNewModel();
MyModel oldModel = getOldModel();
String newValue = null;
newValue = newModel.getName();
if (newValue != null) {
oldModel.setName(newValue);
}
@shekibobo
shekibobo / .travis.yml
Created May 19, 2015 16:58
Android travis yml
language: android
jdk:
- oraclejdk8
android:
components:
- platform-tools
- tools
- build-tools-22.0.1
@shekibobo
shekibobo / build.gradle
Created June 5, 2015 14:53
Using test-variant string resources in espresso tests
def buildConfigAndResStringField(variant, name, value) {
variant.resValue 'string', name.toLowerCase(), value
variant.buildConfigField 'String', name, "\"$value\""
}
// Tried this, tests use the .debug suffix, not the .debug.test suffix
afterEvaluate {
android.applicationVariants.each { variant ->
buildConfigAndResStringField variant, "ACCOUNT_TYPE", variant.applicationId
buildConfigAndResStringField variant, "TOKEN_TYPE", variant.applicationId
class LoginActivity extends Activity {
// Setup stuff
@Override
public void onResume() {
// Subscribe to the login view submit
AppObservable.bindActivity(this, loginView.getUserCredentialsObservable().subscribeOn(mainThread()))
.doOnNext(loginView.showProgress(true))
.flatMap(creds -> getTokenObservable(creds))
.subscribe(this::handleSuccess)
@shekibobo
shekibobo / palindrome.rb
Created January 8, 2012 05:53
Testing for TheRubyGame Palindrome
#!/usr/bin/env ruby
class Palindrome
return string if string.length == 1
l = ""
string.size.times do |i|
break if string.size - i <= l.size
c = -1
while (a = string.rindex(string[i], c)) != i || a - i > l.size do
b = string[i..a]
class User < ActiveRecord::Base
rolify :after_add => :event_added_mew_role #, :role_cname => 'Role'
accepts_nested_attributes_for :roles
attr_accessible :roles_attributes
# Include default devise modules. Others available are:
# :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :token_authenticatable,
:recoverable, :rememberable, :trackable, :validatable