Posts

Showing posts from April, 2010

How to configure SSL termination on Nginx with a Rails application -

i ssl request through load balancer performing ssl termination , sending decrypted traffic server on port 81. i'm running nginx , have setup listener port 81 , tell rails app ssl request. here how nginx config looks like: server { listen 81; server_name server; root /var/www/app/current/public; error_log /var/log/nginx/app-error.log; access_log /var/log/nginx/app-access.log; passenger_enabled on; client_max_body_size 100m; location / { passenger_enabled on; proxy_set_header x-forwarded-proto https; } } it goes through ruby on rails doesn't detect header request.headers['x-forwarded-proto'], takes request non-https. should add in order rails thinking ssl request? so proxy_set_header not used passenger, need use passenger_set_cgi_param instead: passenger_set_cgi_param http_x_forwarded_proto https;

iPhone iOS how to implement a sequence of background network send operations in the fastest way possible? -

i'm trying stream data server @ regular intervals , in way fast , not block ui. ui pretty busy trying display data. implementation uses nstimer fires every 50ms, picks network packet out of circular array , sends over: //this timer networkwritetimer = [nstimer scheduledtimerwithtimeinterval:0.05 target:self selector:@selector(sendactivity:) userinfo:nil repeats:yes]; -(void)sendactivityinbackground:(id)sender { [[appconfig getinstance].activeremoteroom.connection sendnetworkpacket:[circulararray objectatindex:arrayindex%arraycapacity]]; } -(void)sendactivity:(nstimer*)timer { // send out [self performselectorinbackground:@selector(sendactivityinbackground:) withobject:nil]; } i'm not satisfied performance of method. time profiling has revealed there's overhead associated performing background selectors, , performance can quite choppy. i'm thinking of additional ways improve performance: improve p

php - To link website logo to external url from backend interface in drupal 7 -

need link website logo external url backend interface in drupal 7. now hard coded page.tpl.php file. is there option add backend? there no default option linking website logo external url. we need create field in end theme settings. create page theme-settings.php inside theme folder following code function theme_form_system_theme_settings_alter(&$form, $form_state) { $form['theme_settings'] = array( '#type' => 'fieldset', '#title' => t('theme settings') ); $form['theme_settings']['theme_logourl'] = array( '#type' => 'textfield', '#title' => t('logo url'), '#default_value' => theme_get_setting('theme_logourl'), '#description' => t("logo url external linking"), ); return $form; } go , check theme settings page - appearance/settings/theme there new text filed ente

jsf - Reference inputText value from link param -

i have p:inputtext component , h:link that navigate different view: <p:inputtext id="searchvalue" value="#{bean.searchvalue}"> <p:ajax event="keyup" update="search" /> </p:inputtext> <h:link id="search" value="search" outcome="ressearch"> <f:param name="searchvalue" value="#{bean.searchvalue}" /> </h:link> the ressearch page use searchvalue parameter , executes search based on it, after presents result: <f:metadata> <f:viewparam name="searchvalue" value="#{searchbean.searchvalue}" /> <f:event type="prerenderview" listener="#{searchbean.init}" /> </f:metadata> i'd rather not use ajax value of inputtext component. possible value inputtext directly (without using bean properties) , set value of param ? just use plain html form. <form action="ressearch.x

java - Parallel prime factorization -

this question has answer here: parallel algorithms generating prime numbers (possibly using hadoop's map reduce) 1 answer does have idea what's approach parallel prime factorization algorithm ? i can't figure out @ stage of algorithm should divide threads .. how can think prime factorization in parallel way ? consider following 1 thread code: public static void primefactorization(arraylist<integer> factors, int num){ //factors array save factorization elements //num number factorized int limit = num/2+1; if(isprime(num)) factors.add(num); else{ while(num%2==0){ factors.add(2); num=num/2; } (int i=3; i<limit; i+=2){ while (isprime(i) && num%i==0){ factors.add(i);

css - create a grid with no spaces using table html -

i'm trying build grid in html want remove spaces between cels, , can't find. <table id="gamegrid" cellspacing="0" > <tr class="gridrow" > <td class="box" ></td> <td class="box" ></td> <td class="box" ></td> </tr> <tr class="gridrow" > <td class="box" ></td> <td class="box" ></td> <td class="box" ></td> </tr> <tr class="gridrow" > <td class="box" ></td> <td class="box" ></td> <td class="box" ></td> </tr> </table> and css #gamegrid{ border:1px solid black; border-collapse: collapse; padding:0; margin:0; border-spacing: 0; } #gamegrid .gridrow{ margin:0; padding:0; } #gamegrid .gridrow

javascript - IF-statement stroke in a line diagram using d3.js -

i've drawn graph using data out of database, , want line turn red when number in database gets higher 500 (like below). unfortunately doesn't work way, , i've tried other stuff, no succes. though dashed line work using code .style("stroke-dasharray", ("3, 3")) my question: possible let stroke color turn red when y value gets higher point in d3.js? // adds svg canvas var svg = d3.select("body") // explicitly state svg element go on web page (the 'body') .append("svg") // append 'svg' html 'body' of web page .attr("width", width + margin.left + margin.right) // set 'width' of svg element .attr("height", height + margin.top + margin.bottom)// set 'height' of svg element .append("g") // append 'g' html 'body&#

sql - How do I write the join in this query? -

i have following case : two tables structure : [machine] (parent table): machine_id (pk) | machine_name | desc [machine_in_out] (child table): id (pk) | machine_in_id | machine_out_id now want name of machine_in_id , machine_out_id through parent table. how make join?! try this... select mio.id, m1.machine_name, m2.machine_name [machine_in_out] mio join [machine] m1 on mio.machine_in_id = m1.machineid join [machine] m2 on mio.machine_out_id = m2.machineid

python - NSUserNotification not working with wx.app.MainLoop() method -

here simple code uses pyobjc interface show desktop notification. when call notify method without wx.app.mainloop() works fine wx.app.mainloop() not. import foundation, objc nsusernotification = objc.lookupclass('nsusernotification') nsusernotificationcenter = objc.lookupclass('nsusernotificationcenter') def notify(title, subtitle, info_text, delay=0, sound=false, userinfo={}): notification = nsusernotification.alloc().init() notification.settitle_(title) notification.setsubtitle_(subtitle) notification.setinformativetext_(info_text) notification.setuserinfo_(userinfo) if sound: notification.setsoundname_("nsusernotificationdefaultsoundname") notification.setdeliverydate_(foundation.nsdate.datewithtimeinterval_sincedate_(delay, foundation.nsdate.date())) nsusernotificationcenter.defaultusernotificationcenter().schedulenotification_(notification) if __name__ == '__main__': app = wx.app() notify("notify tittle

deployment - Nuspec file renaming is not working with octopack -

i auto publishing using octopus , teamcity. have project multiple configurations , need have different package id's same solution. have 1 nuspec file in project. in teamcity project configuration passing /p:octopusnuspecfilename=team.ius.nuspec msbuild. still not changing name of package 1 passing in build parameter. want team package renamed team.ius. artefact creates still creating team.1.0.0.19.nupkg. idea doing wrong. please guide 1 nuspec = 1 project. if want mulitple packages project should create nuspec each 1 , use post build event name , place different packages in different lib folders.

algorithm - Dynamic Programming : The Zipper -

doing little practice on dynamic programming problems in preparation final , found problem stumped me. zippers: given 3 strings, determine whether third string can formed combining characters in first 2 strings. first 2 strings can mixed arbitrarily, characters each must stay in original order in third string. for example, consider forming "tcarete" "cat" , "tree": string a: c t string b: t r e e string c: t c r e t e as can see, can form string c selecting first charcter of "tree", followed first 2 characters of "cat", followed second , third characters of "tree", followed last charcter of "cat" , "tree" respectively. as second example, consider forming "catrtee" "cat" , "tree": string a: c t string b: t r e e string c: c t r t e e the answer input 'yes' output: output yes if , b can combined (zippered) string c. output no if , b cannot combined for

c# - Set Windows Phone 8 App as default for file extensions -

i want register windows phone 8 app, default app opening specific files (for example files, end *.test ). so question is: how register app windows phone 8, opens app when user want's open *.test -file. any appreciated. you register application in app manifest. detailed instructions, read registering file association on msdn.

PHP mysql edit database entries -

so have 2 php file first one <?php include"db.inc.php";//database connection $order = "select * notes"; $result = mysql_query($order); while ($row=mysql_fetch_array($result)){ echo ("<tr><td>$row[name]</td>"); echo ("<td>$row[comment]</td>"); echo ("<td>$row[timestamp]</td>"); echo ("<td><a href=\"edit_form.php?id=$row[timestamp]\">edit</a></td></tr>"); } ?> and second one. <?php include "db.inc.php";//database connection $order = "select * note timestamp='id'"; $result = mysql_query($order); $row = mysql_fetch_array($result); ?> the , id=$row[timestamp] in first file , where timestamp='id'"; how value of id in second file equal id in first file. thanks use $_get here include "db.inc.php";//database connection $

java - Working only with gedit/vim. How to run JUnit class via command line -

i working on linux mint 14. installed junit , verified on path. in home folder have class named testclass.class , in have defined test methods. when try run program following error: lazarevsky@linuxbox ~ $ java -cp /usr/share/java/junit.jar junit.textui.testrunner testclass.class class not found "testclass.class" how proceed? doing wrong? note not using full-blown ide text editor. you should use java -cp .:/usr/share/java/junit.jar junit.textui.testrunner testclass you should add . (the current directory) classpath you should use class name testclass not testclass.class edit first, should read doc of junit. there lot of manuals. https://github.com/junit-team/junit/wiki if use junit4, can start this: download junit-4.11.jar:hamcrest-core-1.3.jar junit site. create testcase.java file this: import org.junit.test; import org.junit.runner.runwith; import org.junit.runners.junit4; @runwith(junit4.class) public class testcase { @test

c++ - Why is it called dynamic binding? -

we use virtual achieve dynamic binding in cpp i.e. decide @ runtime function has called based on actual object created rather reference or pointer variable. class { int a; public: virtual void show(); }; void a::show() { cout<<a<<endl; } class b:public { int b; public: void show() { cout<<b<<endl; } }; class c:public { int c; public: void show() { cout<<c<<endl; } }; assume, somefunction(a& aref) . can take object of type b or c or a note: assuming values of data members set i mean path defined (it can or b or c). isn't run time dependent [like asking user enter age , user enters word or other datatype]. but why called run time binding ? compiler make check beforehand if object assigned compatible or no. is terminology used indicate there no strict association of reference variable particular type of object , decided @ run-time. there more ? virtual methods create virtual table in object used call

c# - Programmatically delete directory of cloned repository -

i using libgit2sharp clone remote repository windows temp folder. after script has completed, want clean up. however, following error: systemerror: access path 'pack-efcef325f8dc897099271fd0f3db6cf4d9f12393.idx' denied. where pack-efcef325f8dc897099271fd0f3db6cf4d9f12393.idx file in $local_git_clone_path\objects\pack. how can delete local leftovers of git repo cloned using libgit2sharp ? i remember having faced similar situation. and, advised @nulltoken, have dispose() repository before trying delete files being held it. using should best option. using (var repo = new repository(repositorypath)) { //your repo specific implementation. } //code delete local temp dir reference: clone fixture libgit2sharp

javascript - Update a row in Parse.com -

what have when edit button clicked values in 2 input fields create new row , old row dropped.below code used want original row updated , not deleted. live example of how using code below works. editbtn.onclick = function () { alert("edit btn"); alert(name.value + " " + lname.value); contact.save(null, { success: function (contact) { contact.set("firstname", name.value); contact.set("lastname", lname.value); contact.save(); object.destroy({ success: function (myobject) { alert("destroy"); location.reload(); }, error: function (myobject, error) { alert("error: " + error.code + " " + error.message); } }); } }); } just clarify want update rows not create new 1 whil

java - How to assign the location of button? -

how can create button on frame in north , in center horizontally? (i.e not occupy width)? borderlayout expands components in north location fill width of container. therefore need place in container respects preferred size of component, jbutton in case. can use default flowlayout in jpanel : jpanel northpanel = new jpanel(); jbutton button = new jbutton("ok"); frame.add(northpanel, borderlayout.north);

jquery - Chaining dynamically loaded javascript -

i have static page i'm trying add jquery , blockui plugin to. jquery needs loaded first before can use blockui, , while can load jquery fine, cant seem blockui load after , call loaded handler can work. see blockui script tag in html page, @ least being injected in okay far can see. here's code: var jqueryscript = document.createelement( "script" ); jqueryscript.src = "/glptools/scripts/jquery-1.9.1.min.js"; if ( jqueryscript.addeventlistener ) { jqueryscript.addeventlistener( "load", jqueryready, false ); } else if ( jqueryscript.readystate ) { jqueryscript.onreadystatechange = jqueryready; } document.getelementsbytagname( 'head' )[0].appendchild( jqueryscript ); function jqueryready() { if ( typeof jquery != 'undefined' ) { $( document ).ready( function () { //initialize tabber tabberautomatic( "" ); // add blockui plugin var blockuiscript = d

c++ - SQLBindParameter for output varchar -

i have stored procedure has varchar output parameter: @useridout varchar(50) output and in c++ code attempt bind output parameter this: ... sqlchar useridout[50]; int dbreturn = execproc(...(sqlchar**)&useridout); ... int execproc(...sqlchar **useridout) { ... sqlinteger cbparam7 = sql_nts; retcode = sqlbindparameter(hstmt1, 7, sql_param_output, sql_c_char, sql_varchar, 50, 0, *useridout, 50, &cbparam7); retcode = sqlexecdirect(hstmt1, (uchar*)"{? = call updateuser(?,?,?,?,?,?)}", sql_nts); i have several other input parameters, , return value stored procedure. i've tried few variations function call, , yet never in useridout . if execute stored procedure sql server proper output. any thoughts? per comments: you need pass pointer useridout sqlbindparameter . passing isn't pointer useridout , rather, first bytes of useridout reinterpreted pointer. an array implicitly converted pointer first element (and since array

C# Make application compatible on other computers? -

edit: here file if want test: cleaner i'm making program cleans files automatically @ startup performance reasons. how make application work on computer has release files? i made application using framework 2.0 , works correctly without errors on computer if copy release files computer, "application stopped responding" happens when starts. there no resource files except icon , embedded resource. have no idea do. private void cleansystem() { timer1.enabled = true; timer1.start(); progressbar1.maximum = 10; string offline = environment.expandenvironmentvariables("%systemroot%") + "\\offline web pages"; string download = environment.expandenvironmentvariables("%systemroot%") + "\\downloaded program files"; string software = environment.expandenvironmentvariables("%systemroot%") + "\\softwaredistribution\\download"; string wintemp = environ

osx - How can I install GNU Octave on Mac with Fink ? -

i tried install gnu octave on mac using fink instruction http://wiki.octave.org/octave_for_macos_x i think have followed instructions can't run octave. how can check if installed correctly? tried typing 'octave' in terminal says 'command not found' or, there easy instruction octave installation? i've found many install guides different , assumes knowledge. incidentally, have installed octave gnu today twice on 2 different machines (both running lion). i needed latest version of octave (3.6.4), , used homebrew. i had xcode installed, rest: install homebrew based on instructions in this page , ran: ruby -e "$(curl -fssl https://raw.github.com/mxcl/homebrew/go)" install octave following this guide , ran: brew tap homebrew/science brew update && brew upgrade brew install gfortran brew install octave install aquaterm notice need before install gnuplot (or gnuplot won't see aqua valid terminal , may 'un

hudson - What URL will get the status code (result) of the last Jenkins job? -

i wondering if knows url required (as or post) status code (result) of last jenkins job (when build# not known client calling request)? want able detect if result red or green/blue . i have code sample, need adjust works jenkins, purpose (as stated above): public class main { public static void main(string[] args) throws exception { url url = new url("http://localhost/jenkins/api/xml"); document dom = new saxreader().read(url); for( element job : (list<element>)dom.getrootelement().elements("job")) { system.out.println(string.format("name:%s\tstatus:%s", job.elementtext("name"), job.elementtext("color"))); } } } once figure out answer, share full example of how used it. want create job collects information on test suite of 20+ jobs , reports on of them email. you can use symbolic descriptor lastbuild : http://localhost/jenkins/job/<jobn

yeoman create node_modules for new webapp -

i new yeoman , new version grunt , bower, question is, when create new webapp running yo webapp under project folder, command after asking me question regarding inclusion of stuff bootstrap, creates folder called node_modules, lor of files, normal??, don't modules should installed in more global folder? explanation node.js dependencies local project . hence node_modules folder.

excel vba - VBA index in function -

i'm new vba (10 hours) coming bit of python background. there vba equivilant python when comes indexing part of returned function? mean: if have vba code looks this: split(worksheets("range").range("k2").offset(i, 0), "-", "-1") and want third part of split, how output? i imagine simple question can't seem think through. in advance! if function setting value of variant/array variable, e.g.,: dim myarray variant myarray = split(worksheets("range").range("k2").offset(i, 0), "-", "-1") then should able refer 3rd item in array like: debug.print myarray(2) 'option base 0 -- default' or, if have option base 1 then: debug.print myarray(3) those examples use constant expression (2 or 3) index array item. use match function return dynamic value, e.g., let's looking value of "steve" in array: dim aitem long aitem = application.match("steve", my

javascript - HTML: stop rendering HTML code inside div -

this question has answer here: preview html markup inside textarea 1 answer if write below inside textarea <strong>test</strong> inside textarea , display inside div. shows text in bold letter instead of showing html code is. how can avoid rendering html code. want show text entered user. you haven't shown code, since have tagged jquery i'll assume have like: $('div').html( $('textarea').val() ); use text method instead, user has typed treated text instead of html. $('div').text( $('textarea').val() ); see a demonstration .

Add and Remove KML overlay to a Google Map from external link -

i'm trying emulate functionality https://maps.google.com/maps?q=http://en.wikipedia.org/w/index.php%3ftitle%3dtemplate:attached_kml/n_postcode_area%26action%3draw i want able add , remove postcode region external link / checkbox. have kml file loading correctly using code have no idea how attach external event listener / handler. function initialize() { var london = new google.maps.latlng(51.522416,-0.11673); var mapoptions = { zoom: 11, center: london, maptypeid: google.maps.maptypeid.roadmap } var map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); var ctalayer = new google.maps.kmllayer({ url: 'path/to/kml', suppressinfowindows: true }); ctalayer.setmap(map); } google.maps.event.adddomlistener(window, 'load', initialize); i've tried looking in ctalayer object individual nodes kml file dont seem there.

Cointelation (hybrid method between COINTegration and corrELATION technique) on two series using R -

cointelation a hybrid method between cointegration , correlation techniques. ref: http://wilmott.com/pdfs/mvmc_csl_05_2012.pdf there great packages in r on cointegration not find on cointelation on http://www.rseek.org/ or in http://cran.r-project.org/web/views/ i have 2 time series library(quantmod) getsymbols("yhoo",src="google") getsymbols("goog",src="yahoo") how can perform cointelation on 2 series using r? is there package, functions, code or references in r dealing cointelation? grateful on this. there new article came out october 23rd. can found here: http://onlinelibrary.wiley.com/doi/10.1002/wilm.10252/abstract

javascript - Google Earth Plugin not loading sideDatabase from Mapsengine/Earthbuilder -

i have not been able display side database (map mapsengine/earthbuilder). have installed google plugin , tried access firefox, chrome, , ie browsers , nothing seems work. not sure i'm doing wrong have confirmed code code used in google's code playground, , have attempted workaround suggested in similar issue past (issue 21: gmaps engine layer disappeared on gearth plugin). when specifing url of map displayed in ge plugin, changed url include &export=download, 1 of fixes saw in similar issue (it kml files google docs). strangely, when webpage accessed, not give error side database failed download. have included part of code below. any assistance appreciated. thanks in advance, <script type="text/javascript"> var cho; google.load("earth", "1"); function init() { google.earth.createinstance('map3d', initcb, failurecb); } function initcb(instance) { cho = instance; cho.getwindow().setvisibility(true); ch

ms access - Call method from another form -

Image
i have navigation form 2 subforms looks this: when button in subform clicked, call method subform b. method defined this: public sub mymethod() debug.print "mymethod called" end sub i tried using forms!subformb.mymethod error database cannot find referenced form 'subformb' . referring this page, tried forms!navigationform!subformb.mymethod database cannot find referenced form 'navigationform' . know how properly? thank you. function , sub procedures defined in class module of form considered private form. if want sub can called several different forms move sub "regular" vba module (i.e., 1 created when choose insert > module menu bar in vba editor) , sure declare public .

Facebook login dialog doesn't close using javascript SDK -

i've tried facebook login using fb javascript sdk. after login doesn't close login window in opera browser. how can fix problem? i've tried following source code: (on-line in this website - link ) <html> <head></head> <body> <div id="fb-root"></div> <script> window.fbasyncinit = function() { fb.init({ appid: '101103500012652', // app id channelurl: '//www.milujse.cz/app/channel.html', // channel file status: true, cookie: true, xfbml: true }); fb.event.subscribe('auth.authresponsechange', function(response) { if (response.status === 'connected') { testapi(); } else if (response.status === 'not_authorized') { } else { } }); }; (function(d) { var js, id = 'facebook-jssdk', ref = d.getelementsb

.net - Extract group of number from text -

having such text above includes - add/remove member to/from nested group - 1.24.12 / 1.24.13 how create regular expression return 2 groups of 3 numbers have. expected result 1.24.12 1.24.13 i tried use such expression private static regex mrdnumbers = new regex(@"((\d+.?){2,})+"); but doesn't work needed. also, length of group can different, can 1.22 13.4.7 1.2.3.4 1.2.3.4.5 1.2.3.4.5.6 the problem . in pattern. in regular expression language, . character matches character (except in single-line mode), have escape \ character match periods. try instead: private static regex mrdnumbers = new regex(@"((\d+\.?){2,})+"); to capture matched numbers in list, might try this: private regex mrdnumbers = new regex(@"(\d+?)(?:\.(\d+))+"); string input = "above includes - add/remove member to/from nested group - 1.24.12 / 1.24.13"; mrdnumbers.matches(input).cast<match>().dump(); var list = (from m in mr

django - AttributeError: 'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX' -

i trying make smart menu using chainedforeignkey, far stuck import of chainedforeignkey : from smart_selects.db_fields import chainedforeignkey i using pydev on eclipse. downloaded smart select package here: http://pydoc.net/python/django-smart-selects/1.0.2/ , added pythonpath when debug get: traceback (most recent call last): file "c:\users\mr.machine\desktop\eclipse\plugins\org.python.pydev_2.7.0.2013032300\pysrc\pydevd.py", line 1397, in <module> debugger.run(setup['file'], none, none) file "c:\users\mr.machine\desktop\eclipse\plugins\org.python.pydev_2.7.0.2013032300\pysrc\pydevd.py", line 1090, in run pydev_imports.execfile(file, globals, locals) #execute script file "c:\users\mr.machine\desktop\workspace\medbook\testapp\forms.py", line 4, in <module> smart_selects.db_fields import chainedforeignkey file "c:\users\mr.machine\desktop\django-smart-selects-1.0.2\smart_selects\db_fields.py"

html - CSS wrapping and hiding text within a table -

Image
i've searched other answers , none of them seem produce desired results looking for. here table: (removed , added rendered html @ bottom.) currently isn't wrapping text table looks nice , clean. have long procedures names , table pushed off page. what want happen if name longer width of cell hides text. i want procedure have width constrains. edit adding rendered html: i have added no additional css project outside of included in asp.net mvc4 starter template. <table style="width: 100%; white-space: nowrap; overflow: hidden;"> <tbody><tr> <th> department </th> <th> function </th> <th> process </th> <th style="max-width: 75px;"> procedure </th> <th> </th> </tr> <tr> <td>legal process</td&

Is it possible to use ExtJS components in AngularJS? -

i'm enjoying learning use angularjs. i'm looking components can use it. i've been looking @ angular-ui components i'd know if it's possible use nice, supercharged components in extjs. have experience this? hints or tips or angular directive libraries? the company work making similar move. rely heavily on older version (3.x) of extjs, , effort upgrade current (5.0) version @ least equal effort required move angular. to answer question (to best of limited knowledge): they can exist in same js application. can use ui elements of extjs angular? you can put angular in control of markup via html templates in ext. is wise idea? probably not. why consider doing this? i need absolute control on markup , don't care possible page load issues i need serialize or de-serialize in special way ext doesn't innately provide i need special pub/sub (still totally possible ext) in our case, proof of concept few modals. if biased, biased i

pass an array of strings from C# to a C++ dll and back again -

i have looked around googleverse , stack overflow , have seen several similar questions none of answers have found have worked me. new member not allowed comment on answers in else's question ask clarification have had resort asking own. ok trying pass string array c# application c++ dll , grab information in c# application. believe passing c++ can't proper strings dll. i passing c++ so: [dllimport("kinectplugins.dll", callingconvention = callingconvention.cdecl)] private static extern void setgrammardata(string[] strarr, int size); public void setgrammar(string[] strarr) { setgrammardata(strarr, strarr.length); } my c++ code looks this: #define export_api __declspec(dllexport) #pragma data_seg(".shared") char** grammardata; int grammardatalength = 0; #pragma data_seg() #pragma comment(linker, "/section:.shared,rws") export_api void setgrammardata(char** strarr, int size) { grammardata = strarr

python - Django ChainedForeignKey smart menu -

i trying make chained select menu, have model: from django.db import models class health_plan(models.model): name = models.charfield(max_length=15) class doctors_list(models.model): name = models.charfield(max_length=30) specialty = models.charfield(max_length=15) health_plans = models.manytomanyfield(health_plan, related_name="doctors") location = models.charfield(max_length=15) def __unicode__(self): return self.name and forms.py : class specform(modelform): = doctors_list.objects.values_list('specialty', flat=true) unique = [('---------------','---------------')] + [(i,i) in set(a)] specialty = forms.choicefield(choices=unique) class meta: model = doctors_list class healthform(modelform): hplan = chainedforeignkey( health_plan, chained_field="specialty", chained_model_field="specialty", show_all=false, auto_choose=

android - How to set Layoutparams of child view without affecting parent view? -

i have custom row view list. there 2 components parent , child....i want maintain height of parent constant when change height of child... i have set parent height constant , height of child varied dynamically. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/parent" android:layout_width="wrap_content" android:layout_height="150dp" android:background="#fff" android:orientation="vertical" > <relativelayout android:id="@+id/child" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" /> </relativelayout> </linearlayout> and during runtime, child.setlayoutparams(new layoutparams(30, x); where x varying height variable. still height of parent getting affected. solutions? if linearlayout root view, when inflating params android:layout_w

c - scanf inside while loop working only one time -

so have code, supposed coordinates user: #include <stdio.h> #include <time.h> int main() { int number; char letter; int points = 3; while(points < 8){ printf("give me first coordinate (letter)"); scanf("%c",&letter); printf("give me second coordinate (number)"); scanf("%d",&number); } } as far know, should keep taking coordinates user, instead takes once, , crush in weird way, it's skipping scanf without reason. here's output: give me first coordinate (letter)a give me second coordinate (number)1 give me first coordinate (letter)give me second coordinate (number)12 give me first coordinate (letter)give me second coordinate (number)df give me first coordinate (letter)give me second coordinate (number)give me first coordinate (letter)give me second coordinate (number)sss i feel confused, since simple code, , don't have slightes idea whats causing this. anybody?(

c - Bug with __int128_t in Clang? -

this little code compiles both gcc , clang, gives different results: #include <stdio.h> int main(){ __int128_t test=10; while(test>0){ int mytest=(int)test; printf("? %d\n", mytest); test--; } } with gcc counts 10 down 1, intended behaviour, while clang keeps on counting negative numbers. clang, if replace test-- test-=1 gives expected behaviour well. __int128_t gcc extension, above results apply non-standard c, maybe __int128_t "use @ own risk" in clang. is bug in clang, or did make mistake i'm not seeing? edit: i'm using gcc (macports gcc48 4.8-20130411_0) 4.8.1 20130411 (prerelease) , apple clang version 4.0 (tags/apple/clang-421.0.60) (based on llvm 3.1svn). this bug in clang, resolved somewhere between apple clang version 4.0 (tags/apple/clang-421.0.60) (based on llvm 3.1svn) , apple llvm version 4.2 (clang-425.0.28) (based on llvm 3.2svn), see comments -- carl , h2co3.

string - Given the pairwise edit distance of a and b and b and c, can we find the pairwise edit distance of a and c? -

if have 3 string a, b, c , know ( or calculated ) edit_distance(a,b) , edit_distance(b,c), can efficiently calculate edit_distance(a,c) without comparing , c. *edit_distance(a,b) = number of character insertion, deletion , replacement required convert b.* in general, no. example, take a = cap b = cat c = car here, edit_distance(a, b) = 1 , edit_distance(b, c) = 1. moreover, edit_distance(a, c) = 1. however, have a = cap b = cat c = rat here, edit_distance(a, b) = 1 , edit_distance(b, c) = 1, edit_distance(a, c) = 2. therefore, there no way purely use edit distances of , b , of b , c compute edit distance of , c. however, do know edit_distance(a, c) ≤ edit_distance(a, b) + edit_distance(b, c), since can apply transformations in sequence turn c. more generally, edit distance forms discrete distance metric , forms basis of bk-tree data structure . hope helps!

python - Extracting individual frames from an image -

i new python , want extract r, g , b frame separately image. for instance, variable stores image img what want know; how make rimg = img (:,:,1) gimg = img (:,:,2) bimg = img (:,:,3) ofcource, these matlab pseudo codes , rimg, gimg , bimg variables. numpy style : bimg = img[:,:,0] gimg = img[:,:,1] rimg = img[:,:,2] opencv style : b,g,r = cv2.split(img)

macros - Outputting Drop-Down Form Field to String for use in VBA formula -

ok, have word 2010 template i'm playing with. have button @ top users click automatically save word doc pdf (almost) correct name, in correct directory, , opens doc. have drop-down form field can select month. the code button: private sub commandbutton1_click() convert_pdf end sub sub convert_pdf() dim desktoploc string dim filename string dim date string dim user string dim mypath string desktoploc = createobject("wscript.shell").specialfolders("desktop") filename = "installs team metrics" user = vba.environ("username") mypath = desktoploc & "\metrics\" & filename & " - " & date & " - " & user activedocument.exportasfixedformat outputfilename:= _ mypath, _ exportformat:=wdexportformatpdf, openafterexport:=true, optimizefor:= _ wdexportoptimizeforprint, range:=wdexportalldocument, from:=1, to:=1, _ item:=wdexportdocu

java - Can't add to an array list -

i have oddest problem, simple solution. i have created , initialized list , proceeded create 4 objects of list's type. in constructor of these place in list. or @ least supposed to. out of bound exception , cant figure out why. set list have size of 402 (for possible vk values) in console , debug says has size 0, no matter how large or empty set too.... public class inputhandler implements keylistener { public static list<key> keylist = new arraylist<key>(keyevent.key_last); public key = new key(keyevent.vk_up); public key down = new key(keyevent.vk_down); public key left = new key(keyevent.vk_left); public key right = new key(keyevent.vk_right); public class key { public int keycode; public key(int defaultcode) { this.keycode = defaultcode; keylist.add(keycode,this); } public key remapkey(int newkey) { keylist.remove(keycode); keylist.set(newkey, this); this.keycode = newkey; ret

html - UTF8 combination PHP/MySql -

this question has answer here: utf-8 way through 14 answers my sql database have utf8_unicode_ci collation , html have utf8 (meta charset="utf-8"). when write in php: $query = "select * `subjects` `year` = '$year'"; $result = $mysqli->query($query); while($row = mysqli_fetch_array($result)){ echo "<option value='" . $row['name'] . "'>" . $row['name'] . "</option>"; } instead čćšđ getting crazy values like: ?�... add mysql_query("set names 'utf8'"); mysql_query("set character set 'utf8_general_ci'"); before $query = "select * `subjects` `year` = '$year'";

facebook fql - FQL query doesn't return the correct results -

i'm running following fql query in graph explorer: select album_object_id, object_id, aid, pid photo object_id=576544082370719 and correct results want: { "data": [ { "album_object_id": 520085011349960, "object_id": 576544082370719, "aid": "396713620353767_120902", "pid": "396713620353767_2121634" } ] } however, when adding album_object_id statement, nothing returned: select album_object_id, object_id, aid, pid photo object_id=576544082370719 , album_object_id=520085011349960 { "data": [ ] } anyone has idea? tried report said can't reproduce https://developers.facebook.com/bugs/448684285215430 here example doesnt work supposed to, going on? select object_id, modified photo object_id=507652032628572 this gives correct result, however: select object_id, modified photo album_object_id=468672926526483 , modified>1365522434 no results on o

java - How to properly use load array and save array methods? -

i have following code designed user click on button , when click on button, particular string viewing favorited , stored somewhere else. i have 2 questions. one what's wrong have right now? crashes when click button. how go finishing on load array method string loaded , saved array user see array later? thanks time!! fav.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { loadarray("favorites"); favorites = arrays.copyof(favorites, favorites.length+1); favorites[favorites.length]=display.gettext().tostring(); savearray(favorites, "favorites"); } }); home.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { intent openstartingpoint = new intent("starting.rt.menu2"); startactivity(openstartingpoint); } }); search.setonclicklistener(new view.onclicklistener() {