Posts

Showing posts from May, 2014

Adding to a List by Value instead of reference in Java -

i have list of maps , in for-loop want add map list. heard using map.clear() has better performance creating new map problem list.add() works reference of object , using map.clear() reference not ceared. is there possibility force list.add() use value or build other workaround? it possible insert "by value" creating copy of map , inserting copy. problem it's not optimization @ all. instead of creating new empty map , create copy of filled map , clear original map . means: don't avoid overhead of creating new object, introduce work of copying , clearing filled map . and little note on optimization in general: it's ~10% of code that'll doing 90% of work (yes, these numbers made up, it's usual way think optimization , @ least close reality). don't over-optimize code in first run. can done , without making code less readable, run profiler , bottlenecks of code , optimize those. far more efficient , easier optimizing entire code.

How to implement ticket reservation using Firebase? #AskFirebase -

i want build ticket reservation app. app needs able to: temporarily reserve ticket while customer making purchase; prevent more 1 purchase of same ticket; release ticket after amount of time if not purchased. how implement using firebase? how right?

python - Substituting an indexed variable with an expression -

i have sum on a[i] , want change sum on b[i] / 2 . i can change sum on b[i] this: from sympy import * sympy.abc import * = indexedbase('a') b = indexedbase('b') sa = sum(a[i], (i, a, b)) sb = sa.subs(a, b) but want effect of sb2 = sa.subs(a,b/2) any ideas? the solution use replace instead of subs . haven't grok'ed difference, more info can found in difference between replace , subs? sb.replace(a[i], b[i]/2) which returns sum(b[i]/2, (i, a, b))

php - iOS server side coding for supporting IPV6 -

i got rejected message apple because of ipv6 supporting issue. it seems server has problem supporting ipv6. can me it, please? the following code works fine android. <?php include('../config.php'); include('../opendb.php'); require_once '../functions/security.php'; $mysqli->query("set names utf8"); $username = $_post['username']; $pw_old = encrypt($_post['oldpw']); $pw_new = encrypt($_post['newpw']); $response = array(); if ($username == '' || $pw_old == '' || $pw_new == '') { $response['fields'] = 0; } else { $response['fields'] = 1; $qry = "select password member username='$username'"; $result = $mysqli->query($qry); $row = $result->fetch_assoc(); if (strcmp(substr($pw_old, 0, -8), $row['password']) == 0) { $response['exist'] = 1; $qry = "u

python - Tkinter does not show up -

i downloaded canopy , use tkinter , this, disabled pylab , ran program still nothing showed up. additionally, tried tkinter on jupyter , same problem. how can make work? here code : import tkinter tk screen=tk.tk() screen.title("matplot graphies") screen.geometry("500x500") i tried simple code see gui still nothing happens. you need call mainloop() method @ end. import tkinter tk screen=tk.tk() screen.title("matplot graphies") screen.geometry("500x500") screen.mainloop()

httprequest - Vue Resource Cross-site HTTP request -

Image
normally, when make jquery request non-local server, applies cross-site http request rules , sends options request verify existence of endpoint , sends request, i.e. get domain.tld/api/get/user/data/user_id jquery works fine, use vue resource deal requests. in network log, see actual request being made (no options request initially), , no data being received. anybody has idea how solve this? sample code: var options = { headers: { 'authorization': 'bearer xxx' } }; this.$http.get(config.api.base_url + 'open/cities',[options]) .then(function(response){ console.log('new request'); vm.cities = response; }, function(error){ console.log('error in .js:'); console.log(error); }); jquery-request solution: as @

Resolving stash conflict in eclipse egit -

i don't know how got problem stuck. stashed changes in order @ code on different branch. went original branch , tried apply stashed changes. don't understand why decided there conflicts. conflicts want apply. can copy right left resolve removes stashed changes. can me untangle mess? tia.

sql server - How to see the actual values while grouping by instead of count in sql -

i have table in sql server 2008 this: id name ------------ 1 jack 2 john 3 maria 4 jack 5 jack 6 john i trying see ids having same name in 1 column. select count(id), name mytable group name the query above giving me number of ids having same name. see is: id name ------------ 1,4,5 jack 2,6 john 3 maria how can provide this? thanks declare @yourtable table (id int, name varchar(50)) insert @yourtable values (1,'jack'), (2,'john'), (3,'maria'), (4,'jack'), (5,'jack'), (6,'john') select name ,ids = stuff((select distinct ','+cast(id varchar(25)) @yourtable name=a.name xml path ('')),1,1,'') (select distinct name @yourtable ) returns name ids jack 1,4,5 john 2,6 maria 3

bootloader - VxWorks 6.6 on PowerPC Boot Sequence _sysInit() opcode bizarity -

for project working on, running on powerpc mpc-8641d, vxworks6.6. i need launch vip image vip project. investigating boot sequence seems boot-loader is: reading binary header of image, copy binary image (without hdr) 0x100000 , jumps 0x100000 (where _sysinit()) located. doing same thing boot-loader, cpu freeze @ address 0x100004h reading content of 0x100000 revealed following dump: 48 44 01 fc ba ad c0 de 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... ... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 well, 0x484401fc looks function prolog, but, 0xbaadc0de must joke! how vip run calling address. missing else? 0x484401fc b 0x4401fc , should branching 0x4401fc , never executing instruction @ 0x100004 (unless returns, branch doesn't set lr have return manually).

Is it possible to export an Azure Search index schema? -

is possible export index schema ? i'm looking best practices on how create same index schema different staging areas (dev, test, prod). i can't find export in portal, guess recommended approach create index using script/sdk, can applied other areas ? currently way via azure search rest api or .net sdk. not possible export index definition via azure portal. please vote on this uservoice item prioritize. as example of how rest api, schema can request on index. example: https://myservice.search.windows.net/indexes/myindex . can take result as-is , put or post create index result in body.

How to open Ubuntu GUI inside docker image -

Image
i have downloaded ubuntu image inside docker in windows. can run ubuntu docker run -it ubuntu but see root, dont see ubuntu gui, how install or configure gui image , run apps on gui run in vm generally, approach developping docker keep ide on workstation, , build images binary produced sources. you can find many example of such workflow (local compilation, deployment in docker containers) in domeide.github.io/ (docker meets ide!) example: docker tools visualstudio allows tight integration between editor , docker processes. (but visual studio 2015, not visual studio code)

c - How to use arithmatic operations on uint64_t? -

i trying make program divides number given number , prints out remainder , solution of given number divided 10. code isnt printing out correct values. here following code: #include <stdio.h> #include <string.h> #include <stdint.h> #include <stdlib.h> uint64_t divide(uint64_t,uint64_t); int main(int argc, char *argv[]) { uint64_t num1 = 224262; uint64_t num2 = 244212; divide(num1,num2); } uint64_t divide( uint64_t set1, uint64_t set2 ) { printf("%lx\n",set1); uint64_t remainder = set1%10; printf("%lx\n",remainder); set1= set1/10; printf("%lx\n",set1); } currently output of gives me following 36c06 2 579a how have correctly outputs divided value , remainder? assuming platform has long size 64 bits , correct format printf s %lu uint64_t divide( uint64_t set1, uint64_t set2 ) { printf("%lu\n",set1); uint64_t remainder = set1

selenium - Seleium/Ruby - NoSuchElement when trying to access an item in a modal popup -

what i'm attempting: click on profile picture of user created: http://screencast.com/t/ajcfi3xa click on , make selection drop down in pop modal: http://screencast.com/t/ahgohlg05 the selenium ide picks steps as: click > id=patientphoto selectwindow > name=modal3 ( note modal number changes , increases exponentially, if run these steps again next time around it's modal4) click > id=ext-gen115 click > //div[@id='ext-gen179']/div[2] this playback in ide works without issue. my code: @driver.find_element(:id, "patientphoto").click wait_for { displayed?(:id, "ext-gen31") } @driver.find_element(:id, "ext-gen31").click @driver.find_element(:xpath, "//div[@id='ext-gen179']/div[2]").click in other places/workflows have switch default content switch frame trick: @driver.switch_to.default_content @driver.switch_to.frame('chartframe') but no combination of working here. oth

eclipse - Your gradle version is too old -

i using gradle within eclipse, installed marketplace (package called buildship). i'm trying load vaadin project. // tell gradle add vaadin support plugins { id 'fi.jasoft.plugin.vaadin' version '1.0' // tell gradle working in eclipse apply plugin: 'eclipse-wtp' } when try refresh gradle project after entering these commands fails. don't think problem commands i've entered final line of error messages says version of grade (2.14.1) old- plugin requires gradle 3.0.0+. can't find instructions of how upgrade version of gradle i'm using? if use gradle wrapper in project, should have gradle folder in root folder of project. inside gradle\wrapper folder there should 2 files: gradle-wrapper.jar gradle-wrapper.properties open gradle-wrapper.properties editor(e.g. notepad). see content below: #wed jun 29 07:29:15 cest 2016 distributionbase=gradle_user_home distributionpath=wrapper/dists zipstorebase=gradle_user_home zipstor

android - How to access the camera from within a Webview? -

in android app, trying load webpage (that must access camera) on webview . on laptop, when load webpage, access camera. everything else on html page shown. here permission putting in manifest.xml <uses-permission android:name="android.permission.camera" /> <uses-permission android:name="android.webkit.permissionrequest" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.internet" /> i setting sdk follow: <uses-sdk android:minsdkversion="18" android:targetsdkversion="21" /> here webview setting: private void setmywebviewsettings(websettings mywebviewsettings){ mywebviewsetting

google chrome - Beautify local directory listing? -

normally there ugly directory list when navigate through local directory. when i'm working apache. there way change else one: http://demo.directorylister.com/ or can done chrome extension ? regards.

account - Script error login visual studio DefaultLogin_PCore.js -

i have error when trying start account in visual studio, solution? https://auth.gfx.ms/16.000.26754.00/defaultlogin_pcore.js enter image description here i hit same issue. worked through clicking through dialogs , allowing continue running scripts. after script failures done left white dialog. pressed f5 refresh browser page in dialog , showed me box enter password , let me in.

scope for associations - Rails 4 -

i appreciate if someoneone me write scope displaying number of females (women) attending event. models user.rb belongs_to :category_gender has_many :payments category_gender.rb has_many :users event.rb belongs_to :user has_many :payments payment.rb belongs_to :user belongs_to :event terminal event = event.find(7) event_payments = event.payments 2.3.0 :054 > event_payments [ [0] #<payment:0x007fea72ac5b70> { :id => 6, :email => "richill@gmail.com", :user_id => 4, :reference => "spz_ruz5om", :created_at => wed, 16 nov 2016 13:52:23 utc +00:00, :updated_at => wed, 16 nov 2016 13:52:23 utc +00:00, :event_id => 7, :stripe_customer_id => "cus_9yuzzanifczvxn", :stripe_payment_id => "ch

php - Why is my nested IF condition not working? -

i want check if record exists , if go page a, otherwise go page b. goes page whether there record or not. <?php $ini = parse_ini_file("../phpconfig.ini"); $conn = mysqli_connect($ini['hostaddress'], $ini['username'], $ini['password'], $ini['databasename']); if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $options = ['cost' => 10,]; $number = mysqli_real_escape_string($conn, $_post['number']); $password = password_hash((mysqli_real_escape_string($conn, $_post['password'])), password_bcrypt, $options); $sql = "insert usertemp (employee_number, password) values ('$number', '$password')"; if (mysqli_query($conn, $sql)) { $sql2 = "select exists(select 1 employee number = '$number')"; $row2 = mysqli_query($conn, $sql2); if (mysqli_num_rows($row2) > 0) { //has record in employee ta

ios - How do you rescue a view that attempts to break a boundary? -

i have container view serve boundary labels in project. have feature allows users change size of view or not can problematic labels adhere boundary since forced out. know type of behavior how uicollisionbehaviors designed prevent or recover "lost" labels. i have tried turning boundaries on , off before , after changing size of container view doesn't seem help. ideally if label gets popped out recover position , center within container view. when attempt move label center goes before outside container. any appreciated. as can see in following example, label has rescue attempt change it's center position not work. example animated gif github project customlabel.swift import uikit class customlabel: uilabel { var containerview: uiview? var animator: uidynamicanimator? var boundry: uicollisionbehavior? func containwithin(view: uiview) { containerview = view animator = uidynamicanimator(referenceview: view) isus

Is HighCharts possible to combine polar chart with other chart? -

as know, shall set chart.polar true have polar chart highchart. seemed polar chart different other chart types, isn't it? i've seen many other combination of different charts, none of combine polar chart. is possible combine polar chart bar chart? i guess possible since believe highcharts powerful enough.

Some questions related to tornado httpserver and httpclient -

question 1: tornado.httpserver non-blocking http server. there blocking http server? question 2: does asynchronous mean non-blocking? synchronous mean blocking? question 3: are tornado.curl_httpclient , tornado.simple_httpclient both non-blocking, aka, asynchronous? question 1: yes, flask , django , simplehttpserver other multithreaded http servers written in python "blocking". if write code uses 1 of servers implement http server application, code not use "yield" or "await" or callbacks implement logic. question 2: pedants "synchronous" , "blocking" distinct , "asynchronous" , "non-blocking" distinct. expect several of them in answer question. however, interchangeable ideas purposes: synchronous , blocking synonyms, , asynchronous , non-blocking synonyms. question 3: docs say, tornado.simple_httpclient.asynchttpclient non-blocking , curlhttpclient. suggest you read tornado's docs asyn

clear jQuery array after click -

i modified jquery script show customized layer instead of modal when clicking on external links. have link sitting in array until user clicks "ok" or "cancel" , gets redirected. problem happens if click link on page, every external link clicked on loads in separate tabs. being said, can't figure out how clear array after clicking "ok" or "cancel". $('a[href^="http"]').not('a[href^="{{ shop.url }}"]').click(function(e) { var external = $(this).attr('href'); e.preventdefault(); $('#leaving').toggle('slow'); $('#linkgo').click(function() { $('#leaving').fadeout(500); window.open(window.open.location = external); }); $('#linkcancel').click(function() { $('#leaving').fadeout(500); }); }); so...i found workaround. once specified window name (not "_blank") window.open command

javascript - angular - Edit raddiobutton values ​in textarea -

Image
i popover retrieve values ​​of radiobuttons in lines in textarea , after saving make necessary change. <div ng-repeat="controle in dataform.controles" ng-switch on="controle.tipo"> <div ng-switch-when="radio" class="kahiar-block"> <div id="cmp_{{controle.codcontrole}}" class="campos form-group disabled col-md-6 animated bounceinright " ng-controller="controleditctrl" popover-placement="top" uib-popover-template="dynamicpopover.templateurl" popover-title="editar controle"> <div class="conteudo-campo"> <label data-id="lbl{{controle.codcontrole}}" class="label-titulo"></label> <div class="input-group"> <label class="checkbox-inline" id="div_{{$index}}" ng-repeat="item in controle.opcoes track $index" name="{{item.

functional programming - How to prove uniqueness of a function in Coq given a specification? -

given specification of function, e.g., specification_of_sum , how prove in coq 1 such function exists? i studying mathematics, , prove in hand, skills in coq limited (proving using rewrite , apply ). i found code snippet below, i've been struggling time now. i try unfold specification in proof, using old friend rewrite doesn't seem let me go further. can explain how approach problem using simple syntax? definition specification_of_sum (sum : (nat -> nat) -> nat -> nat) := forall f : nat -> nat, sum f 0 = f 0 /\ forall n' : nat, sum f (s n') = sum f n' + f (s n'). (* ********** *) theorem there_is_only_one_sum : forall sum1 sum2 : (nat -> nat) -> nat -> nat, specification_of_sum sum1 -> specification_of_sum sum2 -> forall (f : nat -> nat) (n : nat), sum1 f n = sum2 f n. proof. abort. the following start ejgallego described. intros sum1 sum2 h1 h2 f n. (

javascript - jquery popup window only pulling last popup div -

i trying have link open popup window holds inline html , image when user clicks on link. i've gotten work each link opens popup window, not show right content - keeps pulling last hidden div instead of 1 link clicked on. ;(function($){ function deselect(e) { $('.pop').slidefadetoggle(function() { e.removeclass('selected'); }); } $(function() { $('#popup,#popup2,#popup3,#popup4').on('click', function() { if($(this).hasclass('selected')) { deselect($(this)); } else { $(this).addclass('selected'); $('.pop').slidefadetoggle(); } return false; }); $('.close').on('click', function() { deselect($('#popup,#popup2,#popup3,#popup4')); return false; }); }); $.prototype.slidefadetoggle = function(easing, callback) { return this.animate({ opacity: 'toggle', height: 'toggle' }, 'fast', e

java - OkHttp: A connection to http://example.com/ was leaked. Did you forget to close a response body? -

this error message of okhttp v3.4.1 has been discussed few times, , each time read it, people not closing response body: warning: connection http://www.example.com/ leaked. did forget close response body? but code reads this: private string executerequest(request request) throws ioexception { response response = httpclient.newcall(request).execute(); try (responsebody responsebody = response.body()) { string string = responsebody.string(); logger.debug("result: {}", string); return string; } } so responsebody.close() called. how come above error? configured custom jwt interceptor, don't see how cause problem: public class jwtinterceptor implements interceptor { private string jwt; @override public response intercept(chain chain) throws ioexception { request request = chain.request(); if (jwt != null) { request = request.newbuilder() .addheader("authorization", "bearer &quo

asp.net - Package tried to add reference to System.Runtime which was not found in the GAC -

asp.net 4.5.1 or 4.5.2 updating nuget package microsoftaspnet.identity.entityframework version 2.2.1 version 3.0.0-rc1-final i following error: failed add reference. package 'microsoft.aspnet.identity.entityframework' tried add framework reference 'system.runtime' not found in gac. possibly bug in package. please contact package owners assistance. i had similar issue package. i "solved" adding manually reference missed library, updating package , removing reference added manually: on project go references -> add reference... , click on browse... on installation (windows 10), file located on: c:\windows\microsoft.net\assembly\gac_msil\system.runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\system.runtime.dll add, update , remove. i know, not solution, allow continue working until real solution.

python - WTForms doesn't validate MAC address -

i'm using wtforms' macaddress validator, doesn't recognize valid mac addresses enter. why isn't working? {'choice': [u'invalid mac address.']} class editform(form): choice = textfield('choice', validators=[datarequired(), macaddress()]) @app.route('/', methods=['get', 'post']) def devicechoice(): form = editform() if form.validate_on_submit(): print form.choice.data return redirect(url_for('editdevice')) else: print form.errors return render_template('devicechoice.html', form=form) <form action="" method="post"> {{ form.hidden_tag() }} {{ form.choice() }} <input type="submit"> </form> question has been answered @ketouem, putting ":" after every 2 characters of mac address validates form. (12:34:56:78:ab:cd)

Rails 4 - Rails API using Devise for Authentication (Email and Facebook OAuth) with Tokens -

i building rails api back-end mobile apps. have implemented devise users either email or facebook login. what best method build api authenticate users through devise using either email or facebook? more how can build users controller , routes make api calls user data, , users make crud calls interact app? users using facebook-oauth synced uid provided facebook. rails 4.2.2 ruby 2.2.2 currently using devise authentication. have implemented api key api calls server. i did not use rails-api gem , stay away gems if possible. appreciate help.

Python/ Django- copying buttons from one HTML page to another -

i have taken on development of project management software has been written in python/ django- having not used python or django @ before... there few buttons displayed on 1 of webpages useful display on page within application. can see these buttons defined in budget.html following code: {% block page_options %} <a class="button m-r-md" href="{% url 'costing:export_csv' budget.id %}">export excel</a> <a class="button m-r-md" href="{% url 'costing:schedule_of_works_post_dep' budget.id %}" target="_blank">schedule of works</a> <a class="button m-r-md" href="?pdf=1" target="_blank">pdf</a> <input data-view-url="{% url 'costing:combined_budget' project.id %}?search=" type="text" id="item_search" placeholder="item search" /> {% endblock page_options %} the other page, want able use

mule - DOM to XML transformer logic -

can please explain me why dom xml transformer converts output of web service consumer xml string representation? output of web service consumer org.mule.module.ws.consumer.namespacerestorerxmlstreamreader . according official docs: the domtoxml transformer converts dom objects xml, xmltodom transformer converts xml strings dom objects, , domtooutputhandler transformer converts dom outputhandler serialization. they refer w3c dom object, knowledge html dom used in web browsers? thanks

javascript - Canvas in foreign object of svg doesn't apply the transformation -

i have problem use of canvas in svg, using foreignobject. the probleme canvas inserted in group, have transformation (translation or rotation or scale), canvas isn't printed transformation. i on chrome. you can see example there : https://jsfiddle.net/surre/qjrvxgos/ <body> <svg width="400px" height="300px" viewbox="0 0 400 300" xmlns="http://www.w3.org2000/svg"> <g transform='translate(250,10)rotate(40)'> <foreignobject height="700" width="370" y="0" x="0"> <span xmlns="http://www.w3.org/1999/xhtml"> <canvas id="canvas" width="400px" height="300px" fill-style="#ff0000"></canvas> <div>comment</div> </span> </foreignobject> </g> </svg> </body> the "co

Comparison of List in C# and vector in C++ in terms of initialization -

in c++, 1 can initialize vector as vector<int> nums1 (100, 4); // 100 integers value 4 in additions, there like vector<int> nums2 (nums1.begin() + 5, nums1.end() - 20); is there similar in c# list? you can list . using system.collections.generic; list<int> nums1 = new list<int>(enumerable.repeat(4,100)); //100 elements each value 4 list<int> nums2 = new list<int>(nums1.skip(5).take(75)); // skip first 5 , take 75 elements

swift2 - How to get users location statically and use it in other classes iOS? -

i want separate user's location methods locationutils can use them , not have keep writing duplicate methods struggling that, there resources can learn ? new ios. class locationutils: nsobject, cllocationmanagerdelegate { let locationmanager = cllocationmanager() var usercity: string? func enablelocationservices() { self.locationmanager.requestalwaysauthorization() if cllocationmanager.locationservicesenabled() { locationmanager.delegate = self // comment locationmanager.desiredaccuracy = kcllocationaccuracynearesttenmeters locationmanager.startupdatinglocation() } self.locationmanager.requestlocation() } // try ro call statically func getusersclosestcity(lat: cllocationdegrees, lng: cllocationdegrees){ let geocoder = clgeocoder() let location = cllocation(latitude: lat, longitude: lng) geocoder.reversegeocodelocation(location) { (placemarks, error) -> void in let placearray = placemarks [clplacema

Python XML add element to file -

i have 1000 xml files, , missing element. made script search through xml's , print element. wanted add ability add element if isnt there, unsuccessful. as can see below, dvt3 isnt there , needs added. my code xmlparser = etree.xmlparser(remove_blank_text=true) f in os.listdir(directory): if f.endswith(".xml"): xmlfile = directory + '/' + f tree = etree.parse(xmlfile, parser=xmlparser) root = tree.getroot() hardwarerevisionnode = root.find(".//hardwarerevision") try: print f + ' : ' + hardwarerevisionnode.text except exception e: print str(e) print xmlfile #wearable = root.find(".//wearable") childnode = etree.element(".//wearable") childnode.text = "dvt2" childnode.append(childnode) tree.write(xmlfile, pretty_print=true) xml file <?xml version=&#

android - How to refactor name just for class scope or one package scope -

for example, when have relativelayout name loadingrelativelayout in 2 classes class1 , class2 , how can refactor name in greenloadingrelativelayout class1 ? usually, when want refactor this, reflects on both classes.

When tried executing gui.sh file on linux CentOS I get an error -

i beginner @ linux , hoping me out. i trying run gui.sh file in linux , presented multiple lines "warn" or "error" messages. appreciated if can clarify looking @ , provide possible troubleshoot. thanks in advance! error message

php - recursion - How to construct a data tree without ids, data is ambigious. -

please refer solution, has been solved. i have following dataset , no ids provided, trying completed using recursion. should attempt or should go route? because there no ids. after filter on each attribute root gender, node 1 category , end node label. have tried use array_merge_recursive, array_push , have tried construct own recursive pattern nothing appears pattern want. json data: [{"label":"shirts","tag":"m_shirt","gender":"men","category":"clothing"}, {"label":"pants","tag":"m_pant","gender":"men","category":"clothing"}, {"label":"shorts","tag":"m_short","gender":"men","category":"clothing"}, {"label":"casual","tag":"m_shoe_casual","gender":"men","category":&quo

Inconsistent Symbol Mangling in Rust on Windows -

i have 2 interdependent, cross platform rust projects. project main application, producing main executable , dynamic library containing common dependencies. project b contains plugins application, each distributed dynamic library dependency on project common library. because 2 projects separate, cargo builds common library both projects , b. on windows, symbol name mangling inconsistent between 2 builds, meaning project b plugins cannot use common library produced project build, , vice versa. tried placing #[no_mangle] directive on pertinent symbols in project common library, on windows ignored in project b build. on linux, symbol names consistent between 2 builds, or without #[no_mangle] directive. what causing inconsistency on windows builds , how can resolved? keep 2 projects separate make easier develop new plugins in future. all testing has been done using rust 1.13.0 on windows 10 , centos 7. issue occurs both msvc , gnu abis on windows, application needs compile ms

java - A method that returns a value obtained in an asynchronous call -

i know it's beginner's doubt, i'll try objective possible. i know correct way make method return value obtained through asynchronous call within own method. below simplified code of way i'm trying. for clarification questions, i'm trying in 1 of endpoits of webservice (jersey) @post @path("authentication") public string auth(string token) { gson gson = new gson(); jsonresponse response = new jsonresponse(); new authusertoken(token, authcallback() { @override public void onsuccess(token decodedtoken) { string uid = decodedtoken.getuid(); string email = decodedtoken.getemail(); user user = new userdao().find(uid, email); if ( usuario != null ){ response.setcode(response.status.accepted.name()); response.setmessage("user found"); response.setpayload(gson.tojson(user)); } else{ response.setcod

java - JSP file encoding in TomCat -

Image
i have use tomcat 8.00 , intellij idea 14.0 , h2 database. when text textfields in register form (cyrillic) records in database this: it's importand made these configurations. this index.jsp file <%@ page contenttype="text/html;charset=utf-8" language="java" pageencoding="utf-8" %> <html> <head> <title>home</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> this servlet public class registerservlet extends httpservlet { protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string username = request.getparameter("usernamereg"); string pass = request.getparameter("passreg"); string name = request.getparameter("firstnamereg"); string lastname = request.getparameter("lastnamereg"); string email = requ

ios - Can't get convertRect: fromView to work -

inside viewcontroller have tableview custom cells. on cellforrow:atindexpath: method i'd access location ( rect ), according viewcontroller's coordinate system , of uibutton displayed inside specific cell. how thought work: func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { var cell = tableview.dequeuereusablecellwithidentifier("cellid") as? mycell if cell != nil { cell = mycell(style: .default, reuseidentifier: "cellid") } let convertedframe = view.convertrect(cell!.mybutton.frame, fromview: cell) return cell! } it gives me current frame of button in own coordinate system (0.0, 0.0, 44.0, 44.0) any clues on correct usage of method? it matter of calling before cell placed in view hierarchy. rmaddy pointing out.

json - How do I plot PGSQL queries onto google maps? -

so trying learn how store pgsql queries on google map. database contains 2 json columns lat/long. have slightest idea of how query json pgsql , display on google maps. can give me tutorials or can give me insight on getting done? the usual way choose "backend" programming language, python, php , write little program on web server apache, connects database , queries data when browser asks it. you should have "user interface" part, html/css/javascript displays in browser. there many such projects, can use google, github find open source projects it, or use stackoverflow find answers specific parts of it.

c# - How can I save EntityFramework Model inside itself? -

i have model, called user (derived database) , i'm adding methods inside partial class, allowing user object maintenance type work. as example, application update user's supervisorid in database in alignment database: public partial class user { databaseentities db = new databaseentities(); otherentities otherdb = new commonentities(); public void updatesupervisor() { // lookup supervisor's username in other database: string supervisorusername = (from x in otherdb.vwemployees join y in otherdb.vwemployees on x.supervisor_eid equals y.employee_id x.user_id == searchusername select y.user_id).firstordefault(); // update database record supervisor of staff member: this.supervisoruserid = (from x in db.users x.adusername == supervisorusername

php - How to get user input to insert multiple records into database from table created with a for loop? -

i have created form requires user input information on fields , submit form. goal user input , insert new records on database. current challenges since used loop in php create table/form: i can not access input $_post not sure how go differentiating of rows , inputs each other (since used loop create them). thinking array... please see screenshot of form working with. below have submit button. if (isset($_post['submit'])) { $date = date('m\/d\/y'); $ordnum = $_post['cpordernumber']; $ponum = $_post['cpponumber'] . $_post['cpponumberf']; $palnum = $_post['palnum']; $casecount = $_post['casecount']; $cpsflot = $_post['cpsflot']; $sscc = $_post['sscc']; if(!empty($_post['cpordernumber']) || !empty($_post['cpponumber'])) { require_once('mydatabase.php'); $query = "insert asn (date, ordnum, ponum, palnum, casecoun

sql - Is it possible to get the number of rows from a table in O(1) time? -

in sql server, 1 way of getting number of rows in table is select count(*) mytable but assume that's o(n) time n number of rows. there metadata can access has number of rows stored? yes, can use sys.partitions , might not exact number, it's extremely fast: select sum(rows) sys.partitions [object_id] = object_id('dbo.mytable') , index_id in (0,1);

linear programming - L1-norm minimisation in MATLAB with Gurobi -

i want solve following optimisation problem in matlab: min sum(abs(x)) s.t. a*x = 0, lb <= x <= ub where x dense vector, sparse matrix, lb , ub real lower , upper bounds respectively. convenient function linprog() or lp solver gurobi. know how formulate problem? thanks the objective minimize sum(abs(x)) can translated to: minimize sum(u) s.t. -u_i <= x_i <= u_i (where dim(x) == dim(u) )

python - Import Error from binary dependency file -

i attempting run package after installing it, getting error: importerror: /home/brownc/anaconda3/lib/python3.5/site-packages/dawg.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ztvnst7__cxx1118basic_stringstreamicst11char_traitsicesaiceee the dawg....gnu.so file binary , doesn't give information when opened in sublime. don't know enough binary files in order go in , remove line or fix it. there simple fix not aware of? i found answer specific case, may run case well: i using anaconda (python 3 version) , installing package conda install -c package package worked instead of pip install package . i hope helps someone.

exe - Stackdump - compiled .c code -

if execute following code, it´s prin stack dump error message: 1 [main] myprog 10876 cygwin_exception::open_stackdumpfile: dumping stack trace myprog.exe.stackdump after prints shellcode length: 601 can me, should change, working? have compiled sublime text , cygwin on windows 10 64bit. this code: #include <stdio.h> #include <string.h> const char sc[] = "\xfc\x31\xd2\xb2\x30\x64\xff\x32\x5a\x8b\x52\x0c\x8b\x52\x14\x8b" "\x72\x28\x31\xc0\x89\xc1\xb1\x03\xac\xc1\xc0\x08\xac\xe2\xf9\xac" "\x3d\x4e\x52\x45\x4b\x74\x05\x3d\x6e\x72\x65\x6b\x8b\x5a\x10\x8b" "\x12\x75\xdc\x8b\x53\x3c\x01\xda\xff\x72\x34\x8b\x52\x78\x01\xda" "\x8b\x72\x20\x01\xde\x31\xc9\x41\xad\x01\xd8\x81\x38\x47\x65\x74" "\x50\x75\xf4\x81\x78\x04\x72\x6f\x63\x41\x75\xeb\x81\x78\x08\x64" "\x64\x72\x65\x75\xe2\x49\x8b\x72\x24\x01\xde\x66\x8b\x0c\x4e\x8b" "\x72\x1c\x01\xde\x8b\x14\x8e\x01\xda\x89\x

c# - Import a CSV file to SQL Server using SqlBulkCopy -

i have function creates table , receives csv file. need id column in auto increments used later use. therefore ran below query id field. before wasn't working because csv file had no id column when time came sent database there error. next idea add blank id column no values csv file , attempt query again. still having issue. error in c# code is: "received invalid column length bcp client colid 1." guessing id column. there way have id column inserted , auto increment @ same time? private void button2_click(object sender, eventargs e) { string connectionstring = "data source=lpmsw09000012jd\\sqlexpress;initial catalog=pharmacies;integrated security=true"; string query = "create table [dbo].[" + textbox1.text + "](" +"id int identity (1,1) primary key," + "[code] [varchar] (13) not null," + "[description] [varchar] (50) not null," + "[ndc] [varchar] (50) null," + &

How to set an index of an array within a struct as a variable(Coldfusion) -

Image
this first error getting: invalid data [d6-2014-74, , ] cfsqltype cf_sql_varchar here corresponding code. <cfset x = arguments.surveydocno> <cfprocparam cfsqltype="cf_sql_varchar" value="#x#"> to solve problem, changed code this: <cfset x = arguments.surveydocno[1]> however, returns error: 500 have attempted dereference scalar variable of type class java.lang.string structure members. so array issue fixed, don't know how fix second error. <cfdump var="#arguments.surveydocno#"> i assume pass surveydocno argument string , array of strings. <!--- if argument passed array, take first element ---> <cfif isarray(arguments.surveydocno) , (not arrayisempty(arguments.surveydocno))> <cfset x = arguments.surveydocno[1]> <cfelse> <cfset x = arguments.surveydocno> </cfif> <!--- if provided argument not string, throw exception ---> <cfif not issimp

pycharm - Python convention for specifying compatible interpreter versions? -

similarly __author__ or __version__ top level module variables, there convention specifying supported python versions python source file? my usecase project has scripts need compatible python 2.4. note fact in them in universally recognizable way. i not asking how require minimal python version during execution . problem developers may accidentally use feature not compatible python version particular script needs support. pycharm can warn python incompatibilities. great if pick annotation , configure warning on per-file basis. there's no convention know of specifying supported python versions in python source file. if you're making python library , distributing via pypi (and pip ), can add package metadata says versions of python it's compatible with. for example, scandir module, can see on pypi it's (currently) marked compatible python 2.6, 2.7, , 3.2-3.5. metadata lives in classifiers keyword in package's setup.py : setup( name='sc