Posts

Showing posts from April, 2011

c++ - libconfig++ : adding a setting to the root of the configuration tree -

i have configuration file mycfg.cfg looks : keya = 1.0 keyb = 2 keyc = "hello" note settings @ root of configuration tree. i want c++ program load file add new setting key keyd , assign integer value 5 . eventually, mycfg should in memory : keya = 1.0 keyb = 2 keyc = "hello" keyd = 5 first mycfg.cfg file loaded construct mycfg . setting keyd must added root of mycfg . libconfig documentation indicates setting::add() method : add[s] new child setting given name , type setting, must group however, there isn't group in mycfg … how add setting root of config object ? it looks need is: getroot () . here example: #include <iostream> #include "libconfig.h++" int main () { libconfig::config mycfg; std::string file = "mycfg.cfg"; try { mycfg.readfile (file.c_str () ); libconfig::setting & root = mycfg.getroot (); // works. // libconfig::setting & ro

android - Selector for a drawable within an EditText -

i have edittext drawableend. want change drawable when it's pressed. i've created selector no image visible now. possible in way or maybe i'm doing wrong? layout <edittext android:drawableend="@drawable/selector" android:layout_height="wrap_content" android:layout_width="match_parent"/> selector <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/image_on" android:state_enabled="true" android:state_pressed="true"/> <item android:drawable="@drawable/image_off" android:state_enabled="true"/> </selector> your selector seems wrong, have declare 1 statement in 1 item. , set 2 items state_enabled="true". needs be: <item android:drawable="@drawable/pressed_image" android:state_pressed="

java - Button copying text to clipboard -

i trying copy text clipboard when button pressed. have found other questions this, can't figure out code. here code trying use now: button button = (button)this.findviewbyid(r.id.button1); clipboardmanager clipboard = (clipboardmanager) getsystemservice(context.clipboard_service); clipdata clip = clipdata.newplaintext("label","woop woop in clipboard"); clipboard.setprimaryclip(clip); but confused on how button action. use button onclicklistener button.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { clipboardmanager clipboard = (clipboardmanager) getsystemservice(context.clipboard_service); clipdata clip = clipdata.newplaintext("label", "woop woop in clipboard"); clipboard.setprimaryclip(clip); }});

javascript - Js changes are not reflecting in the browser unless we redeploy the war file -

i have developed spring boot web application using intellij. every js , html change have redeploy war file in order changes reflected on browser. there way changes reflected on fly without redeploying? you can implement real time caching nginx. create seperate project css , ui related changes , link assets folder of nginx. have start nginx server. when u changes in files, no need restart server again , again. more info https://www.nginx.com/blog/scaling-web-applications-nginx-part-ii-caching-monitoring/#caching

javascript - Angular Datatables: Unknown provider -

hej guys. i'm new js , angular trying implement angular-datatable version in project. first used "angular-way", turned out bad decision based on performance. have lot of rows in table. i've decided try building datatable ajax , building columns dtoptionsbuilder , filling table using dtoptions. however, i'm having complications... unkown provider error.. more specifically: error: [$injector:unpr] unknown provider: datatablesprovider <- datatables <- overviewctrl i'm not quite sure, i'm doing wrong? here's controller. angular.module("invoices").controller("overviewctrl", ["apiservice", "datatables", 'utilsservice', "$q", "invoiceservice", "ngdialog", "$controller", "authfactory", "redirectservice", "$rootscope", overviewctrl]); function overviewctrl(apiservice, utilsservice, dtoptionsbuilder, dtcolumnbuilder,

windows - How to get the ODBC name from this trace logs that an application is using to connect -

how odbc name trace logs application using connect (in case: firebird database) autoreps 1f8c-140c enter sqlallocenv henv * 0x5d67b1ac autoreps 1f8c-140c exit sqlallocenv return code 0 (sql_success) henv * 0x5d67b1ac ( 0x02e61078) autoreps 1f8c-140c enter sqlgetenvattr sqlhenv 0x02e61078 sqlinteger 201 <sql_attr_connection_pooling> sqlpointer 0x0012ea64 sqlinteger 4 sqlinteger * 0x0012ea60 autoreps 1f8c-140c exit sqlgetenvattr return code 0 (sql_success) sqlhenv 0x02e61078 sqlinteger 201 <sql_attr_connection_pooling> sqlpointer 0x0012ea64 (0) <sql_cp_off> sqlinteger 4 sqlinteger * 0x0012ea60 (0) autoreps 1f8c-140c enter sqlallocenv henv * 0x5d

audiounit - Reading chunks of audio with ringbuffer -

i analyze chunks of audio data of 1 second. purpose implemented audio unit fills ringbuffer (tpcircularbuffer michael tyson). in file try read chunks of 1 second using nstimer. unfortunately, receive errors consuming these data. the buffer filled in kaudiooutputunitproperty_setinputcallback , works fine device * = (__bridge device *)inrefcon; // render audio buffer audiobufferlist bufferlist; bufferlist.mnumberbuffers = 1; bufferlist.mbuffers[0].mnumberchannels = 2; bufferlist.mbuffers[0].mdata = null; bufferlist.mbuffers[0].mdatabytesize = innumberframes * sizeof(sint16) * 2; checkerror(audiounitrender(this -> riounit, ioactionflags, intimestamp, 1, innumberframes, &bufferlist), "audiounitrender"); // put audio circular buffer tpcircularbufferproducebytes(&circbuffer, bufferlist.mbuffers[0].mdata, innumberframes * 2 * sizeof(sint16)); to read 1 second of samples implemented te following code: - (void)initializetimer { timer = [nstimer sche

openlayers 3 - How to extrude height ol3-Cesium? -

i've got geojson can load in ol3 without problems. var layer = new ol.layer.vector({ source: new ol.source.vector({ format: new ol.format.geojson(), url: 'my_file.json', }) }); my geojson have got properties (let's foo ) want use extrudedheight . i've done in cesium (see cesium exemple): http://cesiumjs.org/cesium/apps/sandcastle/index.html?src=geojson%20and%20topojson.html&label=showcases but can't find way on ol3 layer. any clue ? edit: i've hacked bit , create featureconverter this: test = {}; function extend(base, sub) { // avoid instantiating base class setup inheritance // see https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/object/create // polyfill // also, recursive merge of 2 prototypes, don't overwrite // existing prototype, still maintain inheritance chain // @ccnokes var origproto = sub.prototype; sub.prototype = object.create(base.prototype); (

How do I make variables in PHP and pass them to Ruby? -

i have script running in ruby, , in php, and, needs it's not possible make run in same scripting language. i want use php create variable in ruby. currently, have code: php: $config = fopen("config.txt","w+"); fwrite($config,$sarguments); fclose($config); ruby: while true file = file.new("config.txt", "r") config = file.gets file.close end the php write next configuration in file , ruby read , turn variable. works, ruby has work on reading , reading file, , fail read correct, code badly optimized. is there faster way pass information php script ruby script? i'm no expert in php think " how run ruby code python (python-ruby bridge) " provides ways of how accomplish communication between 2 languages. although page speaks of ruby-python communication, i'm pretty sure of suggestions can implemented ruby , php. one solution use xml-rpc transfer simple data types php ruby. ruby has native support xml-r

Applying bootstrap styles to django forms -

i want use bootstrap decent website design, unfortunately don't know how style form fields. talking this: <form class="form-horizontal" method="post" action="."> {% csrf_token %} {{ form.title.label }} {{ form.title }} </form> how 1 supposed design this?? tried this: <form class="form-horizontal" method="post" action="."> {% csrf_token %} <div class="form-control"> {{ form.title.label }} {{ form.title }} </div> </form> this didn't gave me wanted results. how can apply bootstrap styles django forms? if prefer not use 3rd party tools need add attributes classes, prefer having base class model forms inherit from class bootstrapmodelform(modelform): def __init__(self, *args, **kwargs): super(bootstrapmodelform, self).__init__(*args, **kwargs) field in iter(self.fields): self.fields[field].widget.attrs.upda

c++ - Zeromq zmsg unwrap returns empty address -

im trying simple req - router example using zmsg, seems when unwrap message, address invalid. as example: client.cpp zmq::socket_t *client = new zmq::socket_t (context, zmq_req); int linger = 0; client->connect ("tcp://localhost:5555"); client->setsockopt (zmq_linger, &linger, sizeof (linger)); std::string identifier = "mdpc01"; std::string body = "im saying hi!"; zmsg *request = new zmsg(body.c_str()); request->push_front((char *)identifier.c_str()); request->send(*client); broker.cpp zmq::context_t context(1); zmq::socket_t frontend (context, zmq_router); zmq::socket_t backend (context, zmq_router); frontend.bind("tcp://*:5555"); // clients backend.bind("tcp://*:5556"); // workers std::vector<zmq::pollitem_t> items = {{static_cast<void *> (backend), 0, zmq_pollin, 0}, {static_cast<void *> (frontend), 0, zmq_pollin, 0}}; zmq::poll (items, -1); if (items [1].revents & zmq_p

javascript - jQuery does not find element with ng-repeat -

i have view ng-repeat : <div ng-controller="logbtnctrl"> <li class="item log-btn" ng-repeat="logitem in logbtns"> <div class="log-btn--graph">5,3,9,6,5,9,7</div> </li> </div> i want call jquery('.log-btn--graph') after view rendered. angular.controller('logbtnctrl', function($scope, todaylogbtns) { $scope.logbtns = [0,1,2,3,4]; $scope.$watch('logbtns', function() { console.log('a', $('.log-btn--graph').length); }); console.log('b', $('.log-btn--graph').length); }); but gives b 0 , a 0 . after view rendered, can manually $('.log-btn--graph').length 5 in console. so guess when call @ b , a , view not rendered yet. then, should put calling of $('.log-btn--graph').length make sure it's 5? as have $watch in controller method. so, instead of looking dom nodes have watch on collectio

php - Database driven select box being empty on submit -

i trying submit form value in database php. in form select box value comes database. <?php include_once 'header.php'; $sql="select uid,name emitra_basic block='$user'"; $result = $conn->query($sql); //form validion if(isset($_post['submit'])) { $eid =$_post["eid"]; if($eid=="blank") { $flag=1; $iderr="please select e-mitra"; } $miatm =trim($_post["miatm"]); if(empty($miatm) || !preg_match("/^[a-za-z0-9 ]*$/",$miatm)) { $flag=1; $mierr="please enter valid id"; } .............like if($flag==0) { $sqll="insert **********"; } //my form is <form id="basic" method="post" name="basic"> <select class="select-style gender" name="eid"> <option value="blank">please select e-mitra id</option> <?php while($row=mysqli_fetch_array($result)) { ?> <o

math - Determine the distance of a Vector 3 along another Vector 3 -

Image
i have 2 3d vectors. (objects x, y , z float values) in diagram below, determine length of green line. distance along vector 1 vector 2 is. or, distance origin end of line on vector 1 @ 90' vector 1 , passes thorough point @ end of vector 2. i doing in unity3d have access quite few helper methods enable me length of vector3 , on easily. the length obviously norm(v2)*cos(angle(v1,v2)) and since cos(angle(v1,v2))=abs(dot(v1,v2))/norm(v1)/norm(v2) the final formula is abs(dot(v1,v2))/norm(v1) one e1 = v1/norm(v1) is unit vector in direction of v1 , , green vector is dot(e1,v2)*e1 resulting in same length formula.

javascript - How to select only the first element after class? -

i have dropdown menu. want dynamic can tell li (in nav ) dropdown , give list afterwards dropdown content. problem when click on link .dropdown class shows elements .dropdown-content class. idea of smart selector work here? my html: <li><a class="dropdown" href="#">gallery</a> <ul class="dropdown-content"> <li><a href="#">photos on me</a></li> <li><a href="#">photos of me</a></li> <li><a href="#">photos me</a></li> </ul> </li> <li><a class="dropdown" href="#">blog</a> <ul class="dropdown-content"> <li><a href="#">photos on me</a></li> <li><a href="#">photos of me</a></li> <li&

c# - List and create in same view in asp.net mvc -

i have following model classes public class productviewmodel { public product products { get; set; } public ienumerable<product> lproducts { get; set; } } public partial class product { public string id { get; set; } public string detail { get; set; } } then have following view both list , create @model albaraka.models.productviewmodel <table class="table"> <tr> <th> id </th> <th> detail </th> </tr> @foreach (var obj in model.lproducts) { <tr> <td> @html.displayfor(modelitem => obj.id) </td> <td> @html.displayfor(modelitem => obj.detail) </td> </tr> } </table> <div> @using ()) { <div> <fieldset> <leg

Android volley library doesn't keeping good quality image -

i using volley library download image network , retain image in cache later usage. volley serving need.but strange behavior is, keeps quality image based on network speed , surprised me that, in 2g network keeps poor quality image in wi-fi, keeps quality. stuck here find out root cause of behavior. if have faced problem before , please share knowledge happening in library, why behaving differently on different speed, how can keep same quality irrespective of speed. thanks volley library manage network speed automatically can't adjust it. if want image quality every time can use following image loader universal image loader facebook fresco

How to display the current date in ms since epoch in PHP? -

i display today's date number of ms since epoch i know can use microtime(true) / 1000 to so, strip hour, minutes, ms result. 2016/01/28 00:00:00 in ms. of course example, want date current day. idea on how in php ? how simply echo sprintf('%d',strtotime('midnight')); $midnight_lastnight=strtotime('midnight - 24hours'); $midnight_tonight=strtotime('midnight'); $midnight_tomorrow=strtotime('midnight + 24hours'); echo '<pre>'; echo $midnight_lastnight.' '.date( 'y-m-d h:i:s', $midnight_lastnight ); echo $midnight_tonight.' '.date( 'y-m-d h:i:s', $midnight_tonight ); echo $midnight_tomorrow.' '.date( 'y-m-d h:i:s', $midnight_tomorrow ); echo '</pre>'; outputs: -------- 1453852800 2016-01-27 00:00:00 1453939200 2016-01-28 00:00:00 1454025600 2016-01-29 00:00:00

Regex - Matching two numbers before a certain string -

how match 2 numbers before word "min" sample string: 15min i want match: 15 edit: i've tried matching pattern, how 2 characters before? \w*((?i)min(?-i))\w* here's regex extracts first number in string: ^\d*(\d+).*$ if number must in front of min , can write as: ^\d*(\d+)min.*$

How do I convert a string into an integer in JavaScript? -

how convert string integer in javascript? the simplest way use native number function: var x = number("1000") if doesn't work you, there parseint , unary plus , parsefloat floor , , math.round methods. parseint: var x = parseint("1000", 10); // want use radix 10 // decimal number leading 0 , old browser ([ie8, firefox 20, chrome 22 , older][1]) unary plus if string in form of integer: var x = +"1000"; if string or might float , want integer: var x = math.floor("1000.01"); //floor automatically converts string number or, if you're going using math.floor several times: var floor = math.floor; var x = floor("1000.01"); if you're type forgets put radix in when call parseint, can use parsefloat , round like. here use floor. var floor = math.floor; var x = floor(parsefloat("1000.01")); interestingly, math.round (like math.floor) string number conversion, if want number round

java - Jython 2.7.0 with jersey -

i using jython standalone version 2.5.3 in rest application. working fine. when upgraded jython 2.7.0, getting following exception, javax.servlet.servletexception: org.glassfish.jersey.server.containerexception: javax.xml.transform.transformerfactoryconfigurationerror: provider org.python.apache.xalan.processor.transformerfactoryimpl not found

c++ - When using Lambdas, is it more performant to pass by value through the capture clause or through passing as a parameter? -

this question came mind, , don't know how figure out. let me show mean: int x = 1; auto lambda1 = [x](){ // x, not specified here though } auto lambda2 = [](int x){ // x, not specified here though } lambda1(); lambda2(x); let's assume have either lambda1 or lambda2 @ given time. which function faster in case? pretty sure difference minimal, if there difference @ all, caught interest , i'd know! this might stupid ask if working 1 int, there might measurable difference in larger scaled lambdas. the first 1 translates to struct _ { int x; _(int x_): x(x_) {} void operator()() const {...} }; the second 1 translates to struct _ { _() = default; void operator()(int x) const {...} }; the former may have various effects* around closure construction site, latter may have same effects* around closure call site. * - depends

r - how to set colors of columns in googleCharts? -

gviscolumnchart(df,options = list(gvis.editor="edit chart!",width=500,height=500,colors=df$color)) how put vector state that, colors want of columns in chart? go through link chart.draw(data, { width: 400, height: 240, title: 'toppings on pizza', colors: ['#e0440e', '#e6693e', '#ec8f6e', '#f3b49f', '#f6c7b6'], is3d: true }); https://developers.google.com/chart/interactive/docs/customizing_charts

oracle - Trying to understand how pl sql stored proc work and why my results differ -

i have simple stored proc... create or replace procedure get_person (aname varchar2, p_data out sys_refcursor) begin open p_data select * people_table firstname = aname; end; however when execute stored proc returns of records. declare v_cur sys_refcursor; v_1 number; v_2 varchar2(50); v_3 varchar2(200); v_4 varchar2(50); v_5 varchar2(50); v_6 varchar2(50); begin get_person ('aaa@bbb.com', v_cur); loop fetch v_cur v_1, v_2, v_3, v_4, v_5, v_6; exit when v_cur%notfound; dbms_output.put_line(v_2 || ' ' || v_3); end loop; close v_cur; end; if run simple statement select * people_table firstname = 'aaa@bbb.com'; it correctly returns 1 record. why stored proc not behaving same? i found issue.. my issue name collision. when altered code above when noticed issue. has fistname = firstname. once changed parameter p_firstname well.

java - what is the best way of iterate a arraylist -

this question has answer here: java: best way iterate through collection (here arraylist) 6 answers i have these 5 way iterate through arraylist , these are public static void main(string[] argv) { // create list list<string> alist = new arraylist<string>(); // add 4 different values list alist.add("ebay"); alist.add("paypal"); alist.add("google"); alist.add("yahoo"); // iterate via "for loop" system.out.println("==> loop example."); (int = 0; < alist.size(); i++) { system.out.println(alist.get(i)); } // iterate via "new way loop" system.out.println("\n==> advance loop example.."); (string temp : alist) { system.out.println(temp); } // iterate via "iterator loop" syste

Windows Phone 8.1 Push Notifications BackgroundTask won't start -

i working on push notification in windows phone app , having issues. from time time backgroundtask responsible push notification handling isn't wake know it- cause i've spread logs after each code line in task. i know sure token valid , getting notifications server. this happens when debugger not attached. don't see exception either in log. i can see in logs, 1 line before showing toast cut @ end in middle of writing (guess task terminated suddenly?) any ideas can cause behavior? i think main problem tried use many of cpu time , while writing logs , using heavy application services (mvvmcross) such sqlite. after removing logs, , heavy consuming time operations - worked :)

c# - Binding multiple buttons to a event handler -

i don't have experience on events & delegates. been trying found on , other sources on internet past few days. what i'm trying custom onpagechange event our custom pagination. after (hopefully) did that, i'm told 3 more things; 1 - "onclick event" inside our control 2- making linkbuttons call onclick event 3- raising onpagechange event buttonclick of linkbuttons. so far did these; inside our custom pagination control (name pagingcontrol) public class pagechangeeventargs : eventargs { private int pagenum; public pagechangeeventargs(int pagenum) { this.pagenum = pagenum; } public int page { { return pagenum; } } } public class clickeventargs : eventargs { public clickeventargs() { } } public delegate void pagechangehandler(object sender, pagechangeeventargs e); public delegate void pagechangeclickhandler(object sender, clickeventargs e); //-------------

ruby on rails - How to force Twitter Single Sign-On to use https on port 443 -

i have set rails application uses twitter single sign-on. in twitter configurations, call looks following: https://somesite.com/users/auth/twitter but redirect code https://api.twitter.com/oauth/authenticate?oauth_token=someoauthtoken has following code in html: <meta http-equiv="refresh" content="0;url=https://somesite:80/users/auth/twitter/callback?oauth_token=someoauthtoken&oauth_verifier=someoauthverifier”> how force twitter single sign-on use https on port 443? i tried changing callback setting in twitter account https://somesite.com:443/users/auth/twitter still uses port 80 on redirect. any appreciated. update does have ruby on rails application using https twitter callback? not suppose use https if using twitter single sign on? so going through problem, here solve problem form me. i added middleware changes server port 443 env['server_port'] = '443' unless env['server_port'] == '443' so

business objects - Giving Rights to users to export report only in webi -

i have query access right should give user wherein in webi report play sliders , export report excel locally shuould not able save file in way view --->playwithit---->and export excel. thanks , regards gaurav view on demand. user able save report excel file. not able edit/save.

c - g_hash_table: int64 as key -

i using glib g_hash_table create hash table, int64 key , pointer value. i tried code fails: ghashtable* hash = g_hash_table_new(g_int64_hash, g_int64_equal); uint64_t mer_v = 0; exist_m = g_hash_table_lookup(hash, mer_v); it reports error: (gdb) bt #0 ia__g_int64_hash (v=0x1d89e81700000) @ /build/buildd/glib2.0-2.24.1/glib/gutils.c:3294 #1 0x00007ff2de966ded in g_hash_table_lookup_node (hash_table=0x13a4050, key=0x1d89e81700000) @ /build/buildd/glib2.0-2.24.1/glib/ghash.c:309 #2 ia__g_hash_table_lookup (hash_table=0x13a4050, key=0x1d89e81700000) @ /build/buildd/glib2.0-2.24.1/glib/ghash.c:898 i used glib data structure quite often, never tried hash_table key int64. cannot find google. tutorial not have hits well: http://www.ibm.com/developerworks/linux/tutorials/l-glib/section5.html . please help. thanks. to use g_int64_hash , g_int64_equal need store addresses of 64-bit keys in hash table. so, correct lookup be: exist_m = g_hash_table_lookup(hash, &

javascript - Add animation to scrolling down to a specific div in jquery -

hello there i'm using following code scroll bottom @ specific div, , working fine but, speedy, want scroll specific element, know can jquery , i've been trying different codes hours now, can please me respect code, thankyou. <script> $(document).ready(function(){ $(".cat-anchor").click(function(){ $('html','body').animate({scrolltop: $(".cat-title").offset.top},'slow'); }); }); </script> <div class="bran-cat"> <h2>category</h2> <div class="cat-list"> <?php foreach($cat_arr['cat_pro'] $cat_name){ echo "<a class='cat-anchor'>".">".$cat_name[1]."</a> <br>"; } //$sel_cat= $wpdb->get_results("select * "); ?> </div> </div> <?php foreach($cat_arr['cat_pr

asp.net mvc - Set value for joined table in MVC Razor -

i'm trying create razor page windows auth mvc app tracks created record. basic idea looks this: public class user { public int id {get;set;} public string networkid {get;set;} } public class event { public int id {get;set;} public int userid {get;set;} public datetime created {get;set;} public virtual user user {get;set;} } on razor page, i'm trying create hiddenfor set user id , can't post correctly. setting created field works correctly ( @html.hiddenfor(model => model.created, new { value = datetime.now }) ), userid won't set. this doesn't work: @html.hiddenfor(model => model.user.networkid, new { value = user.identity.name }) this throws null reference exception: @{ model.user.networkid = user.identity.name; } @html.hiddenfor(model => model.user.networkid) there has easier way this, other looking networkid on table , pulling actual primary key. any ideas?

Appending CRC (Checksum) to data stream serial port communication C++ -

Image
i appending crc data stream. using serial port libary rs-232 linux , windows. i want same value 1 displayed on comport tool picture: i using const char[4086]="123456789"; buffer. crc returned bb3d convert unsigned short char * . #define serialport_bufsize 4088 char *im_buf = (char *)malloc(serialport_bufsize + 8); char *tx_buf = (char *)malloc(serialport_rcv_bufsize + 8); const char buf[serialport_bufsize]="123456789"; strcpy(im_buf, buf); writetoserialport(); // call function void serialportcom::writetoserialport(void) { if(!port_open) return; int i,n, tmp, tmp2; if(newline == 1) { strcat(im_buf, "0a"); } else if(newline == 2) { strcat(im_buf, "0d"); } else if(newline == 3) { strcat(im_buf, "0d0a"); } n = strlen(im_buf) / 2; if(n < 1) return; for(i=0; i< n; i++) { tmp = im_buf[i*2]; if((tmp >=

php - Twig shuffled array including duplicates when it shouldn't -

i have simple array of values. need output "random" subset of contents without duplications. however, i've got far including duplicates. the server not have twig array extension installed don't have access shuffle filter. oh, , if there's better approach, i'm open suggestions. {% set arrimgs = {'0':'a','1':'b','2':'c','3':'d','4':'e','5':'f','6':'g','7':'h'} %} {% set outputqty = 5 %} {% set randomizedarr = [] %} {# create new array of randomly selected elements (just shuffle order) , limit result outputqty #} {% in 0..100 if randomizedarr|length < outputqty %} {% set tmpimg = [random(arrimgs)] %} {% if tmpimg not in randomizedarr %} {% set randomizedarr = randomizedarr|merge(tmpimg) %} {% endif %} {% endfor %} {% img in randomizedarr %} {{ img }}, {% endfor %} as there e

forms - send queue number after logging in -

in app, everytime user logs in, server determine his/her queue number day , send client , client needs send each request. problem is, how do this? can embed queue number in response (after credential submission, response payload can't reached anymore). putting queue number in redirect seems unsafe tls. well can use xhr request login. doing this, login process done in background , don't have redirect. , once retrieve queue number xhr request, can use further request or redirect.

asp.net - Can a WebForms class be used to call a wcf (within the same .net .sln) service function? -

we have .net v4.5.1 solution (.sln) contains webforms project , wcf project. set "prove" or "test" wcf service. wcf function work takes in parameter of list(of clsrec_taskparam). have declared of datacontract , datamembers in wcf code files. 'clsrec_taskparam' complex class contains number of other complex classes. wcf wsdl reflects these complex classes expected. this wcf service intended non-public, used background task webforms application not hang page during long-process of wcf-service. the same class code-file (containing of these classes) contained in each project. the problem??? question??? when call service button-click follows: dim bret boolean = false dim osrvc = new genpdfservice.genpdfserviceclient m_lsttaskparams = ctype(session("clstask01"), list(of clsrec_taskparam)) bret = osrvc.genpdfs(m_lsttaskparams) the compiler indicates on last code line, error 1 value of type '1-dimensional array of c

ios - Transferring UITableView Section to Another TableView -

i set transfer section 1 of tableview tableview. done moving didselectrow: rows. however, issue when attempt move section when every row selected (and there nothing in section 0) crashes index beyond bounds error. i using boilerplate code sectionheaders due section 1 header changing section 0 header when items selected in section 1. believe causing index out of bounds error, not sure how correct it. my sections set as: func numberofsectionsintableview(tableview: uitableview) -> int { let numberofsections = frc.sections?.count return numberofsections! } //table section headers func tableview(tableview: uitableview, titleforheaderinsection section: int) -> string?{ let sectionheader = "items needed - #\(frc.sections![section].numberofobjects)" let sectionheader1 = "items in cart - #\(frc.sections![section].numberofobjects)" if (frc.sections!.count > 0) { let sectioninfo = frc.sections![section] if (sectioninfo.na

opencv - Is EarthMoverDistance with signatures having 1 column supported? -

it documented if want use emd weights stored columns in signatures can given give user defined cost matrix. well, problem doesn't work, function crashes if try that. sure is indeed supported? here pseudcode if interested. if (weightsonly) { signature1.create(h,1,cv_32fc1) signature1.create(h,1,cv_32fc1) //fill in signature 1 //fill in signature 2 emd = emd(signature1, signature2, mp[metricspace], cost_mat, 0, flow); } this crashes function. this stupid question ask :) it works, passing wrong metric, given want use cost matrix need specify metric cv_dist_user

php - Registration form SQL syntax error -

i'm trying make simple registration form. when error says have error in sql syntax. but says have problem on line wrote: $stmt->execute(); i guess it's because can not execute sql question? my code: <?php require 'anslut.php'; $submit = filter_input(input_post, "submit", filter_sanitize_special_chars); $output = ""; if (isset($submit)) { $name = filter_input(input_post, "name", filter_sanitize_special_chars); $username = filter_input(input_post, "username", filter_sanitize_special_chars); $password = filter_input(input_post, "password", filter_sanitize_special_chars); if ($name == "" || $username == "" || $password == "") { $output .= "all fields must entered"; } else { $sql = "insert users(username, password, namn) values :username, :password, :name"; $stmt = $dbh->prepare($sql); $stmt->bindparam(":username&q

not well-formed in firefox when parsing XML using jquery -

the following code writes warning in firefox console, not in chrome. in both cases, result correct. $('status', $.parsexml("<root><status>1</status></root>")).text() i understand wrong. suggestion? use: <?xml version="1.0"?> at beginning of xml.

angularjs - Set-cookie in response not set for Angular2 post request -

when make put request in angular2, receive expected set-cookie in response. browser (tried both chrome , firefox) refuses set cookie. instead when use angular 1 app making call same api endpoint, cookies set correctly. the response headers are: access-control-allow-credentials:true access-control-allow-origin:http://example.com allow:get, put, head, options content-type:application/json date:thu, 28 jan 2016 14:41:38 gmt p3p:policyref="http://www.example.com/p3p.xml", cp="non dsp cor cura tia" server:wsgiserver/0.1 python/2.7.6 set-cookie:sessionid=994wl49qfsizog5bqmt57sgx9q2toa25; expires=mon, 28-mar-2016 14:41:37 gmt; max-age=5183999; path=/ set-cookie:csrf=u7uqhpaphtsgykru6jfllft6noyahnms; domain=api.example.com; expires=thu, 26-jan-2017 14:41:38 gmt; max-age=31449600; path=/ vary:accept, cookie the backend programmed in django 1.8. does experienced same thing or have suggestion how solve problem? i seems cors-related issue. perhaps try se

Dispatch_Group crash on iPhone 4s/iOS 8 -

i've written method using dispatch_group : class func loadnewevents(incontext context:nsmanagedobjectcontext, completion:(() -> void)?=nil) { ddlogdebug("loading new events") let context = coredatamanager.backgroundcontext() let events = coredatamanager.fetch(event.self, incontext: context) var earliestevent = events.sort({$0.initialtimestamp.integervalue > $1.initialtimestamp.integervalue}).first let group = dispatch_group_create() var loadedevents:[event]? var failure = false while (loadedevents == nil || loadedevents!.count != 0) && !failure { dispatch_group_enter(group); if let earliesttimestamp = earliestevent?.initialtimestamp.longlongvalue { let url = afterurl(earliesttimestamp) getevents(url: url, success: { events in loadedevents = events earliestevent = events.last dispatch_group_leave(group)

javascript - Generate Random URL, but URL length can't be changed fro some reason? -

as of i've been working on site bit of hobby during class. on site there basic text single button , text field. when press button generates random url , can add own extension it. @ moment it's send people random .onion domains. current problem cant length of url set random length. here code, if can recommend fix great. ` <body> <script> var 'x' = math.random() * 20 </script> <script language="javascript" type="text/javascript"> function randomstring() { var chars = "0123456789abcdefghiklmnopqrstuvwxyz"; var string_length = 'x'; var randomstring = ''; (var = 0; < string_length; i++) { var rnum = math.floor(math.random() * chars.length); randomstring += chars.substring(rnum, rnum + 1); } document.randform.randomfield.value = randomstring; } </script> <form name="randform">

java - Can't deploy my web application in Netbeans on Tomcat 8.0.2 (getting below error) -

i have read many threads regarding issue none of solutions worked me. i'm going crazy trying troubleshoot this. web application worked , couple of days ago started receiving following exception when either trying run application or starting tomcat (from netbeans). (rarely) , tomcat start netbeans8.1 still can't deploy application (deployement error: starting of tomcat failed ). 28-jan-2016 15:32:17.947 severe [main] org.apache.coyote.abstractprotocol.init failed initialize end point associated protocolhandler ["ajp-apr-8009"] java.lang.exception: socket bind failed: [730048] 1 usage of each socket address (protocol/network address/port) permitted. @ org.apache.tomcat.util.net.aprendpoint.bind(aprendpoint.java:471) @ org.apache.tomcat.util.net.abstractendpoint.init(abstractendpoint.java:742) @ org.apache.coyote.abstractprotocol.init(abstractprotocol.java:457) @ org.apache.catalina.connector.connector.initinternal(connector.java:960) @

wpf - Simulating Textbox BorderBrush for a Border -

i need border have borderbrush default textbox has. should changed while mouse on , when element within border focused. right near border , there textbox default style. tried code, works @ normal state. <border borderbrush="{binding path=borderbrush, elementname=txtname}" borderthickness="{binding path=borderthickness, elementname=txtname}"> ... </border> <textbox x:name="txtname"/> first of need find out brush textbox style using when you're hovering (check default style). then can define own style border trigger when mouseover true set borderbrush , borderthickness appropiate values.

c - What happens to a double variable when %d is used in a printf? -

so today class teacher give 3 problems , said research @ home.. try hard solution. there no exact article it. the code is: #include <stdio.h> int main(void){ double x = 2.3; printf("%d\n", x); printf("%d, x\n"); printf("%d\n", "x"); } the output is: 1717986918 1717986918, x 4206639 i know need use %lf double. want know problem when used %d. think there memory problem ( 4bit 8bit) or garbage. want know more details problem. assignment. tia what happens double variable when %d used in printf? undefined behavior. you're not supposed misuse format specifiers printf. so working fine program crash sigsegv possibility. what happen tries treat double int , , depending on how os saves these, garbage print.

swift2 - Associated Types in Swift -

what associated types in swift programming language? used for? as per swift programming language book: when defining protocol, it useful declare 1 or more associated types part of protocol’s definition. associated type gives placeholder name (or alias) type used part of protocol. actual type use associated type not specified until protocol adopted. associated types specified typealias keyword. the above text not clear me. lot if can explain associated types example. also, why useful declare associated type part of protocol definition? you have protocol defines methods , perhaps properties implementing type must provide. of methods/properties use or return objects of different type type implementing protocol. so, instance, if have protocol defines types of collections of objects, might define associated type defines elements of collection. so let's want protocol define stack , stack of what? doesn't matter, use associated type act place hold

create form from 2 models python django: [Errno 2] No such file or directory -

i trying create form 2 models using python , django. below shows models: # create models here. class action(models.model): name = models.charfield("action name", max_length=50) keywords = models.charfield("keywords", max_length=50) object = models.charfield("object", max_length=50, blank=true, null=true) uploaddate = models.datefield("date", default=get_current_date) uploadedby = models.charfield("uploadedby", max_length=50, default="") class image(models.model): image = models.filefield(upload_to=get_upload_file_name, default="") action = models.foreignkey(action) and form classes: class actionform(modelform): #bind form action model class meta: model = action fields = ['name','keywords', 'object', 'uploadedby', 'uploaddate'] class imageform(modelform): class meta: model= image fields =['