Browse | Submit A New Snippet | Create A Package

 

Snippets by category: File Management

Snippet ID Title
Packages Of Snippets1bin2hexXu Jingtao
a small untility that can convert a binary file to assembly or c format hexadecimal string.
4rubypkgJayen Chandra
rubypkg
5File Splitter and JoinerSaajan N
File Splitter: Split a big file into a number of smaller files

File Joiner: Join all your "piece" files into a single file again
9cms for real estateM Ilyas
content management system for real estate
51RubySnipsLarry Kite
Snippets of Ruby
52virtapayCici Wirachmat
Business Website using Ruby on Rails
Snippets
7MS Word document manipulationTom Copeland
Some snippets written by James Toomey in this ruby-talk posting:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/60004

39BatchFileEditorJames McCarthy
Great IO example,
(IMHO)
Replaces simple characters with other ones in files of type specified
Meant for *nix.
My first working Ruby code.
58Filenames to 7-bit ASCIIKaspar Schiess
Convert all directories and files under a given path to contain only 7-bit ascii.
Transliteration is done trough a easy to expand lookup table.
To commit things, replace FileUtils::DryRun with FileUtils
60ruby whichBruno Carnazzi
which command ruby equivalent
77config.rbBalwinder S Dheeman
Class to read/write config files with [sections], keywords = value pairs.
84rubyforge.netRuby Dos Zapatas
This is what I use Spirit and RubyRelease with.
It does it all!
85filesystem recursive deletionGary Shea
A simple script for recursive deletion of a directory. Deletes everything. Originally written to use for a 'clean' target in Rake. The code that actually does the deletion is commented out. Try it. If you decide you trust it, remove the 'puts' and uncomment the File.delete.

Enjoy!
86long argument list parserruy jauregui
This snippet manages a long list of arguments given to a ruby program. It recognizes 2 flags, "-l" which calls a "ls" command to be run and gives the result as arguments to the program and "-f filename" which reads the lines in "filename" and gives the result as arguments. If no flags are given it takes the standard ARGV array.
The resulting argument list is given in an array called @lis.
87File RecursiveFelix Sun
To get every file in the given folder include subfolder.
96onclick en javascriptchristopher espinoza
necesito crear un onclick destro de un arbol creado en javascript, el cual hereda atributos de un archivo *.js
105File SplitterSaajan N
File Splitter: Split a file into a number of smaller pieces
106File JoinerSaajan N
File Joiner: Join all your "piece" files into a single file again
110Create package for release on rubyforgeSoemirno Kartosoewito
Creates packages from a tag in the sourcetree.
128FileUtils.cp_r wrapper for patching a tree of filesAlbert Davidson Chou
A convenience script wrapping FileUtils.cp_r's ability to copy all contents of the source directory instead of the directory itself. I needed to patch a set of PHP files with a newer subset of those files. The :preserve argument is set to TRUE in the FileUtils.cp_r call so the modification dates of all the files will be usable as a version identifier (otherwise, the modification date becomes "today", which only indicates the date the patch was performed, rather than what version the patch applied was).
129Split a file at delimiting linesAlbert Davidson Chou
This script will split a file at lines identified by a regular expression. The output files will be named using the original file's name with ".1", ".2", etc. appended to the name of each consecutive output file.

I wrote this script because I needed to break up a text file of MySQL table contents dumped out by phpMyAdmin into one big CSV-style file. The delimiting line in this case was the column headings declaration for each table, which started with "ID;".

The command line for this situation was (on OS X):

split_at_line input_file.csv ^\"ID\"

where I had to escape the " characters so they would not be stripped away by bash before it passed the argument to the script.

The script implicitly assumes that its input file is text, not binary, as the format is not specified when opening the files.
153cleanruy jauregui
remove 0 size files from a directory
154squeezeruy jauregui
This function reads the contents of a file, or a list of files, and prints a non-redundant version; the same files with repeated lines removed.
499HTML5 OfflineWebAppK Chandrasekhar Omkar
Imagine a website being used by billions, at once. All the requests, responses make huge amounts of data to flow, contributing network congestion. Hence, it would be ridiculous & costly to send a request to the server for a very minor operation. For example, take an online ticket booking server, which is used for planning trips, booking all tickets. Suppose there is a phone-number, and email ID field that is required at the time of booking tickets, and you forgot to fill it before submitting. It then becomes the server's responsibility to ensure valid data is being processed, apart from various other business transactions. For such a busy server, validating input data would surely become an overhead, and has considerable impact on the performance. Hence, it should be ensured before submitting, that all inputs are fed properly. So, JavaScript comes into the picture here. This script is executed suitably, at the client end to ensure that all data adheres to specifications. Script then submits data after thorough validation. Doesn't it reduce atleast half of the requests being made to the server? Obviously, the amount of traffic in the network gets reduced drastically.
256File.each_line (class method for File)Patrik Wenger
Just a quick way for iterating over each line of a given file path. Return value is the number of lines.

Example:
File.each_line("file.txt") do |line|
puts "line = #{line}"
end
287Core Class ExtensionsJames Schneider
All the stuff I've wanted and had to add to Ruby's infrastructure that I've remembered to save.
561GenLibBob Hostern
A small Ruby file generating class. You must include a file called "makefile.opgenc" in the directory of the snippet in order to work out of the box.