Displaying 20 results from an estimated 346 matches for "chomp".
Did you mean:
champ
2006 Jan 23
3
date.to_s trimming
When I convert a datetime to a string, it prints out something like this
Jan 20 12:00:00 EST 2006
I want to trim off the last twelve characters, i.e.
:00 EST 2006
I tried to do it like so:
@date =
@meeting.date.to_s.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp.chomp
but the chomps seem to do nothing. I''d love to use regex, but I don''t
know which method to use to remove text from a string, or to just sever
the end of it (I tried unshift).
--
Posted via http://www.ruby-foru...
2017 Jul 21
3
[PATCH] common/mlstdutils: Add chomp function to remove \n from end of strings.
This is like the Perl chomp function, it removes a single \n from the
end of a string if present, else leaves the string alone.
I believe I found the only (two) places where such a function is used,
but there may be a few more lurking.
---
common/mlstdutils/std_utils.ml | 7 +++++++
common/mlstdutils/std_utils.mli...
2010 Dec 26
6
variables created with generate() function have a newline when used in a template
I have this in nodes.pp
$puppetmaster_fqdn = generate("/usr/bin/facter","fqdn")
and this in a template
http://<%= puppetmaster_fqdn %>:8080
When puppet runs, this is the result:
http://puppet.home
:8080
Anybody any clue to whats causing this? I''ve tried -%>
--
You received this message because you are subscribed to the Google Groups "Puppet
2010 Mar 25
2
NoMethodError (private method `chomp' called for nil:NilClas
Hi:
I am using Rails 2.3.5 with paperclip, mime-types and uploadify. So far
the application is working in development environment. But when I
switched to the production environment, it produced the following error.
NoMethodError (private method `chomp'' called for nil:NilClass):
/usr/lib/ruby/gems/1.8/gems/mime-types-1.16/lib/mime/types.rb:665:in
`type_for''
/usr/lib/ruby/gems/1.8/gems/mime-types-1.16/lib/mime/types.rb:730:in
`type_for''
app/controllers/assets_controller.rb:180:in `new_asset_from_params''...
2010 Dec 30
4
perl code to remove newlines
...lt;\L$1/g; # Downcase XXX in "<XXX".
s/<\/(\w*\W)/<\/\L$1/g; # Downcase XXX in "</XXX".
if(/^>/) # if this line starts with '>'
{ # then
$curr = tell $in; # Note current file position,
seek $in, $prev, 0; # go back to previous line,
chomp; # remove its trailing newline char,
seek $in, $curr, 0; # and reset position to current line.
}
else
{
$curr = tell $in; # Note current file position,
seek $in, $prev, 0; # go back to previous line
s/\n/ /; # Append a space,
chop; # and then chomp.
seek $in, $curr, 0; # and...
2003 Aug 25
2
SetVar on sample.call
...gi (Derived from the agi-test.agi)
======================================
#!/usr/bin/perl
$|=1;
while(<STDIN>) {
chomp;
last unless length($_);
if (/^agi_(\w+)\:\s+(.*)$/) {
$AGI{$1} = $2;
}
}
sub checkresu...
2009 Nov 04
11
Sending Mails with mutations ä,ü,ö
Hi everyone
I am sending mails with rails in German. The Problem is that the German
letters ä,ü,ö are arriving correctly at the receiver.
When the subject contains the word
Für
the receiver gets
Für
Does anybody knows this issue?
Thanks in advance.
Adam
--
Posted via http://www.ruby-forum.com/.
2012 Mar 16
3
custom fact issue
...s one? This fact seems to work, but it
doesn''t return when called directly via facter --puppet noop, but the
resulting facts end up in the reports.
I''m at wits end with this. Thanks!
<snip>
utc_hour = Facter::Util::Resolution.exec(%q</bin/date -u +"%H">).chomp
Facter.add(:noop) do
setcode do
environment = Facter.value(:environment)
if environment.match("test|dev|qa")
result = false
else
if utc_hour.match("01|02|03|04|05|06|07|08|09|10&...
2011 Aug 25
5
custom fact regex problem
...he first part(before the first -) of the hostname
if there exists a pattern/word qa and if it exists then my custom
fact
for envt should be qa.
My old envt.rb code is:
require ''facter''
Facter.add("envt") do
setcode do
%x{hostname -s|cut -c 1-2}.chomp
end
end
I am not good with regex/ patterns please help me out guys.
Thanks
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send...
2005 Dec 29
6
How do I open and read/write to a file?
I need to process some text files quickly. I''ve not been able to find the
answer in the archive. The Ruby Standard Library site times out. Can
someone tell me where to find info on how to:
1. Get a list of filenames in a directory.
2. How to open a file.
3. How to read it a line at a time.
--
Thanks in advance for the help,
-Larry
"Work, work, work...there is no satisfactory
2004 Jan 14
0
Réf. : samba 2.2.8a PDC LDAP CTRL+ALT+DEL password change, not chaning Unix password
...t;;
exit (10);
}
my $dn = get_dn_from_line($dn_line);
my $samba = is_samba_user($user);
print "Changing password for $user\n";
# non-root user
if (!defined($oldpass)) {
# prompt for current password
system "stty -echo";
print "(current) UNIX password: ";
chomp($oldpass=<STDIN>);
print "\n";
system "stty echo";
if (!is_user_valid($user, $dn, $oldpass)) {
print "Authentication failure\n";
exit (10);
}
}
# prompt for new password
my $pass;
my $pass2;
system "stty -echo";
print "New passwor...
2004 Sep 10
0
FLAC to mp3 batch converter?
...n/perl
use MP3::Info;
foreach $file (@ARGV) {
if (!($file =~ /\.flac$/)) {
print "Skipping $file\n";
next;
}
if ($tag = get_mp3tag($file)) {
$artist = $tag->{ARTIST};
$title = $tag->{TITLE};
$album = $tag->{ALBUM};
$track = $tag->{TRACKNUM};
chomp($artist);
chomp($title);
chomp($album);
chomp($track);
$track = sprintf("%2.2d", $track);
} else {
print "Couldn't get MP3 tag for $file.\n";
}
`flac -d "$file"`;
$file =~ s/\.flac$/.wav/;
if (($artist) && ($title) &&...
2010 Dec 30
2
remove newlines / perl /concise example
...ncise
example:
Input file:
<aaaa>
<bbbb>
<cccc>
<dddd>
I want everything on one line, i.e., remove all newlines. Like so:
<aaaa><bbbb><cccc><dddd>
Simple perl code:
#!/usr/bin/env perl
# Remove newlines from a file in two ways:
# (1) Just "chomp" them;
# (2) Replace them with a space.
# Open input file for reading only.
my $infilename = "/tmp/newline-test-in";
open(my $in, "<", "$infilename") or die "Can't open file
\"$infilename\": $!";
# Open output file for writing only.
m...
2008 May 25
2
storing data from a txt file in ruby?
...f books
title ,author so on and i can read in the file with no problem but im
trying to store the list into either a array or hash so i ca say run
different methods view, delete ect..
anyhelp would be great this is what i have so far
IO.foreach("book_list.txt") do |line|
catalog=line.chomp.split(",")
products.store(items[0].to_i,
[catalog[1],catalog[2].to_i,catalog[3].to_i)
end
thanks for anyhelp
Gabriel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
T...
2002 Apr 22
3
no output from perl script
...rsync, it's the first perl script I've written at all.
___________________________
#!/usr/bin/perl -w
print "
This command will DELETE EVERYTHING in Remote~/Research
UNLESS it is also found in Local~/Research.
Do you really wish to do this?
[N/yes]: ";
$answer = <STDIN>;
chomp $answer;
if ( $answer eq "yes" ) {
print "\nOK, here we go.\n";
`rsync -auvz --progress --delete -e ssh
Remote:/home/user/rsync-testing /home/user`
}
else {
print "\nabort mission\n";
}
_________________________...
2008 Nov 20
1
Stopping bdrb from another process gets the process killed
...#39;m running this from another process, let''s say a rake
task, the rake task gets killed because it gets the SIGTERM signal.
In the class StarStop we have:
def kill_process arg_pid_file
pid = nil
pid = File.open(arg_pid_file, "r") { |pid_handle|
pid_handle.gets.strip.chomp.to_i }
pgid = Process.getpgid(pid)
puts "Stopping BackgrounDRb with pid #{pid}...."
Process.kill(''-TERM'', pgid)
File.delete(arg_pid_file) if File.exists?(arg_pid_file)
puts "Success!"
end
What I did was, that instead of killing pgid, I...
2009 May 29
0
[PATCH server] last patch to implement remote freeipa
...b/installer/bin/ovirt-installer
@@ -175,8 +175,7 @@ guest_dev = guest_httpd_dev
#sep_networks = (guest_dev == admin_dev) ? "n" : "y"
ovirt_host = prompt_for_answer("Enter the hostname of the oVirt management server", :regex => IP_OR_FQDN, :default => hostname.chomp)
-#remote_ipa = prompt_yes_no("Is FreeIPA already installed on another machine?")
-remote_ipa = "n"
+remote_ipa = prompt_yes_no("Is FreeIPA already installed on another machine?")
if remote_ipa == "y"
ipa_host = prompt_for_answer("Enter the hostnam...
2010 Mar 23
2
Samba / Lucid / Windows 7 problem
...) and am unable to join
Windows 7 machines to the domain. I have applied the registry changes
described at http://wiki.samba.org/index.php/Windows7
Windows XP machines can join with no problems.
Samba log:
stty: standard input: Inappropriate ioctl for device
Use of uninitialized value $pass in chomp at /usr/sbin/smbldap-useradd
line 324.
stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device
Use of uninitialized value $pass2 in chomp at /usr/sbin/smbldap-useradd
line 330.
stty: standard input: Inappropriate ioctl for device
Use of uninitiali...
2006 May 29
3
File.size() on Uploaded Images Fail
...any files other than
images (jpg,png,gif).
Word, Excel, Powerpoint, .zip and more all work fine.
This is my model asset.rb that handles the file upload.
def newfile=(newfile_field)
self.filename = base_part_of(newfile_field.original_filename)
self.filetype = newfile_field.content_type.chomp
self.filesize = File.size(newfile_field) ### It fails on this line for
images...
end
The error I get is: "can''t convert StringIO into String"
I''m sure there''s an easier method/property to get the file size of the
uploaded file. Like, reading the HTTP hea...
2007 Jun 06
2
lookup in CSV recipe
...not found?
# add Excel and Openoffice support
module Puppet::Parser::Functions
newfunction(:lookup_csv, :type => :rvalue) do |args|
filename = args[0]
key = args[1]
column = args[2]
File.open(filename) do |file|
# find which column we are after
colnum = file.gets.chomp.split(/,/).index(column)
return nil if colnum == nil
# find row
file.each_line { |line|
row = line.chomp.split(/,/)
if (row[0] == key)
return row[colnum]
end
}
end
# no match found
return nil
end
end
Adrian