$> fdupes
$> find . -type f -size +10M
| #!/usr/bin/env ruby | |
| # | |
| # run gtar in parallel | |
| # | |
| l = Dir.glob("summary/*") | |
| names = l.map { |e| File.basename(e[0]).split("_")[0] }.uniq | |
| list = names.map do |user| | |
| spawn(%Q(gtar cvf archive+#{user}_2019-11-14.tgz log/#{user}*.log)) | |
| end |
| // Go grep parallel | |
| // https://golang.hotexamples.com/examples/codesearch.regexp/Grep/File/golang-grep-file-method-examples.html | |
| func main() { | |
| var g regexp.Grep | |
| g.AddFlags() | |
| g.Stdout = os.Stdout | |
| g.Stderr = os.Stderr | |
| flag.Usage = usage | |
| flag.Parse() |
| # USAGE: Hash.from_xml(YOUR_XML_STRING)require 'rubygems' | |
| require 'nokogiri' | |
| # modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#123129 | |
| 7 | |
| class Hash | |
| class << self | |
| def from_xml(xml_io) | |
| begin | |
| result = Nokogiri::XML(xml_io) |
| # Makefile flash card | |
| # | |
| # check if file exist | |
| ifneq ("$(wildcard $(path))","") | |
| FILE_EXISTS = 1 | |
| else | |
| FILE_EXISTS = 0 | |
| endif |
| require 'yaml' | |
| require 'erb' | |
| # render a template | |
| # @param [String] s template | |
| # @param [Binding] ctx binding context | |
| # @return [String] render output | |
| def render(s, ctx) | |
| begin | |
| erb = ERB.new(s) |
| #!/usr/bin/env ruby | |
| # | |
| # Convert CD to mp3 on Linux | |
| # | |
| # reference: https://www.cyberciti.biz/faq/linux-ripping-and-encoding-audio-files/ | |
| # | |
| # Run extraction with | |
| # cdparanoia -B | |
| # | |
| # Convert wav to mp3 with lame |
| # simple fibonnaci benchmark | |
| # | |
| require 'benchmark' | |
| def fib(n) | |
| if n == 1 | |
| 1 | |
| elsif n == 2 | |
| 1 | |
| else |
| require 'mongo' | |
| client = Mongo::Client.new("mongodb://localhost:27017", {database: 'test'}) | |
| db = client.db | |
| # Show all collection | |
| db.collection_names | |
| # Count number of document | |
| db["searches"].count() |