Skip to content

Instantly share code, notes, and snippets.

View dalezak's full-sized avatar

Dale Zak dalezak

View GitHub Profile
<%= form_for(board, html: {class: "space-y-4"}) do |form| %>
<div>
<%= form.label :title, class: "block text-sm font-medium text-gray-700" %>
<%= form.text_field :title %>
</div>
<div>
<%= form.fields_for :embeds do |embed_form| %>
<%= embed_form.label :input, class: "sr-only" %>
<%= embed_form.text_field :input, placeholder: "Enter an embeddable link", data: {reflex_permanent: true} %>
require 'googleauth'
require 'google/apis'
require 'google/apis/calendar_v3'
module GoogleMeetService
def self.create_google_event(event)
authorize_client
google_event = create_calendar_event(event)
updated_google_event = update_calendar_event(event,google_event)
event.update_attribute(:conference_link,updated_google_event.hangout_link)
@mwlang
mwlang / application_controller.rb
Last active April 2, 2024 23:50
Logging headers, params, and body to console -- useful for debugging what a mobile app is sending Rails API backend server.
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
around_action :global_request_logging
def global_request_logging
http_request_header_keys = request.headers.env.keys.select{|header_name| header_name.match("^HTTP.*|^X-User.*")}
http_request_headers = request.headers.env.select{|header_name, header_value| http_request_header_keys.index(header_name)}
puts '*' * 40
pp request.method
@mankind
mankind / rails-jsonb-queries
Last active April 17, 2024 12:14
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@ografael
ografael / deploy.rake
Created March 21, 2012 23:13 — forked from rafaelp/deploy.rake
Rake task to deploy Rails project to Heroku
# -*- encoding : utf-8 -*-
namespace :heroku do
namespace :deploy do
PRODUCTION_APP = 'nomedoprojeto-production'
STAGING_APP = 'nomedoprojeto-staging'
def run(*cmd)
system(*cmd)
raise "Command #{cmd.inspect} failed!" unless $?.success?
end
@rafaelp
rafaelp / deploy.rake
Created March 21, 2012 20:25
Rake task to deploy Rails project to Heroku
# -*- encoding : utf-8 -*-
namespace :heroku do
namespace :deploy do
PRODUCTION_APP = 'nomedoprojeto-production'
STAGING_APP = 'nomedoprojeto-staging'
def run(*cmd)
system(*cmd)
raise "Command #{cmd.inspect} failed!" unless $?.success?
end