Created
August 5, 2008 01:30
-
-
Save Sakurina/4016 to your computer and use it in GitHub Desktop.
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 | |
# linky - easy file sharing on a local network | |
# by Yanik Magnan - http://r-ch.net/ | |
require 'fileutils' | |
require 'socket' | |
require 'tempfile' | |
# LONG USERNAME GOES HERE | |
LONG_USERNAME = "Yanik" | |
# Get important constants | |
HOME = ENV['HOME'] | |
PUB = "#{HOME}/Public" | |
OBJ = ARGV[0] | |
AIM = ARGV[1] | |
def local_ip | |
UDPSocket.open do |s| | |
s.connect '64.233.187.99', 1 | |
s.addr.last | |
end | |
end | |
URL = "afp://;AUTH=No%20User%20Authent@#{local_ip}/#{LONG_USERNAME}'s%20Public%20Folder" | |
if OBJ.nil? then | |
puts "specify an object" | |
exit 1 | |
else | |
type = case | |
when File.file?(OBJ): "F" | |
when File.directory?(OBJ): "D" | |
else "?" | |
end | |
if type == "F" then | |
puts "* File detected." | |
FileUtils::cp(OBJ, PUB) | |
puts "* File now public." | |
`echo "#{URL}" | pbcopy` | |
puts "* URL in clipboard:" | |
puts " #{URL}" | |
elsif type == "D" then | |
puts "compress directory first" | |
end | |
end | |
# AIM sending here | |
if AIM.nil? then | |
# NOTHING | |
else | |
src = <<-src | |
tell application "iChat" | |
send ¬ | |
"#{OBJ} => #{URL}" to buddy "AIM:#{AIM}" | |
end tell | |
src | |
out = Tempfile.new("scpt") | |
out << src | |
out.close | |
`cat #{out.path} | osascript` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment