Posts

Showing posts from August, 2013

c# - ASP.Net MVC 4 scaffolding complex types -

i have complex model. want create create, edit, list, etc. forms it. class contains many objects other classes. example in "create" form, want form able data classes , fill necessary tables. how can achieve that? sample of class this: public class buildingpermit { [key] [databasegeneratedattribute(databasegeneratedoption.identity)] public int id { get; set; } public permit permitinfo { get; set; } public datetime registereddate { get; set; } public int realstateid { get; set; } public virtual person owner{ get; set; } } when use "scaffolding", classes person or permit above getting ignored , fields system types only.

sas - Proc Import. Importing Character values as "Blank" from excel files -

i trying import multiple excel files using code below. there column in each excel file has both numeric , text values proc import importing numeric values, , put text values blank ('.'). can me issue? much. %let subdir=s:\temp\; filename dir "&subdir.*.xls"; data new; length filename fname $ 32767; infile dir eof=last filename=fname; input ; last: filename=fname; run; proc sort data=new nodupkey; filename; run; data null; set new end=last; call symputx(cats('filename',_n_),filename); call symputx(cats('dsn',_n_),scan(scan(filename,7,'\'),1,'.')); if last call symputx('nobs',_n_); run; %put &nobs; %macro import; %do i=1 %to &nobs; proc import datafile="&&filename&i" out=&&dsn&i dbms=excel replace; sheet = "sheet1"; getnames=yes; mixed=yes; run; %end; %mend import; %import the best way control data types in imported excel

python - django modelmultiplechoicefield and widget checkboxselectmultiple -

i have admin interface. here code form: class newrolefrom(forms.form): role = forms.modelmultiplechoicefield( queryset=role.objects.all(), widget=forms.checkboxselectmultiple ) so, it's simple, have role label(role:) each role in database rendered checkbox. can role objects choosen user. @ begining of each line have bullet, how can remove it? possible add on each others attribute when define list_display in admin.py ? in form template iterate on roles form.html {% role in form.role %} <div class="checkbox"> {{ role }} </div> {% endfor %} then pretty css.

arrays - Program returns incorrect values (C++) -

i've wrote simple code play around 2 dimensional arrays, aim of code being solve 2 linear simultaneous equations using matrix method (expressing coefficients in square matrix, computing inverse, multiplying inverse output of each of equations find results of 2 variables). there no warnings when code compiles, so, have no idea problem be. #include <iostream> using namespace std; double determinant(double parametermatrix[2][2]) { return parametermatrix[1][1] * parametermatrix[2][2] - parametermatrix[1][2] * parametermatrix[2][1]; } void invertmatrix (double parametermatrix[2][2], double inversematrix[2][2]) { double parameterdeterminant = determinant(parametermatrix); inversematrix[1][1] = parametermatrix[2][2] / parameterdeterminant; inversematrix[1][2] = - parametermatrix[1][2] / parameterdeterminant; inversematrix[2][1] = - parametermatrix[2][1] / parameterdeterminant; inversematrix[2][2] = parametermatrix[1][1] / parameterdeterminant; }

sling - Java do while loop to for each or for loop -

i'm pretty new java , trying figure out how convert below code loop or each loop. do { testpages.push(testparentpage); if(homepage != null && testparentpage.getpath().equals(homepage.getpath())){ isparent = true; break; } } while((testparentpage = testparentpage.getparent()) != null); any appreciated! thanks! it can rewritten in loop this: for (; testparentpage != null; testparentpage = testparentpage.getparent()) { testpages.push(testparentpage); if(homepage != null && testparentpage.getpath().equals(homepage.getpath())){ isparent = true; break; } } thought must admit don't know if serves benefit.

html - How do I make a div NOT follow me as I scroll? -

i have description box on blog stuck. follows you scroll , rather long description box doesn't show whole thing on page unless "ctrl + minus" , since follows way scroll, doesn't scroll down description box see whole length of description box. can edit make not stuck? i'm not great html take out css says position: fixed on block. that's best guess without seeing html/css

Is is possible to update APK and Store Listing before Publish in the NEW Android Developer Console? -

the "new developer console" standard users. must deal changes in behavior old console. used able upload , release apk update , update store listing in 1 step. cannot figure out how in new console. this tried: i uploaded apk using "simple mode", prompted "publish now" before getting chance change store listing (e.g. recent changes). i changed "advanced mode" , able upload apk , save draft. tried access store listing, said not save changes since had archived or reactivated 1 or more apks. i changed tactics. started going store listing , modified recent changes. tried going apk area upload new version , says can't save store listing without publishing. am missing something? please explain. i noticed same thing new developer console. however, doesn't matter don't let publish both @ same time since takes couple hours before store updates changes anyways. when see store update changes, see update of changes @ once,

javascript - When adding a jQuery Accordion element, need new element to default open -

i have accordion i'm dynamically creating new elements. however, when cannot seem newest element default open. it's first element. ideas? here's html: <asp:multiview id="mainview" runat="server"> <asp:view id="view1" runat="server"> <table style="width: 100%; border-width: 3px; border-color: #c4f691; border-style: solid"> <tr> <td> <div class="rowclassspace"> &nbsp;</div> <div id="accordion"> <a href="#">make/model (insured vehicle)</a> <div> <p> content </p> </div&g

javascript - Unique value validation with Knockout-Validation plugin -

i'm using knockoutjs knockout-validation plugin validate fields on form. i'm having problems validating value unique using native validation rule - unique i'm using editor pattern ryan niemeyer allow user edit or create location . here's fiddle see problem in entirety. function location(data, names) { var self = this; self.id = data.id; self.name = ko.observable().extend({ unique: { collection: names }}); // other properties self.errors = ko.validation.group(self); // update method left out brevity } function viewmodel() { var self = this; self.locations = ko.observablearray([]); self.selectedlocation = ko.observable(); self.selectedlocationforediting = ko.observable(); self.names = ko.computed(function(){ return ko.utils.arraymap(self.locations(), function(item) { return item.name(); }); }); self.edit = function(item) { self.selectedlocation(item); self.

html - 2 100% columns + sticky footer -

so i'm creating website, here is: http://www.testeeee.cixx6.com/ and can't put site_contente, , content , sidebar (this 2 inside site_contente) 100% height. basically want content , sidebar 100% no matter what. , when content on content div more 100%, want scroll, mean, scroll on content scroll. example of want: http://i.stack.imgur.com/i2rid.jpg based on submitted, you'll need user iframe. however, may referring this: how might force floating div match height of floating div?

php - Force Downloading a PDF file, corrupt file -

i've got problem has risen many times on so, can't seem find solution mine! i'm trying deliver pdf file client without opening in browser, file downloads corrupt when open , missing quite few bytes original file. i've tried several such methods downloading file i'll show latest i've used , feedback. i have opened downloaded pdf in text editor , there no php errors @ top of can see! i'm aware readfile() quicker testing purposes desperate working used while(!feof()) approach! anyway enough rambling, heres code (taken why downloaded file alwayes damaged or corrupted? ): $file = __dir__ . '/reports/somepdf.pdf'; $basename = basename($file); $length = sprintf("%u", filesize($file)); header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename="' . $basename . '"'); header('content-transfer-encodin

How to add backslashes to Json response in Java? -

i want used string getting server comes in json regular form. meant without \ jsonparser parser=new jsonparser(); system.out.println("=======decode======="); string s="[0,{\"1\":{\"2\":{\"3\":{\"4\":[5,{\"6\":7}]}}}}]"; object obj=parser.parse(s); jsonarray array=(jsonarray)obj; system.out.println("======the 2nd element of array======"); system.out.println(array.get(1)); system.out.println(); jsonobject obj2=(jsonobject)array.get(1); system.out.println("======field \"1\"=========="); system.out.println(obj2.get("1")); s="{}"; obj=parser.parse(s); system.out.println(obj); s="[5,]"; obj=parser.parse(s); system.out.println(obj); s="[5,,2]"; obj=parser.parse(s); system.out.println(obj); in order send slashes in java, need escape them. so assuming wanted receive {\"key\": \&qu

php - How to force Wordpress admin/login pages with SSL? -

i have wordpress in sub-domain blog.my-site.com , can't use ssl sub-domains (https:// blog.my-site.com) is there way force wordpress admin/login pages ssl url https:// www.my-site.com/blog_dir/wp-admin/ (the folder name not same sub-domain) to force administration , logins on ssl , proper way set force_ssl_admin constant in wp-config.php . define( 'force_ssl_admin', true );

javascript - Callback .hover function isnt working -

i have js function: $('#linknext').on({ mouseenter: function () { if ($('#conteudo .boxes').hasclass('ativo')) { $('#conteudo .boxes').removeclass('ativo'); $('.boxaberto').animate({width: '0'}, 600, function () { // callback $('#linknext').hover(function () { this.iid = setinterval(function () { if (cont > -565) { cont -= 5; $('#conteudo').attr('style', 'left:' + cont + 'px'); console.log(cont) } if (cont <= -565) { $('#linknext').hide(); } }, 0); }); $('#linknext').mouseleave(function () { this.iid &a

jquery - Cannot get html() for parent span -

this question has answer here: get selected element's outer html 26 answers i trying simple thing maybe missing something: var span = $(document.createelement("span")); // create span var img = new image(); // create image , set source img.src = config.graph_url + member.facebook_id + "/picture?width=24&height=24"; span.append($(img)); // add image inside span how can html <span><img src="_source_"/></span> ? span.html() outputs <img src="_source_"/> . it's working fine. html() method sets or returns content (innerhtml) of selected elements in html document, .html() can used contents of element. if selector expression matches more 1 element, first match have html content returned. so can use .outerhtml this $('span')[0].outerhtml;

force.com - Query DB using apex in salesforce -

com , apex triggers i have 2 objects namely customer_c , order_c trying write trigger delete order entry belonging customer has been made inactive. basically want trigger on update customer_c table retrieve entry customer_c active_c ( boolean value) has been made false upon update , take customers ' name ' , in order_c table , delete 'name'(orders ) belonging customer. below trigger code. when trying save trigger in salesforce. following error: error: compile error: unexpected token: 'res2' @ line 13 column 19 could please me on this? trigger newcustomeractive on customer__c(after update) { list<customer__c> res2 = [select name customer__c j j.active__c = false]; list<order__c> res = [select name order__c customer__c = res2]; } change to trigger newcustomeractive on customer__c(after update) { list<customer__c> res2 = [select name customer__c j j.active__c = false]; list<o

ios - How do I use translationInView: with UIPanGestureRecognizer to have an invisible slider effect? -

as shortcut (by no means necessary) have uipangesturerecognizer on view allow user slide his/her finger , down set value quickly, i'm having trouble implementing fully. i want have distance panned or down increases or decreases value proportionately. i tried use translationinview: , seems updating few times unless pan slowly, unless i'm using wrong. - (ibaction)handlepan:(uipangesturerecognizer *)recognizer { cgpoint velocity = [recognizer velocityinview:recognizer.view]; nsnumber *wpm = [[nsuserdefaults standarduserdefaults] objectforkey:@"wpm"]; // if user panning upward if (velocity.y < 0) { cgpoint translation = [recognizer translationinview:recognizer.view]; if (fmodf(translation.y, 10) == 0) { wpm = @([wpm intvalue] + 5); [[nsuserdefaults standarduserdefaults] setobject:wpm forkey:@"wpm"]; nslog(@"%@", wpm); } } // if user panning downward

c# - Multiple exe files in one solution, all referencing a single public class -

Image
i have c# console project (vs2012) getting big. calling multiple 'methods' 1 after other. add more methods able break them out multiple executable files, ran scheduled apps, still able reference (and change using tortoise svn) public class of rules of reference. have create dll accomplish or there simpler way? sorry, i'm new of this. have found similar questions either did not understand them or weren't quite looking for. thanks! yes need build dll , reference whatever project needs code stored there. matter add new library project solution, create public class , insert methods should called other projects click menu file , choose add project then go solution explorer window, click console application , right click on references and select solution folder project of class library now go predefined class1 , add following code namespace consoleapplication1 { // class contains methods , data used/shared various applications public class cla

java - Properties file (user settings) inside a jar file -

i have swing application want package jar file. have properties file store user set properties in. can store file inside jar file , application automatically write jar file? i want avoid having 2 files, jar , properties external of it. you can surely bundle properties file inside of jar , 1 problem is, become kind of read-only . not able write it.

c# - Scan disk unallocated space using .Net framework -

i want play around file recovery programming in dotnet (c#). trouble dont know start. seems in dotnet assumes kind of filesystem, directory and/or file exists , im interested in files that, according os dont exist. i assume have learn more file formats, start , end markers , scan disk space byte codes etc (0xff, 0xd8 in jpegs instance) before wonder how scan disk sector sector, including unallocated space such byte codes in dotnet. i have little program floating around read disk chunks, you, in c++ using windows api , not .net. store internal hdd information: typedef struct drive { handle hdrive; int sector; int *sector_data; dword dwread; int sector_size; } drive; open reading: /*-- create structure store drive data --*/ drive cdrive; /*-- open c drive file --*/ cdrive.hdrive = createfile("\\\\.\\c:", generic_read, (file_share_read | file_share_write), null, open_existing, null, null); /*-- set initial data in drive structure --*/ c

php - Fatal error: Call to undefined method - does not completely -

this how able update quick , easy, select database , same time updater content have right in. this how error: fatal error: call undefined method mebe::boxforside() in /home/jesperbo/public_html/blabla.dk/admin_forside.php on line 30 admin_forside.php show here: <?php $forside_tekst = $mebe->boxforside(); ?> into large file information looks this: *fun_db.php* function boxforside() { if ($stmt = $this->mysqli->prepare("select `tekst` `forside_tekst`")) { $stmt->execute(); $stmt->bind_result($tekst); while ($stmt->fetch()) { ?> <form action="#" method="post"> <textarea name="tekst" cols="20" rows="15" class="new" style="width:100%;"><?php echo $tekst;?></textarea> <input type="submit" name="opret" value="opret

php - Show Products Special From Date - Optimize Magento Script -

i trying list products have special date within last 72 hours. script works fine except on 400 products times out. i think loading many collections or not correctly utilizing ones loaded need optimization advice please. here script: <?php set_time_limit(0); require_once 'app/mage.php'; mage::app('default'); try { $products = mage::getmodel('catalog/product')->getcollection() ->setstoreid(1); $products->addattributetofilter('status', 1); $products->addattributetofilter('visibility', 4); $products->addattributetoselect('*'); $prodids=$products->getallids(); $product_count = 0; $products_changed = 0; //$product = mage::getmodel('catalog/product'); echo "price changes last 72 hours<br><br>"; foreach($prodids $productid) { $product_count++; //$products->load($productid); // load product data

c# - Global MediaElement will not restart once stopped, wp7 -

i have app runs background music @ application level music doesn't stop when user navigates through pages. however, make use of videobrush. found out, cannot have 2 running @ same time videobrush crash when setting source. i found if set source of mediaelement null when user attempts use videobrush, works. sure music stops, chagrin, no error happens. however, when user taps away videobrush, trying make music start (beginning fine) no avail. put, having trouble getting music start again. here code: app.xaml <application.resources> <mediaelement x:key="globalmedia" source="minutelongsong.mp3" mediaended="mediaelement_mediaended" visibility="collapsed" /> </application.resources> app.xaml.cs public static mediaelement globalmediaelement { { return current.resources["globalmedia"] mediaelement; } } private void application_launching(object sender, la

debugging - how to judge the request is from my computer to the php page? -

how can determine if request computer php page? i want print_r($gloabals) debug site computer, don't want other computers this. <?php // can not use ip judge wheather computer mine // ip change always. if($is_my_computer){ echo 'yes'; } i suppose in local machine have website under localhost/mylocalwebsite. if so, check if in environment , it. <?php if($_server['server_name'] == 'localhost') { echo "foo"; }

c - Why does this SEGFAULT? (small amount of code) -

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "mystuff.h" typedef struct node { int size; int status; struct node *next; struct node *previous; } node; node *endnode; node *rootnode; void *my_foo(int size) { node *thenode; void *ptr; if (rootnode->next == null) { thenode->status = 1; ... it segfaults @ "rootnode-> == null" if change "rootnode == null" segfaults when hits "thenode->status = 1" , declaring thenode , rootnode null not help. ...and declaring thenode , rootnode null not help. dereferencing null (usually) will result in segfault. you've got set them more useful (like allocated structure) before go off modifying them!

c - How to make sure interrupt can not be generated between specific Code Snippet? -

i have 1 question timing of interrupt generation between code snippets... @ "example" code 1. ... 2. assign value global variable // 0/1 means invalid/valid 3. set h/w register via memory-mapped io method // 0 means completed @ "example" isr code a. ... b. if(global value valid && h/w register "0") count++; one thing note: after h/w register set, value 0 when "completion" ! my question is : if interrupt generated between 2 , 3 , count increased 1 because step 3 not done yet(value 0)... , if exchange 2 , 3 , possible count not increased 1 because hw register 0(after time, completed) global variable 0 ! my first idea is: possible 2 , 3 can "tied together" in way , interrupt not allowed generated until 3 done ? i use watcom c , test in dos... you can use either inline assembly, or call external function written in assembler, invoke x86 cli , sti instructions disabling , enabling interrupt

algorithm - Random Config Generation for RRT -

Image
i writing code rapidly exploring trees robotic arm movement. have 2 doubts i) distance metric have use find nearest node in graph? if euclidean distance,how calculate because there 2 links in each arm configuration of robot , have no idea how find euclidean distance in case. how find distance between ade , abc if abc nearest config ade in tree? ii) how generate random config towards goal because random configs never seem reach goal after 5000 iterations. thanks in advance. distance metrics 2 revolute-joint arm rrt pretty robust (pseudo-) metric choose, quality of trees (and consequently paths) influenced if you've got isn't particularly good. performance overall, metric function supposed fast, i'd try simpler things before move onto more complex. in case of robot arms number of metrics possible. perhaps simplest use euclidean distance between end effector in 2 configurations. you'll have have working if you're testing planning algorithm.

php - Use textbox text in jQuery AJAX request -

i'm trying send request php form (using get) dynamically generated based on textbox field user types in. i've tried few things can't manage value of textbox. <script> $("#mydiv").on('click', 'p', function(){ setinterval(function() { $.ajax({url:"val",success:function(result){ $("#mydiv").html(result); }}); },1000); }); </script> if leave this, works , sends request "val", i'm not sure how put value of textbox in there. still within same div, dynamically loaded after page has been loaded completely. any appreciated. var val = $("#id-of-textbox").val(); replace #id-of-textbox actual id of textbox , var val contain text value of textbox. you'll send ajax request so: $.ajax({url:"val", data: { value: val }, success: function...

How to add new Device UDID to an existing provisioning profile in the new pattern -

Image
i want add new device udid existing provisioning profile, modify provisioning profile clicked "generate" showing download, there no way add devices there... please consider problem respond me . thank in advance. first add device udid in devices list clicking on '+' button in devices list. then, after adding device udid, go provisioning profile list. there, select provisioning profile want add device. afterwards, edit option want use adding new udid, added devices list. find option @ bottom. after clicking edit button have option select device udids i hope you note : while creating provisioning profile have add atleast 1 device id else dont have add device option in edit mode.( if device count '0' (from screen shot) dont option add devices)

javascript - Auto fade/show between multiple divs -

what's simple jquery script can load on webpage auto fade between each of 3 "box" divs, , repeat? i'd show div 5 seconds while hiding other two, run 1 second fade transition next. the 3 div's stacked on top of each other. <div class="boxes"> <div class="box1">text1</div> <div class="box2">text2</div> <div class="box3">text3</div> </div> you try this: $(document).ready(function () { var allboxes = $("div.boxes").children("div"); transitionbox(null, allboxes.first()); }); function transitionbox(from, to) { function next() { var nextto; if (to.is(":last-child")) { nextto = to.closest(".boxes").children("div").first(); } else { nextto = to.next(); } to.fadein(500, function () { settimeout(function () { transi

c# - Why Jquery pop up it's not woking on Server -

jquery dialog not working on iis server in local machine below code working fine. in server mapped url not working it's throwing error '404 resource not found ' that. jquery code $('#new dialog')dialog({ auto-open: false, width: 345, top: 76, re sizable: false, title: 'add ad details', modal: true, open: function (event, ui) { $(this)load("../ad/ad manage?atype=" + adtype); }, buttons: false, position: { my: 'top', at: 'top', of: $('.maindiv') } }); //--------------------------------- $('.clk')click(function () { $('body,html').addclass('hide scrolls'); $.ajaxsetup({ // disable caching of ajax responses */ cache: fals

issue on displaying images added into .css file in javafx native package -

javafx native package not display images added .css file as using .css file located project "/styles/style.css" givng scene style by, scene scene = new scene(parent, 1080, 800); scene.getstylesheets().add("/styles/style.css"); to set image css have tried 2 ways: -fx-graphic: url("../images/delete_hover.png") no-repeat; and -fx-background-image:url("../images/bgleft.jpg"); but not worked out. where getting color or fonts set css file not images can please suggest ... unzipped jar notice style.css convert style.bss i.e binary format. just make css conversion bss false while building package i.e in pom.xml <css2bin>false </css2bin> this solved problem :)

cakephp find('all') statement returns double entry -

i working site using cakephp 1.3. last month have changed hosting service of site. after having issue. ie. have bookings table in db. when using find() statement, bookings table returns double entry. not find why happening. for example, got vehicle data of particular place returns below, when use 'recursive'=>2 in find('all') statement ,i got following ** parking location : chennai citi centre 2w booking date : 02/04/2013 booking id transaction type vehicle no check in date check out date 187994 normal 7099 02/04/2013 18:31 02/04/2013 22:03 187994 normal 7099 02/04/2013 18:31 02/04/2013 22:03 ** but when use 'recursive'=>-1 in find('all') statement,i got following ** parking location : booking date : 02/04/2013 booking id transaction type vehicle no check in date check out date 187994 normal 7099 02/04/2013 18:31 02/04/2013 22:03

java - Properties file not found - how to locate it as resource? -

i have properties file @ location (from netbeans project explorer) -mytest +web pages +source packages -test packages -<default package> +env.properties <---- here +com.mycomp.gts.test +com.mycomp.gts.logintest ..... .... now when trying find file using code inputstream propertiesinputstream = getclass().getresourceasstream("env.properties"); env.load(propertiesinputstream); its throwing java.lang.nullpointerexception you cannot use class reference load resource, because resource path not relative class. use class loader instead: inputstream propertiesinputstream = getclass().getclassloader() .getresourceasstream("env.properties"); env.load(propertiesinputstream); or alternatively, can use context class loader of current thread: inputstream propertiesinputstream = thread.currentthread() .getcontextclassloader().getresourceasstream("env.properties

Why NHibernate updates old entities in DB though no id is assigned -

i'm using fluent nhibernate , ms sql express 2012. when want save entities db create them , call isession.save() or isession.saveorupdate() not setting id fields. works fine until stop application , start again. after new entities not added db. instead when call save() or saveorupdate() updates old ones. why nhibernate behaves this? seems me when don't set id field must add new entity db not update old one. here's example: consider have class foo: public class foo { public virtual long id { get; set; } public virtual string value { get; set; } } and mapping: public class foomap : classmap<foo> { public foomap() { id(foo => foo.id) .generatedby.native(); map(foo => foo.value); } } here's how save them db: var foo1 = new foo { value = "aaa" }; var foo2 = new foo { value = "bbb" }; var sf = config.buildsessionfactory(); using (var sess = sf.opensession()) { using (va

spring - Is <context: annotation-config> necessary for annotation @Resource , @PostConstruct and @PreDestroy? -

i new in spring , want know if write @resource or @postconstruct or @predestroy annotation on method of class necessary add "context: annotation-config" tag in xml file register method. my confusion @resource or @postconstruct or @predestroy jsr-250 annotation not specific spring-framework why "context: annotation-config" tag added in config file(spring.xml). i know applicable @required , @autowired annotation. can explain please ? the thing that, no matter annotation is, doesn't anything, kind of mark tell other thing means. , when add context: annotation-config in xml file, when start tomcat or other load environment of spring, when found context: annotation-config , register beans spring has implemented scan class find annotation @resource or @postconstruct or @predestroy, , thing do, such instantiate bean, bind value , on.

Saving values in different pages in a gridview,asp.net -

i have grid contains more 30 values.grid view page size 10 .grid view contains check box when select 2 datas in first page , go next page , select 2 data , enter ok button save last select value.i want save datas selected in different pages thanks advance you can try piece of code: * protected void page_load(object sender, eventargs e) { if(!ispostback) { bindgriddata(); } } //this method used bind gridview protected void bindgriddata() { sqlconnection con = new sqlconnection("data source=xxx;integrated security=true;initial catalog=mysampledb"); sqlcommand cmd = new sqlcommand("select * userinformation", con); sqldataadapter da = new sqldataadapter(cmd); dataset ds = new dataset(); da.fill(ds); gvdetails.datasource = ds; gvdetails.databind(); } protected void gvdetails_pageindexchanging(object sender, gridviewpageeventargs e) { savecheckedvalues(); gvdetails.pageindex = e.newpageindex; bindgriddata(); populatecheckedvalues(); } //this method used

windows - How to switch current user using powershell? -

my task create new windows local user, log in, using , actions. creating new user wasn't problem don't know how switch current user new one. what did piece of script start new powershell window using new user: $secpasswd = convertto-securestring $password -asplaintext -force $mycreds = new-object system.management.automation.pscredential ($config_name, $secpasswd) start-process powershell.exe -credential $mycreds -nonewwindow is possible start doing rest of script in new window?? simple way following: create script (let's call init.ps1) put in actions want invoke user add execute right script $config_name change last line (-noexit debugging, without powershell close window after execution finish): start-process powershell.exe -credential $mycreds -nonewwindow -argumentlist "-noexit -command full_path_to_script\init.ps1" more difficult way install winrm , use commands enter-pssession (examples in end of link: http://technet.micro

javascript - Ajax request not working when signed in, works when not signed in -

i have ajax request simple this: $.ajax({ type: "post", url: "/admin.html", data: datastring, success: function(data) { if(data.error) { $('#alertt').text(data.error); $('#alertt').show(); $('#alertt').fadein().delay(2000).fadeout('slow'); } else if (data.success) { var lati = $('#route_latitude').val(); var longi = $('#route_longitude').val(); increment(); setmarker(lati, longi); $('#alertt').text(data.success); $('#alertt').show(); $('#alertt').fadein().delay(2000).fadeout('slow'); } }, error: function(jqxhr, textstatus, errorthrown) { console.log(textstatus + " " + errorthrown) } }) the problem is, if user signed in on webpage, sits @ (pending)

objective c - How does the NSNotificationCenter detect the deallocated observer in ARC? -

i found when using nsnotificationcenter in arc, forget remove observer defaultcenter, , observer has deallocated, post notification observer observed , there no crash anymore !! before xcode 4, there no arc, must remove observer default notification center in dealloc function, this: - (void)dealloc { [[nsnotificationcenter defaultcenter] removeobserver:self]; } otherwise when binded notification posted, triger crash ! so, question how nsnotificationcenter detect deallocated observer in arc ? update: of ios 9 , os x 10.11, no longer necessary nsnotificationcenter observer un-register when being deallocated. (source: unregistering nsnotificationcenter observers in ios 9 ) (old answer:) arc, have remove observer notification center when deallocated. may pure chance program did not crash. the following program demonstrates this. have activated "enable zombie objects" option. @interface myobject : nsobject @end @implementation myobject -(id)

.net - Get process ID of a client that connected to a named pipe server with C# -

i'm not sure if i'm not seeing it, or what? need know process id of client connected via named pipe server instance of namedpipeserverstream . such possible? in meantime came function: [dllimport("kernel32.dll", setlasterror = true)] internal static extern bool getnamedpipeclientprocessid(intptr pipe, out uint32 clientprocessid); public static uint32 getnamedpipeclientprocid(namedpipeserverstream pipeserver) { //return: // = client process id connected via named pipe server, or // = 0 if error uint32 nprocid = 0; try { intptr hpipe = pipeserver.safepipehandle.dangerousgethandle(); getnamedpipeclientprocessid(hpipe, out nprocid); } catch { //error nprocid = 0; } return nprocid; } i'm not strong in "dangerousgethandles" , "dllimports". i'm way better off win32, i'm using here. the main problem code, not perform correct error handling.

java - Too much space between components in Spring layout -

Image
i want create jframe hand , use spring layout this. but, output not good. space between rows much, , between radio buttons too: my code: public final class newuserframe1 extends jframe { public newuserframe1() { add(rowcomponent(), borderlayout.center); setlocation(200, 40); setdefaultcloseoperation(jframe.exit_on_close); setresizable(false); setvisible(true); pack(); } public jpanel rowcomponent() { jpanel panel = new jpanel(); jlabel fnamelbl = new jlabel("first name"); jlabel lnamelbl = new jlabel("last name"); jlabel fntemp = new jlabel(); jlabel lntemp = new jlabel(); jtextfield fntf = new jtextfield(10); jtextfield lntf = new jtextfield(10); jlabel gndlnl = new jlabel("gender"); jradiobutton malerb = new jradiobutton("male"); jradiobutton femalerb = new jradiobutton("female"); buttongroup bgroup = new buttongroup(); bgroup.add(malerb); bgroup.

c++ opencv , compiling a simple prog -

i got many problems while trying compile little program opencv. now after hours of google try compile following command: gcc peas.sample.cc `pkg-config --cflags --libs opencv` but after compiler finds cv.h , highgui.h next problem: /usr/bin/ld: cannot find -lopencv_contrib

html - Plotting tools for dashboard -

after browsing while available solutions, hard choose appropriate tool creating dashboard & populating plots. want have html page multiple plots , tables depicted. i'm thinking have data input stored in csv files, appropriately formatted. the requirements are: plot coordinates showing on mouse hover ability show coordinates of points on plotted line (points in scatter plot or bar values bar chart) 'sticking' nearest lines on hover, appropriate handling of multiple lines (show several y values same x) ability interactively switch plotted data on/off easily embeddable html page, doesn't require additional plugins installed a variety of plot types not slow load , stable, there ~50 plots on 1 page (this internal use only, quickness not important) does minimal effort so far checked out (by no means final opinion, correct me if i'm wrong): gnuplot+canvas - looks good, samples on page fail work me, not getting mouse clicks right python+matplotlib

c# - Absolute path information is required error -

here code: ftpconnection ftp = new ftpconnection(configurationmanager.appsettings["server"], configurationmanager.appsettings["user"], configurationmanager.appsettings["password"]); ftp.open(); ftp.login(); ftpfileinfo[] files = null; if (ftp.directoryexists(some_name)) { ftp.setcurrentdirectory(some_name); files = ftp.getfiles("*.xlsx"); string filename = files[0].name; } return; everything works well. filename variable has correct name. error code 500 though nothing crashed. error says: absolute path information required. what mean? how fix it? when debugged noticed when expand properties of files, there 1 property exists, has exact same error. see below link(s) although not exact same issue - should point in right direction? link1 link2 hope helps

mvcjqgrid - jqgrid datatype:json for url request, and json response not work to populate -

i want make request (sync) server populate jqgrid. did this: $table.jqgrid({ datatype: "json", url:'takepage/page=1', mtype: 'get', ajaxsubgridoptions: { async: false }, colnames:['result','test'], colmodel:[ {name:'result',index:'result',width:120}, {name:'test',index:'test', width:120} ], pager: "#"+pager, caption: "testjqgrid sync request server", jsonreader: { repeatitems: false, page: function(obj) { return obj.page; }, total: function(obj) { return obj.total;

sql server - is the same recursive CTE and trigger instead of delete? -

i using sql server 2008 express r2 , have table self referencing, because have hierarchy struct. i need delete root node, error because of foreign key. have read can use 2 option, use recursive cte o use instead of delete trigger. which difference brtween both of them? more efficient? thanks. when use delete trigger opposed recursive cte, assume going kind of loop in trigger, mean cte more efficient. for cte, try like: with cte ( select id root, parent, id [<yourtable>] parent null -- selects root nodes union select cte.root, d.parent, d.id cte inner join data d on cte.id = d.parent ) delete [<yourtable>] [<yourtable>] inner join cte on rel.id = cte.id cte.root = 1 -- root delete

Scala Constructor Deprecation -

i have class in scala, constructed in standard manner: class test( int : int ) { override def tostring() = "test: %d".format( int ) } however, i'd move on indirect construction via companion object. library i'm modifying used others, don't want make constructor private straight away. instead, i'd deprecate , come , make private once people have had chance change usage. modified code this: object test { def apply( int : int ) = new test( int ) } @deprecated( "don't construct directly - use companion constructor", "09/04/13" ) class test( int : int ) { override def tostring() = "test: %d".format( int ) } however, deprecates whole class. scala> test( 4 ) <console>:10: warning: class test in package foo deprecated: don't construct directly - use companion constructor val res0 = ^ res0: com.foo.test = test: 4 does know if scala supports deprecation of constructors, , if

powershell - How do I get topshelf to return error code when command fails? -

i trying start service powershell fails. don't know why fails not point here. when trying start host don't correct exit code automatic deploy fails silently. what i'm trying is: $cmd = "$folder" + "\myservice.exe" try { & $cmd stop & $cmd uninstall & $cmd install & $cmd start } catch { write-host "error: update of service failed" exit 1 } the start command fails following messge: topshelf.hosts.starthost error: 0 : service failed start., system.invalidoperationexception: cannot start service myservice on computer '.'. ---> system.componentmodel.win32exception: service cannot started, either because disabled or because has no enabled devices associated --- end of inner exception stack trace --- @ system.serviceprocess.servicecontroller.start(string[] args) @ system.serviceprocess.servicecontroller.start() @ topshelf.runtime.windows.windowshostenvironment.startservice

xml - XSL for-each and LEFT JOIN -

i need xslt statement gives me "left join": if selected node exist, return such nodes, otherwise loop once. this different xsl:for-each loop, because when there not such node for-each loop returns 0 lines. here pratical example. xml file: <root> <sec1> <x1/> ... <x1/> </sec1> <sec2> <x2/> ... <x2/> </sec2> ... <sec10> <x10/> ... <x10/> </sec10> </root> now, don't know how many "x1", "x2", .. "x10" have, , want print out possible combinations. easy , wrong solution: <xsl:for-each select="/root/sec1/x1"> <xsl:for-each select="/root/sec2/x2"> ... <xsl:for-each select="/root/sec10/x10"> ...print x1 , x2... , x10 </xsl:for-each> ... </xsl:for-each> </xsl:for-each> this solution wro

Nginx redirect to main domain on SSL -

i have 2 equal domains, served virtual hosts, site.com , additional.com . have ssl cert first 1 , don't want another. when user trying log in, i'm doing permanent redirect: server { listen 443; server_name additional.com; rewrite ^/(.*) https://site.com permanent; } ... server { listen 80; server_name site.com additional.com; root /home/site/production/public; location / { ... } } server { listen 443; server_name site.com; ssl on; ... } and fails, since ssl traffic proxied uplink server, , cannot handle it, because talks http , there's ssl23_get_server_hello:unknown protocol (for chrome; firefix , curl have different error messages). had change (notice http, not https here): server { listen 443; server_name additional.com; rewrite ^/(.*) http://site.com permanent; } errors no longer appear, when going /login page (that should secure , uplink redirects https) it's not rewriting, stating certifi

sqlite - Android Sqllite db is static or dynamic in nature? -

i'm new android , have problem in understanding db concept in android. when create table in android android give app static space? or db size grows in dynamic way, when add more data it? if grows in dynamic way how space can grow max? and db been created app persistent? android guarantees me data wont removed android os? sqlite database management system, light version of sql. yes database's size grows enter data it's table. data ( text,int,float,image ) self made of binary information going take place. if grows in dynamic way how space can grow max? it depends on available space. and db been created app persistent? android guarantees me data wont removed android os? yes, data style persistence, stay system long dont remove programmatically or manually.

php - ajax with html issue -

i want html of website check links, use following ajax code html of remote website: $.ajax({ type : 'get', url : 'proxy.php', datatype : 'html', success : function(data){ alert('success'); }, error : function(xmlhttprequest, textstatus, errorthrown) { alert('error'); } }); proxy.php proxy use data because not on server : <?php // set return content type header('content-type: application/html'); // website url open $daurl = 'http://example.com'; // website's content $handle = fopen($daurl, "r"); // if there something, read , return if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose($handle); } ?> the code alert error , can not understand ok because not expert ajax want check me? wrong ajax datatype? wrong header in proxy file please??? you serving html file retrieved proxy.php wrong content-type .

actionscript 3 - TextField lowercase line -

Image
i need distance between baseline , lowercase line inside the scaled textfield , using actionscript 3. marked it's blue arrows here: does knows how value? what looking called x-height . unfortunately, flash actionscript api not provide way of getting x-height typeface. with tricky techniques, might able calculate x-height though. thinking might able create new textfield "x" in it, , draw bitmapdata. test pixels height.

java - Formatting a number String according to format String -

i have string representing number (e.g. 1234.56) , string representing format (e.g. 1,234.56 or 1 234.56 or 1234,56...) , need format number string according format string. both strings given. some code better underdstanding: public static void main(string[] args) { string number = "1000.0"; formatnumber(number, "1,234.56"); //should 1,000.00 formatnumber(number, "1 234.56"); //should 1 000.00 formatnumber(number, "1234,56"); //should 1000,00 } public static string formatnumber(string number, string format) { return ??? } whats best way achieve that? thanks paul these 3 lines should do. string pattern = format.replaceall("\\d", "#"); decimalformat myformatter = new decimalformat(pattern); return myformatter.format(value); i writing heart, write if encounter problems

java - Comparison between two dates not showing correct result -

in android app, need find date greater or smaller.i have used following code.this code works shows wrong output.pls help string strdate1 = "3/9/2013"; string strdate2 = "4/6/2013"; simpledateformat sdf = new simpledateformat( "m/d/yyyy" ); java.util.date d1; java.util.date d2; try { d1 = sdf.parse( strdate1 ); d2 = sdf.parse( strdate2 ); if ( d1.after(d2)) { system.out.println( "d1 after d2" ); } else if ( d1.before(d2) ) { system.out.println( "d1 before d2" ); } else { system.out.println( "d1 equal d2" ); } } catch (parseexception e) { // todo auto-generated catch block e.printstacktrace(); } for above code got output "d1 after d2".but real thing "d1 before d2".pls suggest if did mist