Skip to content

Instantly share code, notes, and snippets.

View sushant12's full-sized avatar
๐Ÿ˜Ž
Focusing

Suss Buzz sushant12

๐Ÿ˜Ž
Focusing
  • Kathmandu
View GitHub Profile
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
class RemindTest
@queue = :remind_news
def self.perform(reminder)
puts "Hey i am here #{reminder}"
end
end
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
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"
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"
sdfasdf
class TaskController < ApplicationController
get '/' do
@tasks = Task.all
erb :index
end
post '/save' do
Task.create(name: params[:task])
redirect '/'
end
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)
ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
host: 'localhost',
username: 'postgres',
password: 'postgres',
database: 'testdb'
<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>
<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 %>