#Ruby
15 posts tagged “Ruby”
15 posts tagged “Ruby”
Quick tip on how to install Ruby 2.7 and Nodejs 12 on Redhat 8, as it can default to older versions.
# Enable new versions
dnf -y module reset ruby nodejs
dnf -y module enable ruby:2.7 nodejs:12
# Install
dnf install nodejs ruby
# Check installed versions
ruby --version
node --version
npm --version
#!/usr/bin/rubyrequire 'open-uri'require 'twitter'twitDM = "twitter_username"remote_ip = open('http://whatismyip.akamai.com').readold_ip = File.open('remote_ip.txt', 'r').readif (remote_ip != old_ip) thenFile.open('remote_ip.txt', "w") { |file| file.write(remote_ip)}client = Twitter::REST::Client.new do |config|config.consumer_key = "xxxx"config.consumer_secret = "xxxx"config.access_token = "xxxx"config.access_token_secret = "xxxx"endclient.update("D #{twitDM} My IP address is now #{remote_ip}")elseputs "IP addresses match"end
# Find your Twitter Mentions and send them to Arduino on Serial Portrequire “rubygems” require “twitter” #https://github.com/sferik/twitter for config details require “serialport” #http://rubygems.org/gems/serialport require “pp”
prevID = 0 puts “Setting Up Serial Port” myport = SerialPort.new("/dev/ttyACM0",“9600”.to_i) sleep(10) while true puts “Checking for mentions” latestMention = Twitter.mentions(:count => 1)[0] if prevID != latestMention.id msg = latestMention.user.screen_name + " " + latestMention.text puts “-” + msg bytes = myport.write(msg) puts “-” + bytes.to_s prevID = latestMention.id else puts “-No new updates” end sleep 60 end myport.close
# Find your Twitter Mentionsrequire “rubygems” require “twitter” #https://github.com/sferik/twitter for config details require “pp”
prevID = 0 while true latestMention = Twitter.mentions(:count => 1)[0] if prevID != latestMention.id msg = latestMention.user.screen_name + " " + latestMention.text #puts msg.size puts msg prevID = latestMention.id else puts “No new updates” end sleep 60 end
Note: 1 of this post’s 6 links are now broken — mostly dead 2008–2013 feed-syndication infrastructure (FeedBurner, Gawker, AOL’s old blog network, Pheedo, Yahoo Pipes). Left as originally published.
// Auto scroll a message on the LCD and receive new messages via Serial port. // Alastair Montgomery (c) 2013 // Version 1.00 // include the library code: #include <LiquidCrystal.h> #include <string.h>// initialize the library with the numbers of the interface pins // below for SainSmart LCD Shield LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Note: 1 of this post’s 8 links are now broken — mostly dead 2008–2013 feed-syndication infrastructure (FeedBurner, Gawker, AOL’s old blog network, Pheedo, Yahoo Pipes). Left as originally published.
Note: 1 of this post’s 4 links are now broken — mostly dead 2008–2013 feed-syndication infrastructure (FeedBurner, Gawker, AOL’s old blog network, Pheedo, Yahoo Pipes). Left as originally published.
Finally got round to uploading some of my stuff to the GitHub site.
If you want a laugh have a look at my code alastairhm@github ;)
Doodle’s Geek Monkey by Alastair Montgomery
myTable.row_count
myTable.column_countmyTable.rows.lengthmyCols = myTable.strings[0].lengthmyCols = myTable.row.cells.lengthclass Watir::Tabledef row_countreturn self.rows.lengthenddef column_countreturn self.row.cells.lengthendend
myTable.rows.each { |myRow|myCols = myRow.cells.lengthassert_equal(validColumnCount,myCols,"Column count mismatch")}