Skip to content

Instantly share code, notes, and snippets.

View eliotsykes's full-sized avatar

Eliot Sykes eliotsykes

View GitHub Profile

Ruby: The future of frozen string literals

What is a literal?

In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.

Some examples:

7 # integer literal
@brianjbayer
brianjbayer / gist-selenium-chrome-disable-save-popups.md
Created July 4, 2023 16:46
How to disable the Chrome Controlled by automation banner and those Save address?, Save card?, and Save Password? pop up windows in Selenium Webdriver

Disabling Selenium Chrome Automation Banner and Save address?, Save card?, and Save password? Pop Ups

Pencil Sharpener - Wendy Bayer

Image: Pencil Sharpener by Wendy Bayer


This shows you how to disable those Chrome Save address?, Save card?, and Save Password? pop up windows in Selenium Webdriver

@maxivak
maxivak / webpacker_rails.md
Last active November 3, 2024 21:38
Webpack, Yarn, Npm in Rails
@eliotsykes
eliotsykes / angularjs-rails-apps.md
Last active August 1, 2017 18:17
AngularJS Rails apps

Open Source AngularJS Rails Apps

Expect some false positives here, but hopefully most of these are open source Rails apps that use (or once used) AngularJS.

If you'd like to help update the list, please comment below with any of these apps you discover do not use AngularJS and include my username (@eliotsykes) in your message.

Confirmed using AngularJS

@eliotsykes
eliotsykes / multiline_expressions_in_ruby.md
Last active September 28, 2023 08:03
Multiline expressions in Ruby

How to break long lines up in Ruby

This page lists the options for breaking single-line expressions into multiple lines in Ruby.

Developers and teams need to come to their own decisions about which guideline(s) they prefer (preferences below are just my personal choices and I encourage you to disregard them).

# With trailing parens
x = [1, 2, 3].join(
 '-'
@rilian
rilian / config-environments-test.rb
Last active October 5, 2019 07:49 — forked from keithtom/no_animations.rb
Rack Middleware to disable Disable CSS3/jQuery Animations for Capybara
Rails.application.configure do
# ...
require_relative '../../spec/support/no_animations'
config.middleware.use Rack::NoAnimations
end
@alekseyg
alekseyg / stripe.js
Created March 15, 2017 22:03
What Stripe.applePay.checkAvailability actually does
Stripe.applePay.checkAvailability = function (callback) {
if (location.protocol === 'https:') {
var canMakePayments = window.ApplePaySession && ApplePaySession.canMakePayments()
if (/^pk_test_/.test(Stripe.key || Stripe.publishableKey)) {
callback(canMakePayments)
} else if (canMakePayments) {
var merchantId = "merchant." + window.location.hostname + ".stripe"
ApplePaySession.canMakePaymentsWithActiveCard(merchantId).then(callback)
} else {
@eliotsykes
eliotsykes / logger.js
Last active March 13, 2017 10:53
Logging JavaScript client-side to floating div
// Requires jQuery
var logger = {
setup: function() {
$('<div style="position:fixed; top: 0; left: 0; width: 100%; background-color: white;"><pre id="log-output" style="max-height: 70px; font-size: 10px; line-height: 12px;"></pre></div>')
.appendTo('body');
this.logOutput = $('#log-output');
},
info: function(msg) { this.logOutput.prepend(msg + "\n"); },
hide: function() { this.logOutput.parent().hide(); },
show: function() { this.logOutput.parent().show(); }
@eliotsykes
eliotsykes / api_controller.rb
Last active May 10, 2022 03:59
Token Authentication in Rails API Controller and Request Spec
# File: app/controllers/api/api_controller.rb
class Api::ApiController < ActionController::Base
# Consider subclassing ActionController::API instead of Base, see
# http://api.rubyonrails.org/classes/ActionController/API.html
protect_from_forgery with: :null_session
before_action :authenticate
def self.disable_turbolinks_cookies
skip_before_action :set_request_method_cookie
@eliotsykes
eliotsykes / cloud9-postgresql-rails-howto.md
Last active December 20, 2021 13:28
How to setup PostgreSQL & Rails on Cloud9

How to setup PostgreSQL & Rails on Cloud9

At time of writing, Cloud9 has PostgreSQL pre-installed, so you won't need to install it yourself. However, its not running by default, so you will need to start it with this command in the terminal:

sudo service postgresql start

Change the PostgreSQL password to 'password' (or choose a different password):