PORTSCOUT= limit:^1.4
It would appear you can set a regexp variable thus (for example):
PORTSCOUT=limit:^1.4
In a ports Makefile to prevent portscout looking for newer versions, very useful if you need to put a legacy version in the tree.
It would appear you can set a regexp variable thus (for example):
PORTSCOUT=limit:^1.4
In a ports Makefile to prevent portscout looking for newer versions, very useful if you need to put a legacy version in the tree.
Numbers of network addresses available for a given number of network bits… I always forget so…
| Network bits | Mask | Number of addresses |
|---|---|---|
| /20 | 255.255.240.0 | 4096 |
| /21 | 255.255.248.0 | 2048 |
| /22 | 255.255.252.0 | 1024 |
| /23 | 255.255.254.0 | 512 |
| /24 | 255.255.255.0 | 256 |
| /25 | 255.255.255.128 | 128 |
| /26 | 255.255.255.192 | 64 |
| /27 | 255.255.255.224 | 32 |
| /28 | 255.255.255.240 | 16 |
| /29 | 255.255.255.248 | 8 |
| /30 | 255.255.255.252 | 4 |
Clone a running FreeBSD system to another disk. Source drive: ad0, target drive ad1
Prepare the target drive
cd /tmp/
df -h > liveFSsizes
bsdlabel da0s1 > liveSPsizes
dd if=/dev/zero of=/dev/da1 count=2
fdisk -BI /dev/da1
bsdlabel -B -w da1s1
bsdlabel -R da1s1 liveSPsizes
cat liveSPsizes
newfs -U /dev/da1s1a
newfs -U /dev/da1s1d
newfs -U /dev/da1s1e
newfs -U /dev/da1s1f
Mount each partition and dump the source partition (da0) to our backup (-)
mount /dev/da1s1a /mnt
cd /mnt
dump -0Lauf - /dev/da0s1a | restore -rf -
mount /dev/da1s1d /mnt/var
cd /mnt/var
dump -0Lauf - /dev/da0s1d | restore -rf -
mount /dev/da1s1e /mnt/tmp
cd /mnt/tmp
dump -0Lauf - /dev/da0s1e | restore -rf -
mount /dev/da1s1f /mnt/usr
cd /mnt/usr
dump -0Lauf - /dev/da0s1f | restore -rf -
sync
cd /tmp
rm liveSPsizes
rm liveFSsizes
umount /mnt/usr
umount /mnt/tmp
umount /mnt/var
umount /mnt
Note when you fdisk you should expec the following errors:
******* Working on device /dev/da1 *******
fdisk: Class not found
The original version of this can be found on the FreeBSD fora in this thread: http://forums.freebsd.org/showthread.php?t=11680.
One that caught me out for a while … needed to reduce the timeout the Net/HTTP library was defaulting to because the servers I was querying were liable to be offline and I didn’t want my script hanging around.
I wrote something like:
require 'net/http'
res = Net::HTTP.start('http://www.example.com') do |http|
http.open_timeout = 4
http.read_timeout = 4
http.get('/index.html')
end
puts res.body
Pah, why does Ruby seem to totally ignore the timeout settings? It just ignores it… humm. Okay some digging required. It would appear the instance method invokes the connect then yields so by the time the block is actually executed the connection has already been attempted, with the default timeouts – rather than those that appears to be set.
So we need to use code akin to:
require 'net/http'
http = Net::HTTP.new("http://www.example.com")
http.open_timeout = 4
http.read_timeout = 4
res = http.get('/index.html')
puts res.body
For it to respect our timeouts!
I was writing some code akin to:
case something.class when String, Symbol then 1 when Fixnum then 2 when Time then 3 end
Only to find it didn’t work, always returning nil. A bit of trawling turned up the following blog post: http://www.postal-code.com/mrhappy/blog/2007/02/01/ruby-comparing-an-objects-class-in-a-case-statement/, which explains that you don’t need the .class. So my above code would become:
case something when String, Symbol then 1 when Fixnum then 2 when Time then 3 end
Which works.
Just recording the power ratings I measured with this plug-in meter and a Dell R210 server. Firstly some base readings with no operating system installed and the machine powered up (with no power applied the Drac Express draws about 26W).
Now putting an OS on the machine and actually optimising so the OS can power down the CPU, etc.
On a more expensive calibrated meter we tickled 47VA with that last configuration.
Got an iDRAC card in your Dell server and want to generate a 2048 bit certificate signing request? You’ll need to modify the settings on the DRAC to change it from the default 1024 bit request.
SSH into the iDRAC and then type the racadm command as indicated:
/admin1-> racadm config -g cfgRacSecurity -o cfgRacSecCsrKeySize 2048
Object value modified successfully
/admin1->
I’ve been working with the XML-Mapping gem and had the following error when trying to generate XML:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/element.rb:685:in `write': undefined local variable or method `output' for <xml_node> ... </>:REXML::Element (NameError)
A bit of digging lead me to this bug report, which lead me to look properly at the code and sure enough correcting the code (line 674) corrects the bug and I can generate XML. i.e. changing
def write(writer=$stdout, indent=-1, transitive=false, ie_hack=false)
to
def write(output=$stdout, indent=-1, transitive=false, ie_hack=false)
Note writer has now become output. Now since the that function in REXML is depreciated anyway I should probably modify the XML-Mapping code to use the more modern REXML::Formatters
Now this might just be my system and I certainly don’t have this problem with any of my FreeBSD machines, but I’ve got a weird problem with filenames and colons on my Mac (10.5.8) with Ruby (ruby 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]).
Anyhow if I write something like this:
File.open('foo:bar.txt', 'w') {|f| f.write("hello world") }
Rather than get a file in the current directory named foo:bar.txt I actually get one named foo/bar.txt. I’ve tried various potential escape sequences (\: \c etc.).
The colon name totally works as you’d imagine on my FreeBSD machines, so it must be something either to do with the Ruby version or OSX – I guess it must be half identifying the colon as a path seperator, but the file created with the ‘/’ in it is a proper file with that name.
Chalk one up to not enough time to debug, but enough time to note.
Just installed the XML-Mapping Gem (http://xml-mapping.rubyforge.org/) and kept getting a require error every time I tried to use it.
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- xml/mapping (LoadError)
Everything seemed okay, until eventually I noticed that the Gem files themselves were rather restrictive on permissions – owner read and write only. So I had to go into the directory (/Library/Ruby/Gems/1.8/gems/xml-mapping-0.8.1/ on my Mac) and chmod the files to 644 and the directories to 755 and then the Gem loads okay.
cd /Library/Ruby/Gems/1.8/gems/xml-mapping-0.8.1/
find . -type d -exec chmod 755 {} ";"
find . -type f -exec chmod 644 {} ";"
© Chillibear | Theme DePo Skinny | Header image from: Andrews, William: 'Curiosities of the Church: Studies of Curious Customs, Services and Records' (1891)