Skip to content

Instantly share code, notes, and snippets.

View Haumer's full-sized avatar
馃幆
Focusing

Alex Haumer Haumer

馃幆
Focusing
  • London
View GitHub Profile
numbers = [1, 2, 5, 8, 10, 13]
enum.filter_map { |i| i * 2 if i.even? }
# => [4, 16, 20]
const previewImageOnFileSelect = () => {
// we select the photo input
const input = document.getElementById('photo-input');
if (input) {
// we add a listener to know when a new picture is uploaded
input.addEventListener('change', () => {
// we call the displayPreview function (who retrieve the image url and display it)
displayPreview(input);
})
}
array = %w(
1768
1847
1905
1713
1826
1846
1824
1976
1687
string = "1-4 m: mrfmmbjxr
5-16 b: bbbbhbbbbpbxbbbcb
7-8 x: qxrxmxccxxx
9-11 k: kkkkkkktmkhk
8-12 g: sgwvdxzhkvndv
6-9 v: zvmvvmvvvd
8-19 f: ffffsplmfflffhtfrfj
5-16 p: pppppppppspppjpcp
2-3 w: wwmw
7-19 j: jjjjjjjjjjjjjjjjjjvj
# 02-Flow-Array/01-Can-you-vote/
def allowed_to_vote?(age)
# TODO: return (not print!) a boolean stating whether `age` is old enough to vote
# NOTE: Use an if/else statment
unless age > 18
puts false
else
puts true
end
require "date"
def greetings(name)
"Welcome to London #{name}! I hope you enjoy it!"
end
# puts greetings("James")
# puts greetings("Nathan")
# def one_plus_one
puts "----------------------------------------"
puts "-----Welcome to The Price is Right!-----"
puts "----------------------------------------"
puts "Guess the price of this wonderful imaginary product"
# computer picks a random number (generate random number)
computer_number = rand(1..100)
# ask the user to enter a number => gets.chomp
require 'csv'
# 1. Greet/Welcome the user to the Christmas List program!
puts "(炉`路._(炉`路._(炉`路._(炉`路._(炉`路.__.路炉) _.路炉)_.路炉)_.路炉)_.路炉)"
puts "(炉`路._(炉`路._ Welcome to the Christmas List! _.路炉)_.路炉)"
puts "(炉`路._(炉`路._(炉`路._(炉`路._(炉`路.__.路炉) _.路炉)_.路炉)_.路炉)_.路炉)"
options = [
"list",
"add",
"delete",

simple_form_array_input.rb

class ArrayInput < SimpleForm::Inputs::StringInput
  def input
    input_html_options[:type] ||= input_type

    existing_values = Array(object.public_send(attribute_name)).map do |element|
      @builder.text_field(nil, input_html_options.merge(value: element, name: "#{object_name}[#{attribute_name}][]"))
    end