Posts

Showing posts from August, 2013

c# 4.0 - How to keep an object unique -

i have static datatable (with 80k records) in common.dll , common.dll referred 10 windows services. so, instead of having 10 copies of datatable in memory need have 1 copy , services pointing data source. approach possible? given services @ least using different appdomains, , quite possibly different processes, sharing same data between of them tricky. i suggest don't worry - unless each record pretty large, 80k records still going small. you could potentially have 11th service only 1 have data, , talk service other ones. that's introducing lot of complexity little benefit. one way of potentially saving memory use list<t> custom type, instead of datatable - may more efficient, , more pleasant use within code. doesn't if need datatable whatever you're doing it, try avoid that...

android - Unable to submitscore or show leaderboard although I am able to sign in to Google+ successfully -

in activity: public class menuactivity extends activity implements connectioncallbacks, onconnectionfailedlistener and once connected google+, try calling leaderboard. (just testing) @override public void onconnected(bundle bundle) { try{ startactivityforresult(games.leaderboards.getleaderboardintent(mgoogleapiclient,'myactual_leaderboard_id'), request_leaderboard); } catch (exception e){ } } } startactivityforresult throws nullpointerexception. required api not requested. in manifest.xml meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.gms.games.app_id" android:value="@string/app_id" /> i have added numeric app_id string in string.xml. game details in "ready test" state. does has idea why happening? my mistake. realized have missed ou...

json - Use Google Authentication for Java webportal with SSO -

i new ga(oauth). i have few queries while using google authentication on java web based portal. 1) how , configure web-portal(e.g. https://abc.xyz.com )? 2) if have 100 user base, in case have create each user's account in order achieve authentication google? if yes how shall map them above portal? 3) have used http://ocpsoft.org/java/setting-up-google-oauth2-with-java/ there way avoid maintenance of clientid, clientsecret or json @ web application level , can still achieve secure authentication ga? 4) how can implement sso? appreciated. thanks

Rails 3 with HTTPS and SSL is not working (only showing default page of nginx) -

configuring rails 3 nginx use https , ssl not working. shows nginx's default page(the page text --> welcome nginx!) i have written config.force_ssl = true in application.rb my nginx's config file follows # server { #listen 80; ## listen ipv4; line default , implied #listen [::]:80 default ipv6only=on; ## listen ipv6 # root /usr/share/nginx/www; # index index.html index.htm; # make site accessible http://localhost/ # server_name localhost; # location / { # first attempt serve request file, # directory, fall index.html # try_files $uri $uri/ /index.html; # uncomment enable naxsi on location # include /etc/nginx/naxsi.rules # } # location /doc/ { # alias /usr/share/doc/; # autoindex on; # allow 127.0.0.1; # deny all; # } # nginx-naxsi : process denied requests #location /requestdenied { # example, return error code #return 4...

c# - How to Create ItemTemplate of ListPicker -

in following http://www.geekchamp.com/articles/listpicker-for-wp7-in-depth trying set listpicker populated using list of custom class type, reason not see items bound in view. have mainpage.xaml <grid.resources> <datatemplate x:name="searchprovideritemtemplate"> <stackpanel orientation="horizontal"> <image source="{binding favicon}" /> <textblock text="{binding name}" margin="12,0,0,0"/> </stackpanel> </datatemplate> <datatemplate x:name="searchproviderfullmodeitemtemplate"> <stackpanel orientation="horizontal"> <image source="{binding favicon}" /> <textblock text="{binding name}" margin="12,0,0,0"/> </stackpanel> </datatemplate> </grid.resources> .....

editor - Jumping from start to end of code block - vim -

how jump start end of code block code not under {}. eg. can jump around code following using shift + % : if (true) { //do this; } but want same in cases like: def some_func end around def , end. with matchit plugin (that ships vim, see :help matchit ), can define def , end additional keywords match % . if doesn't suffice, countjump plugin allows create custom motions , text objects pair of patterns.

Connecting to other MYSQL database than provided by host -

ok experiencing. have example 2 websites (old , new website). new website stored on different host (one.com) old website on (register.be). if developing new website able connect local (with mamp) database of register.be website running on new host not able connect database of old host got error: warning: mysql_connect(): [2002] connection timed out could host isn't allowing me use database? thanks! you may need go company database hosted , give new website access use database, alternatively, try changing dns records on new host point old host's mysql ip address

jquery - Twitter Bootstrap Popover with dynamically generated content via ajax -

i'm willing set bootstrap popover show emails list have been sent user. content therefore dynamically generated via ajax call. here piece of code : $('#liste').on('mouseover', 'tr[data-toggle=popover]', function(e) { var $tr = $(this); id = $(this).data('id'); $.ajax({ url: '<?php echo $this->url(array(), 'loadrelance');?>', data: {id: id}, datatype: 'html', success: function(html) { $tr.popover({ title: 'relance', content: html, placement: 'top', html: true, trigger: 'hover' }).popover('show'); } }); }); as can see, it'll trigger ajax call on each mouseover on <tr> 's of <table> . works when page loaded first time, when make cha...

ruby ternary operator syntax - spacing between operator -

is following line proper ruby syntax? session[:id]?'foo':'bar' (notice there no spacing between operators) this line works rubies tried (>1.8.7) understand there can misunderstanding ? can part of method identifier. shouldn't syntax error not put spaces arround ternary operator? i believe correct forms ternary operator when selector indexed hash , because char combination ]? invalid same operator: session[:id]?'foo':'bar' session[:id] ? 'foo' : 'bar' session[:id]? 'foo' : 'bar' but if omit space after just method , the question mark , raise syntax error: session?'foo':'bar' ^ syntaxerror: unexpected ':', expecting $end session? 'foo':'bar' ^ syntaxerror: unexpected ':', expecting $end

Servlet to Javascript -

in servlet.java , request.setattribute("f4stat", "somedata"); requestdispatcher rd = request.getrequestdispatcher("my.jsp"); rd.forward(request, response); now, in my.jsp , in javascript function access f4stat data. how in javascript? i've tried, var x = '<%= request.getattribute("f4stat")%>' if (x.length == 0) { document.getelementbyid("display").innerhtml = "<b> data </b>"; } but not working in <div id="display"> no content being displayed when f4stat has no value. you can not access httprequest ,httpresponse objects of servlet in javascript. possible trick. you can have hidden fields in my.jsp , assign value. <script> function getf4(){ document.getelementbyid("display").innerhtml=document.getelementbyid("f4").value; } </script> <input type="hidden" id="f4...

android - Dynamically add an image view to a ScrollView -

i trying make app dynamically loads images computer imageview on scroll view. want make simillar instagram (with likes). im using ftp download images computer. i need ideas direct me code. thank you! ok, here simple workflow: use ftpclient org.apache.commons.net.ftp package download file ftp. example snippet can found here once you've got input stream, use bitmapfactory.decodestream convert bitmap after can use setimagebitmap method set source imageview . since scrollview can have 1 children, can have following layout structure, example: scrollview -> vertical linearlayout id = container . add needed imageviews container calling addview method.

php: exclusive lock on file never obtained -

on php script, after parse string, need write data file (after create if doesn't exist). before write file, need exclusive lock avoid problems. code: foreach ($elements[0] $current) { $file_handler = fopen($my_folder . "/" . $current . ".txt", "a"); $locked = flock($file_handler, "lock_ex"); while (!$locked) { usleep(500000); $locked = flock($file_handler, "lock_ex"); } //got lock fwrite($file_handler, $mystring . "\n"); //release lock flock($file_handler, lock_un); fclose($file_handler); } return; now, seems not work. fopen create file, code seems go in loop inside while (file created, nothing write inside). what's wrong? you passing argument locking string instead of constant. try: $locked = flock($file_handler, lock_ex); notice missing double quotes around lock_ex

asp.net - Sitecore Application access denied -

we've taken on site based in sitecore , windows event log showing exceptions occurring whenever logged admin. anybody know how fix this? looks missing permission can't work out i'd need fix it. exception information: exception type: accessdeniedexception exception message: application access denied. @ sitecore.diagnostics.assert.hasaccess(boolean accessallowed, string message) @ sitecore.diagnostics.assert.canrunapplication(string application) @ sitecore.shell.applications.analytics.trackingfield.trackingfielddetailspage.onload(eventargs e) @ system.web.ui.control.loadrecursive() @ system.web.ui.control.loadrecursive() @ system.web.ui.page.processrequestmain(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint) request information: request url: http://www.sitename.com/sitecore/shell/~/xaml/sitecore.shell.applications.analytics.trackingfielddetails.aspx?db=master&id={31d7150f-352b-4800-8fdf-c90cdad17d67}...

git - Local branch shown ahead of remote branch after rebasing -

every time rebase local branch, git status shows this: # on branch --blah-- # branch ahead of 'origin/--blah--' 11 commits. only after push branch (which doesn't push actually) says everything up-to-date . this strange behavior, , suspect there fundamental i'm missing. why happening? what git rebase origin/branch put work on top of origin/branch branch in local copy. when have: local_branch: 1--2--3--4--1'--2'--3' remote_branch: 1--2--3--4--a--b--c then issuing git rebase remote_branch end with local_branch: 1--2--3--4--a--b--c--1'--2'--3' remote_branch: 1--2--3--4--a--b--c which means local_branch indeed commits ahead of remote rebased on. after git push result in local_branch: 1--2--3--4--a--b--c--1'--2'--3' remote_branch: 1--2--3--4--a--b--c--1'--2'--3' so local up date check out git-rebase doc

django - Wagtail Image template tags -

Image
i'm using django-variant cms wagtail , trying build own templates it. i can upload images rich text field in wagtail's cms shown: in template's html, able call specific images uploaded in body can style specific images differently js. perhaps {{ body.image }}? the html: {% extends 'wagweb/base.html' %} {% load rich_text static compress cache image_tags pageurl %} {% block content %} <div class="box"> <article class ="content"> {{ self.body | richtext }} </article> </div> {% endblock %} i'm lost @ point, can't figure out how find pre-existing tag dictionary (if there any) or create 1 without messing views.py? or more straight-forward install markdown richtextfield , work there? i'm tons more comfortable html , css, 1 solution write in html , use {{ media_url }} call specific images. seems unintelligent way use wagtail , django. currently rich text editor doesn't sup...

javascript - Node JS server Array using Socket IO -

from different socket io clients, sending array consisting of 2 items server. 2 items score, , clients socket id , looks this: [10,'_d4a1eigjrg_zxhryf6a'] on server side, on connection of socket clients create object add users to, based on socket id's: example: users = { '_d4a1eigjrg_zxhryf6a' : user { score : 0, finished : false, winner : false }, 'xnsjpyem_aeo08t4yf5_' : user { score : 0, finished : false, winner : false }, } i attempting update object when send through aforementioned array. code on server side using try achieve this: socket.on('finish', function(data) { users[data[1]]['score'] = data[0]; users[data[1]]['finished'] = true; }); instead happening of properties of users object being updated data being sent in array, rather 1 matching socket id. can tell me i'm doing wrong? th...

ClearCase Command to get older version of commited jars? -

i building jar on unix server using clearcase , want see, last jar i.e jar without update . can in clearcase if yes can suggest best way ? clearcase allows access sources building jar. you can create second view can configure see tag representing sources before modifications, assuming did put label on sources before modifying them. element * checkedout element * yourlabel element * /main/latest even if didn't put label, can still set time-based selection rule .

How to Convert string to date in c# -

this question has answer here: converting string datetime 10 answers i have string format of date looks "04/16/2014 19:10" , want convert datetime. i tried, below codes, didn't work. got error "string not recognized valid datetime." how convert datetime datetime dt1 = datetime.parse(datetimestring); datetime dt = system.convert.todatetime(datetimestring); the problem parse , using it, take account current culture of machine means (depending on are) date interpreted differently. whenever parsing specific dates should use parseexact or tryparseexact , way leave no room ambiguity on how date should interpreted (regardless of culture) datetime dt; if (datetime.tryparseexact("04/16/2014 19:10", "mm/dd/yyyy hh:mm", cultureinfo.invariantculture, datetimestyles.none, out dt)) { // date parsed correctl...

javascript - Bootstrap Timepicker - Minute Intervals -

i swapped using jquery ui timepicker using timepicker found here appears jquery ui incompatible twitter bootstrap. i've managed datepicker , timepicker working lack of functionality of old timepicker - ability control steps in minutes. wish allow user increase minutes of timepicker in 15 minute intervals. worked flawlessly jquery ui using following syntax: $(function() { $('#div_id').timepicker({ stepminute: 15 }); }); my current code, calls timepicker fine: (stepminute gives no effect, incorrect syntax timepicker) jquery(function($){ $('#div_id').timepicker({ stepminute: 15 }); }); i wish emulate using bootstrap-friendly timepicker linked @ start of question, appreciated. if don't want change plugin code can use change.bfhtimepicker event ad increment/decrement hour , minutes step. alternatively, appear little different because ui, can switch bootstrap timepicker plugin implements minutestep feature. code: ...

sitecore6 - Ordering in sitecore template fields -

i have structure in sitecore content tree content type (class 1) content type b (jane) content type b (alex) content type b (liam) content type (class 2) content type b (bob) content type (class 3) .... i display content type b in checkbox list source field in template (essentially picking related content) works need display in alphabetical order regardless of content type content under ie display alex bob jane liam rather than alex jane liam bob i can't see mention of syntax in sitecore query supports type of ordering. have ideas? if list of sitecore items through .net should able yourlistofitems.orderby(i => i.name) . you can list of items using sitecore.contentsearch in sitecore 7 , up, or sitecore query would.

android - Does VersionCode , VersionName of alpha release affect production release -

i went through docs did not see anywhere mentioning on this, if release app alpha testing or beta release version code 1, name 1.0 affect production release needs code 1, name 1.0. does version system carried on or production release have own version flow. thank you. when upload apk, must use unique versioncode (integer value) , show user versionname (string value). playstore not allow upload apk used versioncode

python - plotting dynamic data using matplotlib -

i'm writing application display data changes dynamically (the data being read socket). as dummy case, try draw sine amplitude multiplied 1.1 each second: import numpy np import matplotlib.pyplot plt import time x = np.arange(0, 10, 0.1); y = np.sin(x) in xrange(100): plt.plot(x, y) time.sleep(1) y=y*1.1 this not way it, shows intentions. how can done correctly? edit: following traceback output of code suggested in @mskimm answer: plt.show() #exception in thread thread-2: traceback (most recent call last): file "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner self.run() file "/usr/lib/python2.7/threading.py", line 505, in run self.__target(*self.__args, **self.__kwargs) file "<ipython-input-5-ed773f8e3e84>", line 7, in update plt.draw() file "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 466, in draw get_current_fig_manager().canvas.draw() file "/u...

How to retrieve data RANDOMLY from SQL Server using C# -

i have set of questions in database , need retrieve them in random order every time. can please me out c# code? i'm using visual studio 2012. thanks in advance. here's code i'm using @ moment: using system; using system.data; using system.configuration; using system.collections; using system.web; using system.web.security; using system.web.ui; using system.web.ui.webcontrols; using system.web.ui.webcontrols.webparts; using system.web.ui.htmlcontrols; public partial class perform_test : system.web.ui.page { public int currentpage { { object o = this.viewstate["_currentpage"]; if (o == null) return 0; else return (int)o; } set { this.viewstate["_currentpage"] = value; } } protected void page_load(object sender, eventargs e) { //response.write(session["company"]); if (!page.ispostback) { session.add("correctanswers", 0); ...

mysql - Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in Undefined class constant (PHP 5.5.3) -

i have config file connects remote database, keep receiving error don't know how fix. in earlier versions meant bug assumed have been fixed 5.5.3. <?php error_reporting(e_all); ini_set('display_errors', 'on'); $host = "localhost"; $dbname = "registration"; $username = "databaseeditor"; $password = "yolo10"; // 1002 = mysql_attr_init_command $options = array(pdo::mysql_attr_init_command => 'set names utf8'); try { $db = new pdo("mysql:host={$host};dbname={$dbname};charset=utf8", $username$ } catch(pdoexception $ex) { die("failed connect database: " . $ex->getmessage()); } $db->setattribute(pdo::attr_errmode, pdo::errmode_exception); $db->setattribute(pdo::attr_default_fetch_mode, pdo::fetch_assoc); header('content-type: text/html; charset=utf-8'); echo "file works"; ?> i keep receiving error "undefined class constant 'mysql_attr_init...

python - Django - how to display an object's field names and attributes, excluding null ones? -

so have model of there fields might not filled in: class thing(models.model): name = models.charfield(max_length=300) location = models.charfield(blank=true) comment = models.charfield(blank=true) gallery = models.foreignkey(someotherthing, related_name='things') i need way display info instance of object in template, showing field names , value of them(only if filled in), so: the page thing on name: awesome thing location: wisconsin comment: love thing! uploader: joe schmoe if, example, comment not filled in, want display fields are, not have field name , blank value: the page thing on name: awesome thing location: wisconsin uploader: joe schmoe is there kind of way in django? know there kind of method convert object dict, doesn't solve problem of excluding null fields. thanks you can use model_to_dict method, , iterate on dictionary this: {% key, value in dictionary.items %} {% if value %} <p>{{ key }}: {{ value }}...

java - FlexTable with Uibinder or alternatives -

what's best way use flextable in corperation uibinder, know have provide , initiate befor initwidget @uifield(provided = true) flextable contenttable; but need table input matrix like: pseudo: label."name: " textbox() label."password: " textbox() know idea consider flextable or there better alternativ? help. i'll pass on fact using table form layout not best option nor practice. you can use htmlpanel uibinder, , in html "normal" page, additional gwt tags widgets : <g:htmlpanel> <div class="forminput"> <g:label text="first name - w3c style : "> <g:textbox ui:field="firstnametextbox"> </div> <table> <tbody> <tr> <td>last name - table style :</td> <td><g:textbox ui:field="lastnametextbox" /></td> </tr> <tr> ...

How to monitor access to shared system resources in Android? -

in android, there exists shared resources system settings, can read or modified process without permission declared. there method monitor access shared resources? or, can make system record time , pid of process accessing resource? resources sharedpreferences, streamvolume, ringer_mode, , files in /proc, world-readable or writable. see of these observable using system application layer apis such onsharedpreferenceschanged listener, contentobserver, or fileobserver. then, there place in system in can comprehensive observation of access shared resources? maybe in lower layer of system(kernel)?

javascript - How to populate a dropdown list based on values of the another list? -

i want implement search box same this , @ first, first dropdown list active once user selects option first dropbox, second dropdown box activated , list populated. <s:select id="country" name="country" label="country" list="%{country} onchange="findcities(this.value)"/> <s:select id="city" name="city" label="location" list=""/> jquery chained plugin serve purpose, https://plugins.jquery.com/chained/ usage link - http://www.appelsiini.net/projects/chained this plugin chain textboxes.

ios - Address Book - Select email of Linked contact -

i trying fetch selected email property in delegate callback mentioned below -(bool)peoplepickernavigationcontroller:(abpeoplepickernavigationcontroller *)peoplepicker shouldcontinueafterselectingperson:(abrecordref)person property:(abpropertyid)property identifier:(abmultivalueidentifier)identifier { if (property==kabpersonemailproperty) { abmultivalueref emails = abrecordcopyvalue(person, kabpersonemailproperty); if (abmultivaluegetcount(emails) > 0) { nsstring *email = (__bridge_transfer nsstring*) abmultivaluecopyvalueatindex(emails, abmultivaluegetindexforidentifier(emails,identifier)); [recipientemail settext:email]; [peoplepicker dismissviewcontrolleranimated:yes completion:nil]; } cfrelease(emails); } return no; } but if select email property of linked contact (having single email) identifier 0, result first email-id of primary c...

Ubuntu: Rails installation requires Ruby =>1.9.3 -

i'm having touble installing rails on new installation of ubuntu 12.04 lts. have rvm , rubygems 2.2.2 installed when go install rails error; anesu@ubuntu:~$ gem install rails [sudo] password anesu: #i enter passsword here error: error installing rails: activesupport requires ruby version >= 1.9.3. anesu@ubuntu:~$ ruby -v ruby 1.9.3p545 (2014-02-24 revision 45159) [x86_64-linux] the ruby required installed. i've tried gem install rails #without sudo but still same error. problem? do have rvm in path? if not, add following line ~.bashrc file... path=$path:$home/.rvm/bin be sure , open , close terminal after this. @ terminal should able type 'echo $path' , see rvm listed.

Python + Xbee - interpreting binary data for analog samples -

i've been working on project digi xbee series 2 (zigbee) modules. have python script receives data on coordinator device , saves database. script has been looking , parsing "samples" key in returned data. i've since bought digi xbee l/t/h sensor ( http://www.digi.com/wiki/developer/index.php/xbee_sensors ) , have found returns data using "rf_data" key. appears binary. i'm failing able process , read actual values it. can tell me if can re-program sensor send "samples" key, or how read/convert binary data? i've been trying this: h=struct.unpack('f',response['rf_data'][0:4])[0] but i'm out of depth knowing i'm doing ;-) thanks in advance can give.... it's returning i/o sample, described in digi knowledge base article . the page linked includes formulas converting adc readings temperature, humidity , light readings. section 3.2 of python-xbee documentation seems imply i/o samples pa...

three.js - WebGL: Offscreen buffers were not cleared before new rendering? -

i'm making kind of web-apps using three.js . so far, apps work fine, however, when see them in friend's computer, 3d graphics' canvas blinks , copied(?) objects found. (i wanted paste example didn't have enough reputation upload images...) i think because images drawn on off-screen-buffer 1 several frames before not cleared correctly. when changed webgl.force-layers-readback 'true' in about:config (i using firefox28), apps fine. (with computer, looks ok if webgl.force-layers-readback 'false'.) could tell why happened , how avoid it? want avoid in application side because don't want tell every visitors change options true. environment friend's os: windows 8 browser: firefox28 graphics card: intel hd graphics 4600 mine os: windows 8 browser: firefox28 graphics card: intel hd graphics 4000 hope understand want say. i'm not @ english.>_< it because obsolete graphic drivers.... sorry bothering.>_< ...

javascript - Simple slider with width 100% -

Image
i'm using simple slider plugin create ticker bar this: and changes next slide: it's "plugin" problem in case width of slider must 100% of screen (the plugin has fixed width of 500px ): http://codepen.io/zuraizm/pen/vgdhl i tried adding width: 100% css slider , ul , li no luck: #slider { position: relative; overflow: hidden; margin: 20px auto 0 auto; border-radius: 4px; width: 100% !important; } #slider ul { position: relative; margin: 0; padding: 0; height: 200px; list-style: none; width: 100% !important; } #slider ul li { position: relative; display: block; float: left; margin: 0; padding: 0; width: 500px; height: 300px; background: #ccc; text-align: center; line-height: 300px; width: 100%; } any ideas on how make work on width:100% example images? the slider-elements needs wi...

c# - How to remove black screen on windows form -

i have windows form. in form have loaded panel. when resize form non client area becomes black. how remove black screen. i have tried in many ways passing parameter, double buffer. protected override createparams createparams { { createparams cp = base.createparams; cp.exstyle |= 0x02000000; return cp; } }

javascript - How to consider alpha channel(opacity) for canvas blending(context.globalCompositeOperation) -

Image
we have following sample code blend 2 images global composition. canvas blending works perfect. need detect formulas/algorithms make operation imagedatas , same result. image.src = "landscape.png"; image.onload = function() { img = new image; img.src = "gradient.png"; img.onload = function(){ canvas.width = img.width; canvas.height = img.height; context.save(); context.drawimage(image, 0, 0, canvas.width, canvas.height); drawcustomlogo(context); var id1 = getcontextfromimg(image); var id2 = getcontextfromimg(img); var b = new blending(); var sid = b.overlay(id1, id2); var bc = document.getelementbyid('custom'); bc.width = image.width; bc.height = image.height; var bctx = bc.getcontext('2d'); bctx.putimagedata(sid, 0, 0); } but prob...

nullpointerexception - java null pointer exception- Occurs at varying points in while loop -

i have following java while loop: while(true){ byte buffer[] = new byte[max_pdu_size]; packet = new datagrampacket(buffer, buffer.length); socket.receive(packet); pdu pdu = pdufactory.createpdu(packet.getdata()); system.out.print("got pdu of type: " + pdu.getclass().getname()); if(pdu instanceof entitystatepdu){ entityid eid = ((entitystatepdu)pdu).getentityid(); vector3double position = ((entitystatepdu)pdu).getentitylocation(); system.out.print(" eid:[" + eid.getsite() + ", " + eid.getapplication() + ", " + eid.getentity() + "] "); system.out.print(" location in dis coordinates: [" + position.getx() + ", " + position.gety() + ", " + position.getz() + "]"); } system.out.println(); } } the intended function of while loop capture pdus being sent across network, , display information them. when run code, go output ...

image processing - Why multiple openings/closing with a same kernel does not have effect? -

i know closing , opening, there still 1 question me! according "digital image processing, 3rd edition", gonzales, multiple application of opening/closing doesn't have effect after first time apply it! couldn't figure out? can help? this expected behavior since openings , closings idempotent operations . operation idempotent if, whenever applied twice value, gives same result if applied once: f(f(x)) = f(x). openings operators on lattice l idempotent, increasing, , anti-extensive while closings operators on l idempotent, increasing, , extensive. 1 can find discussion on idempotence here . in more intuitive sense, opening on set x erosion followed dilation same structuring function. once first iteration done set x not change since erosion , dilation remove , add same '1's in set x. product of opening , closing idempotent operation - interesting. 1 other hand if @ each iteration 1 changes radius of structuring element openings/closings, 1 obtain al...

ios - Parsing multiple json objects from signle nsstring variable -

i know how parse json object nsstring using nsdata , nsdictionary , didn't find how parse multiple json object if message this: { "msg_type" : "fist_json", "field" : "param" } { "second_json_field": [ { "name_picture": "0.png", "data_picture":"something" }, { "data_values": "something" } ] } { "third_msg" : "hello" } it's not valid json, can't parse it. json document either single array, or single object (dictionary). 3 objects not valid json. put square brackets around everything, put commas in right places, , parse it, getting array back. finding places commas without writing full-blown json parser tricky. if server gave you, ask server people fix broken server. if code reason combined 3 json messages one, don't that.

c# - Converted Image to Gif, Works Partially? -

i've written short method converting images(image class) gifencoder , saving gif file. however, when go open resulting gif created, has problems. 1) gif stops playing after 2 cycles in browser. 2) when loaded through image editor colors seem mix bit between pixels. public void converttogif( string destinationpath , image myimage , int myframes ) { bitmap mybitmap = new bitmap( myimage.width / myframes , myimage.height ); gifbitmapencoder myencoder = new gifbitmapencoder(); int = 0; while( < myframes ) { graphics grdrw = graphics.fromimage( mybitmap ); var destregion = new rectangle( 0 , 0 , mybitmap.width , mybitmap.height ); var srceregion = new rectangle( mybitmap.width * , 0 , mybitmap.width , mybitmap.height ); grdrw.drawimage( myimage , destregion , srceregion , graphicsunit.pixel ); bitmapsource mysource = system.windows.interop.imaging.createbitmapsourcefromhbitmap( mybitmap.gethbitmap() , intptr.zero , int32r...

php - AWS Beanstalk Deploy Laravel with Grunt Tasks -

i have laravel 4.1 app want run on aws beanstalk. thing have grunt tasks want run on deploy compile less files , requirejs optimize , bower install the thing aws beanstalk php instance. so, think doesn't have nodejs installed run tasks. any ideas how can deal this? possible? i've ended building entire assets in bundle before deploying. detecting environment , pointing production bundle instead of building in server. in end not right.

c# - Implementing 'await' type behavior to non-awaitable task -

there difference in apis windows phone 8 , standard .net when accessing wcf services. api wp8 forces use of callbacks rather offering awaitable interface. furthermore, use custom headers service calls include shenanigans different on these 2 platforms (i prefer code runnable on both though). anyway, ended pattern similar this: private bool moperationcompleted = false; private operationresulttype moperationresult; public async task<operationresulttype> wcfservicerequestoperationname() { mclient.wcfservicerequestoperationnamecompleted += wcfservicerequestoperationnamecompleted; performrequest(mclient, () => mstoreclient.wcfservicerequestoperationname(dem parameters particular call)); while (!moperationcompleted ) { await task.delay(500); /* delay isn't mandatory here */ } // reset moperationcompleted = false; // return return moperationresult; } void client_wcfservicerequestoperatio...

javascript - dxDateBox doesn't want to display Date from database -

i tried display specific date database doesn't want work (the field empty). please me. query: var sejour = json.parse(select_sejourbyid(mydb, params.dc)); html: <div class="dx-field"> <div class="dx-field-label">date début</div> <div class="dx-field-value"> <div id="dated" data-bind="dxdatebox: { value: dated, format: 'date' }"></div> </div> </div> js: dated : ko.observable(new date(sejour.date_debut)),

Jenkins perforce plugin: can I get it to do full sync if key files are missing? -

we using jenkins perforce plugin reasonably in semi-continuous integration setup. "reasonably" in because our builds slow, not related jenkins , more our own code. one of main problems have if files have been deleted outside builds - e.g. if low on diskspace , "prunes" builds on build machines - p4 plugin cannot directly handle that. in mode run (without full-sync flag) assumes files sync'd on previous run still there. this covered under "quirks" on plugin page - https://wiki.jenkins-ci.org/display/jenkins/perforce+plugin - suggests "one time force sync" workspace normal. however, have couple of build machines each config bit of redundancy. in case, machine run next not same 1 had problem. makes tricky adding new machines pool. i wondered if had better solution. e.g. if key files missing (indicative of build being wiped) forced sync anyway? ok took me while twigged approach works @ least in our setup. pretty near top of jo...

PHP convert separate date and time strings into single datetime -

i have 2 separate strings date , time formatted like: 14/04/2014 , 01:15 pm i convert these datetime formatted y-m-d h:i:s any idea how go this?? $date = datetime::createfromformat('d/m/y h:i a', '14/04/2014'.' '.'01:15 pm'); echo $date->format('y-m-d h:i:s'); demo

android - How to control radio button states within a custom SimpleCursorAdapter via bindView / newView for a listfragment -

i have listfragment manages row(s) of 2 radio buttons per row, 1 button allowed checked, i've not been able manage radio button states properly. i'm pretty familiar listview's recycling of views. i've tried many different avenues no success, realize have keep states of radio buttons, list position , whether button has been initialized yet separately, can interface. it's , when set radio button states within adapter i've been wrestling with. i've tried has 1 condition or interfering other. setting radio button database initially, when there recycled view no radio button check , radiogroup.clearcheck() seems override when user chooses button. the state of radio buttons should controlled 2 sources; database source: 1) database column has value i'd set radio button initially, i'd show checked (.setchecked(true)) when user hasn't had interaction row yet, besides scrolling/no clicks. or database column 0 , no radio button should checked...

shell - Loop with variable in bash script -

i deploy website using post-receive git hook. within hook use yui compressor minify js , css files: export temp=/var/www/example.com git_work_tree=/var/www/example.com git checkout master -f #minify mit yui (cd $temp/css && min style.css && rm style.css && mv style.min.css style.css) (cd $temp/addons/css && min bootstrap.css && rm bootstrap.css && mv bootstrap.min.css (cd $temp/js && min script.js && rm script.js && mv script.min.js script.js) (cd $temp/addons/js && min startup.js && rm startup.js && mv startup.min.js startup.js) now not specify exact files, search js , css files through folders in $temp , repeat minify procedure each time. could 1 me right loop , search-syntax case? thanks! just guess here, constructs this? find $temp -name \*.css -exec sh -c 'f="{}"; min "$f" && mv "${f%.css}.min.css" "$f"' \; ...

javascript - Display or use content from <div> tags -

i have form, hidden input: <input id="producten" type="hidden" name="producten" value="<div class='simplecart_items'></div>"/> i want content in between div's , use content submit form. content created when page loads. now, takes actual code ( <div etc></div ). hope can me this! familiar php , javascript. thanks without jquery can this: <script type="text/javascript"> function formbeforesubmit() { document.getelementbyid('producten').value = document.getelementbyid('simplecart_items').innerhtml; return true; } </script> <div id="simplecart_items">mycontent</div> <form action="..." method="post" onsubmit="formbeforesubmit();"> <input id="producten" type="hidden" name="producten" value=""/> <input type="submit" value=...

pdo - Blank Page with PHP script -

im trying input form , delete table data display the updated table blank page don't know problem appericiated here's code: <html> <body> <?php $mysqli = new mysqli("xxxxx", "xxxxxx", "xxxxx", "xxxxxx"); /* check connection */ if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit(); } //----------------------------------------------------------------------------------// $name = $_post['car_id']; if ($stmt = $mysqli->prepare("delete cars name=?")) { // bind variable parameter string. $stmt->bind_param("s", $name); // execute statement. $stmt->execute(); echo "deleted data successfully\n"; // close prepared statement. $mysqli->setattribute(pdo::attr_errmode, pdo::errmode_exception); $result = $db->prepare("select id, doors, transmission, fuel_type, engine_s...

How to render glass/ice material on Android smartphone using OpenGL -

what best way render glass/ice materials on android devices no ray tracing? i have seen aplha+blending proper lighting, results looked "plastic". can better? you need proper reflection , refraction draw looking transparent materials. you need environment texture source of reflection/refraction. recommend render scene without transparent material make environmental source texture. cube-mapping recommended. visit here see how implement reflection , refraction. http://en.wikibooks.org/wiki/glsl_programming/unity/reflecting_surfaces http://en.wikibooks.org/wiki/glsl_programming/unity/curved_glass

physics - Curve fitting differential equations in Python -

i have curve of >1000 points fit differential equation in form of x'' = (a*x'' + b x' + c x + d), a,b,c,d constants. how proceed in doing using python 2.7? certainly intend have third derivative on right. group data in relatively small bins, possibly overlapping. each bin, compute cubic approximation of data. compute derivatives in center point of group. derivatives of groups have classical linear regression problem. if samples equally spaced, might try move problem frequency space via fft. sensible truncation of data might problem here. in frequency space, task reduces polynomial linear regression.

javascript - Change css3 icons color on mouse over with jquery -

i have ok css3 icon created css. http://jsfiddle.net/5c9gn/ js: $('.ok').mouseenter(function(){ $(this).parent().find('.ok:after, .ok:before').css('background','#ccc'); $(this).css('background','#33cc33'); }); $('.ok').mouseleave(function(){ $(this).parent().find('.ok:after, .ok:before').css('background','#ccc'); $(this).css('background','#ccc'); }); css: .ok{height:40px; width:40px; display:block; position:relative; margin-left: auto; margin-right: auto;} .ok:after, .ok:before{content:''; height:32px; width:10px; display:block; background: #ccc; position:absolute; top:6px; left:18px; transform:rotate(45deg);-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg);} .ok:before{height:16px; transform:rotate(-45deg);-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-o-transform:rota...

javascript array into object with same key names -

i have unusual problem solve here. have array of guids [ "c01f8237-72c8-4fa6-9c53-1915750385aa", "2c8a471b-c408-436c-81b1-3f3867d8ffb4", "27a44d46-12bd-4784-ceed-57ada31b0e33" ] this array has transformed into: { id: "c01f8237-72c8-4fa6-9c53-1915750385aa", id: "2c8a471b-c408-436c-81b1-3f3867d8ffb4", id: "27a44d46-12bd-4784-ceed-57ada31b0e33" } i know shouldn't done, unfortunately cannot control end part. idea? thanks the whole point of dictionary key uniquely maps value. desired output attempts duplicate key , therefore neither possible nor make sense. if you're passing backend (as suggest), of course can manually build string pass on wire duplicates keys in payload, won't able in javascript first. you'll have manually build string. also note can call format whatever want, you can't call json , can't use json libraries build (because it's not js...

indy - Delphi, Indy10, How to properly stop and cleanup a readln on a continuous stream -

using delphi 2010 , indy10 i attempting read server sent events delphi. have managed create thread subscribe connection on server (python/flask) , capture events. thread needed because http.get blocking forever. realize entire protocol not implemented, interested in receiving short strings broadcast server. following code works, have not been able figure out how cleanly stop thread , free http_client , stream when stopping program. on server side ""an existing connection forcibly close remote host"" , program indicating memory leaks. have tried many different combinations of trying close http connection @ various points (onterminate,destroy) , can't work. insights or examples appreciated. here relevant code have far: tssethread = class(tthread) private url: string; stream: tmemorystream; http_client: tidhttp; procedure doonwork(asender: tobject; aworkmode: tworkmode; aworkcount: int64); public constructor create(creates...

r - Estimating class probabilities with hierarchical random forest models -

i using random forest classifier (in r) predict spatial distribution of multiple native plant communities using variety of environmental variables predictors. classification system hierarchical each successive level becoming more detailed in class description. example, have hierarchical classification system 2 levels , upper level consists of 2 classes: forest (f) , grassland (g). lets second level each forest , grassland class composed of 2 subclasses (f1,f2 , g1,g2). using forest class example, subclasses might conifer or deciduous forests. i know pretty basic far, here's challenge i've run into. i'd predict spatial distribution of these classes @ finest classification level there environmental variation acceptable accuracy. reduce variability can train multiple random forest models first model (model #1) operates @ uppermost level classifying observations either f or g. @ second level, subset data 2 groups based on f/g class , train 2 models (models #2 , #3) each c...

jquery - Float div to right with margin right at any screen size -

i have background image (size of image 2600x1170) sbbody { background: #999 url(footer_bg.jpg) center top no-repeat; overflow-y: scroll; overflow-x: hidden; height: 1105px; font-family: serif, georgia, times new roman, times; font-size: 12px; } i have special area @ image (on right side of image), , need show special div should @ area, did float right , margin .main_box { float: right; margin-right: 505px; margin-top: 75px; } it looks fine in screen resolution 1900x1200, if change browser size margin div broke. how can have same div position until browser window more 800px; <body class="sbbody"> <div class="main_box"> </div> </body> thanks. as floating div right, need fix background top , right using : background-position:top right; instead of top center see demo css : .sbbody { background: #999 url(http://lorempixel.com/output/nature-q-g-1280-720-10.jpg) righ...

Is it possible to execute another program using C++? -

what i'd have c++ code open mplus (statistical program i've downloaded on computer) , run it. possible? you may able want std::system() calls like: std::system("program -e input_commands.txt"); // assuming accepts sort of command line args std::system("program < input_commands.txt"); // assuming responds stdin it depends on program if approach work.