# Anchor
click_link 'Save'
# Button
click_button 'awesome'
# Both above
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deBruijn(n, k): | |
''' | |
An implementation of the FKM algorithm for generating the de Bruijn | |
sequence containing all k-ary strings of length n, as described in | |
"Combinatorial Generation" by Frank Ruskey. | |
''' | |
a = [ 0 ] * (n + 1) | |
def gen(t, p): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by https://github.com/rspec/rspec-core/pull/596 | |
require 'rspec/core/formatters/base_formatter' | |
module RSpec | |
module Core | |
module Formatters | |
class FailuresFormatter < BaseFormatter | |
def dump_failures | |
return if failed_examples.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.nio.file.*; | |
import java.security.*; | |
import java.security.cert.*; | |
import javax.net.ssl.*; | |
import org.bouncycastle.jce.provider.*; | |
import org.bouncycastle.openssl.*; | |
public class SslUtil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <QuartzCore/QuartzCore.h> | |
// Form validation. You'll probably place this in your buttonClicked action | |
if ([textField.text isEqualToString:@""]) // checks if field is empty, add other form validation here | |
{ | |
textField.layer.cornerRadius = 8.0f; | |
textField.layer.masksToBounds = YES; | |
textField.layer.borderColor = [[UIColor redColor] CGColor]; | |
textField.layer.borderWidth = 1.0f; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Call touch_id_authenticate | |
def touch_id_authenticate | |
context = LAContext.alloc.init | |
auth_error = nil | |
reason = 'Authenticate using your fingerprint' | |
if context.canEvaluatePolicy(LAPolicyDeviceOwnerAuthenticationWithBiometrics, error: auth_error) | |
context.evaluatePolicy(LAPolicyDeviceOwnerAuthenticationWithBiometrics, localizedReason: reason, reply: lambda do |success, error| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to Completely Remove Android Studio | |
Execute these commands from the terminal | |
rm -Rf /Applications/Android\ Studio.app | |
rm -Rf ~/Library/Preferences/AndroidStudio* | |
rm ~/Library/Preferences/com.google.android.studio.plist | |
rm -Rf ~/Library/Application\ Support/AndroidStudio* | |
rm -Rf ~/Library/Logs/AndroidStudio* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Some interesting observations on block comparing. Apparently swift nor objective c don't allow comparing closures | |
// due to the complexity of the process and because of compiler optimisations… bla bla. But it seems to be possible | |
// to do this using conventions blocks, aka the objective c ones that can be cast as objects. The interesting part | |
// is how swift freely casts SwfBlock to ObjBlock, yet in reality two casted SwfBlock blocks will always be different | |
// values, while ObjBlocks won't. When we cast ObjBlock to SwfBlock, the same thing happens to them, they become two | |
// different values. So, in order to preserve the reference, this sort of casting should be avoided. | |
typealias SwfBlock = () -> () |
OlderNewer