Daily Archives

Articles indexed Saturday March 31 2012

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

  • Android Loading Screen: How do I go about using a stack to load elements, and the option of incrementing the size counter?

    - by tom_mai78101
    I have some problems with figuring out what value I should put in the function: int value_needed_to_figure_out = X; ProgressBar.incrementProgressBy(value_needed_to_figure_out); I've been researching about loading screens and how to use them. Some examples I've seen have implemented Thread.sleep() in a Handler.post(new Runnable()) function. To me, I got most of that concept of using the Handler to update the ProgressBar, while pretending to do some heavy crunching work. So, I kept looking. I have read this thread here: How do I load chunks of data from an assest manager during a loading screen? It said that I can try using a stack it needs to load, and adding a size counter as I add elements to the stack. What does it mean? This is the part where I'm totally stumped. If anyone would provide some hints, I'll gladly appreciate it. Thanks in advance.

    Read the article

  • How do you get the total asset size (or total resource size) in an Android game?

    - by tom_mai78101
    In an Android Java project, there are two folders, asset and res. To me, I usually put some stuffs, like PNG files, sound files, etc. in either one of the two folder. When resources are increasingly becoming more and more in those folders, the time it takes to load them will increase. Therefore, a loading screen is a must in these situation. The total size is to be used in a loading screen, so that I can guess the average time it takes to load each resources, from 0 bytes to its individual resource file size. I only know that by adding all individual sizes in a respective order, I will then obtain the total asset or res folder size, simply by adding them up. So, when it comes to getting the total file size from either folder, how do you obtain their individual resource/object sizes, respectively? Thanks in advance.

    Read the article

  • How to move a sprite on a slope in chipmunk Spacemanager

    - by Anil gupta
    I have used one polygon shape image (terrain) in my game. It's just like a mountain, and now I want to move the tanker on a mountain path from one side to the other and then turn around at the edge of the screen and go back. I don't understand the method to move the tanker on the slope (image) path in chipmunk spacemanager. When collision detection happens like that, if any bomb falls on the slope (image of mountain) then I want to do a little damage to the slope (image of mountain) like this video.

    Read the article

  • How do I make A* check all diagonal and orthogonal directions?

    - by Munezane
    I'm making a turn-based tactical game and I'm trying to implement the A* algorithm. I've been following a tutorial and got to this point, but my characters can't move diagonally up and left. Can anyone help me with this? The return x and y are int pointers which the characters are using to move towards the target. void level::aStar(int startx, int starty, int targetx, int targety, int* returnx, int* returny) { aStarGridSquare* currentSquare = new aStarGridSquare(); aStarGridSquare* startSquare = new aStarGridSquare(); aStarGridSquare* targetSquare = new aStarGridSquare(); aStarGridSquare* adjacentSquare = new aStarGridSquare(); aStarOpenList.clear(); for(unsigned int i=0; i<aStarGridSquareList.size(); i++) { aStarGridSquareList[i]->open=false; aStarGridSquareList[i]->closed=false; } startSquare=getaStarGridSquare(startx, starty); targetSquare=getaStarGridSquare(targetx, targety); if(startSquare==targetSquare) { *returnx=startx; *returny=starty; return; } startSquare->CostFromStart=0; startSquare->CostToTraverse=0; startSquare->parent = NULL; currentSquare=startSquare; aStarOpenList.push_back(currentSquare); while(currentSquare!=targetSquare && aStarOpenList.size()>0) { //unsigned int totalCostEstimate=aStarOpenList[0]->TotalCostEstimate; //currentSquare=aStarOpenList[0]; for(unsigned int i=0; i<aStarOpenList.size(); i++) { if(aStarOpenList.size()>1) { for(unsigned int j=1; j<aStarOpenList.size()-1; j++) { if(aStarOpenList[i]->TotalCostEstimate<aStarOpenList[j]->TotalCostEstimate) { currentSquare=aStarOpenList[i]; } else { currentSquare=aStarOpenList[j]; } } } else { currentSquare = aStarOpenList[i]; } } currentSquare->closed=true; currentSquare->open=false; for(unsigned int i=0; i<aStarOpenList.size(); i++) { if(aStarOpenList[i]==currentSquare) { aStarOpenList.erase(aStarOpenList.begin()+i); } } for(unsigned int i = currentSquare->blocky - 32; i <= currentSquare->blocky + 32; i+=32) { for(unsigned int j = currentSquare->blockx - 32; j<= currentSquare->blockx + 32; j+=32) { adjacentSquare=getaStarGridSquare(j/32, i/32); if(adjacentSquare!=NULL) { if(adjacentSquare->blocked==false && adjacentSquare->closed==false) { if(adjacentSquare->open==false) { adjacentSquare->parent=currentSquare; if(currentSquare->parent!=NULL) { currentSquare->CostFromStart = currentSquare->parent->CostFromStart + currentSquare->CostToTraverse + startSquare->CostFromStart; } else { currentSquare->CostFromStart=0; } adjacentSquare->CostFromStart =currentSquare->CostFromStart + adjacentSquare->CostToTraverse;// adjacentSquare->parent->CostFromStart + adjacentSquare->CostToTraverse; //currentSquare->CostToEndEstimate = abs(currentSquare->blockx - targetSquare->blockx) + abs(currentSquare->blocky - targetSquare->blocky); //currentSquare->TotalCostEstimate = currentSquare->CostFromStart + currentSquare->CostToEndEstimate; adjacentSquare->open = true; adjacentSquare->CostToEndEstimate=abs(adjacentSquare->blockx- targetSquare->blockx) + abs(adjacentSquare->blocky-targetSquare->blocky); adjacentSquare->TotalCostEstimate = adjacentSquare->CostFromStart+adjacentSquare->CostToEndEstimate; //adjacentSquare->open=true;*/ aStarOpenList.push_back(adjacentSquare); } else { if(adjacentSquare->parent->CostFromStart > currentSquare->CostFromStart) { adjacentSquare->parent=currentSquare; if(currentSquare->parent!=NULL) { currentSquare->CostFromStart = currentSquare->parent->CostFromStart + currentSquare->CostToTraverse + startSquare->CostFromStart; } else { currentSquare->CostFromStart=0; } adjacentSquare->CostFromStart =currentSquare->CostFromStart + adjacentSquare->CostToTraverse;// adjacentSquare->parent->CostFromStart + adjacentSquare->CostToTraverse; //currentSquare->CostToEndEstimate = abs(currentSquare->blockx - targetSquare->blockx) + abs(currentSquare->blocky - targetSquare->blocky); //currentSquare->TotalCostEstimate = currentSquare->CostFromStart + currentSquare->CostToEndEstimate; adjacentSquare->CostFromStart = adjacentSquare->parent->CostFromStart + adjacentSquare->CostToTraverse; adjacentSquare->CostToEndEstimate=abs(adjacentSquare->blockx - targetSquare->blockx) + abs(adjacentSquare->blocky - targetSquare->blocky); adjacentSquare->TotalCostEstimate = adjacentSquare->CostFromStart+adjacentSquare->CostToEndEstimate; } } } } } } } if(aStarOpenList.size()==0)//if empty { *returnx =startx; *returny =starty; return; } else { for(unsigned int i=0; i< aStarOpenList.size(); i++) { if(currentSquare->parent==NULL) { //int tempX = targetSquare->blockx; //int tempY = targetSquare->blocky; *returnx=targetSquare->blockx; *returny=targetSquare->blocky; break; } else { currentSquare=currentSquare->parent; } } } }

    Read the article

  • Convert Java program to C

    - by imicrothinking
    I need a bit of guidance with writing a C program...a bit of quick background as to my level, I've programmed in Java previously, but this is my first time programming in C, and we've been tasked to translate a word count program from Java to C that consists of the following: Read a file from memory Count the words in the file For each occurrence of a unique word, keep a word counter variable Print out the top ten most frequent words and their corresponding occurrences Here's the source program in Java: package lab0; import java.io.File; import java.io.FileReader; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; public class WordCount { private ArrayList<WordCountNode> outputlist = null; public WordCount(){ this.outputlist = new ArrayList<WordCountNode>(); } /** * Read the file into memory. * * @param filename name of the file. * @return content of the file. * @throws Exception if the file is too large or other file related exception. */ public char[] readFile(String filename) throws Exception{ char [] result = null; File file = new File(filename); long size = file.length(); if (size > Integer.MAX_VALUE){ throw new Exception("File is too large"); } result = new char[(int)size]; FileReader reader = new FileReader(file); int len, offset = 0, size2read = (int)size; while(size2read > 0){ len = reader.read(result, offset, size2read); if(len == -1) break; size2read -= len; offset += len; } return result; } /** * Make article word by word. * * @param article the content of file to be counted. * @return string contains only letters and "'". */ private enum SPLIT_STATE {IN_WORD, NOT_IN_WORD}; /** * Go through article, find all the words and add to output list * with their count. * * @param article the content of the file to be counted. * @return words in the file and their counts. */ public ArrayList<WordCountNode> countWords(char[] article){ SPLIT_STATE state = SPLIT_STATE.NOT_IN_WORD; if(null == article) return null; char curr_ltr; int curr_start = 0; for(int i = 0; i < article.length; i++){ curr_ltr = Character.toUpperCase( article[i]); if(state == SPLIT_STATE.IN_WORD){ article[i] = curr_ltr; if ((curr_ltr < 'A' || curr_ltr > 'Z') && curr_ltr != '\'') { article[i] = ' '; //printf("\nthe word is %s\n\n",curr_start); if(i - curr_start < 0){ System.out.println("i = " + i + " curr_start = " + curr_start); } addWord(new String(article, curr_start, i-curr_start)); state = SPLIT_STATE.NOT_IN_WORD; } }else{ if (curr_ltr >= 'A' && curr_ltr <= 'Z') { curr_start = i; article[i] = curr_ltr; state = SPLIT_STATE.IN_WORD; } } } return outputlist; } /** * Add the word to output list. */ public void addWord(String word){ int pos = dobsearch(word); if(pos >= outputlist.size()){ outputlist.add(new WordCountNode(1L, word)); }else{ WordCountNode tmp = outputlist.get(pos); if(tmp.getWord().compareTo(word) == 0){ tmp.setCount(tmp.getCount() + 1); }else{ outputlist.add(pos, new WordCountNode(1L, word)); } } } /** * Search the output list and return the position to put word. * @param word is the word to be put into output list. * @return position in the output list to insert the word. */ public int dobsearch(String word){ int cmp, high = outputlist.size(), low = -1, next; // Binary search the array to find the key while (high - low > 1) { next = (high + low) / 2; // all in upper case cmp = word.compareTo((outputlist.get(next)).getWord()); if (cmp == 0) return next; else if (cmp < 0) high = next; else low = next; } return high; } public static void main(String args[]){ // handle input if (args.length == 0){ System.out.println("USAGE: WordCount <filename> [Top # of results to display]\n"); System.exit(1); } String filename = args[0]; int dispnum; try{ dispnum = Integer.parseInt(args[1]); }catch(Exception e){ dispnum = 10; } long start_time = Calendar.getInstance().getTimeInMillis(); WordCount wordcount = new WordCount(); System.out.println("Wordcount: Running..."); // read file char[] input = null; try { input = wordcount.readFile(filename); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); System.exit(1); } // count all word ArrayList<WordCountNode> result = wordcount.countWords(input); long end_time = Calendar.getInstance().getTimeInMillis(); System.out.println("wordcount: completed " + (end_time - start_time)/1000000 + "." + (end_time - start_time)%1000000 + "(s)"); System.out.println("wordsort: running ..."); start_time = Calendar.getInstance().getTimeInMillis(); Collections.sort(result); end_time = Calendar.getInstance().getTimeInMillis(); System.out.println("wordsort: completed " + (end_time - start_time)/1000000 + "." + (end_time - start_time)%1000000 + "(s)"); Collections.reverse(result); System.out.println("\nresults (TOP "+ dispnum +" from "+ result.size() +"):\n" ); // print out result String str ; for (int i = 0; i < result.size() && i < dispnum; i++){ if(result.get(i).getWord().length() > 15) str = result.get(i).getWord().substring(0, 14); else str = result.get(i).getWord(); System.out.println(str + " - " + result.get(i).getCount()); } } public class WordCountNode implements Comparable{ private String word; private long count; public WordCountNode(long count, String word){ this.count = count; this.word = word; } public String getWord() { return word; } public void setWord(String word) { this.word = word; } public long getCount() { return count; } public void setCount(long count) { this.count = count; } public int compareTo(Object arg0) { // TODO Auto-generated method stub WordCountNode obj = (WordCountNode)arg0; if( count - obj.getCount() < 0) return -1; else if( count - obj.getCount() == 0) return 0; else return 1; } } } Here's my attempt (so far) in C: #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> // Read in a file FILE *readFile (char filename[]) { FILE *inputFile; inputFile = fopen (filename, "r"); if (inputFile == NULL) { printf ("File could not be opened.\n"); exit (EXIT_FAILURE); } return inputFile; } // Return number of words in an array int wordCount (FILE *filePointer, char filename[]) {//, char *words[]) { // count words int count = 0; char temp; while ((temp = getc(filePointer)) != EOF) { //printf ("%c", temp); if ((temp == ' ' || temp == '\n') && (temp != '\'')) count++; } count += 1; // counting method uses space AFTER last character in word - the last space // of the last character isn't counted - off by one error // close file fclose (filePointer); return count; } // Print out the frequencies of the 10 most frequent words in the console int main (int argc, char *argv[]) { /* Step 1: Read in file and check for errors */ FILE *filePointer; filePointer = readFile (argv[1]); /* Step 2: Do a word count to prep for array size */ int count = wordCount (filePointer, argv[1]); printf ("Number of words is: %i\n", count); /* Step 3: Create a 2D array to store words in the file */ // open file to reset marker to beginning of file filePointer = fopen (argv[1], "r"); // store words in character array (each element in array = consecutive word) char allWords[count][100]; // 100 is an arbitrary size - max length of word int i,j; char temp; for (i = 0; i < count; i++) { for (j = 0; j < 100; j++) { // labels are used with goto statements, not loops in C temp = getc(filePointer); if ((temp == ' ' || temp == '\n' || temp == EOF) && (temp != '\'') ) { allWords[i][j] = '\0'; break; } else { allWords[i][j] = temp; } printf ("%c", allWords[i][j]); } printf ("\n"); } // close file fclose (filePointer); /* Step 4: Use a simple selection sort algorithm to sort 2D char array */ // PStep 1: Compare two char arrays, and if // (a) c1 > c2, return 2 // (b) c1 == c2, return 1 // (c) c1 < c2, return 0 qsort(allWords, count, sizeof(char[][]), pstrcmp); /* int k = 0, l = 0, m = 0; char currentMax, comparedElement; int max; // the largest element in the current 2D array int elementToSort = 0; // elementToSort determines the element to swap with starting from the left // Outer a iterates through number of swaps needed for (k = 0; k < count - 1; k++) { // times of swaps max = k; // max element set to k // Inner b iterates through successive elements to fish out the largest element for (m = k + 1; m < count - k; m++) { currentMax = allWords[k][l]; comparedElement = allWords[m][l]; // Inner c iterates through successive chars to set the max vars to the largest for (l = 0; (currentMax != '\0' || comparedElement != '\0'); l++) { if (currentMax > comparedElement) break; else if (currentMax < comparedElement) { max = m; currentMax = allWords[m][l]; break; } else if (currentMax == comparedElement) continue; } } // After max (count and string) is determined, perform swap with temp variable char swapTemp[1][20]; int y = 0; do { swapTemp[0][y] = allWords[elementToSort][y]; allWords[elementToSort][y] = allWords[max][y]; allWords[max][y] = swapTemp[0][y]; } while (swapTemp[0][y++] != '\0'); elementToSort++; } */ int a, b; for (a = 0; a < count; a++) { for (b = 0; (temp = allWords[a][b]) != '\0'; b++) { printf ("%c", temp); } printf ("\n"); } // Copy rows to different array and print results /* char arrayCopy [count][20]; int ac, ad; char tempa; for (ac = 0; ac < count; ac++) { for (ad = 0; (tempa = allWords[ac][ad]) != '\0'; ad++) { arrayCopy[ac][ad] = tempa; printf("%c", arrayCopy[ac][ad]); } printf("\n"); } */ /* Step 5: Create two additional arrays: (a) One in which each element contains unique words from char array (b) One which holds the count for the corresponding word in the other array */ /* Step 6: Sort the count array in decreasing order, and print the corresponding array element as well as word count in the console */ return 0; } // Perform housekeeping tasks like freeing up memory and closing file I'm really stuck on the selection sort algorithm. I'm currently using 2D arrays to represent strings, and that worked out fine, but when it came to sorting, using three level nested loops didn't seem to work, I tried to use qsort instead, but I don't fully understand that function as well. Constructive feedback and criticism greatly welcome (...and needed)!

    Read the article

  • Are these saml request-response good enough?

    - by Ashwin
    I have set up a single sign on(SSO) for my services. All the services confirm the identity of the user using the IDPorvider(IDP). In my case I am also the IDP. In my saml request, I have included the following: 1. the level for which auth. is required. 2. the consumer url 3. the destination service url. 4. Issuer Then, encrypting this message with the SP's(service provider) private key and then with the IDP's Public key. Then I am sending this request. The IDP on receiving the request, first decrypts with his own private key and then with SP's public key. In the saml response: 1. destination url 2. Issuer 3. Status of the response Is this good enough? Please give your suggestions?

    Read the article

  • What is PrimeFaces p:editor based on?

    - by AlanObject
    I want to add some client-side functionality to the PrimeFaces p:editor, but for some reason I am not able to uncover what JavaScript client side code they used to build the component. Could anyone point me to that? P.S. two things I want to do is make the component resizable (PrimeFaces doesn't support that) and I want to add shortcut buttons to insert pre-programmed text. Any hints about how this will done will be appreciated.

    Read the article

  • Can highlight the current menu item, but can't add the class= to style unhighleted menu items

    - by bradpotts
    <?php $activesidebar[$currentsidebar]="id=isactive";?> <div class="span3"> <div class="well sidebar-nav hidden-phone"> <ul class="nav nav-list"> <li class="nav-header" <?php echo $activesidebar[1] ?>>Marketing Services</li> <li><a href="#">Marketing Technology</a></li> <li><a href="#">Generate More Sales</a></li> <li><a href="#">Direct Email Marketing</a></li> <li class="nav-header" <?php echo $activesidebar[2] ?>>Advertising Services</li> <li><a href="../services-advertising-mass-media-network.php">Traditional Medias</a></li> <li><a href="#">Online & Social Medias</a></li> <li><a href="#">Media Planing & Purchasing</a></li> <li class="nav-header" <?php echo $activesidebar[3] ?>>Technology Services</li> <li><a href="#">Managed Websites</a></li> <li><a href="#">Managed Web Servers</a></li> <li><a href="#">Managed Databases</a></li> <li class="nav-header" <?php echo $activesidebar[4] ?>>About Us</li> <li><a href="../aboutus-contactus.php">Contact Us</a></li> </ul> </div> This is added to the current page I want to add this on. <?php $currentsidebar =2; include('module-sidebar-navigation.php');?> I had programmed this menu individually on each page, but to make my website dynamic I used one file and use php includes to load the file. I can get the menu to highlight on the current page assigning an id="isactive", how can I assign id="notactive" to the other 3 menu items that are not active on that page. Is there an else or elseif I have to include?

    Read the article

  • Send a variable on the heap to another thread

    - by user1201889
    I have a strange problem in C++. An address of a Boolean gets "destroyed" but it doesn't get touched. I know that there are beater way's to accomplish what I try to do, but I want to know what I do wrong. I have a main class; this main class contains a vector of another class. There is a strange problem when a new instance gets created of this object. This is how my code works: There will start a thread when the constructor gets called of the “2nd”object. This thread gets as Parameter a struct. This is the struct: struct KeyPressData { vector<bool> *AutoPressStatus; vector<int> *AutoPressTime; bool * Destroy; bool * Ready; }; The struct gets filled in the constructor: MultiBoxClient::MultiBoxClient() { //init data DestroyThread = new bool; ReadyThread = new bool; AutoThreadData = new KeyPressData; //Reseting data *DestroyThread = false; *ReadyThread = false; //KeyPressData configurating AutoThreadData->AutoPressStatus = &AutoPressStatus; AutoThreadData->AutoPressTime = &AutoPressTime; AutoThreadData->Destroy = DestroyThread; AutoThreadData->Ready = ReadyThread; //Start the keypress thread CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)AutoKeyThread,AutoThreadData,NULL,NULL); } As long as the constructor is running will the program run fine. But when the constructor closes the address of the “AutoThreadData-Destroy” will get corrupted. The program will crash when I call the value of the pointer. void WINAPI AutoKeyThread(void * ThreadData) { KeyPressData * AutoThreadData = (KeyPressData*)ThreadData; while(true) { if(*AutoThreadData->Destroy == true) //CRASH { *AutoThreadData->Ready = true; return; } Sleep(100); } } What did I test: I logged the address of the AutoThreadData and the AutoThreadData-Destroy when the constrcutor is running and clossed; the AutoThreadData address is equal to AutoThreadData when the constructor is closed. So there is no problem here. The address of AutoThreadData-Destroy gets destroyed when the constructor is closed. But how can this happen? The Boolean is on the heap and the KeyPressData struct (AutoThreadData) is on the heap. Destroy before: 00A85328 Destroy after: FEEEFEEE Can someone maby explain why this crash? I know that I can send a pointer to my class to the thread. But I want to know what goes wrong here. That way I can learn from my mistakes. Could someone help me with this problem? Thanks!

    Read the article

  • No persister for: <ClassName> issue with Fluent NHibernate

    - by Amit
    I have following code: //AutoMapConfig.cs using System; using FluentNHibernate.Automapping; namespace SimpleFNH.AutoMap { public class AutoMapConfig : DefaultAutomappingConfiguration { public override bool ShouldMap(Type type) { return type.Namespace == "Examples.FirstAutomappedProject.Entities"; } } } //CascadeConvention.cs using FluentNHibernate.Conventions; using FluentNHibernate.Conventions.Instances; namespace SimpleFNH.AutoMap { public class CascadeConvention : IReferenceConvention, IHasManyConvention, IHasManyToManyConvention { public void Apply(IManyToOneInstance instance) { instance.Cascade.All(); } public void Apply(IOneToManyCollectionInstance instance) { instance.Cascade.All(); } public void Apply(IManyToManyCollectionInstance instance) { instance.Cascade.All(); } } } //Item.cs namespace SimpleFNH.Entities { public class Item { public virtual long ID { get; set; } public virtual string ItemName { get; set; } public virtual string Description { get; set; } public virtual OrderItem OrderItem { get; set; } } } //OrderItem.cs namespace SimpleFNH.Entities { public class OrderItem { public virtual long ID { get; set; } public virtual int Quantity { get; set; } public virtual Item Item { get; set; } public virtual ProductOrder ProductOrder { get; set; } public virtual void AddItem(Item item) { item.OrderItem = this; } } } using System; using System.Collections.Generic; //ProductOrder.cs namespace SimpleFNH.Entities { public class ProductOrder { public virtual long ID { get; set; } public virtual DateTime OrderDate { get; set; } public virtual string CustomerName { get; set; } public virtual IList<OrderItem> OrderItems { get; set; } public ProductOrder() { OrderItems = new List<OrderItem>(); } public virtual void AddOrderItems(params OrderItem[] items) { foreach (var item in items) { OrderItems.Add(item); item.ProductOrder = this; } } } } //NHibernateRepo.cs using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using NHibernate; using NHibernate.Criterion; using NHibernate.Tool.hbm2ddl; namespace SimpleFNH.Repository { public class NHibernateRepo { private static ISessionFactory _sessionFactory; private static ISessionFactory SessionFactory { get { if (_sessionFactory == null) InitializeSessionFactory(); return _sessionFactory; } } private static void InitializeSessionFactory() { _sessionFactory = Fluently.Configure().Database( MsSqlConfiguration.MsSql2008.ConnectionString( @"server=Amit-PC\SQLEXPRESS;database=SimpleFNH;Trusted_Connection=True;").ShowSql()). Mappings(m => m.FluentMappings.AddFromAssemblyOf<Order>()).ExposeConfiguration( cfg => new SchemaExport(cfg).Create(true, true)).BuildSessionFactory(); } public static ISession OpenSession() { return SessionFactory.OpenSession(); } } } //Program.cs using System; using System.Collections.Generic; using System.Linq; using SimpleFNH.Entities; using SimpleFNH.Repository; namespace SimpleFNH { class Program { static void Main(string[] args) { using (var session = NHibernateRepo.OpenSession()) { using (var transaction = session.BeginTransaction()) { var item1 = new Item { ItemName = "item 1", Description = "test 1" }; var item2 = new Item { ItemName = "item 2", Description = "test 2" }; var item3 = new Item { ItemName = "item 3", Description = "test 3" }; var orderItem1 = new OrderItem { Item = item1, Quantity = 2 }; var orderItem2 = new OrderItem { Item = item2, Quantity = 4 }; var orderItem3 = new OrderItem { Item = item3, Quantity = 5 }; var productOrder = new ProductOrder { CustomerName = "Amit", OrderDate = DateTime.Now, OrderItems = new List<OrderItem> { orderItem1, orderItem2, orderItem3 } }; productOrder.AddOrderItems(orderItem1, orderItem2, orderItem3); session.Save(productOrder); transaction.Commit(); } } using (var session = NHibernateRepo.OpenSession()) { // retreive all stores and display them using (session.BeginTransaction()) { var orders = session.CreateCriteria(typeof(ProductOrder)) .List<ProductOrder>(); foreach (var item in orders) { Console.WriteLine(item.OrderItems.First().Quantity); } } } } } } I tried many variations to get it working but i get an error saying No persister for: SimpleFNH.Entities.ProductOrder Can someone help me get it working? I wanted to create a simple program which will set a pattern for my bigger project but it is taking quite a lot of time than expected. It would be rally helpful if you can explain in simple terms on any template/pattern that i can use to get fluent nHibernate working. The above code uses auto mapping, which i tried after i tried with fluent mapping.

    Read the article

  • TextBox Inside TabHost isn't clickable

    - by agam360
    Here is my code:(main.xml -layout) <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/linearLayout2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" > </TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <MultiAutoCompleteTextView android:id="@+id/txtCode" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25" android:capitalize="none" android:focusable="true" android:focusableInTouchMode="false" android:gravity="top|left" android:text="@string/strtxtCode" android:textSize="26dp" android:textStyle="bold" android:typeface="normal" /> <MultiAutoCompleteTextView android:id="@+id/txtCodeHTML" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25" android:capitalize="none" android:focusable="true" android:focusableInTouchMode="false" android:gravity="top|left" android:text="@string/strtxtCode2" android:textSize="26dp" android:textStyle="bold" android:typeface="normal" /> </FrameLayout> </LinearLayout> </TabHost> When I try to click(touch) the text-box, it does nothing. What should I do in order to fix this?

    Read the article

  • Hide long text except the first two paragraphs

    - by Barbara
    I have a very long text and I need to hide everything except the first two paragraphs. For various reasons I'd rather not use jquery for this site. Can this be done with css only? I know nth-child most likely will do the trick but I'm having troubles coming up with a specific rule. <div class="text"> <p>display<p> <p>display</p> <p>hide from this point</p> <p>...</p> </div>

    Read the article

  • Deferred printing in Java

    - by Bober02
    I have a specific issue with general console printing and I was wondering whether anyone has a solution for it. I am trying to print a dataTable which would look like sth like this: Table ---------------------- Name |Surname | ---------------------- Mike |Mikhailowish| Rafaello|Mirena | and so on. In order to print the border of the bar I need to know what the maximum length of each column value is. I don't want to go through the whole database to find that out and then again to print it. I would rather like to do sth like: System.out.printLater(s); //herejust leave a pointer to a StringBuilder you will build ... s.append("--------"); ... System.out.printAllDeferred(); I understand the above is probably in 99.99999% chances impossible, but perhaps you guys have a clever way of achieving the above?

    Read the article

  • How to set an ImageView and two TextviewS to have the same height?

    - by M.ES
    I've got the following layout with one ImageView and 2 TextView, I would like them all to have the same height. However, the ImageView is always taking more than half of the screen. Any help is highly apreciated. Here is the layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF" android:orientation="vertical" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.4" android:src="@drawable/sprint" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.3" android:background="#555555" android:text="@string/hello" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.3" android:text="@string/hello" /> </LinearLayout>

    Read the article

  • Removing dotted border without setting NoFocus in Windows PyQt

    - by Cryptite
    There are a few questions on SO about this, all of which seem to say that the only way to remove the dotted border is to set the focusPolicy on widget/item in question to NoFocus. While this works as a temporary fix, this prevents further interaction with said widget/item in the realm of other necessary focusEvents. Said border in question: Here's an example of why this doesn't work. I have a Non-Modal widget popup, think a lightbox for an image. I want to detect a mousePressEvent outside of the widget and close the widget as a result. To do this, I should catch the focusOutEvent. However, if a vast majority of widgets in my program are set as NoFocus (to remove the border issue), then I cannot catch the focusOutEvent because, you guessed it, they have no focus policy. Here's another example: I have a QTreeWidget that is subclassed so I can catch keyPressEvents for various reasons. The QTreeWidget is also set as NoFocus to prevent the border. Because of this, however, the widget never has focus and therefore no keyPressEvents can be caught. A workaround for this (kludgy, imo) is to use the widget's grabKeyboard class, which is dangerous if I forget to releaseKeyboard later. This is not optimal. So then the question is, is there a way to remove this weird (mostly just ugly) dotted border without turning off focus for everything in my app? Thanks in advance!

    Read the article

  • Real Time Progress Indicator

    - by jignesh
    I am trying to get the real time progress indicator. In the code snippet below,i am trying to set the width of DIV on the basis of the Number of Items retrieve from the Web Service Call Back Function. for (i = 0; i < data.length; i++) { table += '<tr>'; table += '<td>' + data[i].ItemId + '</td>'; table += '<td></td>'; table += '<td>' + data[i].Name + '</td>'; table += '<td>' + data[i].Unit + '</td>'; table += '<td><input type=text value=' + data[i].Quantity + '></td>'; table += '<td>' + data[i].Brands + '</td>'; table += '<td><img border=0 src=../images/Delete_icon.gif></td>'; table += '</tr>'; $('#divProgressIndicator').width((100 * (i / data.length)) + '%'); } As shown in the code above,after the for loop is executed i only see the divProgressIndicator filled with the background color and I am not able to see the progress. Can I achieve this in a for loop or i need to use some thing else. Regards

    Read the article

  • Stateful Iterators Java

    - by Gitmo
    What is a Stateful Iterator? This question relates to an Iterator defined in Hadoop for performing Joins. As the reference documentation states: This defines an interface to a stateful Iterator that can replay elements added to it directly. Note that this does not extend Iterator. What does 'replay elements added to it directly' mean? How is this iterator different from a usual iterator?

    Read the article

  • Problems when I try to see databases in SQLite

    - by Sabau Andreea
    I created in code a database and two tables: static final String dbName="graficeCirculatie"; static final String ruteTable="Rute"; static final String colRuteId="RutaID"; static final String colRuta="Ruta"; static final String statiaTable="Statia"; static final String colStatiaID="StatiaID"; static final String colIdRuta="IdRuta"; static final String colStatia="Statia"; public DatabaseHelper(Context context) { super(context, dbName, null,33); } public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL("CREATE TABLE " + statiaTable + " (" + colStatiaID + " INTEGER PRIMARY KEY , " + colIdRuta + " INTEGER, " + colStatia + " TEXT)"); db.execSQL("CREATE TABLE " + ruteTable + "(" + colRuteId + " INTEGER PRIMARY KEY AUTOINCREMENT, " + colRuta + " TEXT);"); InsertDepts(db); } void InsertDepts(SQLiteDatabase db) { ContentValues cv = new ContentValues(); cv.put(colRuteId, 1); cv.put(colRuta, "Expres8"); db.insert(ruteTable, colRuteId, cv); cv.put(colRuteId, 2); cv.put(colRuta, "Expres2"); db.insert(ruteTable, colRuteId, cv); cv.put(colRuteId, 3); cv.put(colRuta, "Expres3"); db.insert(ruteTable, colRuteId, cv); } Now I want to see tables inputs from command line. I try in this way: C:\Program Files\Android\android-sdk\tools sqlite3 SQLite version 3.7.4 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite sqlite3 graficeCirculatie ... select * from ruteTable; And I got an error: Error: near "squlite3": syntax error. Can someone help me?

    Read the article

  • GitHub solution for personal repo

    - by Luke Maurer
    So I've got my private SVN repo on my home server, and it has maybe 30 different modules thrown together in it, ranging from abortive throw-away larks to a few endeavors that might actually go somewhere someday. But a recent filesystem failure (BTW, never ever EVER use XFS without a battery-backed hardware RAID) has me spooked and thinking of using a DVCS for all that. I've also just had quite the swig of the Git koolaid, and I've been working with GitHub of late, so that's where I'm looking right now. Of course, it would be silly to shell out major cash for a separate private Git repo for every little project, and I don't want to have to be selective about what I throw up there (I love all my children :-D ), so I'll have to be somewhat creative about this. I can happily use SSH to my home box to use Git the way I've been using SVN, and I'm thinking from there I could amalgamate everything into, say, a big project with 30 submodules, which I then push to GitHub. What'd be a sane way to set this up? Does using submodules sound feasible? How do I sync it all to my private GitHub repo? Cron job? Git hook? I'd love to hear it if anyone's done something similar. I'm not really married to Git or GitHub, so a sufficiently compelling feature of another solution might sway me. But if your answer does involve a different system (especially a different VCS), be advised it'll be a tougher sell :-)

    Read the article

  • facing issue when using JDBC in TomCat 7 with Struts

    - by Chethu2288
    Am developing a web application using Struts 2 where am trying to insert some values into my local MySql database. The code for connecting and accessing database works fine in console application. but its giving "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" exception when i tried the same code in Struts. Kindly help me on this. Connection conn = null; String url = "jdbc:mysql://localhost:3306/"; String dbName = "testdatabase"; String driver = "com.mysql.jdbc.Driver"; try { Class.forName(driver).newInstance(); conn = DriverManager.getConnection(url+dbName,"root","root"); Statement statement=conn.createStatement(); System.out.println("HelloWorld.execute()"); int i= statement.executeUpdate("INSERT INTO testTable VALUES('15','Lucky')"); System.out.println("res: "+i); } catch(Exception e) { System.out.println(e); //setMessage(e.getMessage()); } Awaiting your response.

    Read the article

  • PHP Regex to remove nested form elements but not input elements

    - by that0n3guy
    I'm modifying a PHP script that I have and it is currently outputting a nested form. Something like: <form name="input" action="html_form_action.asp" method="get"> <p>stuff here here, this may or may not be in a div, script, etc..</p> <form name="input" action="html_form_action.asp" method="get"> <div>stuff here possibilly</div> Username: <input type="text" name="user" /> <input type="submit" value="Submit" /> </form> <p>otherstuff this may or may not be in a div, script, etc..</p> </form> Nested form's are a no-no (IE hates them and basically causes the form to stop working), so I need to remove the nested form lines, but not the form items. I need to remove the nested: <form name="input" action="html_form_action.asp" method="get"> and </form> but not the outer <form and </form> or the input or submit stuff. Is this possible to do with regex? Note, the reason I just want to regex out the form rather than find the problem is because I know it will take some significant re-working to get rid of the double form... the regex solution is quick for now.

    Read the article

  • Make html footer occupy the rest of the body

    - by w0rldart
    So I am trying to code the footer of my web app of it occupies the rest of the body's height. Picture: http://img1.uploadscreenshot.com/images/orig/3/8906151296-orig.png Notice the light area beneath the dark area, the dark area should occupy all of it. Some of my html code: <body> .... <footer> <hr> <ul id="footerContainer"> <li class="right"> <ul> <li> <a href="" class="family-filter">Filtro Fami....</a> </li> </ul> </li> </ul> </footer> <script>...</script> </body></html> CSS: .... #footerContainer {width: 90%; min-width: 525px; margin: 0 auto; position: relative;} .... footer hr{ border: 0; height: 30px; background: url('../imgs/footer-top.png') repeat-x scroll; } footer { background: url('../imgs/footer-bg.png') repeat scroll bottom; height: 100%; display: block; margin: 0 auto; padding: 0; overflow: auto; } #footerContainer {margin: 0 auto; position: relative;} #footerContainer li { display: inline;} #footerContainer li .right {float: right;} #footerContainer li a {} Any suggestions? Update1: This is what happens: http://img1.uploadscreenshot.com/images/orig/3/8906391235-orig.png when I set html,body { width: 100%; height: 100%; margin: 0; padding: 0; } Update2: http://awesomescreenshot.com/0382hf1ff Zoom out and in at this page: line25.com/wp-content/uploads/2010/blog-design-coded/demo/… and check the footer area, that's how I need it work on my layout.

    Read the article

  • How to loop 3 dimension array using foreach PHP

    - by vzhen
    Below is foreach and the 3 dimension arrays, no problem with the looping but i cannot sepcify which array to echo, they must me the whole arrays like echo $subvalue, any better solutions with looping 3 dimension array? i actually feel weird with this looping. Thanks in adv foreach ($stories as $key => $story){ //echo "<br />"; foreach($story as $subkey => $subvalue){ echo $subvalue."<br />"; foreach($subvalue as $key => $subsubvalue){ echo $subsubvalue."<br />"; } } } Array ( [270] => Array ( [uid] => 36 [user_email] => [email protected] [sid] => 270 [story_name] => Story C [photo_url] => Array ( [0] => story_photos/2012/0322/361332381418153311.jpg [1] => story_photos/2012/0322/361332393792911587.jpg ) [photo_added_date] => Array ( [0] => 1332381418 [1] => 1332393792 ) ) [269] => Array ( [uid] => 36 [user_email] => [email protected] [sid] => 269 [story_name] => Story B [photo_url] => Array ( [0] => story_photos/2012/0322/361332381406580761.jpg ) [photo_added_date] => Array ( [0] => 1332381406 ) ) [268] => Array ( [uid] => 36 [user_email] => [email protected] [sid] => 268 [story_name] => Story A [photo_url] => Array ( [0] => story_photos/2012/0322/361332381393552719.jpg ) [photo_added_date] => Array ( [0] => 1332381393 ) ) )

    Read the article

  • Location-aware applications on WP7.5

    - by salamis
    I would like to create a location-aware application on WP7.5 Is it possible to automatically get a trigger on location change without our application running on background? For example: I would like to know if a user has moved in a new location. If the user has moved I would like to trigger a specific event from my application. My only concern is that if I do that from my application I will consume a significant amount of battery. Is it a specific WP7 service which can inform my application that the user has changed his location and trigger an event from my application? If it is possible can you please point me an example?

    Read the article

  • C#JSON serialization

    - by Bridget the Midget
    I'm trying out the HighStock library for creating stock charts. To fill the chart with data, their example specifies this source. The first parameter is unixtime in milliseconds and the second parameter is the stock closing price. I don't know if this is valid json, but I would argue that the following would be a more appropriate way of writing json. [{"Closing":63.15000,"Date":1262559600000},{"Closing":64.75000,"Date":1262646000000}, ... I guess that I have no other option than to adapt to HighStocks syntax. I could solve this by looping and add correct syntax to a string, but that seems rudimentary. Would it be more wise to serialize C# objects to create my json, and if that's the case - how can I reach the syntax specified in the example? Lets just say this is my c# object: public class Quote { public double Date { get; set; } public decimal Closing { get; set; } } Am I making it unnecessary complex? Should I just format a json string?

    Read the article

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