Get [current, maximum] value pair:
Process.getrlimit(:NOFILE)[1]Set limit:
number = 1000 Process.setrlimit(:NOFILE, number)
Some useful information about everything
Process.getrlimit(:NOFILE)[1]Set limit:
number = 1000 Process.setrlimit(:NOFILE, number)
gunzip filename.dict.dz -S .dzFor ruby You could read it using GZip reader and process as xml using nokogiri.
require 'nokogiri'
require 'zlib'
include Zlib
data = GzipReader.open("dict.dict.dz"){|f|f.read}
doc = Nokogiri::XML(data)
p doc.xpath("k")[0].content
logError: function(error) { console.log(error); }
downloadFile: function(format, file_name, data){
if(!format){
format = 'txt';
}
if(!file_name){
file_name = 'default';
}
file_name = file_name + '.' + format;
if(data.length == 0){
return; // stupid stub
}
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(window.TEMPORARY, 1024*1024, function(fs) {
fs.root.getFile(file_name, {create: true}, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
var blob = new Blob([data]);
fileWriter.addEventListener("writeend", function() {
chrome.tabs.create({ url: fileEntry.toURL() });
}, false);
fileWriter.write(blob);
}, logError);
}, logError);
}, logError);
},
brew install youtube-dlUpdate it:
sudo youtube-dl -UIf You want to have just mp3 files. Install tools for converting files from http://ffmpegmac.net/ Move all files to bin folder:
cd path_to_unpacked_zip_tools sudo mv * /urs/local/binGet video file:
youtube-dl https://www.youtube.com/xyzGet audio file:
youtube-dl https://www.youtube.com/xyz -x --audio-format=mp3
class Command
attr_reader :name
def initialize(name)
@name = name
end
def run
raise "Implement me"
end
end
class MakeBold < Command
def initialize(text)
super("Make bold text: #{text}")
@text = text
end
def run; puts "<b>#{@text}</b>"; end
end
class MakeItalic < Command
def initialize(text)
super("Make italic text: #{text}")
@text = text
end
def run; puts "<i>#{@text}</i>"; end
end
class MakeSized < Command
def initialize(text, size=14)
super("Make text: #{text} to be size: #{size}")
@text = text
@size = size
end
def run; puts "<span style='font-size:#{@size}px;'>#{@text}</span>"; end
end
commands = []
commands << MakeBold.new("to be bold")
commands << MakeItalic.new("to be italic")
commands << MakeSized.new("to be sized", 20)
commands << MakeBold.new("other to be bold")
# show description for each command prior to execution
commands.each {|command| command.name }
# execute commands
commands.each {|command| command.run }
Output:
$ ruby command.rb <b>to be bold</b> <i>to be italic</i> <span style='font-size:20px;'>to be sized</span> <b>other to be bold</b>
class Iterator
def first; end
def last; end
def next; end
def current; end
def has_next?; end
end
class InfiniteNumbers < Iterator
def initialize
@current = 0
end
def first
1
end
def last
raise "Infinite number"
end
def next
@current += 1
end
def current
@current
end
def has_next?
true
end
end
iterator = InfiniteNumbers.new
puts 100.times.collect { iterator.next }.join(',')