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 NewsLettersController < ApplicationController | |
def send_news_letter | |
#if params[:send_news_letter][:email].present? | |
# @user = User.new params[:send_news_letter] | |
# @user.save validate: false | |
# Notifier.send_news_letter(@user).deliver | |
# redirect_to root_path, notice: "Thanks for sharing. We'll keep you in the loop!" | |
#else | |
#redirect_to root_path, error: "Please provide your email for the newsletter." | |
redirect_to *lambda {lambda{ @user = User.new( params[:send_news_letter]); @user.save(validate: false); Notifier.send_news_letter(@user).deliver }.call if params[:send_news_letter][:email].present? ; return [root_path, (params[:send_news_letter][:email].present? ? { notice: "Thanks for sharing. We'll keep you in the loop!" } : {error: "Please provide your email for the news letter!"})] }.call |
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
namespace :enriched do | |
desc "setup settings" | |
task setup_settings: :environment do | |
categories = YAML.load_file(File.join(Rails.root, "app", "yamls", "talents", "parent_categories.yml")) | |
categories["main_categories"].each { |main_category| main_setting, each_loop_method = Setting.create( body: main_category, role_type: "talents" ), lambda { |sub_category| sub_setting = Setting.create(body: sub_category, value: categories[main_category][sub_category]["value"], parent_id: main_setting.id, role_type: "talents")}; categories[main_category]["fields"].each( &each_loop_method ) } | |
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
class @FlashMessage | |
constructor: (@message, @flashType) -> | |
initHideFlashMessage: -> | |
$(".alert").slideUp -> $(this).remove() | |
hideFlashMessage: -> | |
setTimeout @initHideFlashMessage, 2000 | |
render: -> | |
$("header").prepend("<p class='alert alert-#{@flashType} no-radius'>#{@message}</p>") | |
@hideFlashMessage() |
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
<%= simple_form_for @job, html: { class: "form-horizontal" } do |f| %> | |
<% new_and_edit_form_fields.each do |column| %> | |
<%= f.input *column %> | |
<% 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
require 'socket' | |
remote_host = "[some public address]" | |
punch = UDPSocket.new | |
punch.bind('', 6311) | |
punch.send('', 0, remote_host, 6311) | |
punch.close | |
# # Bind for receiving |
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
#!/usr/bin/env ruby | |
require "rubygems" | |
require "nokogiri" | |
require "open-uri" | |
require "faraday" | |
doc = Nokogiri::HTML(open("http://www.songspk.name/a_list.html")) | |
doc.css(".ctlg-holder").each do |ul_holder| | |
ul_holder.css("li a").each do |anchor_holder| |
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
#### app/classes/activity_class.rb | |
require File.join(Rails.root, "app", "classes", "concerns", "methods") | |
class ActivityClass | |
include Classes::Concerns::Methods | |
def user_projects | |
user.projects.date_cont(params[:project_date_cont]).search(params[:project_search]).result( distinct: true ).collect do |project| | |
project.temp_user = user | |
def project.user_hours_count |
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
1.9.1 :001 > Dir.glob("/root/projects/tellum/releases/**/public/uploads/user/photo").each do |p| | |
1.9.1 :002 > FileUtils.cp_r Dir["#{p}/*"], "/root/projects/tellum/shared/uploads/user/photo" rescue puts p | |
1.9.1 :003?> 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
namespace :vf do | |
namespace :server do | |
desc "stop server" | |
task :stop => :environment do | |
puts "-----------------Stoping Server----------------" | |
pid_file = "tmp/pids/server.pid" | |
pid = File.read(pid_file).to_i | |
puts "************pid = #{pid}" | |
Process.kill 9, pid | |
File.delete pid_file |
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 Dashboard::JobDescriptionsController < Dashboard::BaseController | |
skip_authorization_check | |
before_filter only: [:new, :create] { @job_description = JobDescription.send(:new, ( params[:job_description] if params[:job_description]) ) } | |
before_filter only: [:edit, :update] { @job_description = JobDescription.find(params[:id]) } | |
before_filter only: [:create, :update] do | |
if @job_description.send((@job_description.new_record? ? :save : :update_attributes), ( @job_description.new_record? ? {validate: true} : params[:job_description] )) | |
redirect_to edit_dashboard_job_description_path(@job_description), notice: "record successfuly #{params[:action]}d" | |
else | |
render params[:action] == "create" ? :new : :edit | |
end |
NewerOlder