Search Results

Search found 6825 results on 273 pages for 'mt head'.

Page 15/273 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Organization &amp; Architecture UNISA Studies &ndash; Chap 6

    - by MarkPearl
    Learning Outcomes Discuss the physical characteristics of magnetic disks Describe how data is organized and accessed on a magnetic disk Discuss the parameters that play a role in the performance of magnetic disks Describe different optical memory devices Magnetic Disk The way data is stored on and retried from magnetic disks Data is recorded on and later retrieved form the disk via a conducting coil named the head (in many systems there are two heads) The writ mechanism exploits the fact that electricity flowing through a coil produces a magnetic field. Electric pulses are sent to the write head, and the resulting magnetic patterns are recorded on the surface below with different patterns for positive and negative currents The physical characteristics of a magnetic disk   Summarize from book   The factors that play a role in the performance of a disk Seek time – the time it takes to position the head at the track Rotational delay / latency – the time it takes for the beginning of the sector to reach the head Access time – the sum of the seek time and rotational delay Transfer time – the time it takes to transfer data RAID The rate of improvement in secondary storage performance has been considerably less than the rate for processors and main memory. Thus secondary storage has become a bit of a bottleneck. RAID works on the concept that if one disk can be pushed so far, additional gains in performance are to be had by using multiple parallel components. Points to note about RAID… RAID is a set of physical disk drives viewed by the operating system as a single logical drive Data is distributed across the physical drives of an array in a scheme known as striping Redundant disk capacity is used to store parity information, which guarantees data recoverability in case of a disk failure (not supported by RAID 0 or RAID 1) Interesting to note that the increase in the number of drives, increases the probability of failure. To compensate for this decreased reliability RAID makes use of stored parity information that enables the recovery of data lost due to a disk failure.   The RAID scheme consists of 7 levels…   Category Level Description Disks Required Data Availability Large I/O Data Transfer Capacity Small I/O Request Rate Striping 0 Non Redundant N Lower than single disk Very high Very high for both read and write Mirroring 1 Mirrored 2N Higher than RAID 2 – 5 but lower than RAID 6 Higher than single disk Up to twice that of a signle disk for read Parallel Access 2 Redundant via Hamming Code N + m Much higher than single disk Highest of all listed alternatives Approximately twice that of a single disk Parallel Access 3 Bit interleaved parity N + 1 Much higher than single disk Highest of all listed alternatives Approximately twice that of a single disk Independent Access 4 Block interleaved parity N + 1 Much higher than single disk Similar to RAID 0 for read, significantly lower than single disk for write Similar to RAID 0 for read, significantly lower than single disk for write Independent Access 5 Block interleaved parity N + 1 Much higher than single disk Similar to RAID 0 for read, lower than single disk for write Similar to RAID 0 for read, generally  lower than single disk for write Independent Access 6 Block interleaved parity N + 2 Highest of all listed alternatives Similar to RAID 0 for read; lower than RAID 5 for write Similar to RAID 0 for read, significantly lower than RAID 5  for write   Read page 215 – 221 for detailed explanation on RAID levels Optical Memory There are a variety of optical-disk systems available. Read through the table on page 222 – 223 Some of the devices include… CD CD-ROM CD-R CD-RW DVD DVD-R DVD-RW Blue-Ray DVD Magnetic Tape Most modern systems use serial recording – data is lade out as a sequence of bits along each track. The typical recording used in serial is referred to as serpentine recording. In this technique when data is being recorded, the first set of bits is recorded along the whole length of the tape. When the end of the tape is reached the heads are repostioned to record a new track, and the tape is again recorded on its whole length, this time in the opposite direction. That process continued back and forth until the tape is full. To increase speed, the read-write head is capable of reading and writing a number of adjacent tracks simultaneously. Data is still recorded serially along individual tracks, but blocks in sequence are stored on adjacent tracks as suggested. A tape drive is a sequential access device. Magnetic tape was the first kind of secondary memory. It is still widely used as the lowest-cost, slowest speed member of the memory hierarchy.

    Read the article

  • git | error: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied [SOLVED]

    - by Corbin Tarrant
    I am having a strange issue that I can't seem to resolve. Here is what happend: I had some log files in a github repository that I didn't want there. I found this script that removes files completely from git history like so: #!/bin/bash set -o errexit # Author: David Underhill # Script to permanently delete files/folders from your git repository. To use # it, cd to your repository's root and then run the script with a list of paths # you want to delete, e.g., git-delete-history path1 path2 if [ $# -eq 0 ]; then exit 0are still fi # make sure we're at the root of git repo if [ ! -d .git ]; then echo "Error: must run this script from the root of a git repository" exit 1 fi # remove all paths passed as arguments from the history of the repo files=$@ git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch $files" HEAD # remove the temporary history git-filter-branch otherwise leaves behind for a long time rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune I, of course, made a backup first and then tried it. It seemed to work fine. I then did a git push -f and was greeted with the following messages: error: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied error: Cannot update the ref 'refs/remotes/origin/master'. Everything seems to have pushed fine though, because the files seem to be gone from the GitHub repository, if I try and push again I get the same thing: error: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied error: Cannot update the ref 'refs/remotes/origin/master'. Everything up-to-date EDIT $ sudo chgrp {user} .git/logs/refs/remotes/origin/master $ sudo chown {user} .git/logs/refs/remotes/origin/master $ git push Everything up-to-date Thanks! EDIT Uh Oh. Problem. I've been working on this project all night and just went to commit my changes: error: Unable to append to .git/logs/refs/heads/master: Permission denied fatal: cannot update HEAD ref So I: sudo chown {user} .git/logs/refs/heads/master sudo chgrp {user} .git/logs/refs/heads/master I try the commit again and I get: error: Unable to append to .git/logs/HEAD: Permission denied fatal: cannot update HEAD ref So I: sudo chown {user} .git/logs/HEAD sudo chgrp {user} .git/logs/HEAD And then I try the commit again: 16 files changed, 499 insertions(+), 284 deletions(-) create mode 100644 logs/DBerrors.xsl delete mode 100644 logs/emptyPHPerrors.php create mode 100644 logs/trimXMLerrors.php rewrite public/codeCore/Classes/php/DatabaseConnection.php (77%) create mode 100644 public/codeSite/php/init.php $ git push Counting objects: 49, done. Delta compression using up to 2 threads. Compressing objects: 100% (27/27), done. Writing objects: 100% (27/27), 7.72 KiB, done. Total 27 (delta 15), reused 0 (delta 0) To [email protected]:IAmCorbin/MooKit.git 59da24e..68b6397 master -> master Hooray. I jump on http://GitHub.com and check out the repository, and my latest commit is no where to be found. ::scratch head:: So I push again: Everything up-to-date Umm...it doesn't look like it. I've never had this issue before, could this be a problem with github? or did I mess something up with my git project? EDIT Nevermind, I did a simple: git push origin master and it pushed fine.

    Read the article

  • Mutation Problem - Clojure

    - by Silanglaya Valerio
    having trouble changing an element of my function represented as a list. code for random function: (defn makerandomtree-10 [pc maxdepth maxwidth fpx ppx] (if-let [output (if (and (< (rand) fpx) (> maxdepth 0)) (let [head (nth operations (rand-int (count operations))) children (doall (loop[function (list) width maxwidth] (if (pos? width) (recur (concat function (list (makerandomtree-10 pc (dec maxdepth) (+ 2 (rand-int (- maxwidth 1))) fpx ppx))) (dec width)) function)))] (concat (list head) children)) (if (and (< (rand) ppx) (>= pc 0)) (nth parameters (rand-int (count parameters))) (rand-int 100)))] output )) I will provide also a mutation function, which is still not good enough. I need to be able to eval my statement, so the following is still insufficient. (defn mutate-5 "chooses a node changes that" [function pc maxwidth pchange] (if (< (rand) pchange) (let [output (makerandomtree-10 pc 3 maxwidth 0.5 0.6)] (if (seq? output) output (list output))) ;mutate the children of root ;declare an empty accumulator list, with root as its head (let [head (list (first function)) children (loop [acc(list) walker (next function)] (println "----------") (println walker) (println "-----ACC-----") (println acc) (if (not walker) acc (if (or (seq? (first function)) (contains? (set operations) (first function))) (recur (concat acc (mutate-5 walker pc maxwidth pchange)) (next walker)) (if (< (rand) pchange) (if (some (set parameters) walker) (recur (concat acc (list (nth parameters (rand-int (count parameters))))) (if (seq? walker) (next walker) nil)) (recur (concat acc (list (rand-int 100))) (if (seq? walker) (next walker) nil))) (recur acc (if (seq? walker) (next walker) nil)))) ))] (concat head (list children))))) (side note: do you have any links/books for learning clojure?)

    Read the article

  • Does jQuery strip some html elements from a string when using .html()?

    - by Nic Hubbard
    I have a var that contains a full html page, including the head, html, body, etc. When I pass that string into the .html() function, jQuery strips out all those elements, such as body, html, head, etc, which I don't want. My data var contains: <html> <head> <title>Untitled Document</title> </head> <body> </body> </html> // data is a full html document string data = $('<div/>').html(data); // jQuery stips my document string! alert(data.find('head').html()); I am needing to manipulate a full html page string, so that I can return what is in the element. I would like to do this with jQuery, but it seems all of the methods, append(), prepend() and html() all try to convert the string to dom elements, which remove all the other parts of a full html page. Is there another way that I could do this? I would be fine using another method. My final goal is to find certain elements inside my string, so I figured jQuery would be best, since I am so used to it. But, if it is going to trim and remove parts of my string, I am going to have to look for another method. Ideas?

    Read the article

  • jquery selector problem with script tags

    - by Tauren
    I'm attempting to select all <script type="text/html"> tags in a page. I use <script> tags to store HTML templates, similar to how John Resig does it. For some reason, the following jquery selector doesn't seem to be selecting anything: $("script[type*=html]").each(function() { alert("Found script "+this.id); }); This markup is in the BODY of the HTML document: <body> <script id="filter-search" type="text/html"> <dt>Search</dt> <dd><input type="text"/></dd> </script> </body> I've also tried putting it into the HEAD of the HTML document, and it is still not found. No alert is ever shown. If I instead change my code to this: $("script[type*=javascript]").each(function() { alert("Found script "+this.id); }); Then it finds only the scripts in the HEAD that have a src to an external file. Scripts in the actual page are not found. For instance, with the following in HEAD: <head> <script type="text/javascript" src="jquery.js" id="jquery"></script> <script type="text/javascript" src="jquery-ui.js" id="ui"></script> <script type="text/javascript" id="custom"> $(document).ready( function() { $("script[type*=javascript]").each(function() { alert("Found script "+this.id); }); $("script[type*=html]").each(function() { alert("Found TEMPLATE script "+this.id); }); }); </script> <script id="filter-test" type="text/html"> <dt>Test</dt> </script> </head> <body> <script id="filter-search" type="text/html"> <dt>Search</dt> <dd><input type="text"/></dd> </script> </body> I get the following alerts: Found script jquery Found script ui The custom and filter-test scripts in the HEAD are not selected, nor is the filter-search script in the body tag. Is this the expected behavior? Why does this not work? I can work around it, but it is annoying that it doesn't work.

    Read the article

  • Git: can't undo local changes (error: path ... is unmerged)

    - by mklhmnn
    I have following working tree state $ git status foo/bar.txt # On branch master # Unmerged paths: # (use "git reset HEAD <file>..." to unstage) # (use "git add/rm <file>..." as appropriate to mark resolution) # # deleted by us: foo/bar.txt # no changes added to commit (use "git add" and/or "git commit -a") File foo/bar.txt is there and I want to get it to the "unchanged state" again (similar to 'svn revert'): $ git checkout HEAD foo/bar.txt error: path 'foo/bar.txt' is unmerged $ git reset HEAD foo/bar.txt Unstaged changes after reset: M foo/bar.txt Now it is getting confusing: $ git status foo/bar.txt # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: foo/bar.txt # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: foo/bar.txt # The same file in both sections, new and modified? What should I do? Thanks in advance.

    Read the article

  • .NET XML Serialization without <?xml> root node

    - by Graphain
    Hi, I'm trying to generate XML like this: <?xml version="1.0"?> <!DOCTYPE APIRequest SYSTEM "https://url"> <APIRequest> <Head> <Key>123</Key> </Head> <ObjectClass> <Field>Value</Field </ObjectClass> </APIRequest> I have a class (ObjectClass) decorated with XMLSerialization attributes like this: [XmlRoot("ObjectClass")] public class ObjectClass { [XmlElement("Field")] public string Field { get; set; } } And my really hacky intuitive thought to just get this working is to do this when I serialize: ObjectClass inst = new ObjectClass(); XmlSerializer serializer = new XmlSerializer(inst.GetType(), ""); StringWriter w = new StringWriter(); w.WriteLine(@"<?xml version=""1.0""?>"); w.WriteLine("<!DOCTYPE APIRequest SYSTEM"); w.WriteLine(@"""https://url"">"); w.WriteLine("<APIRequest>"); w.WriteLine("<Head>"); w.WriteLine(@"<Field>Value</Field>"); w.WriteLine(@"</Head>"); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); serializer.Serialize(w, inst, ns); w.WriteLine("</APIRequest>"); However, this generates XML like this: <?xml version="1.0"?> <!DOCTYPE APIRequest SYSTEM "https://url"> <APIRequest> <Head> <Key>123</Key> </Head> <?xml version="1.0" encoding="utf-16"?> <ObjectClass> <Field>Value</Field> </ObjectClass> </APIRequest> i.e. the serialize statement is automatically adding a <?xml root element. I know I'm attacking this wrong so can someone point me in the right direction? As a note, I don't think it will make practical sense to just make an APIRequest class with an ObjectClass in it (because there are say 20 different types of ObjectClass that each needs this boilerplate around them) but correct me if I'm wrong.

    Read the article

  • C++ classes & linked list: adding & counting items

    - by user342289
    I need to make a linked list with classes. Each list will store two values: a URI and IP. After doing all the adding, I need to be able count the total number of items in the linked list. I have tried the following code but it doesn't compile. Any suggestions please? #include <iostream> #include <cstdlib> #include <string> using namespace std; class ip_uri_store { protected: string ip; string uri; ip_uri_store *next; public: ip_uri_store(string huri, string hip); void additem(string auri, string aip); void deleteitem(string duri); void findbyuri(string furi); void findbyip(string fip); int totalitems(); }; ip_uri_store *head = NULL; ip_uri_store *curr = NULL; void ip_uri_store::additem(string auri, string aip) { curr = head; while (curr->next != NULL) { curr = curr->next; } curr->uri = auri; curr->next = new ip_uri_store; curr->ip = aip; curr->next = new ip_uri_store; curr = curr->next; curr = head; } int ip_uri_store::totalitems() { int i = 0; curr = head; while (curr->next != NULL) { i += 1; curr = curr->next; } return i; } int main(int argc, char *argv[]) { if (argc == 1) { cout << "123456, [email protected], Gordon Brown" << endl; return (0); } head = new ip_uri_store; curr = head; int i; for (i = 1; i < argc; i++) { if (argv[i][0] == 'A') //add item { ip_uri_store.additem(argv[i + 1], argv[i + 2]); i += 2; } else if (argv[i][0] == 'N') //print total tiems { cout << ip_uri_store.totalitems() << endl; } else { cout << "command error\n"; return 0; } } return (0); }

    Read the article

  • n elements in singly linked list

    - by Codenotguru
    The following function is trying to find the nth to last element of a singly linked list. for ex: if the elements are 8-10-5-7-2-1-5-4-10-10 then the result is 7th to last node is 7. Can anybody help me on how this code is working or is there a better and simpler approach? LinkedListNode nthToLast(LinkedListNode head, int n) { if (head == null || n < 1) { return null; } LinkedListNode p1 = head; LinkedListNode p2 = head; for (int j = 0; j < n - 1; ++j) { // skip n-1 steps ahead if (p2 == null) { return null; // not found since list size < n } p2 = p2.next; } while (p2.next != null) { p1 = p1.next; p2 = p2.next; } return p1; }

    Read the article

  • What should I learn after HTML and CSS?

    - by Ryan B
    I am 5 days into learning how to make my website, flying through my HTML & CSS book and having fun. I’m starting to consider what to order next. I’m not sure what to study next, so please give me some advice if you can. My end goal is to create a site that has a lot of the functionality that www.edufire.com and similar sites have, just for example. I think I’m learning well with the Head First Series, and the style will probably serve me well as an intro to programming. However, I don't think the books dive too deeply into any 1 subject. I could order: A: Head First Programming: A Learner’s Guide to Programming Using the Python Language B: Head First Javascript C: Head First PHP & MySQL D: a different programming book or E: another CSS or design book to solidify my basic HTML & CSS skills Any guidance would be appreciated. Thanks!

    Read the article

  • Can you explain to me git reset in plain english?

    - by e-satis
    I have seen interesting posts explaining subtleties about git reset. Unfortunately, the more I read about it, the more it appear that I don't understand it fully. I come from a SVN background and git is a whole new paradigm. I got mercurial easily, but git is much more technical. I think git reset is close to hg revert, but it seems there are differences. So what exactly does git reset do? Please include detailed explanations about: the options --hard, --soft and --merge; the strange notation you use with HEAD such as HEAD^ and HEAD~1; concrete use cases and workflows; consequences on the working copy, the HEAD and your global stress level. I will put a bounty on this ASAP cause it's really important and I find the git doc cryptic. Holly blessing and tons of chocolate/beer/name_your_stuff to the guy who makes a no-brainer answer :-)

    Read the article

  • .NET: What's the difference between HttpMethod and RequestType of HttpRequest?

    - by Ian Boyd
    The HttpRequest class defines two properties: HttpMethod: Gets the HTTP data transfer method (such as GET, POST, or HEAD) used by the client. public string HttpMethod { get; } The HTTP data transfer method used by the client. and RequestType: Gets or sets the HTTP data transfer method (GET or POST) used by the client. public string RequestType { get; set; } A string representing the HTTP invocation type sent by the client. What is the difference between these two properties? When would i want to use one over the other? Which is the proper one to inspect to see what data transfer method was used by the client? The documentation indicates that HttpMethod will return whatever verb was used: such as GET, POST, or HEAD while the documentation on RequestType seems to indicate only one of two possible values: GET or POST i test with a random sampling of verbs, and both properties seem to support all verbs, and both return the same values: Testing: Client Used HttpMethod RequestType GET GET GET POST POST POST HEAD HEAD HEAD CONNECT CONNECT CONNECT MKCOL MKCOL MKCOL PUT PUT PUT FOOTEST FOOTEST FOOTEST What is the difference between: HttpRequest.HttpMethod HttpRequest.RequestType and when should i use one over the other? Keywords: iis asp.net http httprequest httphandler

    Read the article

  • Implementing Java Priority Queue

    - by Kay
    public class PriorityQueue<T> { private PriorityNode<T> head, tail; private int numItems; public PriorityQueue(){ numItems = 0; head=null; tail=null; } public void add(int priority, T value){ PriorityNode<T> newNode = new PriorityNode<T>(priority,value); if(numItems == 0){ head = newNode; tail = newNode; } else{ head.setNext(newNode); head = newNode; } } } Where PriorityNode is defined as: public class PriorityNode<T> implements Comparable<T> { private T value; private PriorityNode<T> next; private int priority; public PriorityNode(int priority,T newValue){ value = newValue; next = null; priority = 0; } public PriorityNode(T newValue){ value = newValue; next = null; priority = 0; } public void setPriority(int priority){ this.priority = priority; } public int getPriority(){ return this.priority; } public T getValue(){ return value; } public PriorityNode<T> getNext(){ return next; } public void setNext(PriorityNode<T> nextNode){ this.next = nextNode; } public void setValue(T newValue){ value = newValue; } public int compareTo(int pri) { // TODO Auto-generated method stub if(this.priority<pri){ return -1; } else if(this.priority == pri){ return 0; } else{ return 1; } } } I'm having a lot of difficulty using the Comparator here and implementing a priority queue - please point me in the right direction.

    Read the article

  • Linked List pop() function

    - by JKid314159
    Consider the following list: [LinkNode * head -- LinkNode * node1 -- LinkNode * node2] I'm creating a stack of FIFO. I Call pop() which I want to pop node1. LinkNode::LinkNode(int numIn) { this->numIn = numIn; next = null; } . . . int LinkNode::pop() { Link * temp = head->next; head = temp->next; int popped = head->nodeNum; delete temp; Return numOut; Question: 1) head should be a pointer or a LinkNode *? 2) Link * temp is created on the call stack and when pop finishes doesn't temp delete automatically? 3) My major confusion is on what is the value of temp-next? Does this point to node1.next which equals node2? Appreciate your help? My reference is C++ for Java Programmers by Weiss.

    Read the article

  • Dynamically loading css stylesheet doesn't work on IE

    - by pistacchio
    Hi, I dynamically load a css stylesheet (with a little help from jQuery) like this: var head = document.getElementsByTagName('head')[0]; $(document.createElement('link')) .attr({ type: 'text/css', href: '../../mz/mz.css', rel: 'stylesheet' }) .appendTo(head); This works fine in Firefox and Google Chrome, but not in IE. Any help? Thanks

    Read the article

  • C -Segmentation fault !

    - by FILIaS
    It seems at least weird to me... The program runs normally.But after I call the enter() function for the 4th time,there is a segmentation fault!I would appreciate any help. With the following function enter() I wanna add user commands' datas to a list. [Some part of the code is already posted on another question of me, but I think I should post it again...as it's a different problem I'm facing now.] /* struct for all the datas that user enters on file*/ typedef struct catalog { char short_name[50]; char surname[50]; signed int amount; char description[1000]; struct catalog *next; }catalog,*catalogPointer; catalogPointer current; catalogPointer head = NULL; void enter(void) //user command: i <name> <surname> <amount> <description> { int n,j=2,k=0; char temp[1500]; char *short_name,*surname,*description; signed int amount; char* params = strchr(command,' ') + 1; //strchr returns a pointer to the 1st space on the command.U want a pointer to the char right after that space. strcpy(temp, params); //params is saved as temp. char *curToken = strtok(temp," "); //strtok cuts 'temp' into strings between the spaces and saves them to 'curToken' printf("temp is:%s \n",temp); printf("\nWhat you entered for saving:\n"); for (n = 0; curToken; ++n) //until curToken ends: { if (curToken) { short_name = malloc(strlen(curToken) + 1); strncpy(short_name, curToken, sizeof (short_name)); } printf("Short Name: %s \n",short_name); curToken = strtok(NULL," "); if (curToken) { surname = malloc(strlen(curToken) + 1); strncpy(surname, curToken,sizeof (surname)); } printf("SurName: %s \n",surname); curToken = strtok(NULL," "); if (curToken) { //int * amount= malloc(sizeof (signed int *)); char *chk; amount = (int) strtol(curToken, &chk, 10); if (!isspace(*chk) && *chk != 0) fprintf(stderr,"Warning: expected integer value for amount, received %s instead\n",curToken); } printf("Amount: %d \n",amount); curToken = strtok(NULL,"\0"); if (curToken) { description = malloc(strlen(curToken) + 1); strncpy(description, curToken, sizeof (description)); } printf("Description: %s \n",description); break; } if (findEntryExists(head, surname,short_name) != NULL) //call function in order to see if entry exists already on the catalog printf("\nAn entry for <%s %s> is already in the catalog!\nNew entry not entered.\n",short_name,surname); else { printf("\nTry to entry <%s %s %d %s> in the catalog list!\n",short_name,surname,amount,description); newEntry(&head,short_name,surname,amount,description); printf("\n**Entry done!**\n"); } // Maintain the list in alphabetical order by surname. } catalogPointer findEntryExists (catalogPointer head, char num[],char first[]) { catalogPointer p = head; while (p != NULL && strcmp(p->surname, num) != 0 && strcmp(p->short_name,first) != 0) { p = p->next; } return p; } catalogPointer newEntry (catalog** headRef,char short_name[], char surname[], signed int amount, char description[]) { catalogPointer newNode = (catalogPointer)malloc(sizeof(catalog)); catalogPointer first; catalogPointer second; catalogPointer tmp; first=head; second=NULL; strcpy(newNode->short_name, short_name); strcpy(newNode->surname, surname); newNode->amount=amount; strcpy(newNode->description, description); while (first!=NULL) { if (strcmp(surname,first->surname)>0) second=first; else if (strcmp(surname,first->surname)==0) { if (strcmp(short_name,first->short_name)>0) second=first; } first=first->next; } if (second==NULL) { newNode->next=head; head=newNode; } else //SEGMENTATION APPEARS WHEN IT GETS HERE! { tmp=second->next; newNode->next=tmp; first->next=newNode; } } UPDATE: SegFault appears only when it gets on the 'else' loop of InsertSort() function. I observed that segmentation fault appears when i try to put on the list names that are after it. For example, if in the list exists: [Name:b Surname:b Amount:6 Description:b] [Name:c Surname:c Amount:5 Description:c] [Name:d Surname:d Amount:4 Description:d] [Name:e Surname:e Amount:3 Description:e] [Name:g Surname:g Amount:2 Description:g] [Name:x Surname:x Amount:1 Description:x] and i put: " x z 77 gege" there is a segmentation but if i put "x a 77 gege" it continues normally....

    Read the article

  • Pointer initialization

    - by SoulBeaver
    Sorry if this question has been asked before. On my search through SO I didn't find one that asked what I wanted to know. Basically, when I have this: typedef struct node { int data; node *node; } *head; and do node *newItem = new node; I am under the impression that I am declaring and reserving space, but not defining, a pointer to struct node, is that correct? So when I do newItem->data = 100 and newItem->next = 0 I get confused. newItem = 0would declare what exactly? Both data and next? The object as a whole? I'm especially confused when I use typedef. Which part is the macro? I assume node because that's how I call it, but why do I need it? Finally, what happens when I do: node *temp; temp = new node; temp = head->next; head->next = newItem; newItem->next = temp; I mean, head-next is a pointer pointing to object newItem, so I assume not to newItem.data or next themselves. So how can I use an uninitialized pointer that I described above safely like here? is head now not pointing to an uninitialized pointer?

    Read the article

  • Injecting jQuery into a page fails when using Google AJAX Libraries API

    - by jakemcgraw
    I'd like to inject jQuery into a page using the Google AJAX Libraries API, I've come up with the following solution: http://my-domain.com/inject-jquery.js: ;((function(){ // Call this function once jQuery is available var func = function() { jQuery("body").prepend('<div>jQuery Rocks!</div>'); }; // Detect if page is already using jQuery if (!window.jQuery) { var done = false; var head = document.getElementsByTagName('head')[0]; var script = document.createElement("script"); script.src = "http://www.google.com/jsapi"; script.onload = script.onreadystatechange = function(){ // Once Google AJAX Libraries API is loaded ... if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { done = true; // ... load jQuery ... window.google.load("jquery", "1", {callback:function(){ jQuery.noConflict(); // ... jQuery available, fire function. func(); }}); // Prevent IE memory leaking script.onload = script.onreadystatechange = null; head.removeChild(script); } } // Load Google AJAX Libraries API head.appendChild(script); // Page already using jQuery, fire function } else { func(); } })()); The script would then be included in a page on a separate domain: http://some-other-domain.com/page.html: <html> <head> <title>This is my page</title> </head> <body> <h1>This is my page.</h1> <script src="http://my-domain.com/inject-jquery.js"></script> </body> </html> In Firefox 3 I get the following error: Module: 'jquery' must be loaded before DOM onLoad! jsapi (line 16) The error appears to be specific to the Google AJAX Libraries API, as I've seen others use a jQuery bookmarklet to inject jQuery into the current page. My question: Is there a method for injecting the Google AJAX Libraries API / jQuery into a page regardless of the onload/onready state?

    Read the article

  • linked list elements gone?

    - by Hristo
    I create a linked list dynamically and initialize the first node in main(), and I add to the list every time I spawn a worker process. Before the worker process exits, I print the list. Also, I print the list inside my sigchld signal handler. in main(): head = NULL; tail = NULL; // linked list to keep track of worker process dll_node_t *node; node = (dll_node_t *) malloc(sizeof(dll_node_t)); // initialize list, allocate memory append_node(node); node->pid = mainPID; // the first node is the MAIN process node->type = MAIN; in a fork()'d process: // add to list dll_node_t *node; node = (dll_node_t *) malloc(sizeof(dll_node_t)); append_node(node); node->pid = mmapFileWorkerStats->childPID; node->workerFileName = mmapFileWorkerStats->workerFileName; node->type = WORK; functions: void append_node(dll_node_t *nodeToAppend) { /* * append param node to end of list */ // if the list is empty if (head == NULL) { // create the first/head node head = nodeToAppend; nodeToAppend->prev = NULL; } else { tail->next = nodeToAppend; nodeToAppend->prev = tail; } // fix the tail to point to the new node tail = nodeToAppend; nodeToAppend->next = NULL; } finally... the signal handler: void chld_signalHandler() { dll_node_t *temp1 = head; while (temp1 != NULL) { printf("2. node's pid: %d\n", temp1->pid); temp1 = temp1->next; } int termChildPID = waitpid(-1, NULL, WNOHANG); dll_node_t *temp = head; while (temp != NULL) { if (temp->pid == termChildPID) { printf("found process: %d\n", temp->pid); } temp = temp->next; } return; } Is it true that upon the worker process exiting, the SIGCHLD signal handler is triggered? If so, that would mean that after I print the tree before exiting, the next thing I do is in the signal handler which is print the tree... which would mean i would print the tree twice? But the tree isn't the same. The node I add in the worker process doesn't exist when I print in the signal handler or at the very end of main(). Any idea why? Thanks, Hristo

    Read the article

  • Deleting a node from linked list in C

    - by LuckySlevin
    My problem is deleting a node from linked list. I have two structs : typedef struct inner_list { int count; char word[100]; inner_list*next; } inner_list; typedef struct outer_list { char word [100]; inner_list * head; int count; outer_list * next; } outer_list; My problem is in deleting a node from outer_list linked list. For example when user entered aaa to delete, delete function should find the node with outer_list->word = aaa and delete this node and reconnect the list again. I tried the below code to do this. but After finding and deleting I'm losing the list. I don't know what's wrong. Please notice that outer_list have also a linked list of inner_list inside. void delnode(outer_list *head,char num[100]) { outer_list *temp, *m; temp=head; while(temp!=NULL) { if(strcmp(temp->word==num)==0) { if(temp==head) { head=temp->next; free(temp); return; } else { m->next=temp->next; free(temp); return; } }else { m=temp; temp= temp->next; } } printf(" ELEMENT %s NOT FOUND ", num); } What are your ideas about this?

    Read the article

  • C -Segmentation fault after the 4th call of the function!

    - by FILIaS
    It seems at least weird to me... The program runs normally.But after I call the enter() function for the 4th time,there is a segmentation fault!I would appreciate any help. With the following function enter() I wanna add user commands' datas to a list. [Some part of the code is already posted on another question of me, but I think I should post it again...as it's a different problem I'm facing now.] /* struct for all the datas that user enters on file*/ typedef struct catalog { char short_name[50]; char surname[50]; signed int amount; char description[1000]; struct catalog *next; }catalog,*catalogPointer; catalogPointer current; catalogPointer head = NULL; void enter(void) //user command: i <name> <surname> <amount> <description> { int n,j=2,k=0; char temp[1500]; char *short_name,*surname,*description; signed int amount; char* params = strchr(command,' ') + 1; //strchr returns a pointer to the 1st space on the command.U want a pointer to the char right after that space. strcpy(temp, params); //params is saved as temp. char *curToken = strtok(temp," "); //strtok cuts 'temp' into strings between the spaces and saves them to 'curToken' printf("temp is:%s \n",temp); printf("\nWhat you entered for saving:\n"); for (n = 0; curToken; ++n) //until curToken ends: { if (curToken) { short_name = malloc(strlen(curToken) + 1); strncpy(short_name, curToken, sizeof (short_name)); } printf("Short Name: %s \n",short_name); curToken = strtok(NULL," "); if (curToken) { surname = malloc(strlen(curToken) + 1); strncpy(surname, curToken,sizeof (surname)); } printf("SurName: %s \n",surname); curToken = strtok(NULL," "); if (curToken) { //int * amount= malloc(sizeof (signed int *)); char *chk; amount = (int) strtol(curToken, &chk, 10); if (!isspace(*chk) && *chk != 0) fprintf(stderr,"Warning: expected integer value for amount, received %s instead\n",curToken); } printf("Amount: %d \n",amount); curToken = strtok(NULL,"\0"); if (curToken) { description = malloc(strlen(curToken) + 1); strncpy(description, curToken, sizeof (description)); } printf("Description: %s \n",description); break; } if (findEntryExists(head, surname,short_name) != NULL) //call function in order to see if entry exists already on the catalog printf("\nAn entry for <%s %s> is already in the catalog!\nNew entry not entered.\n",short_name,surname); else { printf("\nTry to entry <%s %s %d %s> in the catalog list!\n",short_name,surname,amount,description); newEntry(&head,short_name,surname,amount,description); printf("\n**Entry done!**\n"); } // Maintain the list in alphabetical order by surname. } catalogPointer findEntryExists (catalogPointer head, char num[],char first[]) { catalogPointer p = head; while (p != NULL && strcmp(p->surname, num) != 0 && strcmp(p->short_name,first) != 0) { p = p->next; } return p; } catalogPointer newEntry (catalog** headRef,char short_name[], char surname[], signed int amount, char description[]) { catalogPointer newNode = (catalogPointer)malloc(sizeof(catalog)); catalogPointer first; catalogPointer second; catalogPointer tmp; first=head; second=NULL; strcpy(newNode->short_name, short_name); strcpy(newNode->surname, surname); newNode->amount=amount; strcpy(newNode->description, description); //SEGMENTATION ON THE 4TH RUN OF PROGRAM STOPS HERE depending on the names each time it gets! while (first!=NULL) { if (strcmp(surname,first->surname)>0) second=first; else if (strcmp(surname,first->surname)==0) { if (strcmp(short_name,first->short_name)>0) second=first; } first=first->next; } if (second==NULL) { newNode->next=head; head=newNode; } else { tmp=second->next; newNode->next=tmp; first->next=newNode; } }

    Read the article

  • How to Declare Complex Nested C# Type for Web Service

    - by TheArtTrooper
    I would like to create a service that accepts a complex nested type. In a sample asmx file I created: [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class ServiceNest : System.Web.Services.WebService { public class Block { [XmlElement(IsNullable = false)] public int number; } public class Cell { [XmlElement(IsNullable = false)] public Block block; } public class Head { [XmlElement(IsNullable = false)] public Cell cell; } public class Nest { public Head head; } [WebMethod] public void TakeNest(Nest nest) { } } When I view the asmx file in IE the test page shows the example SOAP post request as: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <TakeNest xmlns="http://schemas.intellicorp.com/livecompare/"> <nest> <head> <cell> <block xsi:nil="true" /> </cell> </head> </nest> </TakeNest> </soap:Body> </soap:Envelope> It hasn't expanded the <block> into its number member. Looking at the WSDL, the types all look good. So is this just a limitation of the post demo page creator? Thanks.

    Read the article

  • Recursion in assembly?

    - by Davis
    I'm trying to get a better grasp of assembly, and I am a little confused about how to recursively call functions when I have to deal with registers, popping/pushing, etc. I am embedding x86 assembly in C++. Here I am trying to make a method which given an array of integers will build a linked list containing these integers in the order they appear in the array. I am doing this by calling a recursive function: insertElem (struct elem *head, struct elem *newElem, int data) -head: head of the list -data: the number that will be inserted at the end of a list -newElem: points to the location in memory where I will store the new element (data field) My problem is that I keep overwriting the registers instead of a typical linked list. For example, if I give it an array {2,3,1,8,3,9} my linked-list will return the first element (head) and only the last element, because the elements keep overwriting each other after head is no longer null. So here my linked list looks something like: 2--9 instead of 2--3--1--8--3--9 I feel like I don't have a grasp on how to organize and handle the registers. newElem is in EBX and just keeps getting rewritten. Thanks in advance!

    Read the article

  • CSS style refresh in IE after dynamic removal of style link

    - by rybz
    Hi! I've got a problem with the dynamic style manipulation in IE7 (IE8 is fine). Using javascript I need to add and remove the < link / node with the definition of css file. Adding and removing the node as a child of < head / works fine under Firefox. Unfortunately, after removing it in the IE, although The tag is removed properly, the page style does not refresh. In the example below a simple css (makes background green) is appended and removed. After the removal in FF the background turns default, but in IE stays green. index.html <html> <head> </head> <script language="javascript" type="text/javascript"> var node; function append(){ var headID = document.getElementsByTagName("head")[0]; node = document.createElement('link'); node.type = 'text/css'; node.rel = 'stylesheet'; node.href = "s.css"; node.media = 'screen'; headID.appendChild(node); } function remove(){ var headID = document.getElementsByTagName("head")[0]; headID.removeChild(node); } </script> <body> <div onClick="append();"> add </div> <div onClick="remove();"> remove </div> </body> </html> And the style sheet: s.css body { background-color:#00CC33 } Here is the live example: http://rlab.pl/dynamic-style/ Is there a way to get it working?

    Read the article

  • Chrome: Dynamically created <style> tag does not have content?

    - by Shizhidi
    Hello. I encountered a weird problem when trying to write a cross-browser script. Basically my header looks like this <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> </head> Then in the body tag: <p id="hey">Hey</p> <input type="button" value="attachStyle" name="attachStyle" onclick="attachStyle();"></input> <script> function attachStyle() { var strVar=""; strVar += "<style type='text\/css'>#hey {border:5px solid red;}<\/script>"; $("head").append(strVar); } </script> The button works in Firefox, but not in Chrome. When I looked at the html DOM elements in the developer tool, the style tag was inserted but without content, like this: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <style type='text/css'></script> </head> I'm curious as to what causes this? And how to create CSS style in a way that is cross-browser? Thanks!

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >