Skip to content

Instantly share code, notes, and snippets.

View michelson's full-sized avatar
🏠
Working from home

Miguel Michelson Martinez michelson

🏠
Working from home
View GitHub Profile
@michelson
michelson / async_method_job.rb
Created April 23, 2024 01:50
Asynchronously Concern
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
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
<%= turbo_frame_tag "conversation-list-#{@app.key}" do %>
<%= render partial: 'conversation', collection: @conversations, locals: {app: @app} %>
<% end %>
@michelson
michelson / danteRenderer
Created December 2, 2019 05:12
dante renderer example from redraft
/**
* 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();
@michelson
michelson / gist:805882
Created February 1, 2011 13:55
examples for lazy high chart
##### 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
@michelson
michelson / file1.txt
Created December 31, 2018 02:49
My first gist
Aren't gists great!
@michelson
michelson / check_boxes_input.rb
Created April 5, 2012 21:56
Formtastic check boxes with awesome_nested_set
# 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
require 'rubygems'
require 'json'
require 'em-hiredis'
require 'faye/websocket'
require 'rack'
Faye::EventSource.class_eval do
attr_accessor :connected_at
end
@michelson
michelson / test_mail_catcher.rb
Created August 3, 2015 20:44
mail catcher for rails env
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
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 = [