- Rails 7.0.2
- stimulus js
- importmaps
- dropzone.js
- direct upload ActiveStorage
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
require 'rspec' | |
require 'time' | |
require 'active_support/time' | |
class Foo | |
def float_range_example | |
33 * 5 * Math::PI | |
end | |
def time_range |
#Since Rails doesn't load classes unless it needs them, you must read the models from the folder. Here is the code | |
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file| | |
begin | |
require file | |
rescue | |
end | |
end | |
models = ActiveRecord::Base.subclasses.collect { |type| type.name }.sort |
# install and make run basic bootstrap date-picker functionality described here http://www.eyecon.ro/bootstrap-datepicker/ | |
# app/assets/javascript/datepicker.js.coffee | |
$(document).on 'pageChanged', -> | |
# datepicker for simple_form & Ransack | |
$(".custom_datepicker_selector").datepicker().on 'changeDate', (en) -> | |
correct_format = en.date.getFullYear() + '-' + ('0' + (en.date.getMonth() + 1)).slice(-2) + '-' + ('0' + en.date.getDate()).slice(-2) # date format yyyy-mm-dd | |
$(this).parent().find("input[type=hidden]").val(correct_format) |
Model.pluck(:id, :name, ...).find_in_batches(10_000) do |ary| | |
CSV.open("tmp.csv", "ab") do |csv| | |
csv << ary.map{|a| a.join ','}.join("\n") | |
end | |
end |
how to delete secondary email from a Contact in Hubspot CRM via a API
hs_additional_emails
to empty will not work)require 'ansi' | |
require 'sqlite3' | |
require 'active_record' | |
require 'elasticsearch/model' | |
ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT) | |
ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ":memory:" ) | |
ActiveRecord::Schema.define(version: 1) do | |
create_table :articles do |t| |
# why and what is solarized http://ethanschoonover.com/solarized | |
# Simple installation notes for iterm2 and Solarized | |
Set ZSH_THEME in ~/.zshrc to blinks | |
https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized | |
#if you create new profile e.g. solarized you have to set him as default | |
#Simple installation notes for janus and Solarized | |
# .vimrc.before | |
let g:solarized_termcolors=256 | |
set t_Co=16 |
#!/usr/bin/env ruby | |
require "openssl" | |
require 'digest/sha2' | |
require 'base64' | |
# We use the AES 256 bit cipher-block chaining symetric encryption | |
alg = "AES-256-CBC" | |
# We want a 256 bit key symetric key based on some passphrase | |
digest = Digest::SHA256.new |
This gist was writen in 2012 and it was solving specific problem in Rails & SimpleForm. Some fellow developers were pointing out this may be out dated concept. That's why I advise everyone to read comment section bellow to have a full grasp of alternative solutions
other sources that may be helpful to understand why this may not be best idea: