Inspired by https://www.facebook.com/techieprogrammer016/videos/1903944506811756
| Python | Ruby | |
|---|---|---|
| Swap two variables | a, b = b, a |
a, b = b, a |
| Reverse a string | s[::-1] |
s.reverse |
| Check palindrome | s == s[::-1] |
s == s.reverse |
Inspired by https://www.facebook.com/techieprogrammer016/videos/1903944506811756
| Python | Ruby | |
|---|---|---|
| Swap two variables | a, b = b, a |
a, b = b, a |
| Reverse a string | s[::-1] |
s.reverse |
| Check palindrome | s == s[::-1] |
s == s.reverse |
| import { Controller } from 'stimulus' | |
| // Sets the visibility of elements based on the checked state of a source | |
| // element. | |
| // | |
| // source target is expected to emit a change event when the value changes so | |
| // the UI can be updated. | |
| // | |
| // Target elements must be configured with a `data-visible-when` attribute set | |
| // to either "on" or "off" depending on when the element should be visible. The |
| #!/bin/sh | |
| # | |
| # Check for Ruby style errors using Rubocop | |
| red='\033[0;31m' | |
| green='\033[0;32m' | |
| yellow='\033[0;33m' | |
| NC='\033[0m' | |
| if git rev-parse --verify HEAD >/dev/null 2>&1 |
| #!/bin/bash | |
| # This script installs the version of Chromedriver that matches the installed | |
| # Chrome applicaton. | |
| # | |
| # It installs the chromedriver binary into ~/bin/. If an existing chromedriver | |
| # is installed it will be replaced by the updated binary. | |
| # | |
| # Assumptions: | |
| # |
| configure: WARNING: you should use --build, --host, --target | |
| checking for ruby... /Users/jakob/.rvm/rubies/ruby-2.6.0/bin/ruby | |
| *** using http instead of https *** | |
| config.guess already exists | |
| *** using http instead of https *** | |
| config.sub already exists | |
| checking build system type... x86_64-apple-darwin18.7.0 | |
| checking host system type... x86_64-apple-darwin18.7.0 | |
| checking target system type... x86_64-apple-darwin18.7.0 | |
| checking whether the C compiler works... yes |
| #!/bin/bash | |
| COUNTER=0 | |
| while [ $COUNTER -lt 10 ]; do | |
| let COUNTER=COUNTER+1 | |
| wget "http://domæne.dk/navn?id=$COUNTER" | |
| done |
| module Delayed::Job::Ext | |
| module_function | |
| # Returns all failed jobs | |
| def failed_jobs | |
| Delayed::Job.where.not(:last_error => nil).order(:failed_at) | |
| end | |
| def failed_with(message) | |
| failed_jobs. |
| def do_stuff | |
| list = [1, 2, 3, 4, 5] | |
| list.map { |value| | |
| return "Fizz" if value == 3 | |
| value | |
| } | |
| end | |
| p do_stuff |
| # frozen_string_literal: true | |
| # A generic presenter class | |
| class Presenter < SimpleDelegator | |
| attr_reader :view | |
| class << self | |
| # Returns true if object has been wrapped in a Presenter | |
| def decorated?(object) | |
| object.is_a?(Presenter) | |
| end |
| begin | |
| require "bundler/inline" | |
| rescue LoadError => e | |
| $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
| raise e | |
| end | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| gem "rails", github: "rails/rails" |