
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
h1. Intro
A ruby implementation of the Line Thermal Printer ESC/POS Command Specifications.
h1. Install
gem install rescpos
h1. Usage
See "examples":https://github.com/towerhe/rescpos/tree/develop/examples
Specify the template path:
bc. Rescpos.configure do |config| config.template_path = "path/to/your/escpos/templates" end
For rails application, the default template path is set to app/escposes. So you should create the templates under app/escposes directory. But if you want to save the templates into another place, you should config the template path in a rails initializer.
h2. Reports
Reports manage the objects that will be used in the templates. You should subclass the Rescpos::Report class to define your own reports. For example:
class SimpleTitledReport < Rescpos::Report attr_reader :title def initialize(title = '') @title = title end end
To render the report, you just need to call the render method of the report.
bc. report = SimpleTitledReport.new('A report with a title') report.render(:template => "<%= title %>")
You can also create a pre-defined template for the report.
bc. report.render(:file => 'path/to/the/template')
Rescpos will search for the template with the underscore name of the report under the template path if you do not provide any params when rendering the report.
bc. report.render
This will cause rescpos to search for a template named simple_titled.escpos.erb under app/escposes.
h2. Templates
Rescpos use erb to define the templates. So any valid erb templates are valid rescpos templates.
Template's extension name is set to 'escpos.erb'.
bc. # dish_item.escpos.erb <%= text(@dish[:dish_category], :font_size => FONT_BIG) %> <%= text(key_value("餐桌", @bill[:table]), :font_size => FONT_BIG) %> <%= text(key_value("人数", @bill[:num_of_people]), :font_size => FONT_BIG) %> <%= single_splitline %> <%= text(key_value("菜品", @dish[:name]), :font_size => FONT_BIG) %> <%= text(key_value("数量", "#{@dish[:quantity]} [根]"), :font_size => FONT_BIG) %> <%= single_splitline %> <%= text(key_value("单号", @bill[:id])) %> <%= text(key_value("操作员", @bill[:waiter])) %> <%= text(key_value("下单时间", @bill[:created_at])) %>
h2. Printers
In order to print the report, you should create a Rescpos::Printer object and then print the report.
bc. printer = Rescpos::Printer.open('192.168.1.250', 9100) printer.print(report) printer.close
You can set the options for printing:
bc. printer.print(report, encoding: 'GBK', cut_mode: :partial_cut)
FAQs
Unknown package
We found that rescpos demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.