Posts

Showing posts from February, 2013

c++ - A core about string -

i have function follow: #define _glibcxx_fully_dynamic_string 1 typedef struct _coordinate{ int posx; int posy; _coordinate(int x = 0,int y = 0){posx = x; posy = y;}; }coordinate; int find_way(int x, int y, int food_x, int food_y, vector <string>& grid, vector<coordinate>& co, vector<coordinate>& cur, nt& min){ if(cur.empty()){ if(!co.empty()){ return 1; } else{ return 0; } } coordinate node = cur.back(); int nx = 0; int ny = 0; if((node.posx == food_x) && (node.posy == food_y)){ if(cur.size() < min){ co.clear(); for(int = 0; < cur.size(); i++){ co.push_back(cur[i]); cout<<cur[i].posx<<" "<<cur[i].posy<<endl; } min = co.size(); } cur.pop_back(); return find_way(x, y, food_x, food_y, grid, co, cur

python - Scrolling camera -

i've been tinkering scrolling camera follows player around , have got follow player. problem moves slower player , because of player wont stay in middle of screen. i believe problem in offset (camerax) , have tried few different values haven't found work. code: import pygame, sys, time, random, math pygame.locals import * backgroundcolor = (255, 255, 255) windoww = 800 windowh = 600 playerw = 66 playerh = 22 fps = 60 movespeed = 3 yaccel = 0.13 gravity = 2 blocksize = 30 pygame.init() screen = pygame.display.set_mode((windoww, windowh), 0, 32) mainclock = pygame.time.clock() testlevel = [ (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,), (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,), (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,), (1,0,0,0,0,0,0,0,0,0,

jsf 2 - Unable to replace div content with JavaScript in JSF -

i use javascript code below replace contents of div , it's not working. <h:head> <script type="text/javascript"> function findchange() { document.getelementbyid("mydiv").innerhtml='ravi'; } </script> </h:head> <h:body> <h:form id="form" onsubmit="findchange();"> <div id="mydiv">hello</div> <h:commandbutton value="submit" ></h:commandbutton> </h:form> </h:body> inspired @louisbros: <h:head> <script> function findchange(){ document.getelementbyid('mydiv').innerhtml = 'ravi'; return false; } </script> </h:head> <h:form onsubmit="return findchange();"> <div id="mydiv">hello</div> <h:commandbutt

c# - Error after setting different datasources for datagridview combobox cells -

i trying display in datagridview control names , fields of database tables. in every row name of table displayed in first cell, , second column allows choose of fields of table. to that, handling 'datagridview.cellbeginedit' event , fill datasource cell names of fields. when trying edit cells, provided list displayed correctly , can b chose fine. however when try same in row, start getting dataerror events cell have edited. event arguments datarow have 'formatting|display' in context field, , have message "value not allowed in datagridviewcomboboxcell" (or close it). in debug, cell event references has correct value field, datasource null , formattedvalue empty string. , displayed text changes blank. how should resolved correctly? should derive own custom datagridview cell displays text has combobox editor? if so, how? edit: here code using: public class fielddataneededeventargs: eventargs { public list<string> fieldnames {

android - Deliver app for beta testing -

i deploy app beta testing. however, confused on best way safely deliver beta tester devices. i understand emailing apk file not logical move. having done bit of research, found following. deploy gate - offers private over-the-air distribution. google play private channel google apps - did not quite hold of it. zubhium - new platform. has tried before? could please walk me through appropriate method? the thing beta testing always run risk of apk being leaked. there literally nothing can prevent this, rooted device can retrieve apk after installation. you should instead consider adding features timed trials apk, , have stop working after date, or after value on server has changed. additionally, beta testing matter of trust. if not trust beta testers, don't give them apk.

SQL Server identity related error -

i using query in sql server 2008.. set identity_insert abc on bulk insert abc 'f:\test.csv' ( fieldterminator = ',', rowterminator = '\n' ) go and getting error : explicit value must specified identity column in table 'abc' either when identity_insert set on or when replication user inserting not replication identity column. table structure 'abc' : id [int] identity(1,1) not null, -- primary key aa [varchar](50) null, bb [varchar](50) null, cc [datetime] null, dd [varchar](50) null, ee [varchar](50) null, ff [int] null, gg [varchar](50) null, ii [int] null, jj [int] null sample data csv file 84,0b0dbe1d,192.168.10.221,2012-07-27 16:15:41.503,0b0dbe1d_16-15-18,1.0.0,2,pra,2,null 85,111de4b6,192.168.10.221,2012-07-27 16:27:06.060,111de4b6_16-27-05,1.0.0,8,diane,5,null the error says, need specify column names while inserting. i don't think have option specify column names during bulk insert. can u

gpgpu - how to assign a "const void*" to a "const uint64_t*" in cuda c? -

i want assign "const void*" "const uint64_t*" in cuda c. i have done this, void func(const void *buffer) { const uint64_t *words = buffer; } but i'm getting error this, error: value of type "const void *" cannot used initialize entity of type "const uint64_t *" can me in solving problem? as @sharptooth indicated, fixed me: #include <stdio.h> #include <stdint.h> void func(const void *buffer) { const uint64_t *words = (const uint64_t *) buffer; } int main(){ void *my_buf=0; func(my_buf); return 0; }

angularjs: preventing route changes -

i've tried doing following in controller: $scope.$on("$routechangestart", function (event, next, current) { if (!confirm('are sure ?')) { event.preventdefault(); } }); but doesn't work. not supposed way ? i put directive on links, should confirmed before changing route. prototyped in jsfiddle, did not test it. think, should proper way. (function (angular) { module = angular.module('confirm', []); confirmdirective = function () { return { restrict: 'a', link: function (scope, elm, attrs, ctrls) { angular.element(elm).bind('click', function (event) { alert("sure?"); event.preventdefault(); return false; //or true, depends on }); } }; }; module.directive("confirm", confirmdirective); }(angular)); http://jsfiddle.net/l6xbf/3/ check , try it. regar

c++ - Calculating GFlops -

i'm wondering how calculate gflops program of mine like, let's say, cuda application. do need measure execution time , number of floating point operations in code? if had operation "logf", count 1 flop? the number of actual floating point operations depend on how code written (compilers can optimize in both directions - is, merging common operatoions c = (a * 4.0 + b * 4.0); can becomes c = (a + b) * 4.0 , 1 less wrote. compiler can convert more operations: c = / b; may turn into: temp = 1 / b; c = temp * a; (this because 1/x "simpler" y/x, , multiplication faster division). as mentioned in comments, floating point operations (log, sin, cos, etc) take more one, more ten, operations result. another factor take account "loads" , "stores". these can quite hard predict, highly dependant on compilers code generation, number of registers available compiler @ given point, etc, etc. whether loads , stores count or n

regex - Regular expression matching a numerical string exactly -

i have string looks 600/-4.412/11 , 1 looks 600/11 [optional sign][float or integer]/[optional sign][float or integer]/[optional sign][float or integer] [optional sign][float or integer]/[optional sign][float or integer] example: 1) 600/-4.412/11 2) 600/11 and need find regular expression matches 1 , 1 matches 2. both expressions mustn't select/match other one. humble regex knowledge managed build expression: ([-+]?[0-9]+(\.?[0-9]+)?\/?){3} the problem expression matches 1) 2) according http://gskinner.com/regexr/ . can fix or @ least tell me why happening since hoped had change {3} {2} in order different matching. problem the problem regex allows repeated subpattern, i.e. [-+]?[0-9]+(\.?[0-9]+)?\/? match without restricting each section of numbers delimited / . for example in question: 600/11 , first repetition match 600/ , second 1 , third 1 last 1 . solution 1 wrong attempt for validation , can change make works want: ^([-+]?[0-9]+(\.[0-9]

c# - Show only small part of picture -

i have write program consists server , client. server makes screenshot desktop, , client receives screenshot , shows on form. there problem in data transfer, see small strip. checked before sending image on server ok. however, client receives wrong image. wrong? xaml: <window x:class="testtcp.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="testtcp" height="350" width="525"> <grid> <image x:name="img1" margin="0"/> </grid> </window> code c#: public partial class mainwindow : window { public mainwindow() { initializecomponent(); task rec = new task(waitclientquery); rec.start(); task tk = new task(send); tk.start(); } private void send()//server part. take screen , send image { bitmap temp

JSON get value at first index -

i stuck @ , have no idea script clear. see php code: <?php $arr = array(); $i = 0; while($i < 10) { $arr[] = $i; $i = $i + 1; } echo json_encode($arr); ?> it returned ajax function : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] suppose stored in d javascript variable how can point first value so, stores 0 variable. if this: success: function(d) { var = d[0]; } it returns null. i don't know how explain question because not @ english. try this: success: function(d){ $.each(d, function(x,y){ var = y['field']; }); }

javascript - Validating url with http:www as optional using regex -

i trying validate url "http:www" optional, yahoo.com , http://www.yahoo.com needs valid url using following regex not take utl3 valid 1 . how can fix ?? function checkurltest(url){ var urlregex = new regexp("^(https?:\/\/www\.)?(^(https?:\/\/www\.)[0-9a-za-z]+\.+[a-z]{2,5})"); return urlregex.test(url); } url3 = "yahoo.com"; url4 = "www.yahoo.com"; alert(checkurltest(url3)); working demo http://jsfiddle.net/fy66p/ solution reside here: negative lookahead: http://www.regular-expressions.info/lookaround.html#lookahead www case , should looking for. lemme know how goes! hope fits needs :) code function checkurltest(url){ // try var urlregex = new regexp("^(?!www | www\.)[a-za-z0-9_-]+\.+[a-za-z0-9.\/%&=\?_:;-]+$") return urlregex.test(url); } url3 = "yahoo.com"; url4 = "www.yahoo.com&quo

apache2 - Apache Module mod_proxy_balancer -

we using apache version 2.2.23 in our environment.we have configured apache in such way should load balance between 2 applications servers same home page. balancermember abc:8101 balancermember abc:8102 status=+h we need know how apache web server detecting server 8101 down??? ping or telnet or other this. apache httpd not have out of band healthcheck balancermember. detect given server down when proxyfied request server fails. the documentation can found here : http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

json - the Loading... Message in Grid when there is no data. ExtJs Grid -

Image
in application, when there no records on db, json receiving below. json message: {"totalcount":0,"responseobject":[]} but in grid loading... mask not going off. says loading if there no data in image below. please suggest me how rid of when there no data, want show empty grid without loading mask. i think may know problem is, because had same issue. for me, reason why loading mask wouldn't resolve not because there no records, because trying select first record in grid when there none. this throws javascript error looks this: "uncaught typeerror: cannot read property 'id' of undefined " because of error, stops other ext javascript processes, , mask never gets chance resolve. so, solve problem, make sure store's 'load' event handlers not try things records not exist in grid. worked me.

symfony - Disable some checkboxes in form -

i wondering if there easy way of how disable 1 checkbox modifying user (symfony 2.1). trying this: $builder->add('adminroles', 'entity', array( 'property' => 'rolename', 'class' => 'mybundle:role', 'query_builder' => function(entityrepository $er) { return $er->createquerybuilder('r') ->orderby('r.rolename', 'asc'); }, 'disabled' => $this->disabledroles, 'expanded' => true, 'multiple' => true )); by $this->disabledroles meant array of ids of role entities or entities themselves, seems accepts boolean value applied entities (checkboxes). advice :-) you need add form listener in order customize individual elements. http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html it might seem l

integer - Restricting floating point values in sqlite3 -

i using sqlite3 , came across strange issue. example, have following table. create table demo (effort integer); insert demo values (10.5); - works fine insert demo values (10.5); - works fine insert demo values (10.5555); - works fine i have 2 concerns: 1.why allowing float values when have declared datatype integer not real ? 2.is there way, can restrict upto 2 decimal places? is there workaround can restrict integer values(strictly no floating values). please suggest. sqlite uses dynamic typing . to enforce column type, add constraint: create table demo( effort integer not null check(typeof(effort) = 'integer') )

math - How to replicate adding/mixing of HSV values in RGB space -

at moment i'm doing colourizing effect using additive blending in hsv space. have diff value in hsv space added image texture's individual pixels desired color effect. turning out expensive fragment shader has 2 costly conversions addition rgb -> hsv hsv addition hsv -> rgb is there better way this? diff value provided in hsv only. , final color representation in rgb draw. many thanks, sak you can similar effect hsv manipulations using color matrix in rgb. example, rotation around r=g=b axis similar hue addition. (adding x degrees in hue channel similar rotation of x degrees around r=g=b in rgb.) translation along r=g=b axis similar value addition. (i believe adding x value channel should similar adding x of r, g, , b.) , uniform scale perpendicular r=g=b axis similar saturation addition. don't know off top of head exact translation between adding x saturation , scaling in rgb, shouldn't hard work out. should able compose these matrixes si

c# - What is Control.Disposing Property? -

according msdn: control.disposing property gets value indicating whether base control class in process of disposing. but when checked, disposing property of control false (inside dispose() method itself). when disposing property become true? control.disposing becomes true after dispose() called , after disposed becomes false again , isdisposed becomes true.

unix - How to print number of particular columns in shell script? -

i have text file temp1 , has more 20 columns , has numerical values follows, 1,0,3,0,5........, 1,0,5,0,8........, 3,0,6,0,3........, 5,0,6,0,4........, ................., i want remove columns has total(sum) of 0 , need redirect remaining columns new file ie : example above 2nd , 4th columns have total of 0 need remove 2nd , 4 th column , redirect separate file . can 1 me pls? $ cat file 1,0,3,0,5 1,0,5,0,8 3,0,6,0,3 5,0,6,0,4 $ awk -f tst.awk file 1,3,5 1,5,8 3,6,3 5,6,4 $ cat tst.awk begin{ fs="," } { (j=1;j<=nf;j++) { val[nr,j] = $j sum[j] += val[nr,j] } } end { (i=1;i<=nr;i++) { ofs = "" (j=1;j<=nf;j++) { if (sum[j]) { printf "%s%s",ofs,val[i,j] ofs = fs } } print "" } }

How to restrict an APK not to get installed in Android Emulator/Simulator but in real device? -

hope know application installed in android device can backed , stored installable file(as apk file) of apps astro file manager. same apk can installed in android simulator well. there chance other can dig installed app's files db, shared preference, etc.. is there way permit installing in real device , not in simulators??? i know if rooted device, can access app's data same in simulator. though know whether can restrict installing apk in simulators. thanks in advance it's not possible prevent apks being installed on emulator. (it used possible adding sensor requirement app, hese days emulators can emulate too) however, @ runtime should able validate if app running on emulator using following check: if (android.os.build.model.equals(“google_sdk”)) { // emulator } else { //not emulator } you check before create db , sharedpreference files etc.

PDO/PHP Script Query Database (Game Server baning system) -

the database structure: name: person offense against reason: reason given punishment admin: issued punishment id: pk type: 1,2,3,4,5 type 3 : kick type 0: ban the way it's setup once player given punishment add new row database. i'm trying create php script players can enter usernames on website (their username=name field in database , show offenses on account. what have far: $name = $_get["username"]; try { $conn = new pdo('mysql:host=localhost;dbname=server', 'username', 'pass'); $conn->setattribute(pdo::attr_errmode, pdo::errmode_exception); $data = $conn->query('select * logs name = ' . $conn->quote($name)); } catch(pdoexception $e) { echo 'error: ' . $e->getmessage(); } i'm not sure go here in terms of displaying data if above correct or not. straight pdo tag wiki $stmt = $conn->prepare('select * logs name = ?'); $stmt->execute(array($_get["username&

html - getting error on browser refresh using cookies in python -

here form.html form name="form1" action="/cgi-bin/form2.py" method="post" input type="text" name="firstname" input type="submit" value="submit" and below form2.py import cgi print 'content-type:text/html\n\n' cookie=cookie.simplecookie() form = cgi.fieldstorage() searchterm = form["firstname"].value print 'set-cookie: lastvisit=' + str(searchterm) cookie["firstname"]=searchterm print "firstname="+ cookie["firstname"].value cookie_string = os.environ.get('http_cookie') if not cookie_string: print '<p>first visit or cookies disabled</p>' else: print '<p>the returned cookie string "' + cookie_string + '"</p>' cookie.load(cookie_string) lastvisit = float(cookie['lastvisit'].value) cookie['lastvisit']['path'] = '/var/www/cgi-bin/' print searchterm

browser - window.onerror does not catch all errors -

for reason able catch of console errors except "unsafe javascript attempt access frame url". know why error filtered? my code: window.onerror = function(message) { alert(message); return true; }; thanks ahead possible duplicate: display javascript "same origin policy" violations catching same origin exception in javascript? i not sure if that's way detect same origin policy violations, since window.onerror catches runtime js errors (see here ). for cross browser compatibility of error event can check out: http://www.quirksmode.org/dom/events/error.html

perl - Find matching pattern of first columns between two files and print the line from each file in a third file -

i have 2 files 1 containing server name , ip , containing server name , machine name, example. files in no real order. have tried using variation of sort, awk, , sed. first file not maintained , contains bogus data offsets how planning on doing it. im trying pattern match between 2 files servers contained in both lines , print data lines in both files on 1 line in thrid file. file 1: server1 10.10.10.1 server2 10.10.10.2 .... server154 10.10.30.8 server155 10.10.30.9 file 2: server1 site site1 server2 site site2 .... server154 site site154 server155 site site155 output: server1 10.10.10.1 site site1 server2 10.10.10.2 site site2 ... server154 10.10.30.8 site site154 server155 10.10.30.9 site site155 this should trick: $ awk 'fnr==nr{a[$1]=$0;next}($1 in a){print a[$1],$2,$3}' file1 file2 server1 10.10.10.1 site site1 server2 10.10.10.2 site site2 server154 10.10.30.8 site site154 server155 10.10.30.9 site site155

r - exctract correlated elements of a correlation matrix -

Image
i have correlation matrix in r , want know how many groups (and put these groups vectors) of elements correlate between them in more 95%. x <- matrix(0,3,5) x[,1] <- c(1,2,3) x[,2] <- c(1,2.2,3)*2 x[,3] <- c(1,2,3.3)*3 x[,4] <- c(6,5,1) x[,5] <- c(6.1,5,1.2)*4 cor.matrix <- cor(x) cor.matrix <- cor.matrix*lower.tri(cor.matrix) cor.vector <- which(cor.matrix>0.95, arr.ind=true) cor.vector contains: row col [1,] 2 1 [2,] 3 1 [3,] 3 2 [4,] 5 4 that means, expected, vectors 1,2 , 3 correlate between them, , 4 , 5. what need 2 vectors c(1,2,3) , c(4,5) final result. this simple example, processing large matrices though. here's approach using igraph package: require(igraph) g <- graph.data.frame(cor.vector, directed = false) split(unique(as.vector(cor.vector)), clusters(g)$membership) # $`1` # [1] 2 3 1 # $`2` # [1] 5 4 what find clusters in graph g (disconnected sets), illustrated in figure be

ios - UITabBarController display -

Image
i newbie in ios development. developing application using tab bar controller. setting frame tab bar controller programmatically when switch iphone 5 there white space created between tab bar items , main view. following screen shot of application on iphone 5 simulator. following line of code setting frame uitabbarcontroller : [roottabbarcontroller.view setframe:cgrectmake(0,-20,320, 480)]; put line of code , check it,you have set frames accordingly.   if ([[uiscreen mainscreen] bounds].size.height == 568)      { [roottabbarcontroller.view setframe:cgrectmake(0,0,320, 568)];      }  else      { [roottabbarcontroller.view setframe:cgrectmake(0,0,320, 480)];      }

ruby on rails 3.2 - ActiveRecord::RecordNotFound (Couldn't find Batch without an ID) -

basically have dropdown that's meant launch partial calling method in controller. partial shown below: <%= form_for :exam_report, :url=>{:action=>'generated_report'} |z| %> <%= select_tag :exam_report_batch, options_for_select( batch.find(:all,:select=>"name,id").collect{|c| [c.name,c.id]}), :data => { :remote => true, :url => url_for(:controller => "exam", :action => "list_exam_types", :prompt =>"select batch")} %> <div id="exam-group-select"> <%= select :exam_report, :exam_group_id, @exam_groups.map{|exam| [exam.name,exam.id]},:prompt=> "#{t('select_exam_group')}" %> </div> <%= z.submit "view", class: "btn btn-large btn-primary" %> <% end %> the "list_exam_types" method in exam controller shown below: def list_exam_type

How to use an external dll file in a managed visual c++ project generated through firebreath -

i have use functions of external dll file in firebreath project. project managed c++ project. want know how refer or include external file in project.i not getting add reference option in visual studio 2010 (because managed c++ project). please tell me way this.. assuming know names of functions want call within dll, mechanism have use following: // these examples of functions --> change return values , params needed typedef char (winapi *dll_func1) (ushort, ushort); typedef char (winapi *dll_func2) (ushort, uchar*, uchar*, ushort, uchar*, ushort*, uchar*); typedef char (winapi *dll_func3) (ushort); // load library hmodule hdll = loadlibrary( l"\\path\\to\\your.dll" ); // check if dll loaded if (hdll == null) { // error return; } // assign functions dll_func1 func1 = (dll_func1) getprocaddress( hdll, "name_of_func1" ); dll_func2 func2 = (dll_func2) getprocaddress( hdll, "name_of_func2" ); dll_func3 func3 = (dll_func3) getproc

c# - How Can I set the form background? -

i'm developing application honeywell dolphin 6100, mobile computer barcode scanner uses windows ce 5.0 os. i want set background of form image. can not find thing "form.backgroundimage". also, if possible, want make picturebox transparent in order behind other controllers. any idea on issue ? you can either use picturebox docked in form or override onpaint eventhandler , use drawimage. ensure using right z-order if have additional elements on form. not draw on top of these elements.

ASP.NET - jquery ui connected sortable save to database -

okay have jquery ui connected sortable on page. works good. being dynamically created database. using asp repeater populate ul. works great. need save updated lists database. has proved difficult. $(function () { $("#include, #exclude").sortable({ connectwith: ".connectedsortable", droponempty: true, }); $("#include, #exclude").disableselection(); }); this have jquery. think there may need more here, cannot seem figure out is. have found way loop through repeater items , them databoundliteralcontrol, every time uses old order , not new order. any appreciated. $("#sortable1 li").each(function (idx, li) { var idinputs = $(li).children(".id"); var nameinputs = $(li).children(".name");//if itemname input used $(idinputs).attr("id", "items_" + idx + "__itemid"); $(idinputs).a

html - Jquery ui Sortable in right diagonal -

i'm trying use jquery ui sortable, changing div's, problem occurs when pressing div diagonally right, movement of div going forward, div i'm on top, stays in place, can not occur. should have gone forward. the problem see example might have caused concern is little difficult swap happen. if change tolerance intersect pointer , think might help. try this: http://jsfiddle.net/uzabv/2/

database - Looking for data in a table through colums with categories/state values -

say have fruits that having high number of reads inserts though not update nor delete. we have 2 columns stores values have small number of options. lets categories[banana, apple, orange or pear] , status[finished, ongoing, spoiled, destroyed or ok]. finally, have column last name of owner. notes: going searchs category , other status. in cases, lastname used search. perform exact match on categories/status start in last name. ex of common queries: select * fruit_table category='banana' , last_name 'cool%' select * fruit_table status='spoiled' , last_name 'co%' select * fruit_table category='banana' , last_name 'smith%' how can prepare have low response time? will index help(taking account values in column not disperse @ all)? might bitmap index here? what partitioning? finally, apologies title, did not know how formulate properly. bitmap indexes immensely items have limited number of available choices.

c# - Code is WRONG but no error is raised -

i have written code in form "load" event messagebox.show("message 1"); string strconnectionstring = @"data source=hb-vaio\sqlexpress;initial catalog=db1;integrated security=true;pooling=false"; sqlcommand cmdaddpackage = new sqlcommand("addpackage"); sqlconnection con = new sqlconnection(); con.connectionstring = strconnectionstring; cmdaddpackage.commandtype = commandtype.storedprocedure; cmdaddpackage.parameters.add(new sqlparameter("@guidoutput",sqldbtype.uniqueidentifier)).direction = parameterdirection.output; guid gui = (guid) cmdaddpackage.executescalar(); // error should raised there no error messagebox.show(gui.tostring()); cmdaddpackage.connection.close(); textbox1.text = gui.tostring(); messagebox.show("end"); i know code wrong ! , should raise "cannot open database "db1" requested login. logi

loops - Excel VBA - Work with Subgroup of Array -

i have 1-dimensional array 1000 entries. loop through parts of array , apply calculate average on subgroup. have done far looks this: temp = array(myarray) temp_range = application.index(temp, evaluate("row(1:10)")) average(i) = application.average(temp_range) by can calculate average of first 10 rows. not dynamic @ all, , wondering if there way of working subgroups of array (so can loop through them)? thanks help, can't figure 1 out... update: tried code here st.dev (not average). works! much. however, code slow. there way of making faster? here loop: return array of 1000 returns. aim calculate standard deviation of 1 year of daily return data. = 2 n if year(dates(i)) > year(dates(i - 1)) test = application.index(return, evaluate("row(" & c & ":" & (i - 2) & ")")) vola(m) = application.stdev(test) * sqr(252) m = m + 1 c = - 1 else

php - Block system commands in a C program -

i compiling , executing c program uses php system command on windows xp server. if c program contains system command system("shutdown -a") or system command, turns system down. i want these kinds of commands denied. how show "permission denied" output when program tries run system command? here code. php script contains- system(gcc code.c -o out); system(out.exe); if c program contains - int main() { system("shutdown -r"); } is there way block commands being run? windows runas command you might able use windows runas command run command specific user. , in user's profile, set list of white listed commands. https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows roll own command white list create list of commands in php or c allowed run through c program, , if command isn't on approved list, denied. or of live dangerously, create black list, , define bunch of things don't

php - How to Create Supplier register through frontend side in prestashop -

how can create supplier register through front end side in prestashop? there's step-by-step here: http://www.inmotionhosting.com/support/edu/prestashop-15/manufacturer-supplier-setup/adding-suppliers .

Jasmine and Requirejs in Resharper 7 -

i'm trying run javascript code using jasmine , resharper 7 within visual studio 2012. follow amd pattern aid of requirejs. however, haven't managed make test run in resharper test runner. has managed similar that? use named requirejs module define("my/sut", function () { var mysut = function () { return { answer: 42 }; }; return mysut; }); and initialize sut asyncronus support of jasmine. don't forgot references! /// <reference path="~/scripts/require.js"/> /// <reference path="../code/sut.js" /> describe("requirejs jasmine , resharper", function () { it("should executed", function () { // init sut async var sut; runs(function () { require(['my/sut'], function (mymodel) { sut = new mymodel(); }); }); waitsfor(function () { return sut; }, &

Vaadin - Disable Column reordering for particular column -

i'm doing project in vaadin 7. in project, need disable column reordering feature particular columns in treetable? i'm searching function 'setcolumnreorderids()'. is possible in vaadin 7. or else need write code 'columnreorderlistener()'? update this code set first column fixed in treetable. want disable reordering in hierarchy column in tree table. public class customtreetable extends treetable { private static final long serialversionuid = 1l; private object[] visiblecolumns; private keymapper<object> columnidmap = new keymapper<object>(); @override public void paintcontent(painttarget target) throws paintexception { super.paintcontent(target); paintcolumnorder(target); } private void paintcolumnorder(painttarget target) throws paintexception { visiblecolumns = this.getvisiblecolumns(); final string[] colorder = new string[visiblecolumns.length]; int = 0; colorder[i++] = columnidmap.key("column 1&q

android - List View Item Scroll able vertical -

currently i'm using listview , it's working fine. have text in listview paragraph , want show 2 lines of text , make rest of text scrollable, i'm having issue if make textview scrollable inside of listview , textview focus of parent ( listview ) , won't let scrolled. so can achieve scrollable textview functionality won't disturb scrolling property of listview ? thank you. i able in following way: into getview method of listadapter obtain textview object of line, , write textview.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { v.getparent().getparent().requestdisallowintercepttouchevent(true); return false ; } }); when touch textview, take control of scrolling

visual studio 2010 - How to step into function of a dll when you have the .pdb file and the C++ source code with VS2010? -

i trying debug dynamic library have wrote used application inside visual studio 2010. can step until function of dll, can't step deeper , see source code. if open disassembly window, can step asm code don't see source code or symbol. i have build .dll , import .lib. .pdb ( /zi ) file associated dll has been built (with /debug ). optimisation disabled ( /od ). my application links import lib #pragma comment(lib, "myimport.lib") because application has build tool can't configure myself. my application run in debug, , in modules of debugger can see dll loaded symbols. i have check options > debugging > general enable code option disable. how force vs2010 step functions of dll? we have different setup launch application don't have source code which, in turn, loads dll built ourselves. debug use visual studio command debug / attach process... maybe command lead successful debugging dll's sources.

android - Lazy loading with fade in -

i'm looking way lazy load images listview. preferably framework support image animations. is available android? i'm using api level 8 , up. you want take @ android query . has support lazy loading of images. can see in the documentation , supports basic animations. example lazy load basic settings: aquery aq = new aquery(context); aq.id(your_imageview).image("your_image_url"); example lazy load image fade in animation: aquery aq = new aquery(context); aq.id(your_imageview).image("your_image_url", true, true, 0, null, 0, aquery.fade_in);

android - onClicks in a custom view are not responding: -

i have created custom view in want implement onclick actions. created following: custom view xml layout: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/leftmenu" android:layout_width="100dp" android:layout_height="fill_parent" android:background="@drawable/left_menu_background" android:orientation="vertical" > <imagebutton android:id="@+id/left_menu_close_button" android:layout_width="fill_parent" android:layout_height="49dp" android:background="@drawable/left_menu_close_button" /> <imagebutton android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/left_menu_separator" /> <scrollview android:layout_width="fill_parent" android:la

ruby on rails 3.2 - Redmine 2.3 relative url root not working with Apache mod_proxy -

i attempting upgrade redmine 1.4 (based on rails 2.3) redmine 2.3 (rails 3.2). forced use apache mod_proxy , proxy balancer, talk of passenger out. trying deploy redmine on sub-uri ( https://mysite.com/redmine ). current apache config follows: proxypass /redmine balancer://redmine_cluster proxypassreverse /redmine balancer://redmine_cluster <proxy balancer://redmine_cluster> order allow,deny allow balancermember http://127.0.0.1:9000 balancermember http://127.0.0.1:9001 balancermember http://127.0.0.1:9002 </proxy> i used able use redmine::utils.relative_url_root="/redmine" handle url_for , link_to, no longer works. i have tried following: editing config.ru map actioncontroller::base.config.relative_url_root || "/" run redmineapp::application end running rails with: rails_relative_url_root='/redmine' script/rails s -p 9000 adding config.action_controller.relative_url_root = "/forge" application.rb

postgresql - Join multiple tables with aggregation in Squeryl -

i'm trying join card part , left join summed stock value part (some parts won't have stock row). i have following thought work.. def stockperbase = from(stock)(s => groupby(s.base) compute(sum(s.quantity))) def allcardswithstock = join(cards, parts, stockperbase.leftouter)((c,p,s) => on(c.partid === p.id, p.base === s.map(_.key)) select(c, p, s.measures)) however following error: too many arguments method on: (table: org.squeryl.table[a])(declarations: => seq[org.squeryl.dsl.ast.basecolumnattributeassignment])unit [error] on(c.partid === p.id, p.base === s.map(_.key)) any on how can such query apprecited. the select clause should come before on in query. try reversing order of 2 clauses , should work.

Facebook insights, page_fans_country accessible, no data for page_fans, page_fans_locale or page_fans_gender_age -

i'm using fql access pages insights , i've got different results depending on metric pass in query. for exemple, query works correctly, datas facebook pages : select value insights object_id='pageid' , metric='page_fans_country' , end_time=end_time_date('2013-04-14t07:00:00+0000') , period='0' but if use metric page_fans_gender_age or page_fans_locale, don't data, except 1 specific page (which maybe related token). i don't understand why metric working differently, don't see specific infos in graph documentation ? are page_fans_country insights datas "public" not other metrics ? can token problem ? or depend on end_time parameters ? is problem related bug : https://developers.facebook.com/bugs/345809555540652?browse=search_5148c3f9aa0392220388804 yes - page_fans_country publicly available, other metrics require appropriately authenticated token. it's worth, don't think 0 valid period, eit

python - Multiple windows in PyQt4? -

i've begun using pyqt4. followed tutorial ( http://zetcode.com/tutorials/pyqt4/ ) 1 thing puzzles me part: def main(): app = qtgui.qapplication(sys.argv) ex = gui() sys.exit(app.exec()) and reason explain here: i have made small program opens 4 more windows except first main window. tried replicate saw worked main-window , created class every new window , tried above. looks this: def main2(): #app = qtgui.qapplication(sys.argv) ex2 = settings() sys.exit(app.exec()) as can see have modified it. if left first line in function uncommented program crash. tried without sys.exit(app.exec_()) -part make new window close milliseconds after showed. way though, runs , works. in command window, error message displays. don't know how fix this, since cannot remove last line, , dont't know replace "app" with. i know i'm doing new windows wrong beginning, don't know how make these windows open original window in other way. haven&#

javascript - Push attributes to array by className? -

can please me how push different attributes of elements same classname array? i'm not @ javascript , have tried arrays turns empty. one array should contain url of images , other 1 image-texts in span-element: function slideshow(){ imgurllist.length = 0; imgtextlist.length = 0; var imgurl = document.getelementsbyclassname('markedimg'); var imgtext = document.getelementsbyclassname('marked'); for(j=0; j<imgurl.length; j++){ imgurllist.push(imgurl.src); } for(k=0; k<imgtext.length; k++){ imgtextlist.push(imgtext.innerhtml); } openwindow(); }

c# - Get all files on UAC protected directory -

this question has answer here: request windows vista uac elevation if path protected? 6 answers i'm beginner in c# , want files , directory in documents , setting or desktop folder etc. i've been trying disable uac on computer doesn't work, tried create manifest in vs 2012 , change "requestedexecutionlevel level" administrator no success. still "access denied" error. how can these folders ? doing wrong ? your application needs admin level privledges. it's best request them during start-up can done in config file: <trustinfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedprivileges> <requestedexecutionlevel level="requireadministrator" /> </requestedprivileges> </security> </trustinfo&g

can we retrieve the geo-localization info from the client browser from the $_SERVER in php? -

some modern browser have no possibility active(or not) geolocalization. so, when activate, how can retrive php server in $_server variable ? is there special constant localisation user-agent ? thanks help remember getting generated client end can spoofed. $_server or get_browser() functions not gather geolocation far know. one thing html use geolocation api navigator.geolocation extract information required , send across server script using async ajax call..

javascript - Unexpected token in jQuery -

this site working fine errors have appeared. unexpected token ( - mean? looks correct me, , has been working fine many months. <script> function (){ <--"uncaught syntaxerror: unexpected token (" here $(".message").focus(function() { $("#bubble").fadeout(); }).blur(function() { $("#bubble").fadein(); }); })(); </script> you haven't specified function name... i.e.: function functionname() { ...} which can later call functionname(); i guess you're trying use (function () { ... })(); (iife)

excel - Create PDF from database and pictures in folders -

i looking suggestions on way create single pdf file database of text , pictures in folders. one page of pdf contain picture of billboard , 5 different text fields database. pictures every billboard (page of pdf) contained in sub folders. database in excel. i have contemplated creating html page every billboard , converting pdf using adobe pro, not want setup php server this. this once off task, looking quick way done. software packages tools available? i ended importing data mysql , writing php script create html layouts pages of pdf file. created pdf file using "create webpage" function in adobe acrobat pro extended. hope helps someone.

java - How to list multi-dimensional arrays values in a loop -

so first off, sorry if appears if asking homework...just me not, question involves 1 tiny little aspect of entire program in making...in other words isn't close finished. i ask teacher, online course. ask friends advice, i'm kid in school taking computer science course. (it's small school) anyways program when completed, allow teacher input list of students of 4 grades per student. i'll add code allows teacher find averages of each student etc etc. however @ moment i'm in process of listing students. there small problem... every time list student (their last , first name) along 4 test scores, outputs nicely. when go output second student different name , different test scores, outs different name...but test scores of previous student. ex. john smith: 67 68 57 87 jane doe: 67 68 57 87 (even though should jane doe: 54 68 75 91) and problem...since students not have exact same grades...ever.. okay code below... public class studentgradesview ext

Perl requires explicit package name -

#!/usr/bin/perl # countlines2.pl bill weinman <http://bw.org/contact/> # copyright (c) 2010 bearheart group, llc use strict; use warnings; sub main { @values = (43,123,5,89,1,76); @values1 = sort(@values); foreach $value(@values1){ print "$value\n"; } } errors - "global symbol "$value" requires explicit package name @ task2.txt line 12 "global symbol "$value" requires explicit package name @ task2.txt line 13 i beginner in perl having above errors. please tell me how perl sorts numbers default(e.g. sort(@values) result in?). you might find helpful add use diagnostics; give additional information: (f) you've said "use strict" or "use strict vars", indicates variables must either lexically scoped (using "my" or "state"), declared beforehand using "our", or explicitly qualified package global variable in (using "::"). foreach $value(@valu