Posts

Showing posts from March, 2012

c++ - Aliasing regular array with vector intrinsics in gcc -

i'm playing around vector instrinsics in gcc, particularly avx, , i'm tempted write vector multiply between 2 arrays: #include <unistd.h> void __attribute__((target("avx"))) vmul(float* __restrict__ cc, const float* __restrict__ aa, const float* __restrict__ bb, ssize_t size) { const ssize_t vecsize=8; typedef float vfloat __attribute__((vector_size(sizeof(float)*vecsize))); // duff's device, process remainder front ssize_t rem = size % vecsize; switch (rem) { case 7: cc[6] = aa[6]*bb[6]; /* fallthru */ case 6: cc[5] = aa[5]*bb[5]; /* fallthru */ case 5: cc[4] = aa[4]*bb[4]; /* fallthru */ case 4: cc[3] = aa[3]*bb[3]; /* fallthru */ case 3: cc[2] = aa[2]*bb[2]; /* fallthru */ case 2: cc[1] = aa[1]*bb[1]; /* fallthru */ case 1: cc[0] = aa[0]*bb[0]; /* fallthru */ case 0: break; } size -= rem; // process rest of array const vfloat *va = (const vfloat*)(...

c# - asp.net mvc - how can I have multiple viewmodels bound to a view -

this question has answer here: multiple models in view 9 answers i new c# please excuse dumb question. creating webapp using asp.net mvc. on nav bar have button brings modal containing form. done in _layouts.cshtml shared view. capture form post use viewsmodel passes controller processing. problem loads model every view loaded in webapp unless use separate shared view. stops me passing model controller view. at moment have created model named masterviewmodel has other view models properties, still stops me passing models view... does have advise on how around problem? yes! can! there many ways there 2 fancy most. 1.) viewbag with 1 simple, can set view bag in controller along lines of viewbag.example = yourviewmodelhere then access on view saying @viewbag.example.attribute 2.) partial view another way keep architecture organized nicely , have...

c++ - Winsock2 select() function: passing {0, 0} as timeout parameter -

i'm creating multiplayer real-time game based on client-server model using <winsock2.h> library. communication part, i've decided use non-blocking sockets, instead of blocking sockets eliminate multi-threading. on client side, handle these tasks in 1 single loop: handling user input (if necessary) sending/receiving data to/from server (if possible) updating game data (with constant frequency) refreshing screen (with constant frequency) i'm wondering, if bad practice call select timeout {0, 0} in second part of loop? found this website says: the timeout value {0, 0} indicates select() return immediately, allowing application poll on select() operation. this should avoided performance reasons. i don't understand, why should avoid using it. if explain, appreciate it. i don't understand, why should avoid [calling select() zero-timeout). if explain, appreciate it. if thread's event-loop never blocks anywhere spinning cp...

android - How to remove Specific values from Shared Preference -

Image
am using sharedpreferences store list of values. need remove specific value sharedpreferences.below code using remove. not working. prefs= detailactivity.this.getsharedpreferences("itemfkid",context.mode_private); edit=prefs.edit(); //edit.clear(); edit.remove(itemfkid); edit.commit(); below screenshot contains values after edit.remove() compiles. here inserting values sharedpreferences prefs= detailactivity.this.getsharedpreferences("itemfkid",context.mode_private); edit=prefs.edit(); (int = 0; < config.favouriteslist.size(); i++) { edit.putstring("itemfkidvalue" +i, config.favouriteslist.get(i)); } edit.putint("itemfkidlength", config.favouriteslist.size()); edit.commit(); the documentation sharedpreferences.editor has 2 bits...

Bootstrap - number of columns in the list on the sidebar -

on small size want have 3 columns of list above 'main' div. on bigger size screens need 1 column on left of 'main' div. it works fine on extra-small size on bigger screens affects 'sidebar div' in way on top of 'main', had class assigned "col-xs-4 col-sm-12". how can change it? <div class="container"> <div class="row"> <div class="col-sm-2" id="sidebar"> <ul class="row"> <li "col-xs-4 col-sm-12"> 1</li> <li "col-xs-4 col-sm-12"> 2 </li> <li "col-xs-4 col-sm-12"> 3</li> <li "col-xs-4 col-sm-12"> 4</li> <li "col-xs-4 col-sm-12"> 5</li> </ul> <div class="col-sm-10" id="main"> </div> </div>

twitter bootstrap - Jquery daterangepicker bugged inside modal -

Image
i'm creating daterangepicker when bootstrap modal visible following code: var $ruleinput = $("#rulesvalueadd"); $ruleinput .attr("placeholder", "dd/mm/aaaa - dd/mm/aaaa") .daterangepicker({ format: "dd/mm/yyyy" } ); the image of picker here: doesn't work well. when click on both inputs of daterangepicker start , end date can defined, cancel or apply buttons, picker automatically closes. i found kind of solution @ least applies dates defined calendar doing function: var $ruleinput = $("#rulesvalueadd"); $ruleinput .attr("placeholder", "dd/mm/aaaa - dd/mm/aaaa") .daterangepicker({ format: "dd/mm/yyyy" }, function (start, end, label) { $ruleinput.val(start.format('dd/mm/yyyy...

Excel-VBA/App Function: Derive Hierarchy Level from Parent/Child Data -

i have child in column , parent in column b. need derive hierarchy level sort them. data extract comes unsorted , i'm trying figure out way achieve through vba or excel app function. child parent 00004467 00001083 00019886 00014581 00011572 00001083 00002353 00011572 00014581 00001083 00003935 00004467 00001083 00001437 00019887 00014581 00001888 00004467 00002606 00011572 00004289 00004467 00051941 00014581 00008847 00011572 expected output child parent hierarchy 00001083 00001437 1 00004467 00001083 1.1 00011572 00001083 1.2 00014581 00001083 1.3 00003935 00004467 1.1.1 00001888 00004467 1.1.2 00004289 00004467 1.1.3 00002353 00011572 1.2.1 00002606 00011572 1.2.2 00008847 00011572 1.2.3 00019886 00014581 1.3.1 00019887 00014581 1.3.2 00051941 00014581 1.3.3

django - Avoiding existence errors -

def clean_bank_account(self): import ipdb; ipdb.set_trace() ssn = self.form.cleaned_data.get('ssn') customer = customerprofile.objects.filter(ssn=ssn) bank_account = self.form.cleaned_data.get('bank_account') bank = self.form.cleaned_data.get('bank') bank_transit = self.form.cleaned_data.get('bank_transit') qs = financialprofile.objects.filter( bank=bank, bank_transit=bank_transit, bank_account=bank_account) if customer.count() == 1: cust in customer: qs = qs.exclude(customer_id=cust.id) if qs.count() > 0: # concatenation of bank transit, bank account , bank # number must unique. hence, following message # displayed if in use. raise validationerror( _('the bank, bank transit , bank in use.') ) if bank not in (none, ''): # check bank account format specific banks length = ...

xamarin - Can I set the font size of a button inside the <Button> tag directly? -

i have code: <button x:name="correctbutton" heightrequest="60" horizontaloptions="fillandexpand" verticaloptions="startandexpand"> <button.fontsize> <onplatform x:typearguments="x:double" x:key="windowbackgroundtable"> <on platform="android" value="20" /> <on platform="ios" value="25" /> </onplatform> </button.fontsize> </button> is there way platform specific sizes can set without have <button.fontsize> no, need kind of code if want make difference per platform. normally, set this: <button fontsize="25" x:name="correctbutton" heightrequest="60" horizontaloptions="fillandexpand" verticaloptions="startandexpand" /> but cannot distinguish values platforms. do, anto mentioned, create style , set values, per platform,...

react native - Undefined is not an object (evaluating 'this.fetchData().then') -

native function draw scene inside main render. error title of question ( undefined not , object...) this function block : fetchdata() { const { params } = this.props.navigation.state; fetch(request_url+'&'+'cabnum='+params.cabreg) .then((response) => response.json()) .then((responsedata) => { //alert(params.cabreg); alert.alert('','your driver :'+responsedata[0].driver); return responsedata; }).done(); } and main render : render() { const { params } = this.props.navigation.state; return ( <view> <text>{params.cabreg}</text> <view>{this.fetchdata() .then((responsedata)=>{ ...

reporting services - SSRS External Images with Dynamic File Extensions -

i have report needs show images windows folder on server, working (see here ). now, wondering how report pull images of differing file types, jpg & tif. (i using png default). there relatively easy way this? image names file extension not in sql database. edit: entered in custom code block, daniel's below. public function getimage(byref filename string) string ' full image path used testing if exists dim imagepath string imagepath = "\\gvsserver1\gvsserverd\acclamare_images\" + filename ' test see if file exists gif try if system.io.file.exists(imagepath + ".png") return "file://" + imagepath + ".png" elseif system.io.file.exists(imagepath + ".jpg") else return "file://" + imagepath + ".jpg" end if catch ex exception return "hit error" end try return "hit end" end function when run re...

parallel processing - Only one image in Fortran Coarrays in gfortran -

i'm using gfortran compiler , trying work on parallel programming without mpi. though, spent time on reading fortran, gfortran, parallel programming, couldn't use different processors @ same time. my purpose create matrix multiplication working on different processor reduce time. have many ideas first of all, have use different processors. use written codes, computer have 1 image. example: program hello_image integer::a write(*,*) "hello image ", this_image(), & "out of ", num_images()," total images" read(*,*), end program hello_image this simple program took pdf parallel programming in fortran. should give output: hello image 1 out of 8 hello image 2 out of 8 hello image 3 out of 8 hello image 4 out of 8 hello image 5 out of 8 hello image 6 out of 8 hello image 7 out of 8 hello image 8 out of 8 but compiler giving output: hello image 1 out of 1. i use gfortran compiler command gfortran "codenam...

ios - Animate CAShapeLayer with circle UIBezierPath and CABasicAnimation -

Image
i'd animate circle angle 0 360 degrees in 15 sec. the animation weird. know start/end angle issue, faced kind of problem circle animations, don't know how solve one. var circle_layer=cashapelayer() var circle_anim=cabasicanimation(keypath: "path") func init_circle_layer(){ let w=circle_view.bounds.width let center=cgpoint(x: w/2, y: w/2) //initial path let start_angle:cgfloat = -0.25*360*cgfloat.pi/180 let initial_path=uibezierpath(arccenter: center, radius: w/2, startangle: start_angle, endangle: start_angle, clockwise: true) initial_path.addline(to: center) //final path let end_angle:cgfloat=start_angle+360*cgfloat(cgfloat.pi/180) let final_path=uibezierpath(arccenter: center, radius: w/2, startangle: start_angle, endangle: end_angle, clockwise: true) final_path.addline(to: center) //init layer circle_layer.path=initial_path.cgpath circle_layer.fillcolor=uicolor(hex_code: "ea535d").cgcolor ...

javascript - JS Power of Issue -

i have been given calculation in excel, have replicate in js, cannot life of me figure out. the calculation in excel 70*3^0.75 . result 159.565493987 , rounded 160. in js have tried following math.pow(70 * 3, .75); // 55.16510778290732 math.pow(70, .75) * 3; // 72.60136477480762 70*.75*3; // 157.5 console.log(70 * math.pow(3, .75)) // or console.log(70 * 3 ** .75) in javascript, languages, exponentiation evaluates before multiplication. see order of operations . note: exponentiation operator ** added in ecmascript 2016 standard , if want use portably, consider transpiler babel script.

javascript - Google Maps API loads from html file, but not on local host -

i trying connect google maps api localhost through angularjs application map not appear , map request not reach google. javascript file being found html, , test1 being outputted in console, initmap not being called , test2 not outputted. expect failing because https connection not being made google. when open html file in browser, map loads fine when run on localhost, nothing comes up. here html code: <script src="client/services/maps.client.services.map.js"></script> <script src="https://maps.googleapis.com/maps/api/js?key={{api_key}}&callback=initmap"></script> and javascript (map.js): console.log('test1'); function initmap() { console.log('test2'); //markers var markers = [ ['cardiff', 51.4539, -3.1694, 'city/cardiff'], ['swansea', 51.6148, -3.92927895, 'city/swansea'] ]; // initialise map var map = new google.maps.map(document.getelementbyid(...

linux - How to insert a new line between 2 specific characters -

is there anyway insert new lines in-between 2 specific sets of characters? want insert new line every time }{ occurs in text file, want new line inserted between 2 curly brackets. example }\n{ you can run sed -i -e 's/}{/}\n{/g' filename.ext where sed stream editor program -i option edit file filename.ext in place -e means regular expression follows s/}{/}\n{/g regular expression meaning find ( g ) instances of }{ in every line , replace them }\n{ \n regex new line. if omit g , replace first occurrence of search pattern still in every line. to test before committing changes file, omit -i option , print result in stdout. example: create file: echo "first }{ last" > repltest.txt run sed -e 's/}{/}\n{/g' repltest.txt prints following stdout: first } { last to effect change in same file, use -i option. to run against stdin instead of file, omit -i , filename in piped command after outputs stdin, e...

jms - ActiveMQ create hierarchical topics with wildcards -

Image
i have read in activemq documentation, subtopics can created using wildcards. instance create topics: physicalenvironmet.conditions physicalenvironmet.infrastructure physicalenvironmet.location i register either 1 of topics, or (physicalenvironmet.>) but how working more complex structures, this: would topic flickering called: physicalenvironmet.conditions.light.flickering and still have precise selection, subscribing topics considered light: physicalenvironmet.conditions.light.> so asking if there level restriction subtopics , if there maybe more easy way create hierarchical topic orders. in 10+ yrs of messaging, every hierarchal topic structure ends being replaced, b/c taxonomy never works out. overall message pattern suggests moderate total volume, suggest flexible event model use fields define variance vs topic names eventtype="environmental" sensortype="light". allows add new ones , have option of filtering out clien...

c - Prints numbers in a certain sequence or series -

i trying write code in c print @ given range (0 - 100). x print 0 3, , 8 11, , 16 19 , on. y print rest, example 4 7, , 12 15, , 20 23 , on. the output should this: x = 0 1 2 3 8 9 10 11 ... 93 94 95 96 y = 4 5 6 7 12 13 14 15 ... 97 98 99 100 progress far: #include <stdio.h> main () { int i, limit, k, divisor; limit = 100; divisor = 4; (i = 0; < limit; i++) { k = i; k = % divisor; printf ("%d \n ", k); } } but prints 0 3, , keeps repeating. what's wrong? using % won't far... k = % divisor; make sure k somewhere between [0,4] (since divisor = 4 ) not want. what using 2 loops? int main(){ int i,j; for(i = 0; < 100; i+=8){ // increment 8 make 0 -> 8 -> 16 jumps for(j = 0; j < 4; j++){ // print 4 values x , y, starting initial value i, , i+4 printf("x = %d\ty = %d\n", i+j, i+j+4); } } return 0; }

c# - How can I update an area route after the website is started? -

i trying update route table after application has started. doing in mvc area called "pages". website has custom urls each customer: www.mydomain.com/pages/companyname/ it works fine when start website. picks existing customers urls , can navigate them: public override void registerarea(arearegistrationcontext context) { context.routes.ignoreroute("{resource}.axd/{*pathinfo}"); list<customer> custs = new custbll().getactivecustomers(); string urllist = string.join("|", custs.select(c => c.urlidentifier).toarray()); context.maproute( "pages_custurl", // route name "pages/{custurl}/{controller}/{action}/{id}", // url parameters new { controller = "home", action = "index", id = urlparameter.optional }, // parameter defaults constraints: new { custurl = urllist } ); context.maproute( ...

Explanation on Angular CLI 1.2.4 command ng build -

i learning angular4 , wondering ng build , ng build --prod us. when running ng build, there are, instance main.bundle.js, main.bundle.js.map , generated inside dist folder but ng build --prod, there only, instance main.90e798078cb11a3159ce.bundle.js , generated inside dist folder can please explain how ng build work , without --prod thank you according angular-cli documentation: both --dev/--target=development , --prod/--target=production 'meta' flags, set other flags. if not specify either --dev defaults. and difference between them explained in link: https://github.com/angular/angular-cli/wiki/build#--dev-vs---prod-builds flag --dev --prod --aot false true --environment dev prod --output-hashing media --sourcemaps true false --extract-css false true

node.js - How do I prevent Slack RTM from flooding bot with messages on connect? -

i'm trying use slack's rtm receive (and send) messages using rtmclient class included in slack's @slack/client npm package. issue appeared other packages, that's not causing problem. when i'm running bot, after connecting lots of messages flood in. messages have been sent while ago , have been received previous times ran bot. want bot receive messages sent in runtime. so, example, want bot respond user says. should that: run bot, user writes something, bot responds. goes like: run bot, bot receives whole (?) chat history , responds that. i know, check each message if timestamp approximately now, don't think that's recommended. how fix this?

android - Here Maps JS API v3 doesnt work in Xamarin app at Android18 platform -

i got xamarin application use here maps. have web view, web page here maps scripts loaded: <head> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1.0,width=device-width" /> <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-ccuebr6csya4/9szppfrx3s49m9vuu5bgtijj06wt/s=" crossorigin="anonymous"></script> <script type="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"> </script> <script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script> <!--here places--> <script type="text/javascript" charset="utf-8" src="https://js.api.here.com/v3/3.0/mapsjs-core.js"></script> <script type="text/...

android - Dynamically added EditText is not visible when created -

i have been reading how dynamically add edittext field linear layout, every-time user clicks textview (which has onclick listener attached). i have had mild success - know edittext field being created because when button clicked, other elements move if being added screen. my problem edittext aren't visible , haven't clue why is, appreciated. the app isn't crashing nothing add in terms of stacktrace , log, far app concerned, being created. <?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:fillviewport="true"> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/linearla...

javascript - How to evaluate front-end frameworks? -

i understand how conduct independent evaluation of available popular js front-end frameworks (react/redux, vue, angular , others) use in new app trying build ground up. many references online end conclusions , rates 1 framework on another. however, find difficult relate with. say, 1 report says learning curve vue simpler jsx react. don't find argument meaningful since depends on one's exposure , idea of modularizing ui component. so, question raised receive mixed bag of evaluation suggestions/strategies/schemes conduct independent inquiry these available , popular frameworks. what themes , approaches can consider evaluate popularly available front-end frameworks ? please advise. the community behind framework 1 of important factors me. want able find answers on stack overflow questions, , want able find libraries , packages can use actively maintained. i react of because easy integrate other backend framework e.g. rails.

android - Retrieve data from Google Books Api -

i'm new android , using web apis, , i'm writing android app scans barcode book , search isbn in google books api. i have url after barcode scan: https://www.googleapis.com/books/v1/volumes?q=isbn:9788432250651&aizasycpyez5556x4uzpv6rf4kkspj9dscs_q_c and next code: private class getbookinfo extends asynctask <view, void, integer> { @override protected integer doinbackground(view... urls) { // make call url makecall("https://www.googleapis.com/books/v1/volumes?" + "q=isbn:" + ean_content + "&aizasycpyez5556x4uzpv6rf4kkspj9dscs_q_c"); //print call in console system.out.println("https://www.googleapis.com/books/v1/volumes?" + "q=isbn:" + ean_content + "&aizasycpyez5556x4uzpv6rf4kkspj9dscs_q_c"); return null; } @override protected void onpreexecute() { ...

How change default channel on Spring Integration Flow with Java DSL -

i not understand well, can change error channel integration flow. need handle exceptions invalidaccesstokenexception can thrown in subflow inside router. what i've tried handle exceptions default channel "errorchannel" by: @bean public integrationflow errorflow() { return integrationflows.from("errorchannel") .handle("errorservice", "handleerror") .get(); } this error treated method following signature: void handleerror(message<exception> exception) but default behavior persists, still shows trace console. so question is: in java dsl how can configure error channel? possible map group of exceptions particular error channel make management service of group more cohesive?. the configuration of integration flow explain below: @configuration @integrationcomponentscan public class infrastructureconfiguration { private static logger logger = loggerfactory.getlogger(infrastructureconfiguration.class); ...

arrays - Unable to load more than 23 items from jquery cookie -

this question has answer here: what current cookie limits in modern browsers? 3 answers i looking way save/load array jquery cookie , used top answer of question how store array in jquery cookie? can add many items cookie list want , right number when check array length. refresh page , load cookie list, maximum of 23 items in array, , can't find reason it. here's code //this not production quality, demo code. var cookielist = function(cookiename) { //when cookie saved items comma seperated string //so split cookie comma original array var cookie = $.cookie(cookiename); //load items or new array if null. var items = cookie ? cookie.split(/,/) : new array(); //return object can use access array. //while hiding direct access declared items array //this called closures see http://www.jibbering.com/faq/faq_notes/closur...

java.lang.IllegalAccessError while using spring batch to get the list of executions -

i getting error when trying run spring batch load list of executions. java.lang.illegalaccesserror: tried access method org.springframework.batch.core.repository.dao.jdbcjobexecutiondao.getjobparameters(ljava/lang/long;)lorg/springframework/batch/core/jobparameters; class org.springframework.batch.admin.service.jdbcsearchablejobexecutiondao after doing analysis, found jdbcjobexecutiondao part of spring-batch , has implementation of getjobparameters() protected method while, jdbcsearchablejobexecutiondao part of spring-batch-admin has extended jdbcjobexecutiondao. so per oracle documentation, says illegalaccesserror - thrown if application attempts access or modify field or call method not have access to. normally, error caught compiler; error can occur @ run time if definition of class has incompatibly changed. i don't understand, don't have control on these jars/classes. doing wrong while using them? or there problem versions using both ...

Implementing angular 2 set title tag -

i'm trying adapt example ( https://angular.io/guide/set-document-title ) implementation, has more pieces. don't yet understand angular 2 pieces , how fit together. their main.ts: import { platformbrowserdynamic } '@angular/platform-browser-dynamic'; import { appmodule } './app/app.module'; platformbrowserdynamic().bootstrapmodule(appmodule); mine: import { enableprodmode } '@angular/core'; import { platformbrowserdynamic } '@angular/platform-browser-dynamic'; import { appmodule } './app/app.module'; import { environment } './environments/environment'; if (environment.production) { enableprodmode(); } const platform = platformbrowserdynamic(); platform.bootstrapmodule(appmodule); ok far. their app.module: import { ngmodule } '@angular/core'; import { browsermodule, title } '@angular/platform-browser'; import { appcomponent } './app.component'; @ngmodule({ imports: [ b...

How to extract string inside a string in python? -

need solution bellow code. variable = ' "value" ' how variable = 'value' thanks try: variable.replace("\"","").strip() replace replaces double quotes nothing (removes it) , strip() removes trailing , leading spaces

How to migrate Maven Release Plugin to from SVN to Git? -

we in process of moving our projects svn git. use maven release plugin mvn release:prepare , mvn release:perform our packages. along that, modifying pom.xml file scm properties point our git repositories. however, following error when run mvn release:prepare : [error] failed execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project myproject: unable check local modifications [error] provider message: [error] svn command failed. [error] command output: [error] 'svn' not recognized internal or external command, [error] operable program or batch file. [error] -> [help 1] [error] [error] see full stack trace of errors, re-run maven -e switch. [error] re-run maven using -x switch enable full debug logging. [error] [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/mojofailureexception why still attempting execute cmd.exe /x /c...