Skip to content

Instantly share code, notes, and snippets.

View kmiscia's full-sized avatar

Kevin Miscia kmiscia

  • Philadelphia, PA
View GitHub Profile
class FtpRemoteFileUtils < RemoteFileUtils
attr_reader :destination_dir
CURL_COMMAND = OS.is_ubuntu ? "/usr/bin/curl" : "/usr/local/largecurl/bin/curl"
def initialize(params)
super(params)
raise ArgumentError unless params[:destination_dir]
@destination_dir = params[:destination_dir]
class FtpRemoteFileUtils < RemoteFileUtils
attr_reader :destination_dir
def initialize(params)
super(params)
raise ArgumentError unless params[:destination_dir]
@destination_dir = params[:destination_dir]
end
def cp(filename_with_path, destination_directory)
clean_filename_with_path = clean_dir(filename_with_path)
clean_destination = clean_dir(destination_directory)
local_filename = File.basename(filename_with_path)
local_destination = "/tmp/#{local_filename}"
if filename_with_path.local? && destination_directory.remote?
cmd = "#{curl_command} ftp://#{@host}/#{@destination_dir}/#{clean_destination}/#{local_filename} -T '#{local_destination}'"
xpwadmin103:script kmiscia$ rails console
Loading development environment (Rails 3.0.10)
irb(main):001:0> require 'ruby-debug'
LoadError: cannot load such file -- ruby-debug
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:239:in `block in require'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:593:in `new_constants_in'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:225:in `load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.0.10/lib/active_support/dependencies
function addStatusToDatagridLinks(data) {
$(".pagination a, th a, #headline .tabs a").each(function(index, element) {
var href = $(element).attr("href");
var params = href.slice(href.indexOf('?') + 1).split('&');
for(var i=0; i<params.length; i++) if(params[i].indexOf("selection=")===0) {
params[i] = "selection="+data;
break;
}
if(i===params.length) params.push("selection="+data);
$(element).attr("href", href.replace(/\?.*/, "?"+params.join("&")));
# The args to use for a radio button set of roles.
# Can be the args for a specific user, or a more
# generic non-model form.
def role_tag_args(role, user = nil)
if user
role_class = "user_role_#{role.name.downcase.gsub(" ", "_")}"
["user[role_ids][]", role.id, role_selected?(user, role), {:id => role_to_id(role), :class => role_class}]
else
['role_ids[]', role.id, (role.name == 'Contributor'), :style => 'margin-bottom: 2px;']
end
[8] pry(main)> some_day_in_future = Date.today + 5.days
=> Mon, 19 Mar 2018
[9] pry(main)> today = Date.today
=> Wed, 14 Mar 2018
[11] pry(main)> duration = some_day_in_future - today
=> (5/1)
[12] pry(main)> duration.class
=> Rational
-- Seller Timelines
SELECT
timelines.name,
versions.created_at as fell_through_at
FROM
timelines
LEFT OUTER JOIN timeline_fields on timeline_fields.timeline_id = timelines.id
LEFT OUTER JOIN versions ON versions.item_id = timeline_fields.id AND versions.item_type = 'TimelineField'
WHERE
timelines.is_template = FALSE