Daily Archives

Articles indexed Friday October 25 2013

Page 9/19 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Should webmasters "index" dashboard and edit account page

    - by francoboy7
    New here, I did my research and found nothing, but sorry if it has already been asked. As webmasters should be let google and other search engine INDEX our member's dashboard and edit account page. For example my member John has access to a page name "Edit your account" where he can fill some fields and updates his info. Or another pages where John can manage his posts (edit, delete) Such pages have no interest to the other people so should be let google and others INDEX it or should we NOINDEX it ? Thanks for your time ! Franck

    Read the article

  • How should game objects be aware of each other?

    - by Jefffrey
    I find it hard to find a way to organize game objects so that they are polymorphic but at the same time not polymorphic. Here's an example: assuming that we want all our objects to update() and draw(). In order to do that we need to define a base class GameObject which have those two virtual pure methods and let polymorphism kicks in: class World { private: std::vector<GameObject*> objects; public: // ... update() { for (auto& o : objects) o->update(); for (auto& o : objects) o->draw(window); } }; The update method is supposed to take care of whatever state the specific class object needs to update. The fact is that each objects needs to know about the world around them. For example: A mine needs to know if someone is colliding with it A soldier should know if another team's soldier is in proximity A zombie should know where the closest brain, within a radius, is For passive interactions (like the first one) I was thinking that the collision detection could delegate what to do in specific cases of collisions to the object itself with a on_collide(GameObject*). Most of the the other informations (like the other two examples) could just be queried by the game world passed to the update method. Now the world does not distinguish objects based on their type (it stores all object in a single polymorphic container), so what in fact it will return with an ideal world.entities_in(center, radius) is a container of GameObject*. But of course the soldier does not want to attack other soldiers from his team and a zombie doesn't case about other zombies. So we need to distinguish the behavior. A solution could be the following: void TeamASoldier::update(const World& world) { auto list = world.entities_in(position, eye_sight); for (const auto& e : list) if (auto enemy = dynamic_cast<TeamBSoldier*>(e)) // shoot towards enemy } void Zombie::update(const World& world) { auto list = world.entities_in(position, eye_sight); for (const auto& e : list) if (auto enemy = dynamic_cast<Human*>(e)) // go and eat brain } but of course the number of dynamic_cast<> per frame could be horribly high, and we all know how slow dynamic_cast can be. The same problem also applies to the on_collide(GameObject*) delegate that we discussed earlier. So what it the ideal way to organize the code so that objects can be aware of other objects and be able to ignore them or take actions based on their type?

    Read the article

  • Jquery UI autocomplete header

    - by Kanaka
    I have a jQuery UI autocomplete (with custom styling) where I added an header. You can see it at work here: http://jsfiddle.net/fbonomi/wJWGV/ the header is added like this: function cComboboxOpen( event) { var s='.... header .....'; $("ul.ui-autocomplete[style*='block']").prepend(s); } it works, and it keeps the column-like form I need (the real data will also be in columns) BUT, I would like to have the header NOT scrolling away when you have a long, scrollable list (e.g if you type "a" in the list) I have seen another very similar question here: jQuery UI Autocomplete with fixed header But it hasn't been answered, and in its current form it does not work properly (the header is "fixed" even when one scrolls the page, for example) How can I avoid the header to scroll away?

    Read the article

  • Javascript to PHP, mysql uploading, one button pressing solution

    - by user2897858
    my program is generating buttons from a mysql database.When one of the button is pressed, it would uplod the current time and the gps coordinate. Sadly, it only works if the same button is pressed twice, but its not an option, because the button has to dissappear. I would like to have some help in coding how to make that possible the user only need to press the button once for the correct upload.Thanks in advance Here is the full code of my my file: <?php session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>title</title> </head> <?php $maidatum=date("Ymj"); echo "<script>getLocation();</script>"; //Az adatbázishoz való csatlakozás $conn = mysql_connect("localhost","root","asd"); if(!($conn))die("Nincs conn a kiszolgálóval!".mysql_error()); $adatbazisneve="schtrans"; mysql_select_db($adatbazisneve,$conn); mysql_query("set names 'utf8'"); mysql_query("set character set 'utf8'"); //Combobox $sql = "SELECT Jaratszam,Vezeto FROM user"; $rs = mysql_query($sql) or die(mysql_error()); echo "<form action=\"\" method=\"post\">"; echo<<<nev <select name='Lista'> nev; while($row = mysql_fetch_array($rs)){ echo "<option value='".$row["Jaratszam"]."'>".$row["Vezeto"]."</option>"; }mysql_free_result($rs); echo "</select>"; ///Combox vége echo<<<lekerd <form action="" method="post"> <input type="submit" name="bekuldes" value="Lekérdez" /> </form> </form> lekerd; echo<<<gps <form action="" method="post"> <input type="hidden" name= "longitude" id="longitude"> <input type= "hidden" name ="latitude" id="latitude"> </form> gps; if(isset($_POST["bekuldes"])) { $jaratszam = $_POST['Lista']; $_SESSION['jaratsz']=$jaratszam; $lekerdez_parancs="SELECT * FROM cim_$maidatum WHERE jarat=$jaratszam;"; $lekerdez=mysql_query($lekerdez_parancs, $conn); echo "<table border=\"1\">"; echo "<td>Utánvétel</td> <td>Megrendelés összege</td> <td>ISZ</td> <td>Város</td> <td>Utca</td> <td>Megjegyzés</td> <td>Csomagok</td> <td>Raklaphely</td> <td>Súly</td><td>Térfogat</td><td>Latitude</td><td>Longitude</td><td>Ido</td>"; $g=1; //cimszámláló while ($adatok=mysql_fetch_array($lekerdez)) { echo "<tr>"; $_SESSION['adatok0'][$g]=$adatok[0]; echo "<td>$adatok[2]</td> <td>$adatok[3]</td> <td>$adatok[4]</td> <td>$adatok[5]</td> <td>$adatok[6]</td> <td>$adatok[7]</td> <td>$adatok[8]</td> <td>$adatok[9]</td> <td>$adatok[10]</td><td>$adatok[11]</td><td>$adatok[13]</td><td>$adatok[14]</td>"; if ($adatok[12]==null) { echo<<<gomb <form action="" method="post"> <td> <input type="hidden" name= "longitude" id="longitude$g"> <input type= "hidden" name ="latitude" id="latitude$g"> <input type="submit" name="ido" value="$g" /></td> </form> gomb; } else {echo "<td>$adatok[12]</td>";} $g++; } echo "</table>"; } if(isset($_POST["ido"])) { $hanyadik=$_POST["ido"]; $longitudee="longitude$hanyadik"; $latitudee="latitude$hanyadik"; ?> <script> var x=document.getElementById("log"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else{x.innerHTML="GPS szolgáltatás nem müködik ezen a böngészon, kérlek értesítsd a rendszergazdát!";} } function showPosition(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; document.getElementById("<?php echo $longitudee;?>").value = longitude; document.getElementById("<?php echo $latitudee;?>").value = latitude; } </script> <?php echo "<script>getLocation();</script>"; $latitude=$_POST["latitude"]; $longitude=$_POST["longitude"]; print_r($_POST); $currentime=date("H:i:s"); $acim=$_SESSION['adatok0'][$hanyadik]; $idofeltolt_parancs="UPDATE cim_$maidatum SET ido='$currentime',lat='$latitude',longi='$longitude' WHERE cimid='$acim';"; $feltoltes=mysql_query($idofeltolt_parancs, $conn) or die(mysql_error()); //tryy $jaratszam=$_SESSION['jaratsz']; $lekerdez_parancs="SELECT * FROM cim_$maidatum WHERE jarat=$jaratszam;"; $lekerdez=mysql_query($lekerdez_parancs, $conn); mysql_query("set names 'utf8'"); mysql_query("set character set 'utf8'"); echo "<table border=\"1\">"; echo "<td>Utánvétel</td> <td>Megrendelés összege</td> <td>ISZ</td> <td>Város</td> <td>Utca</td> <td>Megjegyzés</td> <td>Csomagok</td> <td>Raklaphely</td> <td>Súly</td><td>Térfogat</td><td>Latitude</td><td>Longitude</td><td>Ido</td>"; $g=1; //cimszámláló while ($adatok=mysql_fetch_array($lekerdez)) { echo "<tr>"; $_SESSION['adatok0'][$g]=$adatok[0]; echo "<td>$adatok[2]</td> <td>$adatok[3]</td> <td>$adatok[4]</td> <td>$adatok[5]</td> <td>$adatok[6]</td> <td>$adatok[7]</td> <td>$adatok[8]</td> <td>$adatok[9]</td> <td>$adatok[10]</td><td>$adatok[11]</td><td>$adatok[13]</td><td>$adatok[14]</td>"; if ($adatok[12]==null) { echo<<<gomb <form action="" method="post"> <td> <input type="hidden" name= "longitude" id="longitude$g"> <input type= "hidden" name ="latitude" id="latitude$g"> <input type="submit" name="ido" value="$g" /></td> </form> gomb; } else {echo "<td>$adatok[12]</td>";} $g++; } echo "</table>"; } mysql_close($conn); ?> </html>

    Read the article

  • How can I filter images and use filesystemview icons in my jtree?

    - by HoLeX
    First of all sorry about my english. So, i have some problems with my JTree because i want to filter specific types of images and also i want to use icons of FileSystemView class. Can you help me? I will appreciate so much. Here is my code: import java.awt.BorderLayout; import java.io.File; import java.util.Iterator; import java.util.Vector; import javax.swing.JPanel; import javax.swing.JTree; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; public class ArbolDirectorio extends JPanel { private JTree fileTree; private FileSystemModel fileSystemModel; public ArbolDirectorio(String directory) { this.setLayout(new BorderLayout()); this.fileSystemModel = new FileSystemModel(new File(directory)); this.fileTree = new JTree(fileSystemModel); this.fileTree.setEditable(true); this.fileTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent event) { File file = (File) fileTree.getLastSelectedPathComponent(); System.out.println(getFileDetails(file)); } }); this.add(fileTree, BorderLayout.CENTER); } private String getFileDetails(File file) { if (file == null) { return ""; } StringBuffer buffer = new StringBuffer(); buffer.append("Name: " + file.getName() + "\n"); buffer.append("Path: " + file.getPath() + "\n"); return buffer.toString(); } } class FileSystemModel implements TreeModel { private File root; private Vector listeners = new Vector(); public FileSystemModel(File rootDirectory) { root = rootDirectory; } @Override public Object getRoot() { return root; } @Override public Object getChild(Object parent, int index) { File directory = (File) parent; String[] children = directory.list(); return new TreeFile(directory, children[index]); } @Override public int getChildCount(Object parent) { File file = (File) parent; if (file.isDirectory()) { String[] fileList = file.list(); if (fileList != null) { return file.list().length; } } return 0; } @Override public boolean isLeaf(Object node) { File file = (File) node; return file.isFile(); } @Override public int getIndexOfChild(Object parent, Object child) { File directory = (File) parent; File file = (File) child; String[] children = directory.list(); for (int i = 0; i < children.length; i++) { if (file.getName().equals(children[i])) { return i; } } return -1; } @Override public void valueForPathChanged(TreePath path, Object value) { File oldFile = (File) path.getLastPathComponent(); String fileParentPath = oldFile.getParent(); String newFileName = (String) value; File targetFile = new File(fileParentPath, newFileName); oldFile.renameTo(targetFile); File parent = new File(fileParentPath); int[] changedChildrenIndices = { getIndexOfChild(parent, targetFile) }; Object[] changedChildren = { targetFile }; fireTreeNodesChanged(path.getParentPath(), changedChildrenIndices, changedChildren); } private void fireTreeNodesChanged(TreePath parentPath, int[] indices, Object[] children) { TreeModelEvent event = new TreeModelEvent(this, parentPath, indices, children); Iterator iterator = listeners.iterator(); TreeModelListener listener = null; while (iterator.hasNext()) { listener = (TreeModelListener) iterator.next(); listener.treeNodesChanged(event); } } @Override public void addTreeModelListener(TreeModelListener listener) { listeners.add(listener); } @Override public void removeTreeModelListener(TreeModelListener listener) { listeners.remove(listener); } private class TreeFile extends File { public TreeFile(File parent, String child) { super(parent, child); } @Override public String toString() { return getName(); } } }

    Read the article

  • Rewriting usort function because of fatal error (PHP bug)

    - by Lionel
    The two following usort functions throw fatal error Base lambda function for closure not found in our productive environment (PHP 5.4). This seems to be a known PHP bug that should be fixed by now (https://bugs.php.net/bug.php?id=52144), but it still occurs for us. Anyway, we unfortunately don't have time to figure out what's wrong with our PHP configurations etc. We would like to rewrite these two functions without the use of anonymous functions, so that the error doesn't occur anymore. Ordering of a multidimensional array ($array) by value of key "position": usort($array, function($a, $b) { return $a['position'] - $b['position']; }); Ordering of a multidimensional array ($array) according to the order of a second array ($position_order): usort($array, function($a, $b) use($position_order) { return (isset($position_order[$a['ftid']]) ? ($position_order[$a['ftid']] - $position_order[$b['ftid']]) : 1); }); Especially the latter causes some headache, as we don't know how to pass the "outside" array $position_order.

    Read the article

  • Same route nested in multiple resources ember.js

    - by Daniel Upton
    I'm building an ember.js app which has a model called "Programme". A user can drill down to a programme by going: Genre > Subgenre > Programme or Folder > List > Programme Here's my router: this.resource('mylists', { path: '/' }, function() { this.resource('folder', { path: '/folder/:folder_id' }, function() { this.resource('list', { path: '/list/:list_id' }, function() { this.resource('programme', { path: '/programme/:programme_id' }); }); }); }); this.resource('catalogue', function() { this.resource('genre', { path: '/genre/:genre_id' }, function() { this.resource('subgenre', { path: '/subgenre/:subgenre_id' }, function() { this.resource('programme', { path: '/programme/:programme_id' }); }); }); }); The UI needs to be deeply nested (the genre view renders in the outlet of the catalogue template, the subgenre in the outlet of the genre template... and so forth). The problem I have is as both generated routes are called ProgrammeRoute when I linkTo the programme route inside the list template, it actually goes to the programme route nested in the subgenre route. What should I be doing here? To work around it I've named one route ListProgrammeRoute and SubgenreProgrammeRoute but that leads to some duplication.

    Read the article

  • Preserving timestamps on Clojure .clj files when building shaded jar via Maven Shade Plugin

    - by Dereference
    When using the maven-shade-plugin to package our jar artifact that contained a few Clojure libs and some Java. We were using AOT compilation for our Clojure code. When we loaded the jar, it was having very slow load times. AOT compilation is supposed to help this quite a bit, but that wasn't what we were seeing. We noticed in java jar -verbose output that there was a lot of JVM__DEFINE_CLASS calls happening when Clojure classes were being loaded. This didn't make sense, since more of our Clojure code was AOT compiled to .class files. Turns out the maven-shade-plugin creates all new files, with new timestamps in the final artifact Clojure uses the timestamp information on a .clj file vs. a .class file, to determine if the file needs to be recompiled. The maven-shade-plugin was causing the .clj file and it's associated .class file to have the same timestamp, so Clojure always chose to dynamically recompile the source. The only workaround that we have been able to figure out, at this point, is to write a script that would re-open the shaded jar and bump the .clj file timestamps back to some time in the past, so that they wouldn't be equal to the timestamps of their associated .class files. Does anyone know of a better approach?

    Read the article

  • jquery validatie if statement

    - by Mariana Hernandez
    i have this validate function: var validator =$('#form1').validate( { ignore: "", rules: { usu_login: { required: true }, usu_email: { required: true }, usu_nombre1: { required: true }, usu_apellido1: { required: true }, usu_fecha_nac: { required: true }, usu_cedula: { required: true }, usu_telefono1: { required: true }, usu_password: { required: function() { return focusout == true; } }, usu_password2: { required: function() { return focusout == true; } }, usu_password3: { required: function() { return focusout == true; }, equalTo: "#usu_password2" } i need to apply the same if statement in the "equalTo" fuction so this can work as i want to, but i dont know how to do that. Dows anyone knows? Thanks

    Read the article

  • preg_match not defined in php4 in openwrt?

    - by user2723949
    I have installed the packages PHP4 and PHP4-CGI in openwrt through command line (opkg install) when I tried this simple code by putting this in the openwrt www folder, <?php $subject = "abcdef"; $pattern = '/^def/'; preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3); print_r($matches); ?> I got this error Fatal error: Call to undefined function: preg_match() in /www/phptest.php on line 4 but php manual says preg_match() is defined in php4 also.. What might be the reason for this error? Is there any other PHP module that is to be installed? Or is there any alternate method for preg_match?

    Read the article

  • Syntax Error? When parsing XML value

    - by Ace Munim
    I don't know if I'm having a syntax error but the compiler is giving me TypeError: 'undefined' is not an object (evaluating 'xmlDoc.getElementsByTagName("icon")[i].childNodes') Its me giving me this problem when im parsing the XML from my server, my actual javascript code is like this var xmlDoc = Obj.responseXML; var count = 0; if(xmlDoc){ while(count <= xmlDoc.getElementsByTagName("item").length){ document.getElementById("flow").innerHTML += "<div class='item'><img class='content' src='" + xmlDoc.getElementsByTagName("icon")[i].childNodes[0].nodeValue.replace(/\s+$/g,' ') +"' /></div>"; count++; } }else{ alert("Unable to parse!"); } and my XML goes like this. <feed> <item> <title>Given Title</title> <icon> http://i178.photobucket.com/albums/w255/ace003_album/Logo-ETC-RGB-e1353503652739.jpg </icon> </item> <item>...</item> <item>...</item> <item>...</item> <item>...</item> <item>...</item> <item>...</item> </feed> i just want to parse the image link and to show it.

    Read the article

  • Optimizing a "set in a string list" to a "set as a matrix" operation

    - by Eric Fournier
    I have a set of strings which contain space-separated elements. I want to build a matrix which will tell me which elements were part of which strings. For example: "" "A B C" "D" "B D" Should give something like: A B C D 1 2 1 1 1 3 1 4 1 1 Now I've got a solution, but it runs slow as molasse, and I've run out of ideas on how to make it faster: reverseIn <- function(vector, value) { return(value %in% vector) } buildCategoryMatrix <- function(valueVector) { allClasses <- c() for(classVec in unique(valueVector)) { allClasses <- unique(c(allClasses, strsplit(classVec, " ", fixed=TRUE)[[1]])) } resMatrix <- matrix(ncol=0, nrow=length(valueVector)) splitValues <- strsplit(valueVector, " ", fixed=TRUE) for(cat in allClasses) { if(cat=="") { catIsPart <- (valueVector == "") } else { catIsPart <- sapply(splitValues, reverseIn, cat) } resMatrix <- cbind(resMatrix, catIsPart) } colnames(resMatrix) <- allClasses return(resMatrix) } Profiling the function gives me this: $by.self self.time self.pct total.time total.pct "match" 31.20 34.74 31.24 34.79 "FUN" 30.26 33.70 74.30 82.74 "lapply" 13.56 15.10 87.86 97.84 "%in%" 12.92 14.39 44.10 49.11 So my actual questions would be: - Where are the 33% spent in "FUN" coming from? - Would there be any way to speed up the %in% call? I tried turning the strings into factors prior to going into the loop so that I'd be matching numbers instead of strings, but that actually makes R crash. I've also tried going for partial matrix assignment (IE, resMatrix[i,x] <- 1) where i is the number of the string and x is the vector of factors. No dice there either, as it seems to keep on running infinitely.

    Read the article

  • Issue with undefined namespace

    - by SoBeK
    "xmlns="VL01" Seems to be causing the style-sheet to fail(works fine if removed), do no know how to address it the style-sheet. I feel like this is basic XLST 101 but I am having a hard time wrapping my brain around it. Any assisting would be greatly appreciated. Cheers XML <?xml version="1.0" encoding="utf-8"?> <Report xsi:schemaLocation="VL01 http://site.com/ReportServer?%2FVMS%20Reports%2FVL01&amp;rs%3ACommand=Render&amp;rs%3AFormat=XML&amp;rs%3ASessionID=lk44ff55z5q3ck3b5pfuxo45&amp;rc%3ASchema=True" Name="VL01" textbox41="VL01 - Checklist Report&#xD;&#xA;" textbox1946=" 2) Target Element&#xD;&#xA;     Target Element List&#xD;&#xA;        Windows 7&#xD;&#xA;3) Report Options&#xD;&#xA; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="VL01"> <list2> <Item_Collection> <Item /> </Item_Collection> </list2> <list1> <list1_Details_Group_Collection> <list1_Details_Group Key="V0001070" EffectiveDate="04 Mar 1998 16:03:47:000" LongName2="Name..."/> </list1_Details_Group_Collection> </list1> </Report> XSL <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xsl:output method="xml" version="4.0" indent="yes"/> <xsl:variable name="var-checklist_name"> <xsl:value-of select="substring-after(substring-before(translate(Report/@textbox1946, '&#xD;&#xA;', ''),'3)'),'Target&#x00A0;Element&#x00A0;List')"/> </xsl:variable><xsl:template match="/"> <html> <body> <table> <xsl:apply-templates select="Report/list1/list1_Details_Group_Collection"/> </table> </body> </html> </xsl:template> <xsl:template match="Report/list1/list1_Details_Group_Collection"> <xsl:for-each select="list1_Details_Group"> <Import_List> <Checklist_Name> <xsl:value-of select="normalize-space(translate($var-checklist_name, '&#x00A0;', ' '))"/> </Checklist_Name> <Vuln_ID><xsl:value-of select="number(substring-after(@VulKey,'V'))"/></Vuln_ID> <Short_Name><xsl:value-of select="substring(@LongName2,1,255)"/></Short_Name> <Release_Date><xsl:value-of select="substring(@EffectiveDate,1,11)"/></Release_Date> </Import_List> </xsl:for-each> </xsl:template> </xsl:stylesheet>

    Read the article

  • removing the first value in an array c# or java

    - by MrCode
    hey there i was working on a program and was thinking is it possible was to remove the value from the first element in an array. Has anyone any ideas on how this could be done ? thanks for all input is much appreciated. i have only tried removing from the last element wasnt sure on how i would remove the first this is how i done the last element try { if (isEmpty()) { throw new Exception("list is empty"); } size = size -1; return values[size]; } catch(Exception e) { System.out.println(e); return -1; }

    Read the article

  • How do i make a UILabel act as a link?

    - by user2918086
    I have built a "teacher directory" of sorts, i have the data fill into 3 fields, name, position, and email. All of the fields are UILabels. How do i make it so that you can click on the email and it opens a blank email? @interface PersonDetailTableViewController () @end @implementation PersonDetailTableViewController @synthesize fnameLabel, snameLabel, emailLabel, person; - (void)viewDidLoad { [super viewDidLoad]; [super viewDidLoad]; self.fnameLabel.text = self.person.fname; self.snameLabel.text = self.person.sname; self.emailLabel.text = self.person.email; } (this is the table view controller where the data is being displayed)

    Read the article

  • Clojure multimethod dispatching on functions and values

    - by Josh Glover
    I have a function that returns the indexes in seq s at which value v exists: (defn indexes-of [v s] (map first (filter #(= v (last %)) (zipmap (range) s)))) What I'd like to do is extend this to apply any arbitrary function for the existence test. My idea is to use a multimethod, but I'm not sure exactly how to detect a function. I want to do this: (defmulti indexes-of ???) (defmethod indexes-of ??? [v s] ;; v is a function (map first (filter v (zipmap (range) s)))) (defmethod indexes-of ??? [v s] ;; v is not a function (indexes-of #(= v %) s)) Is a multimethod the way to go here? If so, how can I accomplish what I'm trying to do?

    Read the article

  • Save Values AUTOMATICALLY with NSUserDefaults

    - by Edouard Tarter
    I have an app with two UITextFields, where the user enters an integer, and then a method is called with the values the user enters. But when I completely close the app, the values are deleted. I want to change it to save the value the user entered when it closes, and loads it up when the app is re-opened. I tried this with NSUserDefault, and it worked fine (with save and load button), but I want it to make it automatically, without pressing any buttons. I saw some other people do it with the basic methods in the AppDelegate.m, but I don't know anything about that, therefore I didn't understand it at all. I saw MANY tutorials online, but I didn't understand any of them, please help, and give a detailed answer, thanks :)

    Read the article

  • JAVA String split on interval

    - by user2920611
    I would like to split my strings in JAVA based on a regular interval, not on regex. This is what I have to split: 1 x3.1.105.41 1 -10 2 x4.1.105.41 0 -10 3 x12.1.105.41 0 -10 4 y3.1.105.41.19 1 0 5 y4.1.105.41.21 0 0 6 y1.1.105.41.23 0 0 7 y12.1.105.41.25 0 0 I would like to seperate each column. Currently, I use the strLine.spli function Any help would be great!

    Read the article

  • validation of form with Jquery within asp.net mvc4 application

    - by slatnia wadii
    I am a beginner with Jquery and asp MVC4 I use the Jquery validate plugin <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.js" type="text/javascript"> the code <script> jQuery(document).ready(function() { jQuery("#monFormulaire").validate({ rules: { "reclamation": { "required": true, "minlength": 4, "maxlength": 60000 }, "cause": { "required": true, "minlength": 4, "maxlength": 60000 }, "curative": { "required": true, "minlength": 4, "maxlength": 60000 }, "Closing_date": { "required": true, "minlength": 1, "maxlength": 60000 } }, submitHandler: function (form) { /* envoyer Mail*/ mailJob(); } }); }); <button type="submit" value="Page5" name="btnPage1" style="margin-left:1%" class="backRow" ></button> <table border="1" class="mytab" style="margin: auto;"> formulaire . </table> </form> The validation runs in the right way but the Action in the server side is not invoked anyone have any Idea ???

    Read the article

  • AngularJs not working with dynamic html

    - by user2541753
    In my cshtml file I have a form named 'ApplyMedicalMain' and I want to show a dynamically loaded division when the form is dirty but its not happening even though the form is dirty ... Below is my code that i got in Firefox Inspect Element: <form class="form_section ng-dirty ng-valid ng-valid-required" name="ApplyMedicalMain" method="post" action="/MVC/Quote/ApplyMedical"> <div id="Step1_PartialView" class="QuoteStep1"> <script type="text/javascript" src="/Scripts/Renderings/Presales/ApplyMedical.js"> <div name="Conditions" id="conditions_or_symptoms" ng-hide="ApplyMedicalMain.$dirty"> <div class="generic_error_message select"> <div class="error_icn_message"></div> </div> As you can see above, I have mentioned ng-hide for the division name='conditions' but it is not getting hidden even though the form has class 'ng-dirty'.And please note that the the division 'conditions' is loaded dynamically from other partial view. can someone help me ?

    Read the article

  • Entity Framework: An object with the same key already exists in the objectstatemanager

    - by NealR
    I see that this question has been asked a lot, however I haven't found anything yet that solves the problem I'm having. Obviously i'm using the Entity Framework to perform an update to a record. Once the updates are complete, however, whenever I try to save I get the following error message: An object with the same key already exists in the objectstatemanager At first I was passing in a collection object from the view that contained a copy of the the ZipCodeTerritory model object zipToUpdate. I changed the code by pulling this object out and just sending in the relevant fields instead. However, I'm still getting the same error. What's also weird is the first time I run this code, it works fine. Any attempt after that I get the error. Controller Here is the code from the method calling the edit function public static string DescriptionOnly(ZipCodeIndex updateZip) { if (!string.IsNullOrWhiteSpace(updateZip.newEffectiveDate) || !string.IsNullOrWhiteSpace(updateZip.newEndDate)) { return "Neither effective or end date can be present if updating Territory Code only; "; } _updated = 0; foreach (var zipCode in updateZip.displayForPaging.Where(x => x.Update)) { ProcessAllChanges(zipCode, updateZip.newTerritory, updateZip.newStateCode, updateZip.newDescription, updateZip.newChannelCode); } _msg += _updated + " record(s) updated; "; return _msg; } And here is the method that actually does the updating. private static void ProcessAllChanges(ZipCodeTerritory zipToUpdate, string newTerritory, string newStateCode, string newDescription, string newChannelCode) { try { if (!string.IsNullOrWhiteSpace(newTerritory)) zipToUpdate.IndDistrnId = newTerritory; if (!string.IsNullOrWhiteSpace(newStateCode)) zipToUpdate.StateCode = newStateCode; if (!string.IsNullOrWhiteSpace(newDescription)) zipToUpdate.DrmTerrDesc = newDescription; if (!string.IsNullOrWhiteSpace(newChannelCode)) zipToUpdate.ChannelCode = newChannelCode; if (zipToUpdate.EndDate == DateTime.MinValue) zipToUpdate.EndDate = DateTime.MaxValue; _db.Entry(zipToUpdate).State = EntityState.Modified; _db.SaveChanges(); _updated++; } catch (DbEntityValidationException dbEx) { _msg += "Error during update; "; EventLog.WriteEntry("Monet", "Error during ProcessAllChanges: " + zipToUpdate.ToString() + " |EX| " + dbEx.Message); } catch (Exception ex) { _msg += "Error during update; "; EventLog.WriteEntry("Monet", "Error during ProcessAllChanges: " + zipToUpdate.ToString() + " |MESSAGE| " + ex.Message); } } EDIT The ZipCodeIndex object contains a list of ZipCodeTerritory model objects. These aren't being pulled from a linq query, but instead simply passed back to the controller from the view. Here is the signature of the controller method that starts the process: [HttpPost] public ActionResult Update(ZipCodeIndex updateZip, string button)

    Read the article

  • Dynamic Column lookup with different pages in excel

    - by CinCity
    I have a multi page spread sheet in excel that needs to read information dynamically from columns on other pages and have these values show up on a main page. This is the formula I'm using: =IF(VLOOKUP($B:$B,'CP01'!$B:$BN,3,FALSE)="r","r", IF(VLOOKUP($B:$B,'CP01'!$B:$BN,3,FALSE)="a","a","")) CP01 is a sheet in the excel file and instead of look at the specific sheet I want it to look at all of the sheets in the file. Is there a way to do this as an excel formula or with excel-VBA? Edit: I also tried CP* (* being a wildcard character) and it didn't work. Edit2: Is there a way to match the value where the 'CP' is placed with its a other columns value?

    Read the article

  • Binary Search Tree Contains Function

    - by Suede
    I am trying to write a "contains" function for a binary search tree. I receive the following error at compile "Unhandled exception at 0x77291CB3 (ntdll.dll) in BST.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x001E2FFC)." The following is my code. struct Node { int data; Node* leftChild; Node* rightChild; Node() : leftChild(NULL), rightChild(NULL) {} }; struct BST { Node* root; BST() : root(NULL) {} void insert(int value); bool contains(int value); }; void BST::insert(int value) { Node* temp = new Node(); temp->data = value; if(root == NULL) { root = temp; return; } Node* current; current = root; Node* parent; parent = root; current = (temp->data < current->data ? (current->leftChild) : (current->rightChild) while(current != NULL) { parent = current; current = (temp->data < current->data) ? (current->leftChild) : (current->rightChild) } if(temp->data < parent->data) { parent->leftChild = temp; } if(temp->data > parent->data) { parent->rightChild = temp; } } bool BST::contains(int value) { Node* temp = new Node(); temp->data = value; Node* current; current = root; if(temp->data == current->data) { // base case for when node with value is found std::cout << "true" << std::endl; return true; } if(current == NULL) { // base case if BST is empty or if a leaf is reached before value is found std::cout << "false" << std::endl; return false; } else { // recursive step current = (temp->data < current->data) ? (current->leftChild) : (current->rightChild); return contains(temp->data); } } int main() { BST bst; bst.insert(5); bst.contains(4); system("pause"); } As it stands, I would insert a single node with value '5' and I would search the binary search tree for a node with value '4' - thus, I would expect the result to be false.

    Read the article

  • Crossthread exception and invokerequired solution doesn't change my control value

    - by Pilouk
    EDIT Solution : Here i'm setting my byref value in each object then i'm running a backgroundworker Private Sub TelechargeFichier() Dim DocManquant As Boolean = False Dim docName As String = "" Dim lg As String = "" Dim telechargementFini As Boolean = False lblMessage.Text = EasyDealChangeLanguage.Instance.GetStringFromResourceName("1478") prgBar.Maximum = m_listeFichiers.Count For i As Integer = 0 To m_listeFichiers.Count - 1 m_listeFichiers(i).Set_ByRefLabel(lblMessage) m_listeFichiers(i).Set_ByRefPrgbar(prgBar) m_listeThreads.Add(New Thread(AddressOf m_listeFichiers(i).DownloadMe)) Next m_bgWorker = New BackgroundWorker m_bgWorker.WorkerReportsProgress = True AddHandler m_bgWorker.DoWork, AddressOf DownloadFiles m_bgWorker.RunWorkerAsync() ''Completed 'lblMessage.Text = EasyDealChangeLanguage.Instance.GetStringFromResourceName("1383") 'Me.DialogResult = System.Windows.Forms.DialogResult.OK End Sub Here is my downloadFiles function : Note that each start will do the downloadMe function see below too Private Sub DownloadFiles(sender As Object, e As DoWorkEventArgs) For i As Integer = 0 To m_listeThreads.Count - 1 m_listeThreads(i).Start() Next For i As Integer = 0 To m_listeThreads.Count - 1 m_listeThreads(i).Join() Next End Sub I have multiple thread that each will download a ftp file. I would like that each file that have been completed will set a value to a progress bar and a label from my UI thread. For some reason invokerequired never change to false. Here is my little function that start all the thread Private Sub TelechargeFichier() Dim DocManquant As Boolean = False Dim docName As String = "" Dim lg As String = "" Dim telechargementFini As Boolean = False lblMessage.Text = EasyDealChangeLanguage.Instance.GetStringFromResourceName("1478") prgBar.Maximum = m_listeFichiers.Count For i As Integer = 0 To m_listeFichiers.Count - 1 m_listeFichiers(i).Set_ByRefLabel(lblMessage) m_listeFichiers(i).Set_ByRefPrgbar(prgBar) m_listeThreads.Add(New Thread(AddressOf m_listeFichiers(i).DownloadMe)) Next For i As Integer = 0 To m_listeThreads.Count - 1 m_listeThreads(i).Start() Next For i As Integer = 0 To m_listeThreads.Count - 1 m_listeThreads(i).Join() Next 'Completed lblMessage.Text = EasyDealChangeLanguage.Instance.GetStringFromResourceName("1383") Me.DialogResult = System.Windows.Forms.DialogResult.OK End Sub Here my property that hold the Byref control from the UI thread. This is in my object which content the addressof function that will download the file (DownloadMe) Public Sub Set_ByRefPrgbar(ByRef prgbar As ProgressBar) m_prgBar = prgbar End Sub Public Sub Set_ByRefLabel(ByRef lbl As EasyDeal.Controls.EasyDealLabel3D) m_lblMessage = lbl End Sub Here is the download function : Public Sub DownloadMe() Dim ftpReq As FtpWebRequest Dim ftpResp As FtpWebResponse = Nothing Dim streamInput As Stream Dim fileStreamOutput As FileStream Try ftpReq = CType(WebRequest.Create(EasyDeal.Controls.Common.FTP_CONNECTION & m_downloadFtpPath & m_filename), FtpWebRequest) ftpReq.Credentials = New NetworkCredential(FTP_USER, FTP_PASS) ftpReq.Method = WebRequestMethods.Ftp.DownloadFile ftpResp = ftpReq.GetResponse streamInput = ftpResp.GetResponseStream() fileStreamOutput = New FileStream(m_outputPath, FileMode.Create, FileAccess.ReadWrite) ReadWriteStream(streamInput, fileStreamOutput) Catch ex As Exception 'Au pire la fichier sera pas downloader Finally If ftpResp IsNot Nothing Then ftpResp.Close() End If Dim nomFichier As String = m_displaynameEN If EasyDealChangeLanguage.GetCurrentLanguageTypes = EasyDealChangeLanguage.EnumLanguageType.Francais Then nomFichier = m_displaynameFR End If If m_lblMessage IsNot Nothing Then EasyDealCommon.TH_SetControlText(m_lblMessage, String.Format(EasyDealChangeLanguage.Instance.GetStringFromResourceName("1479"), nomFichier)) End If If m_prgBar IsNot Nothing Then EasyDealCommon.TH_SetPrgValue(m_prgBar, 1) End If End Try End Sub Here is the crossthread invoke solution function : Public Sub TH_SetControlText(ByVal ctl As Control, ByVal text As String) If ctl.InvokeRequired Then ctl.BeginInvoke(New Action(Of Control, String)(AddressOf TH_SetControlText), ctl, text) Else ctl.Text = text End If End Sub Public Sub TH_SetPrgValue(ByVal prg As ProgressBar, ByVal value As Integer) If prg.InvokeRequired Then prg.BeginInvoke(New Action(Of ProgressBar, Integer)(AddressOf TH_SetPrgValue), prg, value) Else prg.Value += value End If End Sub The problem is the invokerequired never get to false it actually goes in to beginInvoke but never end in the Else section to set the value.

    Read the article

  • pushd - handling multiple drives from cmd

    - by user673600
    I'm trying to figure out how to install some programs where the components reside on two different drives on a networked path. However whenever I use pushd \\xyz\c$ I get a mapped drive which means I cannot use any knowledge of using for example c:\install e:\mycomponents.dll. Is there anyway that I can do this once I have used the pushd command? How can I ensure that I keep the drives the same for example. I'm in the process of installing services. So it seems that when I install the service, I need to keep the path as the same as the actual location of the .exe which means that I'm running into issues. Is there a way to simply use pushd but at the sametime not actually map drives? As when installing services, when I've been using net use, I've found that there is an issue with installing on drives which are mapped, as the service whilst can be installed doesn't find the actual .exe when it comes to starting up the service. So to expand this, is there a way to solve this using net use or pushd or a combination that lets me install a service as such: c:\windows\..\installutil e:\mynode? So to clarify, I need to somehow be able to see both drives on the remote machine by their relative drives i.e. E:\ and C:\ - if I use a mapped drive letter then it means installing service is a pain because I cannot use the path.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >