Skip to content

Instantly share code, notes, and snippets.

View davidteren's full-sized avatar
👋
Hey, nice to meet you.

David Teren davidteren

👋
Hey, nice to meet you.
View GitHub Profile
@bburdiliak
bburdiliak / date_range_formatter_without_duplicity.rb
Last active November 21, 2020 00:16
Date range formatter without duplicity
# Takes in: 29/09/20 - 29/09/20
# Outputs: 2020-09-28 18:00:00..2020-09-29 17:59:59.999999
def add_time_to_date(date)
date_from, date_to = date.split(' - ').map { |d| Time.parse(convert_date_format(d)) }
date_from.beginning_of_day.to_datetime..date_to.end_of_day.to_datetime
end
def convert_date_format(value)
return DateTime.strptime(value, '%d/%m/%y').strftime("%Y-%m-%d")
@boddhisattva
boddhisattva / setup_system_tests_with_rspec_devise_rails6.md
Last active November 9, 2023 20:58
Setup System tests to work with RSpec, Devise and Rails 6

Setting this up took quite a bit of time and research for me, so just thought of sharing the learnings along the way that led to a working setup.

  • Initial error that I was getting with running System tests in Rails 6

    System test integration requires Rails >= 5.1 and has a hard dependency on a webserver and `capybara`, please add capybara to your Gemfile and configure a webserver (e.g. `Capybara.server = :webrick`) before attempting to use system tests.
    • since the error above says specify Capybara in the Gemfile, a part of my Gemfile looked like below:
@leastbad
leastbad / action_mailbox.md
Last active April 8, 2025 20:26
Action Mailbox: The Missing Manual

This is all you really need to know in order to make Action Mailbox work in development.

  1. Fire up ngrok http 3000 and make note of your subdomain for steps 3 and 8.
  2. Create a Mailgun account because they offer sandbox addresses; grab your domain from the Dashboard.
  3. Go into Receiving and create a catch-all route pointing to: https://XXX.ngrok.io/rails/action_mailbox/mailgun/inbound_emails/mime
  4. Add your Mailgun API key to your credentials:
action_mailbox:
 mailgun_api_key: API KEY HERE
@lazaronixon
lazaronixon / _form.html.erb
Last active March 28, 2025 10:19
Dropzone.js + Stimulus + Active Storage + CSS Zero (2025)
<%= form_with(model: billboard) do |form| %>
<%= tag.div class: "dropzone", data: { controller: "dropzone", dropzone_param_name_value: "billboard[images][]", dropzone_url_value: rails_direct_uploads_url, dropzone_accepted_files_value: "image/*", dropzone_max_files_value: 3, dropzone_max_filesize_value: 0.300 } do %>
<div class="dz-default dz-message flex flex-col items-center">
<%= image_tag "upload.svg", size: 28, class: "colorize-black", aria: { hidden: true } %>
<h5 class="font-semibold mbs-4">Drop files here or click to upload.</h5>
<p class="text-sm text-subtle">Upload up to 10 files.</p>
</div>
<% end %>
<div class="inline-flex items-center mbs-2 mie-1">
@frank-who
frank-who / gist:af1e3c3dba1627451abc8552a5e99baf
Last active June 25, 2018 13:13
Ruby random South African ID number generator
def id_number(birthday, gender)
gender = (0..4).to_a.sample if gender == 'female'
gender = (5..9).to_a.sample if gender == 'male'
random_sequence = rand.to_s[2..5]
citizenship = 0
race = 8
id_number = [
birthday.gsub('-', '')[2..-1],
gender,
@joyrexus
joyrexus / README.md
Last active December 30, 2024 01:37
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@imthatcarlos
imthatcarlos / instructions.txt
Created December 4, 2016 05:04
Create a new rails application with a specific version
# make directory for new rails app
mkdir app
cd app
# specify ruby version
echo 2.3.1 > .ruby-version
# initialize bundler (creates Gemfile)
bundler init
@paulmillr
paulmillr / active.md
Last active March 17, 2025 08:21
Most active GitHub users (by contributions). https://paulmillr.com

Most active GitHub users (git.io/top)

The list would not be updated for now. Don't write comments.

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Because of GitHub search limitations, only 1000 first users according to amount of followers are included. If you are not in the list you don't have enough followers. See raw data and source code. Algorithm in pseudocode:

githubUsers
@chetan
chetan / yardoc_cheatsheet.md
Last active April 13, 2025 14:08
YARD cheatsheet