Posts

Showing posts from July, 2010

java - Android Retrofit post information to api database -

how can post in case information android device api route. not response in android monitor. i have created basic retrofitbuilder class. have created apiservice contains this: @formurlencoded @post("device") call<deviceresponse> device(@field("device_name") string device_name, @field("device_producer") string device_producer, @field("device_pixel_width") int device_pixel_width, @field("device_pixel_height") int device_pixel_height, @field("device_ratio_width") int device_ratio_width, @field("device_ratio_height") int device_ratio_height, @field("device_android_version") int device_android_version, @field("device_status") int device_status); a device model contains device constructor setter

c - General Exception Handler in PIC32 in MPLAB -X , How does software know when to throw this? -

Image
void _general_exception_handler (unsigned caused, unsigned status) { rcon = rcon_exception; // point of no return. kernel_reset(); } my code seems getting in trap , have few questions figure out why here calling valid functions in code or better question keeps bothering me how processor know there has been violation. 1) when in watch window in debugger, cause shows me address 0xa0007ec0 , value 0x10800c1c , status shows me address 0xa0007ec4 , value 0x00100003 . how can i, these address , value information figure out cause , status of exception? 2) how processor know there has been exception fault? here handler use in pic32 project: // exception handler: static enum { excep_irq = 0, // interrupt excep_adel = 4, // address error exception (load or ifetch) excep_ades, // address error exception (store) excep_ibe, // bus error (ifetch) excep_dbe, // bus error (load/stor

python - SQLAlchemy select by custom column -

i have sqlalchemy model custom id in uuid format class email(base): __tablename__ = 'email' id = column(uuid(), primary_key=true, default=uuid.uuid4) raw_email = column(text) and when try object id session.query(email).get("0c7a2a97-c93b-4f26-9408-25d2bf597bc0") it returns error can't escape uuid binary i understand problem in custom id because id uuid type, can create preprocessor or similar thing gives me opportunity select objects using str . because convert str uuid every time need select object annoying i create own function converting def str_to_uuid(value): uuid = uuid() return uuid.process_bind_param(value) and helpful if can decorate id use function. or it's bad style ? i understand why have problem this. class uuid(types.typedecorator): impl = types.largebinary def __init__(self): self.impl.length = 16 types.typedecorator.__init__(self, length=self.impl.length) def

html - Unique Situation - Placing text next to other text without using CSS -

i have unique situation going explain best can! i want output users in style so: username:password username2:password2 etc etc... but cannot place text in paragraph <p>username:password</p> i can so... <p>username:</p><p>password</p> and can have seperate tags on username , password design ents looking so: username: password i cannot use css whatsoever. but able use type of html tags like! (span tags of course wouldn't work both separate still) is there possible way rules have given you, have tried everything! (i know sounds strange wanting have strange parser software can this) here snippet of code show how works: $ids = array(); $usernames = array(); $passwords = array(); while ($row = $getaccounts->fetch_assoc()) { $ids[] = $row["id"]; $usernames[] = "<span>".$row["username"].":</span>"; $passwords[] = "<span>".$row["password&

What is type and what is type constructor in scala -

i'm bit confused understanding of type in scala means. in documents read list[int] type , list type constructor. but keyword type means when write following? val ls: _root_.scala.collection.immutable.list.type = scala.collection.immutable.list and how type related type can defined field in trait example. what keyword type means when write following type member defined on object in scala. suppose have class , companion object: class foo(a: string) object foo { def apply(a: string) = new foo } now suppose want write method accepts object foo input. what's type? if write this: def somemethod(fooobj: foo) = fooobj.apply("x") // doesn't compile it's not going compile. foo refers type of instance of class (i.e. 1 returned new foo("x") or foo("x") ). that's why objects have type member can refer own type: def somemethod(fooobj: foo.type) = fooobj.apply("x") // compiles! in

c++ - Segmentation fault with my Move assignment opertaor overloading -

note: bug in program in question has been find, , rearrange content of question. if have similar problem, post recommend check not move assignment operator destructor. first, can see image know data structure of classes below. enter image description here .h class list{ public: // destructor ~list(); // default constructor list(); // move assignment operator list& operator=(list&& src); private: node* lead; ///boundary sentinel: dummy head node* new_dummy_head(); }; .cc // destroctors list::~list(){ node* cur = lead->next; node* nex = cur->next; while(cur->data!=null){ delete cur; cur = nex; nex = nex->next; } delete lead; } // default constructors (just create dummy node) list::list(){ lead = new_dummy_head(); } // move assignment operator overloading list& list::operator=(list&& src){ // release resources *this owns , reset *this // not point of question, hide // pilfer src lead

javascript - Function execution is not in order react native -

i using react-navigation navigating through screens. have following button tag onpress property if pressed, navigate called , should go downloading screen. after that, call, generatereports() function, passing callback function. <button transparent onpress={() => { navigate('downloading') generatereports(() => navigate('home')) }}> export const generatereports = (callback) => { generatereportstable(callback) } export const generatereportstable = (callback) => { let currentyear = new date(new date().getfullyear(), 0, 1); let organizations = realm.objects('organization') let tickets = realm.objects('ticket') let currentyeartickets = tickets.filtered('created_at > $0', new date(currentyear).gettime()) for(organization of organizations) { let currentorganizationtickets = [] console.log(organization.name) for(ticket of currentyeartickets) { if(ticket.organizat

regex - How to extract data from formatted string using python? -

i have set of strings this: c001f01.png c001g01.png c002f10.png which follow format of : c(id number)(f or g)(another id number).png i want know ids' , know if class f or g, have read re.split() similar work, i'm confused , don't understand how re works exactly. you should read more on regex. first hint when want capture pattern need enclose in parentheses. e.g. (\d+). example though, code need is: match = re.match(r'c(\d+)([f|g])(\d+)\.png', s) first_id = match.group(1) fg_class = match.group(2) second_id = match.group(3)

python - How to check the file names are in os.listdir('.')? -

i use regex & string if file name & similars exists in os.listdir('.') or not, if exists print('yes'), if not print('no'), if file name doesn't exists in listdir('.') shows me yes. how should check ? search = str(args[0]) pattern = re.compile('.*%s.*\.pdf' %search, re.i) if filter(pattern.search, os.listdir('.')): print('yes ...') else: print('no ...') filter on python 3 lazy, doesn't return list , returns generator, "truthy", whether or not produce items (it doesn't know if until it's run out). if want check if got hits, efficient way try pull item it. on python 3, you'd use two-arg next lazily (so stop when hit , don't further): if next(filter(pattern.search, os.listdir('.')), false): if need complete list la py2, you'd wrap in list constructor: matches = list(filter(pattern.search, os.listdir('.'))) on python 2, existing c

apache spark - can saveToCassandra() work with multiple tables -

i have rdd contains 4 lines : stock(test1,2017/07/23 00:01:02,14,status) stock(test1,2017/07/23 00:01:03,78,status) stock(test2,2017/07/23 00:01:02,86,status) stock(test2,2017/07/23 00:01:03,69,status) stock(test3,2017/07/23 00:01:02,46,status) stock(test3,2017/07/23 00:01:03,20,status) which test1,test2,test3 tables names, ask if possible save rdd in 3 tables ? thansk

intellij idea - The projectDir is invisible from the task class in Gradle script -

it example of build.gradle set on empty freshly created gradle/groovy project on intellj. use projectdir here in 2 places: in task definition , in task class definition. intellij shows me first use incorrect - cannot resolve symbol. , sees second use correct one. group 'test' version '1.0-snapshot' apply plugin: 'java' apply plugin: 'groovy' sourcecompatibility = 1.8 repositories { mavencentral() } dependencies { compile 'org.codehaus.groovy:groovy-all:2.3.11' testcompile group: 'junit', name: 'junit', version: '4.12' } task projectdirtest(type: projectdirtestclass){ println " -------------- $projectdir task" } class projectdirtestclass extends defaulttask { @taskaction def greet() { println " -------------- $projectdir class" } } configure(projectdirtest) { group = 'projectdirtest' description = 'projectdirtest' } but if run task

r - How to make a Choropleth Density Map using dataset with Spatial Point data -

i have dataset contains points data in form of longitude , latitude across uk. i trying create choropleth density map show density of points within geographic boundaries (e.g. oa, msoa) or grid on top of uk. i have been unsuccessful in finding methods of doing this. would able help?

Zip files in a folder using c# and return response -

i want zip files , folders in folder using c# , i've checked asked questions don't work me...i'm trying work dotnetzip. here's bit of code: using (zipfile zip = new zipfile()) { string[] files = directory.getfiles(@"c:\users\t1132\desktop\logs"); // add files logs folder in zip file zip.addfiles(files, "logs"); zip.comment = "this zip created @ " + system.datetime.now.tostring("g"); var = system.datetime.now.tostring(); zip.save(@"c:\users\t1132\desktop\logs\archiver.zip"); foreach (var f in files) { system.io.file.delete(f); system.diagnostics.debug.writeline(f + "will deleted"); } } the code above works zips files , leaves folders. kindly assist me please, thanks. there many ways zip files using dotnetzip. using (zipfile zip = new zi

java - Configuration class that extends Application in REST -

the class extends application in rest import javax.ws.rs.applicationpath; import javax.ws.rs.core.application; import java.util.arrays; import java.util.hashset; import java.util.set; @applicationpath("/rest-prefix") public class applicationconfig extends application { public set<class<?>> getclasses() { return new hashset<class<?>>(arrays.aslist(simplerestpojo.class, simplerestejb.class)); } } what's function? why should extend application class class nothing? if don't, ide throws warning on rest classes, warning doesnt implement jersey or ee services. whay should extend application class, , tutorials without other explanation. thank you.

jsp - Error in sending mail in java/servlet -

Image
i trying send email using java . face error below javax.mail.authenticationfailedexception: failed connect, no password specified why getting error when have passed correct email-id , password authentication? this code import java.io.ioexception; import java.net.passwordauthentication; import java.util.properties; import javax.mail.authenticator; import javax.mail.message; import javax.mail.messagingexception; import javax.mail.session; import javax.mail.transport; import javax.mail.internet.internetaddress; import javax.mail.internet.mimemessage; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; /** * servlet implementation class testmail */ @webservlet("/testmail") public class testmail extends httpservlet { private static final long serialversionuid = 1l; public testmail() {

c# - StackOverflowException in multi-threaded UI update application -

Image
i have application bunch of jobs off working (await task.whenall...) , updating progress section of form. i've noticed when running particularly fast (e.g. when there not processing do, checks), i'm getting following exception thrown: the invokerequired helper method 1 found on site while ago , looks this: internal static void invokeifrequired<t>(this t control, action<t> action) t : isynchronizeinvoke { if (control.invokerequired) { control.invoke(new action(() => action(control)), null); } else { action(control); } } could tell me why assigning label text value causing stackoverflowexception please? edit: here detail of exception there 2 situations: you requests workflow update info , breaks application - in case need known 'debouncing' - when request don't execute update set timer let's 200 ms , cancel previous timer , tim

javascript - Why I am unable to catch URI error in decodeURIComponent() method -

i writing timestamp api freecodecamp project using node , express. works if request sent. request http://localhost:3000/x%y method decodeuricomponent throwing error. problem unable handle error.here code.. app.get('/:ts',function(req,res){ var reply; var timestamp = req.params.ts; if(timestamp){ if(number(timestamp)){ timestamp = timestamp * 1000; var d = new date(number(timestamp)); reply = { "unixtime": timestamp, "noramtime": d.getdate() + " " + months[d.getmonth()] + ", " +d.getfullyear() } } else{ try{ timestamp = decodeuricomponent(timestamp); console.log(1); if(timestamp){ var d = new date(timestamp).gettime(); if(!isnan(d)){ reply = { "unixtime": d/1000, "noramtime": timestamp

javascript - EcmaError: TypeError: cannot find function bind -

i using lesscss-engine-161.jar in webapp (compiling less files css) , everytime try deploying on tomcat server have javascript ecmaerror: 11:47:36,305 error [lessengine] - less engine intialization failed. org.mozilla.javascript.ecmaerror: typeerror: cannot find function bind. (file:/d:/workspace/apache-tomcat-7.0.77/webapps/webapp-1.0.0/web-inf/lib/lesscss-engine-161.jar!/meta-inf/1.6.1/less.js#2664) @ org.mozilla.javascript.scriptruntime.constructerror(scriptruntime.java:3350) @ org.mozilla.javascript.scriptruntime.constructerror(scriptruntime.java:3340) @ org.mozilla.javascript.scriptruntime.typeerror(scriptruntime.java:3356) @ org.mozilla.javascript.scriptruntime.typeerror1(scriptruntime.java:3368) @ org.mozilla.javascript.scriptruntime.notfunctionerror(scriptruntime.java:3428) @ org.mozilla.javascript.scriptruntime.getpropfunctionandthis(scriptruntime.java:2052) @ org.mozilla.javascript.interpreter.interpretloop(interpreter.java:3081) @ sc

java - Crud Repository, date comparison -

i have following sql query: select * wash_history w w.wash_id in (select wash.id wash wash.car_wash_id = 17) , w.time between '2017-07-13' , '2017-07-22' and want create query inside interface extends crudrepository . method is page<washhistory> findwashhistorybytimebetweenorderbytimedesc(date datefrom, date dateto, pageable pageable); but method returns empty list, think due java date , sql timestamp? if want more details can add them question. class: public class washhistory implements serializable { private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.identity) @basic(optional = false) @column(name = "id") private integer id; // @max(value=?) @min(value=?)//if know range of decimal fields consider using these annotations enforce field valida

php - WordPress SSL redirects through Cloudflare -

i have added website cloudflare use of flexible ssl. on static content ok. example, can access files directly https (ex: https://www.samanik.com/logo.png ). can't access wordpress site. have changed both site_url , home_url in db. have added codes .htaccess, when type website without https redirects https (as want). but, nothing shown there. error called err_too_many_redirects don't know how fix problem. here .htaccess content. # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> # end wordpress <ifmodule mod_rewrite.c> rewritecond %{https} off rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301] rewritecond %{http_host} !^www\. rewriterule ^(.*)$ https://www.%{http_host}%{request_uri} [l,r=301] </ifmodule> can me? you can redirect https using action hook

c++ - Add network to Qt Project -

i try use qtnetwork library , added dependencies in .pro file. when compile code qt creator fails in building project , claims c1083: include "qtcpsocket": no such file or directory - telnet.h:4 i thought adding network .pro file enough? networkmonitor.pro #------------------------------------------------- # # project created qtcreator 2017-07-24t13:18:19 # #------------------------------------------------- qt += core gui network charts # greaterthan(qt_major_version, 4): qt += widgets target = networkmonitor template = app # following define makes compiler emit warnings if use # feature of qt been marked deprecated (the exact warnings # depend on compiler). please consult documentation of # deprecated api in order know how port code away it. defines += qt_deprecated_warnings # can make code fail compile if use deprecated apis. # in order so, uncomment following line. # can select disable deprecated apis version of qt. #defines += qt_disable_deprecated_be

show - Showing of JavaFX Scene randomly delayed -

i have created javafx application (running on ubuntu, java(tm) se runtime environment (build 1.8.0_131-b11)) , have made simple test application: public class delayedsceneapplication extends application { @override public void start(stage primarystage) throws exception { primarystage.settitle("test"); primarystage.setresizable(false); // root. borderpane root = new borderpane(); scene scene = new scene(root); primarystage.setscene(scene); // buttons box. hbox buttonbox = new hbox(); buttonbox.setpadding(new insets(10)); buttonbox.getchildren().addall(new button("test")); root.setbottom(buttonbox); primarystage.show(); } } the problem sometimes, after stage has been shown, scene not loaded. takes 1 second show button, more 20 seconds. when scene has not been shown yet , clicking on scene, button shows immediately. again, button shows correctly @

mule - Exception not being caught in mulesoft -

i working on app , in case exception occurs prints exception message appropriately.here custom filter package filter; import java.io.ioexception; import java.util.map; import javax.servlet.servletexception; import javax.servlet.servletrequest; import javax.servlet.servletresponse; import org.mule.api.mulemessage; public class exceptionclass implements org.mule.api.routing.filter.filter { @override public boolean accept(mulemessage message) { map<string,object> payload=(map<string,object>)message.getpayload(); if(!payload.containskey("productid")) { throw new java.lang.nullpointerexception("no data found in payload "+payload.tostring()); } if(integer.parseint((string) payload.get("productid"))<5) { throw new illegalargumentexception("invalid input payload " +payload.tostring()); } return true; } } here configuration of a

sass - How to use webpack with extract-text-webpack-plugin to compile scss files to css -

i have created angular2 project angular material2 components. want customise theme have used webpack module create 1 single file scss files have used extract-text-webpack-plugin create individual files. here webpack.config.js var path = require('path') var webpack = require('webpack') var extracttextplugin = require("extract-text-webpack-plugin"); // multiple extract instances let extractcss = new extracttextplugin('[name].css'); module.exports = { entry: [ '/src/assets/theme/' ], output: { path: path.join(__dirname, 'dist'), filename: 'index.js', publicpath: '/dist/' }, module: { loaders: [ { test: /\.scss$/i, loader: extractcss.extract(['css', 'sass']) } ] }, plugins: [ extractcss ] } and here script in package.json "build:css": "webpack --config webpack.config.js" a

multer s3 - var upload = this.s3.upload(params) TypeError: this.s3.upload is not a function -

i trying upload file s3 using multer s3.however, fails. aws.config.update({ secretaccesskey: 'key', accesskeyid: 'secret', }); var s3 = new aws.s3() var upload = multer({ storage: multers3({ s3: s3, bucket: 'pdsfiles', metadata: function (req, file, cb) { cb(null, {fieldname: file.fieldname}); }, key: function (req, file, cb) { cb(null, date.now().tostring()) } }) }) this error looks like: typeerror: this.s3.upload not function @ s3storage. (/home/simran/downloads/node-backend/node_modules/multer-s3/index.js:172:26) @ /home/simran/downloads/node-backend/node_modules/multer-s3/index.js:58:10 @ s3storage.getcontenttype (/home/simran/downloads/node-backend/node_modules/multer-s3/index.js:8:5) @ /home/simran/downloads/node-backend/node_modules/multer-s3/index.js:55:13 @ end (/home/simran/downloads/node-backend/node_modules/run-parallel/index.js:16:15) @ _combinedtickcallback (internal/process/n

c# - Is this a proper way of putting quotes in SQL query in ADO.NET -

string query = @"insert uczniowie (id, name, surname, age)" + "values('" + textbox1.text + "'" + ", '" + textbox2.text + "'" + ",'" + textbox3.text + "'" + ",'" + textbox3.text + "'"; no , it's not since it's open sql injection attack. rather use parameterized query like string query = "insert uczniowie (id, name, surname, age) values(@id, @name, @surname, @age)"; see msdn documentation on how to: execute parameterized query more information on same

Excels Macro enabled to API -

i have scenario. using set of excel files reporting. of these excels macro enabled connect server. i'm not programmierer. sorry silly question. know question - possible connect api confluence? my steps links: https://www.extendoffice.com/documents/excel/2406-excel-template-macro-enabled.html https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples

PHP How to export image from large object Postgresql -

i have postgresql database stores images in large objects application (i can't change type, avoid use bytea type store images). trying export images database image files in web server through pg_lo_export() php function doesn't work. is there solution problem? i have searched answer on google before posting found no solution. thanks in advance. regards. [edit] there php code: pg_query($con, "begin"); $oid = pg_lo_import($con, $_files['userfile']['tmp_name'][$i]); pg_query($con, "commit"); if(!is_dir("images/colaboration")) mkdir("images/colaboration"); pg_query($con, "begin"); pg_lo_export($con, $oid, "images/colaboration/eiffel.jpg"); pg_query($con, "commit"); echo "<image src='images/colaboration/eiffel.jpg' />";" with code image never creates getting 404 html error.

java - Cannot be resolved error in JavaEE project -

Image
i doing semestral project. opened javaee file , had issue, fine on friday last time opened can see dbao shows has none. says cannot resolved. file meant connect mysql database. restart eclipse project -> clean -> clean projects followed project -> build all right click on error project -> properties -> java build path -> check build path missing, looked jre missing, try selecting right or existing jre

visual studio c# split string into variables -

im hopeing somone can me, ive created interface using visual studio ide,which connected arduino. had issue reading data, has been solved. data sent arduino looks 1,2,3, issue having every time try split string, seprate variables doesnt seem work. post code both parts below. if me figure out great visual studio : using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.io.ports; namespace windowsformsapp3 { public partial class form1 : form { public serialport myport; int irisvalue; string mystring; string s; //string[] words; string readstring; string firstvalue; string secondvalue; string thirdvalue; public form1() { initializecomponent(); //load += new eventhandler(form1_load);

mysql - Looping through folder of images and also select query of names using PHP to display in HTML list item -

this question has answer here: reference - error mean in php? 29 answers i have folder of images , database containing list of names. attempting loop through folder , names simultaneously , display both outputs in list item. <ul> <?php $names_query = "select name people"; $names_results = mysqli_query($con, $names_query); $dir = "images/people/"; $opendir = opendir($dir); while (mysqli_fetch_array($names_results) && ($file = readdir($opendir)) !== false) { ?> <li> <?php if ($file != "." && $file != "..") { echo $names["name"]; echo "<img class=" . "people" . " src='$dir/$file'/>"; } ?> </li> <?php } ?&

java - Javascript won't interact with html code -

the code written in jsp should validate password , confirm password correctness , continue submit event java servlet. problem won't show alert messages nor focusing on password input if fails validation script. i've used chrome, explorer , eclipse default browser.. won't work function validate(event){ event.preventdefault(); var pattern = /^(?=.*[a-z].*[a-z])(?=.*[a-z])(?=.*\d)[a-za-z\d]{8,32}$/; var pwd = document.form.password.value; var confpwd = document.fomr.confpass.value; if(pwd.match(pattern)){ alert("password must between 8 32 characters,\n have @ least 1 digit \n 2 lower , 1 upper case letters."); document.form.password.focus(); return false; }else if(pwd == confpwd){ alert("passwords not match. please try again."); document.form.password.focus(); document.form.confpass.focus(); return false; }else{ document.form.submit(); } } <form name="form" method=&quo

javascript - why is it giving error "appendChild is null" error and how do i fix it -

when trying append td element tr , throwing error: cannot read property appendchild of null this code: var col = prompt('enter number of columns, table needs have'); var row = prompt('enter number of rows, table should have'); function columncreator() { var table = document.queryselector('tablediv'); var tablerow = document.createelement('tr'); table.appendchild(tablerow); (var = 0; < col; i++) { var tabledata = document.createelement('td'); tablerow.appendchild(tabledata); var dummytext = document.createtextnode('table data'); tabledata.appendchild(dummytext); } } columncreator(); var table = document.queryselector('tablediv'); console.log(table)//undefined theres nothing tablediv , either id,class, or nested structure: var table = document.queryselector('#tablediv') //id || document.queryselector('.tablediv') //class || docum

c# - Xamarin Studio / VS for Mac Storyboard not opening -

i bought new macbook pro developing ios universal app. before have sold old one, pushed code bitbucket repository. now have installed vs mac , xamarin studio , pulled source code bitbucket. working fine (building, debugging, etc.) designing in storyboard designer wont work. i getting following exception: [2017-07-25 15:55:16.3] error: ensuresession (counter 1): monotouch.design.client.designerremoteexception: system.notsupportedexception: not parse xml @ monotouch.design.parser.parse (monotouch.design.parsecontext context) in /users/builder/data/lanes/4470/6c2f6737/source/md-addins/xamarin.designer.ios/monotouch.design.shared/parser.cs:220 @ monotouch.design.uikitparser.parse (monotouch.design.parsecontext context) in /users/builder/data/lanes/4470/6c2f6737/source/md-addins/xamarin.designer.ios/monotouch.design.server/typesystem/loader.cs:205 @ monotouch.design.server.sessioncontroller.loadxmlcore (monotouch.design.parsecontext ctx) in /users/builder/data/lane