Posts

python - How to Detect event generated by USB device into raspberry pi -

hello geniuses want detect event generated usb device attached barcode scanner.now want barcode scanner plugged in usb port of raspberry pi.now when scan how can rpi detect usb device has generated event. hopefully pyusb works, , in case can follow this guide if whatever reason doesn't work, open /dev/tty device direclty standard: with open('/dev/tty4', 'rb') fh: event in fh.read(8) note /dev/tty out-of-the-hat example, device might end somewhere else. check dmsg , lsusb determine device got mounted, if @ mounted or discovered. might need specific drivers scanner.

php - check if the row exists or not in the database -

hi i'm inserting rows in database , , want check if value exists don't insert , if not insert , that's controller : <?php namespace app\http\controllers; use illuminate\http\request; use app\http\requests; use app\http\controllers\controller; use input; use auth; use app\user; use app\product; use db; class listcontroller extends controller { // public function getindex(request $request){ $user_id=auth::user()->id; $list=db::table('wishlist') ->join('products','wishlist.product_id','=','products.id') ->join('users','wishlist.user_id','=','users.id') ->select('wishlist.id','wishlist.product_id','wishlist.user_id', 'products.id p_id','products.name','products.salary','products.image_name', 'users.id u_id') ...

python - How to extract the specific contents from the html doc I grasp -

i'm new on beautifulsoup , urllib. want read data pm25.in ,which website offering atmospheric quality data of china. my attempt ### set specific city name, token public key free use city = 'zhuhai' html_doc = urllib.urlopen("http://www.pm25.in/api/querys/co.json? city=zhuhai&token=5j1znbvasnsf5xqynqyq").read().decode('utf-8') soup = beautifulsoup(html_doc) result <html> <body> <p> [{"aqi":29,"area":"珠海","co":0.591,"co_24h":0.955,"position_name":"吉大","primary_pollutant":null,"quality":"优","station_code":"1367a","time_point":"2016-01-07t20:00:00z"},{"aqi":51,"area":"珠海","co":0.913,"co_24h":1.059,"position_name":"前山","primary_pollutant":"颗粒物(pm10)","quality...

GZIP compression always 1.00x on iOS Safari? -

Image
i'm looking @ web traffic between ios 9.2 safari , our web server , see of our responses gzip-ed, factor 1.00x. we're not saving bandwidth, whole point. does know going on here? overlooking something? or misconfigured? on desktop browser content compressed @ least factor 5. thanks! pascal. actually, misinterpretation of safari webinspector. may find answer here: http://forums.tumult.com/t/turning-on-compression-enabling-gzip-on-your-server-to-speed-up-loading-times/4762/3 safari encoded, decoded, transfered, compression rate not reliable (or @ least, not have same meaning has in chrome/firefox/edge). this "safari feature" has been pinpointed in 2014 here: https://stackoverflow.com/a/21943693/7173518 without "content length", safari lost in indicators. , there no "content length" on nginx dynamic gzip activated. c.

javamail - Unable to send richtext content type mail to outlook using java mail -

i sending mail outlook using java mail api. able send plain text , html content mail when set content type text/richtext receive mail in plain text only. can body suggest how send richtext mail? here tried: // parent or main part if multipart mainmultipart = new mimemultipart("related"); // hold text , html , tells client there 2 versions of message (html , text). presumably text // being alternative html multipart htmlandtextmultipart = new mimemultipart("alternative"); // set html mimebodypart htmlbodypart = new mimebodypart(); htmlbodypart.setcontent("hi", "text/richtext"); htmlandtextmultipart.addbodypart(htmlbodypart); mimebodypart htmlandtextbodypart = new mimebodypart(); htmlandtextbodypart.setcontent(htmlandtextmultipart); mainmultipart.addbodypart(htmlandtextbodypart); message.setcontent(mainmultipart); first - try adding richtext content, not plaintext: {\rtf1\ansi\deff0 {\fonttbl {\f0 courier;}} {\colortbl;\red0\...

bash - lua os.execute doesn't work if the script runs from /etc/rc.local -

i have simple lua script listens particular event , fire post request twilio.com web service start call , send mail. #!/usr/bin/lua -- february 2015, suxsem local sock = require("socket") local mosq = require("mosquitto") local mqtt = mosq.new("sonny_lua_scattato", true) mqtt:login_set("***", "***") local call = function (from, to) os.execute([[curl -x post 'https://api.twilio.com/2010-04-01/accounts/***/calls.json' \ --data-urlencode 'to=]] .. .. [[' \ --data-urlencode 'from=]] .. .. [[' \ -d 'url=https://demo.twilio.com/welcome/voice/' \ -d 'method=get' \ -d 'fallbackmethod=get' \ -d 'statuscallbackmethod=get' \ -d 'timeout=20' \ -d 'record=false' \ -u ***:***> twiliolog.txt]]) end local call...

Run ruby script from rake task -

i have small ruby script runs fine when run manually command line. uses 3 gems have installed using "gem install x" , @ top of script file have lines "require x". works fine. now creating task in rake call ruby script. have tried both use system("/tools/myscript.rb #{foo} #{bar}") and `/tools/myscript.rb #{foo} #{bar}` but both give me error: myscript.rb:2:in `require': no such file load -- ruby-audio (loaderror) it seems gem not loaded. tried add gems gemfile of rails app after necessary gems had been added , ran bundle update ended in error mysql adapter not working script. but since script works fine command line, thought there should easy way call within rake task. any ideas? use bundle exec <script> to sure load bundled gems script want run