Skip to content

Instantly share code, notes, and snippets.

@shekibobo
shekibobo / LICENSE.md
Last active February 24, 2016 17:26
Sidekiq+Redis JobManager to allow querying and deleting jobs

The MIT License (MIT)

Copyright (c) 2016 Joshua Kovach

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@shekibobo
shekibobo / capybara.rb
Created February 3, 2016 05:44
Capybara to toggle poltergeist/selenium in RSpec features
require "capybara/poltergeist"
Capybara.asset_host = "http://localhost:3000"
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new app, js_errors: true
end
Capybara.javascript_driver = :poltergeist
@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
@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
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 / README.md
Last active March 2, 2020 11:04
Android: Base Styles for Button (not provided by AppCompat)

How to create custom button styles using Android's AppCompat-v7:21

Introduction

AppCompat is an Android support library to provide backwards-compatible functionality for Material design patterns. It currently comes bundled with a set of styles in the Theme.AppCompat and Widget.AppCompat namespaces. However, there is a critical component missing which I would have thought essential to provide the a default from which we could inherit our styles: Widget.AppCompat.Button. Sure, there's Widget.AppCompat.Light.ActionButton, but that doesn't actually inherit from Widget.ActionButton, which does not inherit from Widget.Button, so we might get some unexpected behavior using that as our base button style, mainly because Widget.ActionButton strictly belongs in the ActionBar.

So, if we want to have a decently normal default button style related to AppCompat, we need to make it ourselves. Let's start by digging into the Android SDK to see how it's doing default styles.

Digging In

MyModel newModel = getNewModel();
MyModel oldModel = getOldModel();
String newValue = null;
newValue = newModel.getName();
if (newValue != null) {
oldModel.setName(newValue);
}
@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),
public List<String> getOptions() {
if (mOptions == null) {
FluentIterable<String> options = FluentIterable
.from(mAvailableThings)
.transform(Thing::getName);
mOptions = Lists.newArrayList(ImmutableSet.copyOf(options));
}
return mOptions;
}
class Object
def tapp(msg = nil)
tap do |obj|
if msg.nil?
pp obj
elsif obj.respond_to?(msg)
pp obj.send(msg)
else
puts "#{obj} does not respond to #{msg}."
end