Skip to content

Instantly share code, notes, and snippets.

View sdsantos's full-sized avatar

Sérgio Santos sdsantos

View GitHub Profile
@mattconnolly
mattconnolly / gist:4158961
Created November 28, 2012 04:04
RSpec basic authentication helper module for request and controller specs
module AuthHelper
def http_login
user = 'username'
pw = 'password'
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end
end
module AuthRequestHelper
#
@JakeWharton
JakeWharton / ShampooRule.java
Last active August 31, 2023 15:47
Got flaky tests? Shampoo them away with a quick JUnit rule. Apache 2.
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/** Got flaky tests? Shampoo them away. */
public final class ShampooRule implements TestRule {
private final int iterations;
public ShampooRule(int iterations) {
if (iterations < 1) throw new IllegalArgumentException("iterations < 1: " + iterations);
@Peddro
Peddro / ScreengrabHelper.java
Last active February 23, 2016 11:30
Helper for screengrab to take delayed screenshots
public class ScreengrabHelper {
private static ScreengrabHelper instance;
private static final long INIT_DELAY = 2000;
private long delay;
private boolean screenShotTaken;
public ScreengrabHelper() {
this.delay = INIT_DELAY;
@cbeyls
cbeyls / KotlinFunctions.md
Last active August 12, 2024 07:36
Comparison of Kotlin functions: also, apply, let, run, with
Function Function type Target passed as Returns
also Extension it Target
apply Extension this Target
let Extension it Block return value
run Extension this Block return value
with Regular this Block return value