Skip to content

Instantly share code, notes, and snippets.

View Haumer's full-sized avatar
🎯
Focusing

Alex Haumer Haumer

🎯
Focusing
  • London
View GitHub Profile
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
array = %w(
1768
1847
1905
1713
1826
1846
1824
1976
1687
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);
})
}
numbers = [1, 2, 5, 8, 10, 13]
enum.filter_map { |i| i * 2 if i.even? }
# => [4, 16, 20]
class BaseRepo
def initialize(csv_file)
@csv_file = csv_file
@elements = []
@next_id = 1
load_csv if File.exist?(@csv_file)
end
def create(element)
element.id = @next_id
class Patient
attr_accessor :room, :id
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@cured = attributes[:cured] || false
end
end
require_relative "task"
require_relative "view"
class Controller
def initialize(repository)
@repository = repository
@view = View.new
end
def add_task
@Haumer
Haumer / gsub.rb
Created September 14, 2020 16:03
something.gsub(/src=(?<url>[^\s]+)/, 'src="" data-src=\k<url> class="lozad"')
# here \k<something> where something is the name of the group in your regex.