This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AsyncMethodJob < ApplicationJob | |
queue_as :default | |
def perform(target:, method_name:, args:, queue_name: :default) | |
self.class.queue_as(queue_name) | |
# `target` could be either an instance or a class | |
target = target.constantize if target.is_a?(String) # Convert class name to class object if needed | |
target.send(method_name, *args) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Rauversion.AutoContext do | |
defmacro __using__(opts) do | |
quote bind_quoted: [opts: opts] do | |
import Ecto.Query, warn: false | |
alias Rauversion.Repo | |
def list do | |
Repo.all(unquote(opts)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= turbo_frame_tag "conversation-list-#{@app.key}" do %> | |
<%= render partial: 'conversation', collection: @conversations, locals: {app: @app} %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* You can use inline styles or classNames inside your callbacks | |
*/ | |
import React, {Component} from 'react' | |
import redraft from 'redraft' | |
var Prism = require('prismjs'); | |
//Prism.highlightAll(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### controllers | |
@time_chart = HighChart.new('chart_tag') do |f| | |
f.chart({:zoomType =>'x', :defaultSeriesType => 'spline'}) | |
f.title(:text => 'Flower Market') | |
f.x_axis({:type =>'datetime'}) | |
f.y_axis({:title => 'flowers'}) | |
chart_begin_js = "Date.UTC(#{@last_x_days[0].year}, #{@last_x_days[0].month-1}, #{@last_x_days[0].day})" | |
f.series(:name => 'violets', :data => generate_numbers(number), :pointInterval => 24*3600*1000) | |
f.series(:name => 'sunflowers', :data => generate_numbers(number), :pointInterval => 24*3600*1000) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aren't gists great! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this file in any autoloaded path on rails app. HINT: app/inputs/check_boxes_input.rb | |
class CheckBoxesInput < Formtastic::Inputs::CheckBoxesInput | |
def to_html | |
unless options[:nested_set] | |
super | |
else | |
nested_wrapping(options) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'json' | |
require 'em-hiredis' | |
require 'faye/websocket' | |
require 'rack' | |
Faye::EventSource.class_eval do | |
attr_accessor :connected_at | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.test? | |
class MailCatcher | |
def self.create(opts) | |
File.open("#{Rails.root}/tmp/mailcatcher/mail-#{Time.now.to_i}.html", 'w') do |f| | |
f.write(opts[:body].raw_source) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule UploaderHandler do | |
use Application | |
# See http://elixir-lang.org/docs/stable/elixir/Application.html | |
# for more information on OTP Applications | |
def start(_type, _args) do | |
# import Supervisor.Spec | |
IO.puts "iniciando" | |
children = [ |
NewerOlder