Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
github.com/otgapps/motion_print
A RubyMotion pretty printer.
instead of using p
or puts
, use mp
to log your debug values to the RubyMotion REPL.
Colors don't show up correctly on github, so these are just examples of what you can do with motion_print
. Try it out for yourself to see the more colorful output!
mp "a string"
"a string"
mp :some_symbol
:some_symbol
mp [1, 'two', :three, 4.0]
[
1,
'two',
:three,
4.0
]
mp({b: "bee", a: 'a', see: 4})
{
a => a,
b => bee,
see => 4
}
Add this line to your application's Gemfile:
Stable:
gem 'motion_print'
Bleeding Edge:
gem 'motion_print', github: 'OTGApps/motion_print'
And then execute:
bundle
motion_print
?motion_print
supports other gems (or even your own classes in your project ) with an opt-in feature. All you have to do is implement the motion_print
method in your class (with option mp
and options
arguments). You can see an example implementation of this in the specs.
def MyCustomClass
def motion_print(mp)
# This will output in red!
mp.colorize("Some Output Here!", :red)
end
end
Here's CDQ's implementation:
class CDQManagedObject
def motion_print(mp, options)
if respond_to? :attributes
"OID: " + mp.colorize(oid.gsub('"',''), options[:force_color]) + "\n" + mp.l_hash(attributes, options)
else
# old colorless method, still more informative than nothing
log
end
end
end
Ruby comes with some great methods for method introspection. These methods look great in motion_print.
mp __method__
will echo the name of the method from which you called motion_print.
mp caller
will trace back up the call stack, so you can see how a method got called.
You can force a color of the output if you want like this:
mp "My String", force_color: :blue # This is usually yellow
UIView
, Struct
, etc. Please open an issue to make suggestions or just implement it yourself and send me a pull request!I used to be a big fan of awesome_print_motion. Then I ran the Instruments allocations profiler on an app that had a big loop with lots of ap
statements. You should have seen the graph increase exponentially over a few seconds. Then I took a look at the actual awesome_print_motion
source code. It's basically a direct port of the awesome_print
gem and just modified to "work" with RubyMotion. There's all kinds of core class extensions and crazy threading things going on... way too complex for my needs to output a pretty version of an object or hash or array.
That, coupled with the fact that the developer of awesome_print_motion doesn't seem responsive to issues or pull requests, I decided to roll my own debugging tool specifically written for RubyMotion development.
awesome_print_motion
is 793 lines of code and extends Array
, Kernel
, Class
, and Object
, and is not tested.
motion_print
is 174 lines of code, adds one method each to String
, and Kernel
, and is fully tested (run rake spec
to see the tests pass).
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Mark Rickert (http://otgapps.io)
motion_print is available under the MIT license. See the LICENSE file for more info.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.