Copy Public Key To Host In One Line
ssh username@host "echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys"
11395 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
ssh username@host "echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys"
public static void fileCopy( File in, File out )
throws IOException
{
FileChannel inChannel = new FileInputStream( in ).getChannel();
FileChannel outChannel = new FileOutputStream( out ).getChannel();
try
{
// inChannel.transferTo(0, inChannel.size(), outChannel); // original -- apparently has trouble copying large files on Windows
// magic number for Windows, 64Mb - 32Kb)
int maxCount = (64 * 1024 * 1024) - (32 * 1024);
long size = inChannel.size();
long position = 0;
while ( position < size )
{
position += inChannel.transferTo( position, maxCount, outChannel );
}
}
finally
{
if ( inChannel != null )
{
inChannel.close();
}
if ( outChannel != null )
{
outChannel.close();
}
}
}
a = AmazoneS3Asset.new a.copy_over_bucket("myapp_production", "myapp_production")
require 'aws/s3' require 'mechanize' class AmazonS3Asset include AWS::S3 S3ID = "your s3 id" S3KEY = "your s3 key" def initialize puts "connecting..." AWS::S3::Base.establish_connection!( :access_key_id => S3ID, :secret_access_key => S3KEY ) end def delete_key(bucket, key) if exists?(bucket, key) S3Object.delete key, bucket end end def empty_bucket(bucket) bucket_keys(bucket).each do |k| puts "deleting #{k}" delete_key(bucket,k) end end def bucket_keys(bucket) b = Bucket.find(bucket) b.objects.collect {|o| o.key} end def copy_over_bucket(from_bucket, to_bucket) puts "Replacing #{to_bucket} with contents of #{from_bucket}" #delete to_bucket empty_bucket(to_bucket) bucket_keys(from_bucket).each do |k| copy_between_buckets(from_bucket, to_bucket, k) end end def copy_between_buckets(from_bucket, to_bucket, from_key, to_key = nil) if exists?(from_bucket, from_key) to_key = from_key if to_key.nil? puts "Copying #{from_bucket}.#{from_key} to #{to_bucket}.#{to_key}" url = "http://s3.amazonaws.com/#{from_bucket}/#{from_key}" filename = download(url) store_file(to_bucket,to_key,filename) File.delete(filename) return "http://s3.amazonaws.com/#{to_bucket}/#{to_key}" else puts "#{from_bucket}.#{from_key} didn't exist" return nil end end def store_file(bucket, key, filename) puts "Storing #{filename} in #{bucket}.#{key}" S3Object.store( key, File.open(filename), bucket, :access => :public_read ) end def download(url, save_as = nil) if save_as.nil? Dir.mkdir("amazon_s3_temp") if !File.exists?("amazon_s3_temp") save_as = File.join("amazon_s3_temp",File.basename(url)) end begin puts "Saving #{url} to #{save_as}" agent = WWW::Mechanize.new {|a| a.log = Logger.new(STDERR) } img = agent.get(url) img.save_as(save_as) return save_as rescue raise "Failed on " + url + " " + save_as end end def exists?(bucket,key) begin res = S3Object.find key, bucket rescue res = nil end return !res.nil? end end
rsync -a -e ssh source/ username@remotemachine.com:/path/to/destination/
require 'ftools' File.copy('notes.xml', 'notes2.xml')
INSERT INTO TABLE2 (COL1, COL2, COL3) SELECT COL1, COL4, COL7 FROM TABLE1
a = [1, 2, 3] b = a[:]
Simple copy routine Written by Davor Babic davorb@gmailDOTcom ,[>>+<<-]>>[<+<+>>-]<.>>>++++++++++
copy-dir: func [source dest] [
if not exists? dest [make-dir/deep dest]
foreach file read source [
either find file "/" [
copy-dir source/:file dest/:file
][
print file
write/binary dest/:file read/binary source/:file
]
]
]
find *.orig.jpg | perl -p -e 's/\n//; $x = $_; s/\.orig/\.large/; $_ = "cp " . $x . " " . $_ . "\n"'