Daily Archives

Articles indexed Monday October 21 2013

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

  • Are VM-based languages becoming viable for Graphics since the move to GPU computing?

    - by skiwi
    Perhaps the title is not the most clear, so let me elaborate it more: I am talking about VM-based languages, by that I mean languages that run on the JVM (java) and for example C#. Also I am talking about 3D graphics, just to be clear. Lately the trend has been that most computing is being done on the GPU and not on the CPU, and since times the issue with programming games on a VM-based language is that garbage collecting may happen randomly. So let's take a look which is responsible for what: Showing the graphics: GPU Uploading graphics to the GPU: CPU? Needs to be done every frame? Calculating physics constraints: GPU Doing the real game logic (Determining when to move objects (independent of physics calculations), processing AI): CPU Is my list actually correct? And if it is, is for example Java becoming more viable? Or is uploading the graphics (vertices) still the most expensive operation? Would like to get more insight into this.

    Read the article

  • Timing Calculations for Opengl ES 2.0 draw calls

    - by Arun AC
    I am drawing a cube in OpenGL ES 2.0 in Linux. I am calculating the time taken for each frame using below function #define NANO 1000000000 #define NANO_TO_MICRO(x) ((x)/1000) uint64_t getTick() { struct timespec stCT; clock_gettime(CLOCK_MONOTONIC, &stCT); uint64_t iCurrTimeNano = (1000000000 * stCT.tv_sec + stCT.tv_nsec); // in Nano Secs uint64_t iCurrTimeMicro = NANO_TO_MICRO(iCurrTimeNano); // in Micro Secs return iCurrTimeMicro; } I am running my code for 100 frames with simple x-axis rotation. I am getting around 200 to 220 microsecs per frame. that means am i getting around (1/220microsec = 4545) FPS Is my GPU is that fast? I strongly doubt this result. what went wrong in the code? Regards, Arun AC

    Read the article

  • How to handle date difference between client and server?

    - by daydreamer
    I have an API which looks like /summary/yyyy/mm Which returns the summary of their data for the year and month requested. One of the things it returns the number of days left if this is current year and month. For example: days_left: 9 for 2013 and 10 and current date on server is 21 Oct 2013 How I calculate remaining days? This is implemented in python as def current_financial_month_details(self): time_from, time_to = self \ .get_start_end_time_current_financial_month() today = datetime.today() from_time = datetime(year=today.year, month=today.month, day=today.day) return { 'time_from': time_from, 'time_to': time_to, 'remaining_days': (time_to - from_time).days } The problem? The server is in east coast and the client(me with browser) is on pacific time zone When its 9PM PST the time changes in east coast, so if I run hit /summary/2013/10 and if it is Oct 21 2013 for me on PST, the date has already changed on EST, so days_left: 8 which is incorrect on client end. right? How do I handle this situation?

    Read the article

  • Finding the unique paths through a Neo4j graph

    - by Larry
    I have a Neo4j graph with 12 inputs and 4 outputs, and am trying to write a query with the Java Traverser that will return the 14 unique paths from an input to an output node. All the queries I have tried return only a subset of the 14 paths. For example, the code below returns 4 paths, but the other 10 all stop 1 node short of the output. RelationshipType relType = RelationshipTypes.EDGE; TraversalDescription td = new TraversalDescriptionImpl() .depthFirst() .relationships(relType, Direction.OUTGOING); for (Node node : inputs){ Traverser tv = td.traverse(node); Iterator<Path> iter = tv.iterator(); // ... print path } I've tried uniqueness and depth settings as well, with no effect. The query below returns all 14 paths using the web interface, but when I use the ExecutionEngine class, I only get 13 paths back. START s=node(*) MATCH (s)-[p:EDGE*]->(c) WHERE s.type! = "INPUT" AND c.type! = "OUTPUT" RETURN p How do I get all the unique paths using the Java API?

    Read the article

  • Recursively determine average value

    - by theva
    I have to calculate an average value of my simulation. The simulation is ongoing and I want (for each iteration) to print the current average value. How do I do that? I tried the code below (in the loop), but I do not think that the right value is calculated... int average = 0; int newValue; // Continuously updated value. if(average == 0) { average = newValue; } average = (average + newValue)/2; I also taught about store each newValue in an array and for each iteration summarize the whole array and do the calculation. However, I don't think that's a good solution, because the loop is an infinity loop so I can't really determine the size of the array. There is also a possibility that I am thinking too much and that the code above is actually correct, but I don't think so...

    Read the article

  • Detect EXIF Orientation of an image in javascript

    - by Obi Wan
    In my mobile web application, I have a need to examine the EXIF orientation tag of an image file selected using an input type=file control, and this needs to be done on the client side in javascript, before the selected image file gets uploaded to the server. I have seen several threads similar to this but most of them say to use a library called binaryajax.js to be able to access the EXIF data from the file object. Unfortunately, simply including binaryajax.js in my project causes an Access Denied error in jQuery 1.7.1, and I have no idea why this is happening. This error precludes me from using this jquery library. So I am looking for a solution that does not use this library. Another library I have tried to use is jquery.exif.js and I also get an Access Denied Error Trying to use it.

    Read the article

  • Python/Django tests running only one test at a time

    - by user2876296
    I have a unittest for my view class TestFromAllAdd(TestCase): fixtures = ['staging_accounts_user.json', 'staging_main_category.json', 'staging_main_dashboard.json', 'staging_main_location.json', 'staging_main_product.json', 'staging_main_shoppinglist.json'] def setUp(self): self.factory = RequestFactory() self.c = Client() self.c.login(username='admin', password='admin') def from_all_products_html404_test(self): request = self.factory.post('main/adding_from_all_products', {'product_id': ''}) request.user = User.objects.get(username= 'admin') response = adding_from_all_products(request) self.assertEqual(response.status_code, 404) But I have a few more classes with tests and I cant run them all at the same time: python manage.py test main doesnt run tests, but if i run; python manage.py test main.TestFromAllAdd.from_all_products_html404_test , runs one test;

    Read the article

  • Using Mod_Rewrite in HTTPD.CONF file

    - by Mike Lovely
    I want to rewrite URLs so when a user goes to; http://www.example.com/applications/newWeb/www/index.php?page=48&thiscontent=2660&date=2013-10-11&pubType=0&PublishTime=09:30:00&from=home&tabOption=1 and if the URL contains thiscontent=2660 (which in this example above, it does) I want to redirect them to; http://www.example.come/index.php/publications/finance-and-economics/departmental-resources I have about 30 different thiscontent=XXXX types and imagine I’ll have to copy and edit this rule 30 different times for any links to my old website still knocking around out there. I have access to my httpd.conf file but have never done a mod_rewrite before. I also don't really need these showing up in the error logs as 301s. Will that happen? Because at the moment there are hundreds!

    Read the article

  • C# Can I return HttpWebResponse result to iframe - Uses Digest authentication

    - by chadsxe
    I am trying to figure out a way to display a cross-domain web page that uses Digest Authentication. My initial thought was to make a web request and return the entire page source. I currently have no issues with authenticating and getting a response but I am not sure how to properly return the needed data. // Create a request for the URL. WebRequest request = WebRequest.Create("http://some-url/cgi/image.php?type=live"); // Set the credentials. request.Credentials = new NetworkCredential(username, password); // Get the response. HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Get the stream containing content returned by the server. Stream dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); // Clean up the streams and the response. reader.Close(); dataStream.Close(); response.Close(); return responseFromServer; My problems are currently... responseFromServer is not returning the entire source of the page. I.E. missing body and head tags The data is encoded improperly in responseFromServer. I believe this has something to do with the transfer encoding being of the type chunked. Further more... I am not entirely sure if this is even possible. If it matters, this is being done in ASP.NET MVC 4 C#. Thanks, Chad

    Read the article

  • IOException during blocking network NIO in JDK 1.7

    - by Bass
    I'm just learning NIO, and here's the short example I've written to test how a blocking NIO can be interrupted: class TestBlockingNio { private static final boolean INTERRUPT_VIA_THREAD_INTERRUPT = true; /** * Prevent the socket from being GC'ed */ static Socket socket; private static SocketChannel connect(final int port) { while (true) { try { final SocketChannel channel = SocketChannel.open(new InetSocketAddress(port)); channel.configureBlocking(true); return channel; } catch (final IOException ioe) { try { Thread.sleep(1000); } catch (final InterruptedException ie) { } continue; } } } private static byte[] newBuffer(final int length) { final byte buffer[] = new byte[length]; for (int i = 0; i < length; i++) { buffer[i] = (byte) 'A'; } return buffer; } public static void main(final String args[]) throws IOException, InterruptedException { final int portNumber = 10000; new Thread("Reader") { public void run() { try { final ServerSocket serverSocket = new ServerSocket(portNumber); socket = serverSocket.accept(); /* * Fully ignore any input from the socket */ } catch (final IOException ioe) { ioe.printStackTrace(); } } }.start(); final SocketChannel channel = connect(portNumber); final Thread main = Thread.currentThread(); final Thread interruptor = new Thread("Inerruptor") { public void run() { System.out.println("Press Enter to interrupt I/O "); while (true) { try { System.in.read(); } catch (final IOException ioe) { ioe.printStackTrace(); } System.out.println("Interrupting..."); if (INTERRUPT_VIA_THREAD_INTERRUPT) { main.interrupt(); } else { try { channel.close(); } catch (final IOException ioe) { System.out.println(ioe.getMessage()); } } } } }; interruptor.setDaemon(true); interruptor.start(); final ByteBuffer buffer = ByteBuffer.allocate(32768); int i = 0; try { while (true) { buffer.clear(); buffer.put(newBuffer(buffer.capacity())); buffer.flip(); channel.write(buffer); System.out.print('X'); if (++i % 80 == 0) { System.out.println(); Thread.sleep(100); } } } catch (final ClosedByInterruptException cbie) { System.out.println("Closed via Thread.interrupt()"); } catch (final AsynchronousCloseException ace) { System.out.println("Closed via Channel.close()"); } } } In the above example, I'm writing to a SocketChannel, but noone is reading from the other side, so eventually the write operation hangs. This example works great when run by JDK-1.6, with the following output: Press Enter to interrupt I/O XXXX Interrupting... Closed via Thread.interrupt() — meaning that only 128k of data was written to the TCP socket's buffer. When run by JDK-1.7 (1.7.0_25-b15 and 1.7.0-u40-b37), however, the very same code bails out with an IOException: Press Enter to interrupt I/O XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXX Exception in thread "main" java.io.IOException: Broken pipe at sun.nio.ch.FileDispatcherImpl.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) at sun.nio.ch.IOUtil.write(IOUtil.java:65) at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487) at com.example.TestBlockingNio.main(TestBlockingNio.java:109) Can anyone explain this different behaviour?

    Read the article

  • Removing specific ticks from matplotlib plot

    - by Jsg91
    I'm trying to remove the origin ticks from my plot below to stop them overlapping, alternatively just moving them away from each other would also be great I tried this: xticks = ax.xaxis.get_major_ticks() xticks[0].label1.set_visible(False) yticks = ax.yaxis.get_major_ticks() yticks[0].label1.set_visible(False) However this removed the first and last ticks from the y axis like so: Does anyone have an idea about how to do this? Any help would be greatly appreciated.

    Read the article

  • Trouble with ID in NSString

    - by useboot
    I am trying to create something interesting in my application. So, I created an UILabel and I want to output new value. So, my code. NSString *test = @"13"; self.UserAge.text = @"Your age is %@", test; But it doesn't work. In Console-Command Mode I can do it with NSLog(); My result is "Your age is %@". But I need to output "Your age is 13". What do I should do with name? Sorry, if my question is easy for you. I am beginner. :) Thank you everyone who will answer on my question.

    Read the article

  • SELECT Statement without duplicate rows on the multiple join tables

    - by theBo
    I have 4 tables built with JOINS and I would like to SELECT DISTINCT rows on the setsTbl.s_id so they always show regardless if there's relational data against them or not!. This is what I have at present which displays the data but doesn't display all of but not the entire distinct row! SELECT setsTbl.s_id, setsTbl.setName, userProfilesTbl.no + ' ' + userProfilesTbl.surname AS Name, trainingTbl.t_date, userAssessmentTbl.o_id FROM userProfilesTbl LEFT OUTER JOIN userAssessmentTbl ON userProfilesTbl.UserId = userAssessmentTbl.UserId FULL OUTER JOIN trainingTbl ON userAssessmentTbl.tt_id = trainingTbl.tt_id RIGHT OUTER JOIN setsTbl ON trainingTbl.s_id = setsTbl.s_id WHERE (userProfilesTbl.st_id=@st_id AND userProfilesTbl.sh_id=@sh_id) AND (DATEPART(yyyy,t_date) = @y_date ) OR (userAssessmentTbl.o_id IS NULL) ORDER BY setName ASC, t_date ASC With this statement I get some of the rows (the ones with data against them) but as stated the s_id field does not return distinct. This following inner select statement works in part when used in SQL Query analyzer and returns pretty much the data i require s_id setName Name o_id ----- ----- ----- ------ 1 100 Barnes 2 2 100 Beardsley 3 3 101 Aldridge 1 4 102 Molby 2 5 102 Whelan 3 but not when used outside of that environment. select * from ( SELECT userProfilesTbl.serviceNo + ' ' + userProfilesTbl.surname AS Name, userProfilesTbl.st_id, userProfilesTbl.sh_id, userAssessmentTbl.o_id, setsTbl.s_id, setsTbl.setName, row_number() over ( partition by setsTbl.s_id order by setsTbl.s_id ) r FROM userProfilesTbl LEFT OUTER JOIN userAssessmentTbl ON userProfilesTbl.UserId = userAssessmentTbl.UserId FULL OUTER JOIN trainingTbl ON userAssessmentTbl.tt_id = trainingTbl.tt_id RIGHT OUTER JOIN setsTbl ON trainingTbl.s_id = setsTbl.s_id ) x where x.r = 1 Not receiving any errors just not displaying the data?

    Read the article

  • Django Auth Model Issue - AUTH_USER_MODEL Not Installed

    - by Ian Warner
    Trying to debug this error with getting a Django project running ImproperlyConfigured: AUTH_USER_MODEL refers to model 'accounts.User' that has not been installed Running python manage.py migrate Must iterate i am in no way a python or django expert - I have simply inherited someone elses project that I am trying to get running for the team here. I have followed steps to install postgres required modules including south creating database for postgres Any help appreciated on how to debug this. settings/base.py contains INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS LOCAL_APPS = ( 'apps.core', 'apps.accounts', 'apps.project_tool', 'apps.internal', 'apps.external', ) so apps.accounts exits - but it asks for AUTH_USER_MODEL = 'accounts.User' - should it be AUTH_USER_MODEL = 'apps.accounts.User'?

    Read the article

  • How to increment counters based on a printed array

    - by Sam Liew
    I managed to developed a simple board of 5x5 using random numbers and array. Big achievement for someone like me! :) Now I have to increment the counters depending on the frequency of the numbers. If the value within 0-49 is printed..then nCounter++ If the value within 50-75 is printed..then pCounter++ something like that. The problem is that I don't know how to increase the counters based on the printed board. Here is the code: #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { //Initialize Variables int randomNumber; int rows; int columns; int hdCounter =0; int hCounter = 0; int cCounter = 0; int pCounter = 0; int nCounter = 0; //Declare board size int board[5][5]; //size of board is 5 x 5 //Create the random number generator seed srand(time(NULL)); //Assign the random numbers from 1 - 25 into variable randomNumber //Create the rows for the board for ( rows = 1; rows <= 5 ; rows++ ) { //Create the colimns for the board for ( columns = 1; columns <= 5 ; columns++ ) { //Assign variable randomNumber into variable board randomNumber = rand() %100 + 1; board[rows][columns] = randomNumber; //print the board printf("%d\t", board[rows][columns]); //calculate the frequency of numbers on the printed board if (randomNumber >= 85 && randomNumber <= 100 ) hdCounter++; else if ( randomNumber >= 75 ) hCounter++; else if ( randomNumber >= 65 ) cCounter++; else if ( randomNumber >= 50 ) pCounter++; else if ( randomNumber >= 1 ) nCounter++; else continue; } //Newline after the end of 5th column. printf("\n\n"); } printf( "N \t P \t C \t H \t HD\n\n" ); printf("%d \t %d \t %d \t %d \t %d \t", nCounter, pCounter, cCounter, hCounter, hdCounter); }//end main I tried replacing randomNumber in the if-statement with board[rows][columns] but I seem to get the same undesired results.

    Read the article

  • Adding Content to a Randomized Background

    - by user2903815
    On refresh my background image changes. I need to add a header to change with each background. How would I add an h1 tag to the php. I am unfamiliar with php but I feel like this should be an easy fix. Here's my script: <script type="text/javascript"> var bgcount = 3; function changebg() { var num = Math.ceil( Math.random() * bgcount ); document.body.background = 'bgs/'+num+'.jpg'; document.body.style.backgroundRepeat = "no-repeat"; document.body.style.backgroundAttachment = "fixed"; document.body.style.backgroundSize = "cover"; } </script> Thanks!

    Read the article

  • SQL Query, return value from table with no join

    - by jdenomme19
    I'm hoping for an idea on the best way to approach what I'm trying to do. I have a table with a list of transactions. Each transactions has a PostDate in DateTime format. I have another table holding the fiscal period values. This table has the following columns; FiscalYear, FiscalMonth, StartDate, EndDate. I'm trying to write a query that will return all values from my transactions table, along with the FiscalYear and FiscalMonth of the PostDate. So I guess I'm just trying to return the FiscalYear and FiscalMonth values when the PostDate falls between the StartDate and EndDate. I've tried using a Subbuery, but I have little experience with them and kept returning an error message that the subquery was returning more than 1 value. Help would be appreciated SELECT Transactions.PostDate, Transactions.TranKey, Transactions.CustKey, (SELECT FiscalPeriod.FiscPer FROM FiscalPeriod WHERE (Transactions.PostDate > CONVERT(Datetime, FiscalPeriod.StartDate, 102)) AND (Transactions.PostDate < CONVERT(DATETIME, FiscalPeriod.EndDate, 102))) AS FisPer FROM Transactions

    Read the article

  • Align col in a bootstrap collapsable menu

    - by Grimm
    I got my hands on bootstrap recently and I'm still discovering it. I made collapsable menu from a tutorial online but now that I want to had an image on each entry of my menu that I wasn't expecting. I want my image to be always aligned to the text in the menu but it still getting on top of it. I tried to remove row and col tag and forget about the responsiveness of my menu but it still doesn't work... Here is the source code of my menu: <div id="menu" class="menu nav-collapse collapse width"> <div class="collapse-inner"> <div class="navbar navbar-inverse"> <div class="menu_titlenav nav-tabs nav-stacked"> <h3>Menu</h3> </div> </div> <div class="row well menu_entry"> <div class="span2 search_ico_ina"></div> <div class="span9 search_ent_ina">Recherche</div> </div> <div class="row well menu_entry" > <div class="span2 pro_ico_ina"></div> <div class="span9 pro_ent_ina">Espace PRO</div> </div> <div class="row well menu_entry"> <div class="span2 account_ico_ina"></div> <div class="span9 account_ent_ina">Mon Compte</div> </div> </div> </div> and the entire source: http://jsfiddle.net/Grimtork/JLFMW/

    Read the article

  • Celery tasks not works with gevent

    - by Novarg
    When i use celery + gevent for tasks that uses subprocess module i'm getting following stacktrace: Traceback (most recent call last): File "/home/venv/admin/lib/python2.7/site-packages/celery/task/trace.py", line 228, in trace_task R = retval = fun(*args, **kwargs) File "/home/venv/admin/lib/python2.7/site-packages/celery/task/trace.py", line 415, in __protected_call__ return self.run(*args, **kwargs) File "/home/webapp/admin/webadmin/apps/loggingquarantine/tasks.py", line 107, in release_mail_task res = call_external_script(popen_obj.communicate) File "/home/webapp/admin/webadmin/apps/core/helpers.py", line 42, in call_external_script return func_to_call(*args, **kwargs) File "/usr/lib64/python2.7/subprocess.py", line 740, in communicate return self._communicate(input) File "/usr/lib64/python2.7/subprocess.py", line 1257, in _communicate stdout, stderr = self._communicate_with_poll(input) File "/usr/lib64/python2.7/subprocess.py", line 1287, in _communicate_with_poll poller = select.poll() AttributeError: 'module' object has no attribute 'poll' My manage.py looks following (doing monkeypatch there): #!/usr/bin/env python from gevent import monkey import sys import os if __name__ == "__main__": if not 'celery' in sys.argv: monkey.patch_all() os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webadmin.settings") from django.core.management import execute_from_command_line sys.path.append(".") execute_from_command_line(sys.argv) Is there a reason why celery tasks act like it wasn't patched properly? p.s. strange thing that my local setup on Macos works fine while i getting such exceptions under Centos (all package versions are the same, init and config scripts too)

    Read the article

  • Unordered list appears higher than div

    - by LordArmadillo
    I am trying to create a simple page, which I normally can without any trouble. However, the unordered list appears higher up the page than the div. I do know a solution for this, however I cannot remember it. The page goes like this: <style> ul.menu { list-style-type: none; margin:150; margin-bottom:30px; padding:0; display: block; width: 708px; margin-left: auto; margin-right: auto; } li.menu { float:left; display: block; width: 118px; } a.menu:link,a.menu:visited { color:black; display:block; border:1px solid black; background-color:#FFFF00; width:118px; text-align:center; text-decoration:none; font-family:"Courier New", Courier, monospace } a.menu:hover { background-color:#FFBB11; } </style> <div id="head"> My images here & such</div> <ul class="menu"> <li class="menu"> <a class="menu">Main</a> </li> </ul> Normally I welcome suggestions to change my code, but I have a deadline today! So, quick & simple help would be appreciated! Thanks! LordArmadillo

    Read the article

  • Rewrite Mod issue

    - by Caro Fiedler
    I have the follow code: if (isset($_GET['preis']) && $_GET['preis']==="0-100-euro"){ $preis = "WHERE preis >= 0 and preis <= 100"; } elseif (isset($_GET['preis']) && $_GET['preis']==="100-200-euro"){ $preis = "WHERE preis >= 100 and preis <= 200"; } elseif (isset($_GET['preis']) && $_GET['preis']==="200-300-euro"){ $preis = "WHERE preis >= 200 and preis <= 300"; } elseif (isset($_GET['preis']) && $_GET['preis']==="300-500-euro"){ $preis = "WHERE preis >= 300 and preis <= 500"; } else { } $abfrage = "SELECT * FROM outfits $preis LIMIT $start, $eintraege_pro_seite"; $ergebnis = mysql_query($abfrage); example.com/?preis=100-200-euro works but example.com/preis-100-200-euro/ is not This is my htaccess: RewriteEngine On RewriteRule ^preis-([^-]*)/seite-([^-]*)/$ ?preis=$1&seite=$2 [L] RewriteRule ^preis-([^-]*)/$ ?preis=$1 [L] RewriteRule ^seite-([^-]*)/$ ?seite=$1 [L] I use the same rules for many other links and it works fine, but only in this case not

    Read the article

  • Empty text view message when listview is empty

    - by Blid Tounsi
    I have a ListView with an empty list catch in the XML and it works fine. How to toggle ListView Empty Text please ? This is my XML code : <?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:orientation="vertical" > <TextView android:id="@+id/empty" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/emptyList" /> <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> I'm not using a ListActivity. It s possible to do that please ?

    Read the article

  • XCode 5 says I got a duplicate, which I don't

    - by GoodMove
    The point is every time I try to run a C++ code in XCode 5 (the file s "File.cpp") xcode returns this: duplicate symbol _main ld: 1 duplicate symbol for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) And it only returns the error, when I got the following function whatever it contains: int main() { } I checked the folder, which XCode points to (where it says the duplicates are placed), but didn't find anything though. What am I supposed to do??? #include "File.h" using namespace std; void func (void){ cout << "Hello World!" << endl; }

    Read the article

  • Strange (Undefined?) Behavior of Free in C

    - by Chris Cirefice
    This is really strange... and I can't debug it (tried for about two hours, debugger starts going haywire after a while...). Anyway, I'm trying to do something really simple: Free an array of strings. The array is in the form: char **myStrings. The array elements are initialized as: myString[index] = malloc(strlen(word)); myString[index] = word; and I'm calling a function like this: free_memory(myStrings, size); where size is the length of the array (I know this is not the problem, I tested it extensively and everything except this function is working). free_memory looks like this: void free_memory(char **list, int size) { for (int i = 0; i < size; i ++) { free(list[i]); } free(list); } Now here comes the weird part. if (size> strlen(list[i])) then the program crashes. For example, imagine that I have a list of strings that looks something like this: myStrings[0] = "Some"; myStrings[1] = "random"; myStrings[2] = "strings"; And thus the length of this array is 3. If I pass this to my free_memory function, strlen(myStrings[0]) > 3 (4 3), and the program crashes. However, if I change myStrings[0] to be "So" instead, then strlen(myStrings[0]) < 3 (2 < 3) and the program does not crash. So it seems to me that free(list[i]) is actually going through the char[] that is at that location and trying to free each character, which I imagine is undefined behavior. The only reason I say this is because I can play around with the size of the first element of myStrings and make the program crash whenever I feel like it, so I'm assuming that this is the problem area. Note: I did try to debug this by stepping through the function that calls free_memory, noting any weird values and such, but the moment I step into the free_memory function, the debugger crashes, so I'm not really sure what is going on. Nothing is out of the ordinary until I enter the function, then the world explodes. Another note: I also posted the shortened version of the source for this program (not too long; Pastebin) here. I am compiling on MinGW with the c99 flag on. PS - I just thought of this. I am indeed passing numUniqueWords to the free function, and I know that this does not actually free the entire piece of memory that I allocated. I've called it both ways, that's not the issue. And I left it how I did because that is the way that I will be calling it after I get it to work in the first place, I need to revise some of my logic in that function. Source, as per request (on-site): #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include "words.h" int getNumUniqueWords(char text[], int size); int main(int argc, char* argv[]) { setvbuf(stdout, NULL, 4, _IONBF); // For Eclipse... stupid bug. --> does NOT affect the program, just the output to console! int nbr_words; char text[] = "Some - \"text, a stdin\". We'll have! also repeat? We'll also have a repeat!"; int length = sizeof(text); nbr_words = getNumUniqueWords(text, length); return 0; } void free_memory(char **list, int size) { for (int i = 0; i < size; i ++) { // You can see that printing the values is fine, as long as free is not called. // When free is called, the program will crash if (size > strlen(list[i])) //printf("Wanna free value %d w/len of %d: %s\n", i, strlen(list[i]), list[i]); free(list[i]); } free(list); } int getNumUniqueWords(char text[], int length) { int numTotalWords = 0; char *word; printf("Length: %d characters\n", length); char totalWords[length]; strcpy(totalWords, text); word = strtok(totalWords, " ,.-!?()\"0123456789"); while (word != NULL) { numTotalWords ++; printf("%s\n", word); word = strtok(NULL, " ,.-!?()\"0123456789"); } printf("Looks like we counted %d total words\n\n", numTotalWords); char *uniqueWords[numTotalWords]; char *tempWord; int wordAlreadyExists = 0; int numUniqueWords = 0; char totalWordsCopy[length]; strcpy(totalWordsCopy, text); for (int i = 0; i < numTotalWords; i++) { uniqueWords[i] = NULL; } // Tokenize until all the text is consumed. word = strtok(totalWordsCopy, " ,.-!?()\"0123456789"); while (word != NULL) { // Look through the word list for the current token. for (int j = 0; j < numTotalWords; j ++) { // Just for clarity, no real meaning. tempWord = uniqueWords[j]; // The word list is either empty or the current token is not in the list. if (tempWord == NULL) { break; } //printf("Comparing (%s) with (%s)\n", tempWord, word); // If the current token is the same as the current element in the word list, mark and break if (strcmp(tempWord, word) == 0) { printf("\nDuplicate: (%s)\n\n", word); wordAlreadyExists = 1; break; } } // Word does not exist, add it to the array. if (!wordAlreadyExists) { uniqueWords[numUniqueWords] = malloc(strlen(word)); uniqueWords[numUniqueWords] = word; numUniqueWords ++; printf("Unique: %s\n", word); } // Reset flags and continue. wordAlreadyExists = 0; word = strtok(NULL, " ,.-!?()\"0123456789"); } // Print out the array just for funsies - make sure it's working properly. for (int x = 0; x <numUniqueWords; x++) { printf("Unique list %d: %s\n", x, uniqueWords[x]); } printf("\nNumber of unique words: %d\n\n", numUniqueWords); // Right below is where things start to suck. free_memory(uniqueWords, numUniqueWords); return numUniqueWords; }

    Read the article

  • How to stop tcpdump remotely using expect from a new telnet session

    - by The CodeWriter
    I am trying to stop the tcpdump command from running on a remote terminal. If I telnet to the terminal, start tcpdump, and then send a ^c, tcpdump stops with no issues. However if I telnet to the same terminal, start tcpdump, and then exit the telnet session, when I reconnect to the same telnet session I am unable to stop tcpdump via a ^c. When I do this instead of stopping tcpdump it seems that it just quits the telnet session and tcpdump continues to run on the remote terminal. I provided my script below. Any help is greatly appreciated. #!/usr/local/bin/expect -f exp_internal 1 set timeout 30 spawn /bin/bash expect "] " send "telnet 192.168.62.133 10006\r" expect "Escape character is '^]'." send "\r" expect "# " set now [clock format [clock seconds] -format {%d_%b_%Y_%H%M%S}] set command "tcpdump -vv -i trf400 ip proto 89 -s 65535 -w /tmp/test_term420_${now}.pcp " send "$command\r" expect "tcpdump: listening on" # This works correctly. tcpdump quits and I am returned to the expected prompt send "\x03" expect "# " send "$command\r" expect "tcpdump: listening on" # Exit telnet session send -- "\x1d" expect "telnet> " send -- "q\r" expect "] " # Reconnect to telnet session send "telnet 192.168.62.133 10006\r" expect "Escape character is '^]'." send "\r" # This does not work as intended. The ^c quits the telnet session instead of stopping tcpdump send "\x03" expect "] " send "ls\r" expect "] "

    Read the article

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