Posts

Showing posts from May, 2014

asp.net - Query web.config for a key - in values -

can 1 let me know how bool result, verifying value exists in web.config's key. scenario is, i have tag in website... <add key="isenabled" value="false"/> website, on key value keep site 'on' , 'off' using public static bool isenabled = convert.toboolean(webconfigurationmanager.appsettings["isenabled "]); if(isenabled) { // } now requirement got 3-4 websites now, want change above line like <add key="sitesenabled" value="1,4,5"/> because want enable 1st, 4th, 5th site 1 - static value 1st website, 2 - 2nd..... but how do on , off...my websites like public static bool onesiteenabled = convert.toboolean(webconfigurationmanager.appsettings[sitesenabled="1"]); // true public static bool twositeenabled = convert.toboolean(webconfigurationmanager.appsettings[sitesenabled="2"]); //false please let me know ...thanks i this: using system.linq; var sites

mysql - PHP outputs from command line but not from the browser -

i have php file testphp.php following content: <?php echo system('mysql -u root -pmypassword -e "select version();"'); ?> it outputs command line: d:\>php testphp.php version() 5.5.24-log 5.5.24-log d:\> when execute same file via web browser ( http://localhost/testphp.php ) , see no output. why? there lots of reasons this: you using command mysql may not in path of user web server runs as. when run command line, running own user account. web server runs under different (restricted) account. should provide full path mysql binary. type which mysql normal user prompt find out full path executable. the command mysql may restricted system configuration not users can execute it. your php configuration on web server prohibits use of system() . you can same information running (assuming have mysql configured php installation): $con = new mysqli("localhost", "root", "mypassword"); printf("%s"

sql server - Restoring database - Cannot access file because it is in use by another process -

i have backup of database sql server 2005 machine. i'm attempting restore sql server 2008 instance. i have created new database restore go in to, when attempting restore following (generated ssms): restore database [wendyuat] disk = n'd:\wanda20130503.bak' file = 1, move n'wendy' n'd:\databases\\wendyuat.mdf', move n'wendy_log' n'd:\databases\\wendyuat.ldf', move n'sysft_wendyfti' n'd:\databases\\wendyuat.wendyfti', nounload, replace, stats = 10 i following error: system.data.sqlclient.sqlerror: operating system returned error '32 (the process cannot access file because being used process.)' while attempting 'restorecontainer::validatetargetforcreation' on 'd:\databases\wendyuat.mdf'. as far can tell (using process explorer etc) nothing else using file. i've disabled real-time protection in windows defender. cannot understand why sql server thinks file in use windows e

if statement - How to apply conditional treatment with line.endswith(x) where x is a regex result? -

i trying apply conditional treatment lines in file (symbolised list values in list demonstration purposes below) , use regex function in endswith(x) method x range page-[1-100]) . import re lines = ['http://test.com','http://test.com/page-1','http://test.com/page-2'] line in lines: if line.startswith('http') , line.endswith('page-2'): print line so required functionality if value starts http , ends page in range of 1-100 returned. edit: after reflecting on this, guess corollary questions are: how make regex pattern ie page-[1-100] variable? how use variable eg x in endswith(x) edit: this not answer original question (ie not use startswith() , endswith() ), , have no idea if there problems this, solution used (because achieved same functionality): import re lines = ['http://test.com','http://test.com/page-1','http://test.com/page-100'] line in lines: match_beg = re.search( r&#

javascript - Viewport always centralized on a bigger background image -

Image
it possible make viewport behave css and/or javascript/jquery: currently, i'm using css below make background cover whole viewport: #background { width: 100%; height: 100%; top:0; left:0; position: absolute; -webkit-background-size: cover !important; -moz-background-size: cover !important; -o-background-size: cover !important; background-size: cover !important; overflow: hidden; } but that's not need. using way, on low screen resolutions background image distort , looks real bad. edit clear, i'm not concerned mobile users. that's not purpose of system i'm working @ at first. desktop system. thanks everybody. try this... #background { background: url('image/myimage.jpg') center center; } or body { background: url('image/myimage.jpg') center center; } if can set ground @ body level there no need #background element. but setting image using css not scale image , "center center&qu

jquery - Social buttons on fancybox -

i want integrate script http://jsfiddle.net/g5tc3/ pre existent configuration of fancybox (i use fancybox plugin wordpress, can edit part of configuration of fancybox) this configuration: <script type="text/javascript"> jquery(function(){ jquery.fn.gettitle = function() { // copy title of every img tag , add parent fancybox can show titles var arr = jquery("a.fancybox"); jquery.each(arr, function() { var title = jquery(this).children("img").attr("title"); jquery(this).attr('title',title); }) } // supported file extensions var thumbnails = jquery("a:has(img)").not(".nolightbox").filter( function() { return /\.(jpe?g|png|gif|bmp)$/i.test(jquery(this).attr('href')) }); thumbnails.addclass("fancybox").attr("rel","fancybox").gettitle(); jquery("a.fancybox").fancybox({ 'cyclic': false, 'autoscale': true,

java - Out of two ways to get/create items concurrently from/in ConcurrentHashMap, which one is better? -

i have found myself using 2 different approaches getting/creating items from/in concurrenthashmap , wonder 1 better. the first way: public class item { private boolean m_constructed; ... public void construct() { if (m_constructed) { return; } synchronized (this) { if (m_constructed) { return; } // heavy construction m_constructed = true; } } } concurrenthashmap<string, item> m_items = new concurrenthashmap<string, item>(); ... // following code executed concurrently multiple threads: public item getorcreateitem(string key) { item newitem = new item(); // constructor empty item item = m_items.putifabsent(key, newitem); if (item == null) { item = newitem; } item.construct(); // real construction return item; } please, not comment on using this in synchronize (this) . aware of crappiness of using this lock object, fine in pa

printing - how to print odd numbered observations from a dataset SAS -

i have simple question, unfortunately cannot seem solve myself. how print observations odd observation number data set? one way might data step view. assuming have data set named "mysasdata", try this: data my_view / view=my_view; set mysasdata; if mod(_n_,2) = 1; run; proc print data=my_view; run; if wanted "even" observations, use if mod(_n_,2) = 0; . however, note observation numbers displayed proc print relative view , not original data set. data step views useful things this.

php - Can't reload jQuery Masonry -

i got site shows 25 images. i've created button says "load more". buttons pull 25 images php script via ajax. part working fine. problem is, i'm using jquery masonry align images. right now, calls masonry function when page loaded. function masonry() { var $container = $('#fit'); $container.imagesloaded(function () { $container.masonry({ itemselector: '.masonryimage' }); }); } however, when want call masonry() function afterwards, doesn't work. if don't call masonry() on load, works fine in ajax function. any ideas why happens? calling bulk masonry() again after reload fixed issue me. $('#fit').append(newitems).masonry('reloaditems').masonry();

Different Facebook accounts Objective-C -

i start integration of facebook on iphone app. i can log , profile picture , name, when try switch account (not developer account), error : fbloginview encountered error=error domain=com.facebook.sdk code=2 "the operation couldn’t completed. (com.facebook.sdk error 2.)" i search on internet don't find solution, don't know how fix :/ thx ! [edit] : in fact, app on facebook developer account in 'sandbox mode' so, developers , testers launch app on iphone !!

c# - Why can't I reach data within Method? -

i'm trying fill tablelayoutpanel through method goes follows: private int _rowcount; public void initpaths() { int c = 1; int = 1; while (a < _pathrows.length - 1) { var label = new label(); // // label - format. // label.dock = dockstyle.fill; label.autosize = false; label.text = _pfadzeilen[a]; label.textalign = system.drawing.contentalignment.middleleft; label.size = new system.drawing.size(22, 13); label.backcolor = system.drawing.color.transparent; tablelayoutp.controls.add(label, 3, c); //checkboxen einfügen var cbox = new checkbox(); // //checkbox format. cbox.anchor = system.windows.forms.anchorstyles.none; cbox.autosize = true; cbox.checkalign = system.drawing.contentalignment.middlecenter; cbox.name = "checkboxpfad" + a; cbox.size = new system.drawing.size(15, 14); cbox

c# - Use Decorator Pattern for asp.net controls -

i've created custom textboxes inherited textbox. next step want register javascript wrapper. decorator pattern allow me if can inherit textbox , pass custom textbox constructor parameter. problem how can use constructor when add control aspx page or how can use decorator pattern asp.net controls. edit: simply validation base class (ifield validation interface. can ignored): public abstract class validationbase : textbox, ifield { private readonly ifield _field; protected validationbase(ifield field) { _field = field; } public int minlength { { return _field.minlength; } set { _field.minlength = value; } } public bool required { { return _field.required; } set { _field.required = value; } } // other porperties etc... protected override void onprerender(eventargs e) { // stuff... base.onprerender(e); } } and concrete class (emailfield concrete impl. of

mongodb php - PHP Mongo:command not found -

Image
i have been trying use mongo::command in php build mapreduce every time run code following error: php fatal error, call undefined method "mongo:command" my code: try { $map = new mongocode("function() { if (!this.tags) { return; } (index in this.tags) { emit(this.tags[index], 1); }"); $reduce = new mongocode("function(previous, current) { var count = 0; (index in current) { count += current[index]; } return count; }"); $tags = $this->db->command(array( //line error found on "mapreduce" => "blog", "map" => $map, "reduce" =

How to get input value attribute with jquery -

i'm trying target value of value attribute in input field precedes label class="selected" <div id="placeholder"> <div id="product-options" class="options"> <input checked="checked" id="option_33295465" name="cart[add][id]" type="radio" value="33295465" class="input_hidden"/> <label for="option_33295465" class="selected"> <span>option1</span> </label> <input id="option_33544344" name="cart[add][id]" type="radio" value="33544344" class="input_hidden"/> <label for="option_33544344"> <span>option2</span> </label> </div> </div> at moment i'm trying log value, undefined each time. $('body').on('click','#button1',function(e){ e.preventdefault();

javascript - Get XML file with JQuery? -

this question has answer here: using “is less than” character (<) in xml document , parse it 1 answer i save following xml code xml file. <z> <f>{"attributes":{"type":"form"}}</f> <m><%@ taglib prefix="zf" uri="http://www.zcore.org/tags/form" %></m> </z> now when want load jquery error : timestamp: 5/5/2013 7:05:13 pm error: not well-formed and <%@ ... %> syntax put in xml file. how can read file xml file without error? thanks all. you need wrap values in cdata blocks xml parser ignores inner text. see below: <z> <f><![cdata[{"attributes":{"type":"form"}}]]></f> <m><![cdata[<%@ taglib prefix="zf" uri="http://www.zcore.org/tags/form" %>]]>&

c++ - Recursive Way to Find 2nd/3rd Smallest Element In Array -

below code written find smallest element of unsorted array in c++. how should go editing recursive function find second or third smallest element in array? i understand there other methods out there (i've searched), i'd know how using recursive function works minimum number. int min(vector<int> &array, int &min, int &next_min, int left,int right) { int a; int b; if(left == right) { return array[left]; } else { int mid= (right+left)/2; = min(array,left,mid); b = min(array,mid+1,right); if (a<b) return b; else return a; } } many in advance here attempt @ finding 2nd smallest: #include<iostream> #include<vector> #include <cstdlib> using namespace std; int counter=0; void minf(vector<int> &array,int left,int right,int &min, int &next_min); int main() { int next_min; cout <<

facebook - PHP-SDK publish_stream? -

when try publish on walls of friends, not work. don't know problem is. can me? if ($user) { try { // user profile data have permission view $user_profile = $facebook->api('/me/feed', 'post', array( 'link' => 'www.your-website.com', 'message' => 'hello world!' )); } catch (facebookapiexception $e) { $user = null; } } else { $loginurl = $facebook->getloginurl(array('scope' =>'publish_stream','redirect_uri'=>'http://your-website/index.html')); die('<script> top.location.href="'.$loginurl.'";</script>'); } in code above, calling end point "me" publish action. means publishing wall of current user, not friend. further this, facebook has removed ability post on friend's walls

ruby - DataMapper Many-to-Many Delete Constraint -

let's have 2 models many-to-many relation: class tag include datamapper::resource property :id, serial has n, :articles, through: resource end class article include datamapper::resource property :id, serial has n, :tags, through: resource end now if create article tag: tag.create(articles: [ article.create ]) if run tag.first.delete now, returns false since there foreign key constraint due many-to-many relationship. if run tag.first.delete! deletes tag not association record in article_tags table. if use dm-contraints , set :destroy destroys article not want. i can do tag = tag.first tag.articles = [] tag.save tag.destroy but seems seems unclean. there better way? since tag , article linked through many-to-many relationship, you'll need first destroy 'articletag' join model references object you're trying delete. #get tag delete tag = tag.first #deletes rows in article_tags table reference #the tag want delete artic

html - How to access form input value in javascript with special characters in input name? -

i have form cannot change input value field names. 1 such field in html follows: <body> <form id="f" method="get" action="/code/submit.php"> <input type="text" name="var[list]" id="ixv[list]" value=""> <button type="button" title="save" onclick="check();"> </form> </body> now in javascript, want access input value. tried this, , of course doesn't work since [] looks array in js. function check() { var x=var[list].value; alert(x); } the problem variable name has [] in it. how can input field value in javascript? this works: http://jsfiddle.net/mqv82/1/ <input type="text" name="var[list]" id="ixv[list]" value="foo"> alert(document.getelementbyid('ixv[list]').value);

Do we really need to explicitly add Sencha View to Viewport? -

in examples on sencha touch 2 see code samples like:- //contents of app.js ext.application({ name: 'myapp', views: ['myview'], launch: function() { ext.create('myapp.view.myview'); } }); however, code generated sencha cmd like:- //contents of app.js ext.application({ name: 'myapp', views: ['myview'], launch: function() { // destroy #apploadingindicator element ext.fly('apploadingindicator').destroy(); ext.viewport.add(ext.create('myapp.view.myview')); // <--- notice line } }); notice example code did not add newly instantiated view viewport actual code did. both codes equivalent? in example code, how view add viewport or optional? ext.viewport container layout set 'card'. in first sample, class should have config option 'fullscreen' set true. setting fullscreen:true automatically add comoponent viewport when instance crea

ios - Instagram Logout API -

i'm using instagram api latest app , having problems logging out of instagram within app. has else had problems or know of way fix this? thank you. i've found simple workaround issue. it's not elegant, still may useful. in instagram.m authorizewithsafary method located, instead of opening generated igappurl string in safari, send notification string webview handle instagram login page. then watch current request in shouldstartloadwithrequest. request actual redirect uri ends error, when catch request (don't forget check app's redirect uri though), hide webview. at same time you'll receive uri, application handling rest of authorization logic, if authorising safari. however, if app doesn't receive uri, can manually grab request , manually call delegate's handleopenurl method. with such approach, logout logic work expected, since we're clearing our app's instagram-related cached data. however, don't think practice, since

How would a DOM-less,statically typed, ahead-of-time-compiled javascript code compare to native code performance-wise? -

the traditional answer "why javascript slower native code?" is: "because it's interpreted". problem claim interpretation not quality of language itself. matter of fact, nowadays javascript code being jited, still, isn't close native speed. what if remove interpretation factor equation , make javascript aot compiled? match performance of native code? if yes, why isn't done on web*? if no, performance bottleneck now? if new bottleneck dom, if eliminate too? dom-less, compiled javascript efficient native code? if yes, why isn't done on web**? if no, performance bottleneck now? after stripping dom part , interpretation part, big difference can see between javascript , c/c++ fact former has dynamic types. suppose eliminate , end dom-less,statically typed, ahead-of-time-compiled javascipt. how compare native code? if efficient, why isn't used? if not, bottleneck now? in state, javascript identical c. *one might jit faster load, wouldn'

java - Tracking how many cars are rented and available in a Class -

i've been having trouble code. assignment java class.its past due i'm going nuts trying figure out problem. problem: when upload wileyplus(automatic correcting server), keeps saying when 'int n = 14' it's expecting result "24 , 15", "23, 16". however, when enter 12 expected, "7,5". can't seem find what's causing this. with code, make more sense. public class rentalcar { private boolean rented; private static int availablecars = 0; private static int rentedcars = 0; public rentalcar() { availablecars++; rented = false; } public static int numavailable() { return availablecars; } public static int numrented() { return rentedcars; } public boolean rentcar() { availablecars--; rentedcars++; rented = true; return rented; } public boolean returncar() { if (rented) { availablecars++;

c - Comparing values of two arrays -

i have 2 arrays containing, each one, values of coordinates. in other words, first array contains values of x , second array contains values of y. goal consists of not having equal coordinates, means every coordinate must different others. tried this: for (i=0; i<len(lrs)-1; i++) { (j=0; j<len(lrs) ; j++) { if ((pos.x[j]==pos.x[i+1])&&(pos.y[j]==pos.y[i+1])) printf("1"); } } however, there's moment values of "j" , "i" same and, therefore, condition verified, not intended. maybe i'm not thinking right way, can't figure out. it better make inner loop j > only: for (i=0; i<len(lrs); i++) { (j=i+1; j<len(lrs) ; j++) { if ((pos.x[j]==pos.x[i])&&(pos.y[j]==pos.y[i])) printf("1"); } } in case never check condition i==j. more on check each pair once.

c++ - Multiple definitions in different translation units -

i know 1 definition rule can define class in multiple translation units if have same tokens in same order, program weird me file main.cpp #include "source.h" struct mystructure { int field1; float field2; }; int main() { mystructure myvar; myvar.field2= 2.0f; mycustomfunction(myvar); return 0; } file source.h struct mystructure; void mycustomfunction(mystructure& vv); file source.cpp #include "source.h" struct mystructure { char otherfield; int anotherone; bool anotheranotherone; }; void mycustomfunction(mystructure& vv) { vv.otherfield = 'a'; } i'm using msvc2012 , compiler isn't complaining. why that? normal? it's hard compiler complain, since never sees conflicting declarations during same compilation. code not correct, unfortunately compilers don't pick every mistake, nor standard require them to.

java - replace dash by position with user input then store -

i'm working on hangman app right now. programming , trying @ moment replace dash in tw position ( pos ) user input ( input ) store array... can't find issue , driving me insane!!! please me? public static void main(string[] args) { //get random array element system.out.println("welcome hangman app"); string array[] = new string[10]; array[0] = "hamlet"; array[1] = "mysts of avalon"; array[2] = "the iliad"; array[3] = "tales edger allan poe"; array[4] = "the children of hurin"; array[5] = "the red badge of courage"; array[6] = "of mice , men"; array[7] = "utopia"; array[8] = "chariots of gods"; array[9] = "a brief history of time"; arraylist<string> list = new arraylist<string>(arrays.aslist(array)); collections.shuffle(list); string s = list.get(0); //for testing system.out.p

c++ - How to read a string file from second line in C? -

this code reads characters in file , calculates length of characters. how can read second line , ignore read first line? this part of code: int lena = 0; file * filea; char holder; char *seqa=null; char *temp=null; filea=fopen("d:\\str1.fa", "r"); if(filea == null) { perror ("error opening 'str1.fa'\n"); exit(exit_failure); } while((holder=fgetc(filea)) != eof) { lena++; temp=(char*)realloc(seqa,lena*sizeof(char)); if (temp!=null) { seqa=temp; seqa[lena-1]=holder; } else { free (seqa); puts ("error (re)allocating memory"); exit (1); } } cout<<"length seqa is: "<<lena<<endl; fclose(filea); make counter of how many \n have seen,and when ==1 goto read 2nd line. int line=0; while((holder=fgetc(filea)) != eof) { if(holder == '\n') line++; if(holder == 1) break;

maven - Spring web-flow with JSF ClassNotFoundException issue -

i working on project using spring webflow , jsf. trying accomplish similar booking-faces example of spring webflow https://github.com/springsource/spring-webflow-samples/tree/master/booking-faces . following error while trying execute web-flow. org/apache/myfaces/renderkit/statecacheutils viewid=/web-inf/flows/main/entersearchcriteria.xhtml location=c:\users\workspace4\.metadata\.plugins\org.eclipse.wst.server.core \tmp1\wtpwebapps\mywebapp\web-inf\flows\main\entersearchcriteria.xhtml phaseid=render_response(6) caused by: java.lang.classnotfoundexception - org.apache.myfaces.renderkit.statecacheutils @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1678) the full stacktrace is: java.lang.noclassdeffounderror: org/apache/myfaces/renderkit/statecacheutils @ org.springframework.faces.webflow.myfacesflowresponsestatemanager.getwrappedmyfacesresponsestatemanager(myfacesflowresponsestatemanager.java:66) @ org.springframework.faces.webflow.m

html - aligning image next to textbox -

i having difficulty in aligning image next text box. wondering if there easy way other setting padding , margin. because measures can vary in each browsers. have made fiddle http://jsfiddle.net/wd5t9/ <div id='searchwrapper'> <input id='searchbox' style='width:250px; border:1px solid #cccccc; border-radius:7px 7px 7px 7px; padding:5px 28px 5px 10px; margin-top:14px; margin-left:50px;height:18px;' type='text' placeholder='search'/><img src='http://www.q-park.ie/portals/8/images/search-icon.png'/> </div> just add css: #searchwrapper img { vertical-align: middle; }

Hide default text in a field - Javascript? -

i want when click on field, default text hidden , when enter text , click again same field text not hide it. i tried code doesn't work javascript code: for(var = 0; < inputs.length; i++) { inputs[i].onfocus = function() { if(typeof value1 != undefined) { this.value = value1; }else { value = this.value; this.value = ''; this.style.color = "#000"; } } inputs[i].onblur = function() { if(this.value == '' || this.value == value) { this.value = value; this.style.color = "#707070"; }else { value1 = this.value; } } } } are looking placeholder attribute? <input type="text" name="fname" placeholder="first name"> if not want html 5, have simulate of course. have add class flag "state" of input field , test

c# - Is it possible to dynamically add embedded code blocks to asp.net page similar to how controls are added dynamically from code? -

Image
one can dynamically add controls asp.net page. label mylabel = new label(); mylabel.text = "sample label"; panel1.controls.add(mylabel); i want know if possible add embedded code blocks dynamically? if code below, embedded code rendered literally . // use <%#page.title%> or <%=page.title%> example literalcontrol literal = new literalcontrol("<%=page.title%>"); panel1.controls.add(literal); the output of above code be <%=page.title%> is there way make asp.net evaluate embedded code blocks added dynamically? literalcontrol literalcontols = new literalcontrol(); literalcontols.text = page.title; this.masterform.controls.add(literalcontols);

delphi - Indy IMAPClient UIDRetrieveAllEnvelopes not getting other character set properly -

Image
using: delphi xe2, windows 8 us-english default language i writing email client delphi. i'm using tidimap4 connect gmail mailbox via imap , getting message list this: var messagelist: tidmessagecollection; begin imapclnt.selectmailbox('inbox'); imapclnt.uidretrieveallenvelopes(imapclnt.messagelist); then i'm retrieving message subjects this: var idmsg: tidmessage; s: string begin c := 0 fimapclnt.messagelist.count - 1 begin idmsg := fimapclnt.messagelist[c]; s := idmsg.subject; however, if message subject in different language (say, hebrew) message subjects not displayed (see attached image) on computer hebrew set default windows language. how can correct code ensure works properly, retrieving language in correct unicode characters? screen capture: tia. the email headers in screenshot have been encoded per rfc 2047 ("mime part three: message header extensions non-ascii text"). tidimap4.uid

c# - How to give a value to a variable that is in a WebService? -

i making project using webservices in c#. wanted ask you, how can give value variable client web service? for example: in web service have variable , 2 methods, getvariable() , setvariable(bool a); bool var = false; [webmethod] public void setvariable(bool a) { var = a; } [webmethod] public bool getvariable() { return var; } this how web service looks (it's simple because learning). my client: //in client added web service service reference , added code: servicereference.servicesoapclient obj = new servicereference.servicesoapclient(); private void form_load(object sender, eventargs e) { obj.setvariable(true); label1.text = obj.getvariable().tostring(); } and when load form, label1.text isn't equal "true" "false"!! means didn't execute code: obj.setvariable(true); professor said in class webservice "full...." (but couldn't hear well), said have find way make webservices "ful..." can me ?

ruby on rails 3 - how to use sessions in my project to store project id and how to match sessions in code -

i want store selected project's project_id in session , check current user logged in... , match in _shared.html.erb file. how can write condition in _shared file , how can match them in controller??\ i selecting project dropdown list. jquery needed do... got id of selected project in dropdown list not able list activity... @project = project.find(params[:id]) session[:project_id] = @project.id is works store session? i want list activity acording project select dropdown list , make session until select next project. all activity should change project dashboard. , same other links works it. if have best , understandable ajax video or tutorial link pls suggest me.... thanks in advance.. :) this way u can store in sessions. @project = project.find(params[:id]) session[:project_id] = @project.id you going in right direction. , access session using session[:project_id] where u needed.

c# - Different Application Size On Different Screens -

Image
this question has answer here: .net controls changing size between computers 3 answers first time i'm developing windows form application c# . i'm using visual studio 2012. my form's size = 1096x508. set minimum size , maximum size properties 1096x508 . this screenshot of app , but when execute app on computer, result : as see, red line (at bottom of app) invisible. because applciation's height 508 px (as expected) on pc 416px on other computer. because of , red line staying out of form. couldn't see it. in shortly, form's size 1096x508px it's 823x416px on computer. can tell me why there difference? , how can fix this? there resolution difference between screens. the main issue, have discovered, computers different dpi setting cause controls scale. what hans suggesting in linked answer need re-design form when gets

sharding - Relation between shard keys and chunks in MongoDB sharded cluster? -

i can't understand shard key concept in mongodb sharded cluster, i've started learning mongodb. citing mongodb documentation: a chunk contiguous range of shard key values assigned particular shard. when grow beyond configured chunk size, mongos splits chunk 2 chunks. it seems chuck size related particular shard, not cluster itself. right? speaking cardinality of shard key: consider use of state field shard key: the state key’s value holds state given address document. field has low cardinality documents have same value in state field must reside on same shard , if particular state’s chunk exceeds maximum chunk size. since there limited number of possible values state field, mongodb may distribute data unevenly among small number of fixed chunks. my question how shard key relates chunk size. it seems me that, having 2 shard servers, wouldn't possible distribute data because same value in state field must reside on same shar

c++ - Implementing the [B,C]=f(A) syntax (function f acting on an array with two or more output arrays) -

i have question extension of other 2 questions have posted: implementing b=f(a), b , arrays , b defined and implementing b=f(a) syntax move assignment suppose have array a . want create function f acts on a , returns 2 other arrays b , c , enabling following matlab-like syntax [b,c]=f(a); is possible in c++? solution following leemes' answer #include <tuple> using std::tie; std::tuple<typeofb,typeofc> f(const matrix<t1>&a,const matrix<t2>&a) { // instruction declaring , defining b_temp , c_temp return std::make_tuple(b_temp,c_temp); } int main( int argc, char** argv) { // instruction declaring a, b , c tie(b,c)=f(a); // stuff return 0; } everything works when changing std::tuple , make_tuple std::pair , std::make_pair particular case (only 2 outputs). in general, if want return multiple values, have little work-around, since c++ doesn't allow out of box. the first option r

How to capture still image from webcam on linux -

i trying write c++/qt program linux, take still image photo webcam, make transformations photo (cropping, resizing, etc.), , save jpeg file. but have encountered problems. main problem standart uvc (usb video device class) linux driver not support direct still image capture: http://www.ideasonboard.org/uvc/ . so, there 2 possible ways capture still image. can take 1 frame video stream camera, or can take separate photo, digital portable camera. second way not supported in linux uvc driver, first method way. problem is, if want take frame video stream, size of photo can't bigger size of video in video preview window. so, if want take 2 megapixel photo, must start videostream size 1600x1200, not comfortable (at least, in qt size of videostream depends on videopreview window size). i know there video linux 2 api, may helpful in task, don't know how use it. learning gstreamer, can't figure out how need using these tools. so, appreciate help. think not hard problem

Dynamic Linq Library to generate particular type object for selected properties -

im using dynamic linq library application, in sample of dynamic linq library, can pass string of comma separated columns name or property names select clause of linq below .select("new (accountingdocumentnbr,documentfiscalyearnbr)"); can pass object instantiate , populate property values object below .select("new accountingobject(accountingdocumentnbr,documentfiscalyearnbr)"); accountingobject have accountingdocumentnbr,documentfiscalyearnbr. possible dynamic linq library . http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx need inputs on this.. well, in theory code should looks this: function parsenew() expression nexttoken() validatetoken(tokenid.openparen, res.openparenexpected) nexttoken() dim properties new list(of dynamicproperty)() dim expressions new list(of expression)() dim exprpos = tokenval.pos dim expr = parseexpression()

preg replace - convert ereg_replace to preg_replace in php -

this question has answer here: replace ereg_replace preg_replace 4 answers i have following ereg_replace statement: ereg_replace ( ".*alternative0=\"[^\"]*\"[ ]{0,10}>", "", $v ); since ereg_replace deprecated upgrade preg_replace , want upgrade code first occurrence replaced. preg_replace ("/.*alternative0=\".*?\".*>/", "", $v,1 ); but seems work partially. the major problem when have whitespace between " , > preg not work here example strings want to change: <tag type="head" alternative0="not head">{!head!}</tag> <tag type="tail" alternative0="tail>{!not tail!}</tag> but may be: <tag type="head" alternative0="not head">{! xxxx !}</tag> or even: <tag type="header&