This file contains hidden or 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 'resque-scheduler' | |
require 'resque/scheduler/server' | |
# require './app/jobs/remind_news' | |
require './app/jobs/remind_test' | |
Resque.redis = 'localhost:6379' | |
Resque::Scheduler.dynamic = true |
This file contains hidden or 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 RemindTest | |
@queue = :remind_news | |
def self.perform(reminder) | |
puts "Hey i am here #{reminder}" | |
end | |
end |
This file contains hidden or 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 RemindNews < ApplicationJob | |
@queue = :remind_news | |
def self.perform(reminder) | |
name = 'remind_news' | |
config = {} | |
config[:class] = 'RemindTest' | |
config[:args] = 'POC email subject' | |
config[:every] = ['1m', { first_in: 1.second }] | |
# config[:cron] = "58 13 13 12 3 2017"#['1h', {first_in: 5.minutes}] | |
config[:persist] = true |
This file contains hidden or 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
uri = URI.parse("https://oapi.dingtalk.com/robot/send?access_token=#{setting_chat.token}") | |
https = Net::HTTP.new(uri.host, uri.port) | |
https.use_ssl = true | |
req = Net::HTTP::Post.new(uri.path) | |
req['Content-Type'] = 'application/json' | |
# req['charset'] = 'UTF-8' | |
req.body = { | |
"msgtype": "text", | |
"text": { | |
"content": "Hello world" |
This file contains hidden or 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
uri = URI.parse("https://oapi.dingtalk.com/robot/send") | |
https = Net::HTTP.new(uri.host, uri.port) | |
https.use_ssl = true | |
req = Net::HTTP::Post.new(uri.path.concat("?access_token=#{setting_chat.token}")) | |
req['Content-Type'] = 'application/json' | |
# req['charset'] = 'UTF-8' | |
req.body = { | |
"msgtype": "text", | |
"text": { | |
"content": "Hello world" |
This file contains hidden or 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
sdfasdf |
This file contains hidden or 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 TaskController < ApplicationController | |
get '/' do | |
@tasks = Task.all | |
erb :index | |
end | |
post '/save' do | |
Task.create(name: params[:task]) | |
redirect '/' | |
end |
This file contains hidden or 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 'bundler/setup' | |
Bundler.require(:default) | |
ActiveRecord::Base.establish_connection( | |
adapter: 'postgresql', | |
host: 'localhost', | |
username: 'postgres', | |
password: 'postgres', | |
database: 'testdb' |
This file contains hidden or 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
<form method="post" action="/update/<%= @task.id%>"> | |
Name: <input type="text" name="task" value="<%= @task.name%>"> | |
Finished?: <input type="checkbox" name="finished" value="1" <% if(@task.finished == 1)%> checked <% end %> > | |
<input type="submit" value="Save"> | |
</form> |
This file contains hidden or 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
<form method="post" action="save"> | |
Name: <input type="text" name="task"> | |
<input type="submit" value="Save"> | |
</form> | |
<h1>Tasks</h1> | |
<ol> | |
<% @tasks.each do |task|%> | |
<li><%= task.name %> <% if(task.finished == 1) %>(Finished) <% end %> <a href="/edit/<%= task.id %>">Edit</a> | <a href="/delete/<%= task.id%>">Del</a> </li> | |
<% end %> |