Last active
August 29, 2015 14:19
-
-
Save retrography/a25fff5cdfe97d217375 to your computer and use it in GitHub Desktop.
Ruby one-liners
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MongoDB GridFile export | |
CSV::foreach('/Volumes/Content/Dropbox/Code/reuse/reimport/licenses/licensefiles.csv',{headers: true}) {|r| puts %x[mongofiles -d github -l #{r[1].gsub(/^\.\/([^\/]+)\/([^\/]+)\/.*/,'"\1\|\2"')} get "#{r[1]}"];} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OrientDB CSV import | |
CSV::foreach('./out.csv',{headers: true}) {|r| client.command "create edge COAUTHOR from (select from Gem where title='#{r['sourcegem']}') to (select from Gem where title='#{r['targetgem']}') content #{r.to_hash.to_json}"; puts "#{r['sourcegem']} -> #{r['targetgem']}"} | |
# OR | |
CSV::foreach('./yanknmissing.tsv',{headers: true, col_sep: "\t"}) do |r| | |
@oc.command "insert into _missing_and_yanked (gem, minup, maxup) values ('"+r[0]+"', date('"+r[1][0..9]+"','yyyy-MM-dd'),date('"+r[2][0..9]+"','yyyy-MM-dd'))" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment