build app which scans barcodes and sends info to google sheet - barcode

Total newbie here but I have a question. We are trying to simplify a second hand book sale and want to build an app which allows parents to scan the barcode of books they want to sell then send this barcode, along with their name and email address (plus maybe a few other questions) to a Google Sheet.
A) is it possible to do this.
B) Any pointers to get started?

EDIT: This is for python code
a) Yes, this is very possible
b)
You are going to need a bar-code scanner that can be connected to a computer and will then, somehow, have to enable this to input into python variables.
In terms of adding to google sheets, it is very possible to do this via Googles current API - if this sounds like jumble, there are plenty of guides at there for doing this in various 'easy' ways.
Here is some basic code to help you get started: (Haven't had the time to test it, and apologies if it is not relevant as I do not know how good you are at python.)
import time
class barcode:
def init(self):
self.code = int()
def getBarcode(self):
print("Insert code to get barcode here. Assign barcode to variable: self.barcode")
if self.barcode != None or self.barcode != "":
return self.barcode()
else:
return False
def getDetails(self):
name = input("Enter your full name: ")
email = input("Enter your email address: ")
return [name, email]
def sendInfo(self, barcode, details):
name = details[0]
email = details[1]
barcode = self.barcode
print("ENTER CODE HERE TO SUBMIT TO GOOGLE SHEETS")
def main(self):
while True:
time.sleep(1)
barcode = self.getBarcode()
if barcode != False:
details = self.getDetails()
self.sendInfo(barcode, details)
If you need more help, or are worse at python than I expect, feel free to comment below.
Extra:
- Haven't had the chance to check it out or check its full relevance however this may help you: https://gist.github.com/JoachimL/1629f701fdb38427091710fc0caef67d

Related

I am trying to retrieve data from a Ruby cdn of the Pokemon API but I am struggling

Below is my Pokemon TCG API key
I have read the documentation but I cannot find a way to retrieve the data I need which is the images of each card in a set. If anyone can help with or give me any pointers on how to retrieve this I would greatly appreciate it.
https://github.com/PokemonTCG/pokemon-tcg-sdk-ruby/blob/master/README.md
This above is the link to the documentation on Github.
Pokemon.configure do |config|
config.api_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
end
sets = Pokemon::Set.where(q: 'legalities.standard:legal').first
p sets
I am expecting to retrieve specific data from the Pokemon TCG API which from above should be within these Ruby classes.
p sets.images.symbol will print out the link to:
"https://images.pokemontcg.io/swshp/symbol.png"
p sets.images.logo will print out the link to:
"https://images.pokemontcg.io/swshp/logo.png"
When you are unsure what is contained within the class you're getting, in this case a Pokemon::Set class, you may see all the methods of this resulting variable with sets.methods.sort.each{|m| p m}, there you'll find the images method and can dig deeper to symbol and logo.
In your example you are searching for sets. In case of cards:
cards = Pokemon::Card.where(page: 5, pageSize: 100)
cards.each{|card| p card.images.large}
This will print out all the links to large cards.
Update
Clarification based on comments
How to print out methods and how to know which class you are referring to.
Let's start with you code snippet:
sets = Pokemon::Set.where(q: 'legalities.standard:legal').first
puts sets.class
Output:
Pokemon::Set
It would be more clear if you name your variable as set because you're selecting the .first element of an array.
Back to my cards example:
cards = Pokemon::Card.where(page: 5, pageSize: 100)
puts cards.class
Output:
Array
As I did not select any item from the array cards naming makes perfect sense, and this array will contain a card:
card = cards.first
puts card.class
Output
Pokemon::Card
Printing methods
So, given we are now well aware of class each variable contains and what we are referring to, we are ready to print out the methods for both:
sets.methods.sort.each{|method| p method}
cards[0].methods.sort.each{|method| p method}
Output:
…
:hash
:hp
:hp=
:id
:id=
:images <== Here!
:images=
:inspect
:instance_eval
:instance_exec
:instance_of?
…
Once again, mind the [0] selection of the first item. When we want to know methods, we want to know it either for Pokemon::Set or Pokemon::Card.

RASA FormAction ActionExecutionRejection doesn’t re-prompt for missing slot

I am trying to implement a FormAction here, and I’ve overridden validate method.
Here is the code for the same:
def validate(self, dispatcher, tracker, domain):
logger.info("Validate of single entity called")
document_number = tracker.get_slot("document_number")
# Run regex on latest_message
extracted = re.findall(regexp, tracker.latest_message['text'])
document_array = []
for e in extracted:
document_array.append(e[0])
# generate set for needed things and
document_set = set(document_array)
document_array = list(document_set)
logger.info(document_set)
if len(document_set) > 0:
if document_number and len(document_number):
document_array = list(set(document_array + document_number))
return [SlotSet("document_number", document_array)]
else:
if document_number and len(document_number):
document_array = list(set(document_array + document_number))
return [SlotSet("document_number", document_array)]
else:
# Here it doesn't have previously set slot
# So Raise an error
raise ActionExecutionRejection(self.name(),
"Please provide document number")
So, ideally as per the docs, when ActionExecutionRejection occurs, it should utter a template with name utter_ask_{slotname} but it doesn’t trigger that action.
Here is my domain.yml templates
templates:
utter_greet:
- text: "Hi, hope you are having a good day! How can I help?"
utter_ask_document_number:
- text: "Please provide document number"
utter_help:
- text: "To find the document, please say the ID of a single document or multiple documents"
utter_goodbye:
- text: "Talk to you later!"
utter_thanks:
- text: "My pleasure."
The ActionExecutionRejection doesn't by default utter a template with the name utter_ask_{slotname}, but rather leaves the form logic to allow other policies (e.g. FallbackPolicy) to take action. The utter_ask_{slotname} is the default for the happy path in which it's trying to get a required slot for the first time. This default implementation of the action rejection is there in order to handle certain unhappy paths such as if a user decides they want to exit the flow by denying, or take a detour by chatting, etc.
If you want to implement the template to re-ask for the required slot using the utterance, you could replace the ActionExecutionRejection with dispatcher.utter_template(<desired template name>, tracker). However, this will leave you with no way to exit the form action without validation -- I don't know what your intents are, but perhaps you want to also incorporate some logic based on the intent (i.e. if it's something like "deny", let the ActionExecutionRejection happen so it can exit, it it's an "enter data" type of intent make sure it asks again).

Qt GUI Table / Spreadsheet type layout in Ruby

I am trying to design a GUI that will output data in a spreadsheet type of format, rows and columns.
The cells will be populated with data that will be fetched by another object at predefined intervals. Being able to change individual cell color would be ideal to highlight any cells that have changed.
After some research it seems like QtBindings gem for ruby is the most powerful GUI choice for this but I can't seem to find any documentation or examples that would help me with what I am trying to accomplish. Any advice in the form of code or examples would be more than helpful. Thank you.
Update:: after some research and brute force, I came up with this code:
class PositionModel < Qt::AbstractTableModel
slots 'timerhit()'
def initialize(risk)
super()
#timer = Qt::Timer.new(self)
connect(#timer, SIGNAL('timeout()'), self, SLOT('timerhit()'))
#timer.start(1000)
#risk = risk
#risk_a = #risk.to_a
#pp #risk_a
end
def timerhit()
emit dataChanged(createIndex(0,0), createIndex(0,0))
#emit dataChanged()
end
def rowCount(parent)
#risk_a.size
end
def columnCount(parent)
1
end
def data(index, role)
col = index.column
row = index.row
if role == Qt::DisplayRole
return Qt::Variant.new( #risk_a[row] )
else
return Qt::Variant.new()
end
end
end
app = Qt::Application.new(ARGV)
model = PositionModel.new(##risk)
table = Qt::TableView.new
table.model = model
table.setSortingEnabled(true)
table.show
It seems to be working well, and more importantly is a solid foundation for what I ultimately want to accomplish. However, I I tried to enable sorting by clicking on a column header, but it doesnt seem to be working. Does anyone know why?
Two words: Use QTableView or QTableWidget.
Populating Table Widget from Text File in Qt
How change row color with Null items?
Converting the c++ code to ruby qt should be trivial. Also the C++ Qt docs are awesome! Good luck.
Hope that helps.

Creating barcode images

I need to send emails out to several thousand customers with a unique barcode present so they can redeem it either instore or online.
We have a list of coupon/barcode codes to use and have a way to dynamically pull these codes into the email so a customer will see a unique code. The problem is I need to somehow generate several thousand barcode images that are created using the unique codes. How can I solve this?
This would be perfect if our email marketing company had this functionality but unfortunately they don't:
http://www.emaildirect.com/blog/2011/11/create-unique-barcodes-with-emaildirect/
Any help would be greatly appreciated.
I have found my answer!
By using the barcode generator www.barcodesinc.com I generated a URL and input this into my email.
Eg: http://www.barcodesinc.com/generator/image.php?code=999999999&style=197&type=C128B&width=200&height=50&xres=1&font=3
I then changed the 999999999 in the URL to my conditional code to change to the specific code for that person and also bring back the barcode image for that code too!
I have found my answer!
By using the barcode generator www.barcodesinc.com I generated a URL and input this into my email.
Eg: http://www.barcodesinc.com/generator/image.php?code=999999999&style=197&type=C128B&width=200&height=50&xres=1&font=3
I then changed the 999999999 in the URL to my conditional code to change to the specific code for that person and also bring back the barcode image for that code too!
<img src="http://qrfree.kaywa.com/?s=8&d=your+text+here" alt="QRCode"/>
OR
http://qrfree.kaywa.com/?s=8&d=your+text+here
I'm no expert on this and haven't touched html but you could serialize each image and follow this example that has some sample code on QR code given a string.
Imports ThoughtWorks.QRCode.Codec
Dim objQRCode As QRCodeEncoder = New QRCodeEncoder()
Dim imgImage As Image
Dim objBitmap As Bitmap
objQRCode.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE
objQRCode.QRCodeScale = 2
objQRCode.QRCodeVersion = 5
objQRCode.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.L
imgImage = objQRCode.Encode("Test Data")
objBitmap = New Bitmap(imgImage)
objBitmap.Save("C:\QRCode.jpg")
Hi Try getting in touch with http://www.linktagger.com and ask if they can help. They provide Enterprise type services for the city where I live on maps and bus terminals so it might help you.
Here is an working example to generate barcode for the array of barcodes.We can
retrieve thousands of barcodes from csv file using pandas as well.
This example calls API and save the response in image(.png format) obtained as response from API call.
import shutil
import requests
data = [11111111111, 22222222222222222, 33333333333333, 4444444444444]
url = 'https://www.barcodesinc.com/generator_files/' + 'image.php?'
for d in data:
params = {
'code': d,
'style': '197',
'type': 'C128B',
'width': '200',
'height': '50',
'xres': '1',
'font': '3',
}
response = requests.get(url, params, stream=True)
with open('image-%s.png' % d, 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response

Simple question in ClientLogin using python gdata library

I have incorporated ClientLogin into my python application to retrieve contact list of the user , I like to know how to get the name of the user who has logged in.My code to get the names from the contact list of the user is as given below
gd_client = gdata.contacts.service.ContactsService()
gd_client.email = yemail
gd_client.password = ypass
gd_client.source = 'GoogleInc-ContactsPythonSample-1'
gd_client.ProgrammaticLogin()
query = gdata.contacts.service.ContactsQuery()
query.max_results=150
feed = gd_client.GetContactsFeed(query.ToUri())
for i, entry in enumerate(feed.entry):
#print '\n%s %s' % (ctr+i+1, entry.title.text)
na=entry.title.text
names.append(na)
Please help me to know how to get the name of the user who has logged in
Thanks
ganesh
Edit: Turns out this is only for iterating through the AppsService which will not help you. I am using GAE so for me the google.appengine.api users class takes care of all the heavy lifting for me. I will keep looking into this.
You might try the following code:
gd_client = gdata.contacts.service.ContactsService()
gd_client.email = yemail
gd_client.password = ypass
gd_client.source = 'GoogleInc-ContactsPythonSample-1'
gd_client.ProgrammaticLogin()
nick_feed = gd_client.RetrieveAllNicknames()
for nick_entry in nick_feed.entry:
print nick_entry.nickname.name
print nick_entry.login.user_name
This should work across all the gdata services. I am going to test it though and I will let you know how it goes. This information was found at this location.

Resources