Search Results

Search found 133 results on 6 pages for 'casey'.

Page 4/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Mathematica - Import CSV and process columns?

    - by Casey
    I have a CSV file that is formatted like: 0.0023709,8.5752e-007,4.847e-008 and I would like to import it into Mathematica and then have each column separated into a list so I can do some math on the selected column. I know I can import the data with: Import["data.csv"] then I can separate the columns with this: StringSplit[data[[1, 1]], ","] which gives: {"0.0023709", "8.5752e-007", "4.847e-008"} The problem now is that I don't know how to get the data into individual lists and also Mathematica does not accept scientific notation in the form 8.5e-007. Any help in how to break the data into columns and format the scientific notation would be great. Thanks in advance.

    Read the article

  • How to draw RTL text (Arabic) onto a Bitmap and have it ordered properly?

    - by Casey
    I'm trying to draw Arabic text onto a Bitmap for display: Bitmap img = Bitmap.createBitmap( (int) f+100, 300, Config.RGB_565); Canvas c = new Canvas(); c.setBitmap( img ); mFace = Typeface.createFromAsset(getAssets(),"DejaVuSansCondensed.ttf"); mPaint.setTypeface(mFace); content = "????"; content = ArabicUtilities.reshape( content ); System.out.println("Drawing text: " + content); c.drawText(content, 30, 30, mPaint); The ArabicUtilities class is a tool to reshape the unicode text so the letters are connected. see: http://github.com/agawish/Better-Arabic-Reshaper/ However, the bitmap that is generated looks like this: When it should look like ???? I believe the issue is because, unlike a TextView, the Bitmap class is not BiDi aware, so it draws the letters from left to write. Try as I might, I can't figure out how to draw the text in the correct order.

    Read the article

  • Is there a way in Sphinx/Pygments to emphasize one or more lines of code in literal includes?

    - by Casey
    In some sphinx docs I am writing, I am including code samples from an ancillary file like so: .. literalinclude:: mymodule.py :pyobject: MyClass :linenos: This particular doc is a tutorial, where the classes are build up step by step. What I would like to do is include the entire class or a single method, and emphasize only the lines of interest to that section. That way the context is preserved but the interesting parts are obvious at a glance. Right now I have resorted to just referring to line numbers in the text, which is ok, but far from ideal. Looking at the docs and code for sphinx and pygments I don't find an obvious way to do this. I'm not opposed to patching them or doing something tricky in conf.py, but I wondered if anyone had solved this.

    Read the article

  • SQL Query to delete oldest rows over a certain row count?

    - by Casey
    I have a table that contains log entries for a program I'm writing. I'm looking for ideas on an SQL query (I'm using SQL Server Express 2005) that will keep the newest X number of records, and delete the rest. I have a datetime column that is a timestamp for the log entry. I figure something like the following would work, but I'm not sure of the performance with the IN clause for larger numbers of records. Performance isn't critical, but I might as well do the best I can the first time. DELETE FROM MyTable WHERE PrimaryKey NOT IN (SELECT TOP 10,000 PrimaryKey FROM MyTable ORDER BY TimeStamp DESC)

    Read the article

  • How to copy an array of char pointers with a larger list of char pointers?

    - by Casey Link
    My function is being passed a struct containing, among other things, a NULL terminated array of pointers to words making up a command with arguments. I'm performing a glob match on the list of arguments, to expand them into a full list of files, then I want to replace the passed argument array with the new expanded one. The globbing is working fine, that is, g.gl_pathv is populated with the list of expected files. However, I am having trouble copying this array into the struct I was given. #include <glob.h> struct command { char **argv; // other fields... } void myFunction( struct command * cmd ) { char **p = cmd->argv; char* program = *p++; // save the program name (e.g 'ls', and increment to the first argument glob_t g; memset(&g, 0, sizeof(g)); int res = glob(*p, 0, NULL, &g); *p++ // increment while (*p) { glob(*p++, GLOB_APPEND, NULL, &g); // append the matches } // here i want to replace cmd->argv with the expanded g.gl_pathv memcpy(cmd->argv, g.gl_pathv, g.gl_pathc ); // this doesn't work globfree(&g); }

    Read the article

  • Traceroute comparison and statistics

    - by ben-casey
    I have a number of traceroutes that i need to compare against each other but i dont know the best way to do it, ive been told that hash maps are a good technique but i dont know how to implement them on my code. so far i have: FileInputStream fstream = new FileInputStream("traceroute.log"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; // reads lines in while ((strLine = br.readLine()) != null) { System.out.println(strLine); } and the output looks like this: Wed Mar 31 01:00:03 BST 2010 traceroute to www.bbc.co.uk (212.58.251.195), 30 hops max, 40 byte packets 1 139.222.0.1 (139.222.0.1) 0.873 ms 1.074 ms 1.162 ms 2 core-from-cmp.uea.ac.uk (10.0.0.1) 0.312 ms 0.350 ms 0.463 ms 3 ueaha1btm-from-uea1 (172.16.0.34) 0.791 ms 0.772 ms 1.238 ms 4 bound-from-ueahatop.uea.ac.uk (193.62.92.71) 5.094 ms 4.451 ms 4.441 ms 5 gi0-3.norw-rbr1.eastnet.ja.net (193.60.0.21) 4.426 ms 5.014 ms 4.389 ms 6 gi3-0-2.chel-rbr1.eastnet.ja.net (193.63.107.114) 6.055 ms 6.039 ms * 7 lond-sbr1.ja.net (146.97.40.45) 6.994 ms 7.493 ms 7.457 ms 8 so-6-0-0.lond-sbr4.ja.net (146.97.33.154) 8.206 ms 8.187 ms 8.234 ms 9 po1.lond-ban4.ja.net (146.97.35.110) 8.673 ms 6.294 ms 7.668 ms 10 bbc.lond-sbr4.ja.net (193.62.157.178) 6.303 ms 8.118 ms 8.107 ms 11 212.58.238.153 (212.58.238.153) 6.245 ms 8.066 ms 6.541 ms 12 212.58.239.62 (212.58.239.62) 7.023 ms 8.419 ms 7.068 ms what i need to do is compare this trace against another one just like it and look for the changes and time differences etc, then print a stats page.

    Read the article

  • Drawing Quadratic Bezier circles with a given radius: how to determine control points

    - by Casey
    Just to clarify; the code below works, but I don't understand where the formula for the variable "controlRadius" comes from. I wrote this function by dissecting an example I found elsewhere, but I can't find any explanation and the original code comments were not able to be translated. Thanks in advance //returns an array of quadratic Bezier segments public static function generateCircularQuadraticBezierSegments(radius:Number, numControlPoints:uint, centerX:Number, centerY:Number):Array { var segments:Array = []; var arcLength:Number = 2 * Math.PI / numControlPoints; var controlRadius:Number; var segment:QuadraticBezierSegment; for (var i:int = 0; i < numControlPoints; i++) { var startX:Number = centerX + radius * Math.cos(arcLength * i); var startY:Number = centerY + radius * Math.sin(arcLength * i); //control radius formula //where does it come from, why does it work? controlRadius = radius / Math.cos(arcLength * .5); //the control point is plotted halfway between the arcLength and uses the control radius var controlX:Number = centerX + controlRadius * Math.cos(arcLength * (i + 1) - arcLength * .5); var controlY:Number = centerY + controlRadius * Math.sin(arcLength * (i + 1) - arcLength * .5); var endX:Number = centerX + radius * Math.cos(arcLength * (i + 1)); var endY:Number = centerY + radius * Math.sin(arcLength * (i + 1)); segment = new QuadraticBezierSegment(new Point(startX, startY), new Point(controlX, controlY), new Point(endX, endY)); segments.push(segment); } return segments; }

    Read the article

  • Using GCC (MinGW) to compile OpenGL on Windows

    - by Casey
    I've searched on google and haven't been able to come up with a solution. I would like to compile some OpenGL programming using GCC. In the GL folder in GCC I have the following headers: gl.h glext.h glu.h Then in my system32 file I have the following .dll opengl32.dll glu32.dll glut32.dll If I wanted to write a simple OpenGL "Hello World" and link and compile with GCC, what is the correct process? I'm attempting to use this code: #include <GL/gl.h> #include <GL/glut.h> void display() { glClear(GL_COLOR_BUFFER_BIT); glFlush(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitWindowSize(512,512); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutCreateWindow("The glut hello world program"); glutDisplayFunc(display); glClearColor(0.0, 0.0, 0.0, 1.0); glutMainLoop(); // Infinite event loop return 0; } Thank you in advance for the help.

    Read the article

  • complex web forms and javascript

    - by Casey
    I need to create a few data heavy complicated forms. Currently, the information is being entered into a spread sheet, but the users will need to enter the information into the online form where it will be saved to a database. The problem is that the business users currently using the spread sheet aren't going to want to use the online application if it isn't as easy as entering the information into the spread sheet. This is further complicated in that the information they are entering into the spread sheet is represented by three different DB tables where one "object" is composed of two of the others. I would prefer to not have them have to go through multiple forms. Some of what I have been thinking is: Use of auto complete where possible Hiding/removing form fields dynamically possible wizard style page flow?? I've been googling for other data heavy web forms but can't seem to really find any good examples. I am familiar with jQuery and prototypejs and have also tried googling for frameworks designed for data heavy applications but didn't come up with anything. Any thoughts? Thanks.

    Read the article

  • Parsing xml file that comes in as one object per line

    - by Casey
    I haven't been here in so long, I forgot my prior account! Anyways, I am working on parsing an xml document that comes in ugly. It is for banking statements. Each line is a <statement>all tags</statement>. Now, what I need to do is read this file in, and parse the XML document at the same time, while formatting it more human readable too. Point beeing, Original input looks like this: <statement><accountHeader><fiAddress></fiAddress><accountNumber></accountNumber><startDate>20140101</startDate><endDate>20140228</endDate><statementGroup>1</statementGroup><sortOption>0</sortOption><memberBranchCode>1</memberBranchCode><memberName></memberName><jointOwner1Name></jointOwner1Name><jointOwner2Name></jointOwner2Name></summary></statement> <statement><accountHeader><fiAddress></fiAddress><accountNumber></accountNumber><startDate>20140101</startDate><endDate>20140228</endDate><statementGroup>1</statementGroup><sortOption>0</sortOption><memberBranchCode>1</memberBranchCode><memberName></memberName><jointOwner1Name></jointOwner1Name><jointOwner2Name></jointOwner2Name></summary></statement> <statement><accountHeader><fiAddress></fiAddress><accountNumber></accountNumber><startDate>20140101</startDate><endDate>20140228</endDate><statementGroup>1</statementGroup><sortOption>0</sortOption><memberBranchCode>1</memberBranchCode><memberName></memberName><jointOwner1Name></jointOwner1Name><jointOwner2Name></jointOwner2Name></summary></statement> I need the final output to be as follows: <statement> <name></name> <address></address> </statement> This is fine and dandy. I am using the following "very slow considering 5.1 million lines, 254k data file, and about 60k statements takes around 8 minutes". foreach(String item in lines) { XElement xElement = XElement.Parse(item); sr.WriteLine(xElement.ToString().Trim()); } Then when the file is formatted this is what sucks. I need to check every single tag in transaction elements, and if a tag is missing that could be there, I have to fill it in. Our designer software will default prior values in if a tag is possible, and the current objects does not have. It defaults in the value of a prior one that was not Null. "I know, and they swear up and down it is not a bug... ok?" So, that is also taking about 5 to 10 minutes. I need to break all this down, and find a faster method for working with the initial XML. This is a preprocess action, and cannot take that long if not necessary. It just seems redundant. Is there a better way to parse the XML, or is this the best I can do? I parse the XML, write to a temp file, and then read that file in, to the output file inserting the missing tags. 2 IO runs for one process. Yuck.

    Read the article

  • Simple jQuery toggle() and return false inside click()

    - by Casey Stark
    I'm mostly a djangonaut and phper, but I'm getting javascript development. I've been looking at this very simple block for a feedback widget on a page. The code is pretty self-explanatory. <a id="feedback-widget-toggle" href="[feedback_url]">Feedback</a> <div id="feedback-widget"> <form method="POST" action="[form_url]"> ... </form> </div> <script type="text/javascript"> $(document).ready(function() { $("#feedback-widget-toggle").click(function() { $("#feedback-widget").toggle("slide", {}, 500); return false; }); }); </script> It's really simple. So simple that I feel pretty dumb for this one. The jQuery is just supposed to disable the link and slide out the feedback-widget div. That's it. I'm new to jQuery, so it's probably some very simple syntax error that I'm not sure how to debug well enough. Thanks.

    Read the article

  • Why does Python Array Module Process Strings and Lists Differently?

    - by Casey
    I'm having trouble understanding the result of the following statements: >>> from array import array >>> array('L',[0xff,0xff,0xff,0xff]) array('L', [255L, 255L, 255L, 255L]) >>> from array import array >>> array('L','\xff\xff\xff\xff') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: string length not a multiple of item size

    Read the article

  • Should I return an NSMutableString in a method that returns NSString

    - by Casey Marshall
    Ok, so I have a method that takes an NSString as input, does an operation on the contents of this string, and returns the processed string. So the declaration is: - (NSString *) processString: (NSString *) str; The question: should I just return the NSMutableString instance that I used as my "work" buffer, or should I create a new NSString around the mutable one, and return that? So should I do this: - (NSString *) processString: (NSString *) str { NSMutableString *work = [NSMutableString stringWithString: str]; // process 'work' return work; } Or this: - (NSString *) processString: (NSString *) str { NSMutableString *work = [NSMutableString stringWithString: str]; // process 'work' return [NSString stringWithString: work]; // or [work stringValue]? } The second one makes another copy of the string I'm returning, unless NSString does smart things like copy-on-modify. But the first one is returning something the caller could, in theory, go and modify later. I don't care if they do that, since the string is theirs. But are there valid reasons for preferring the latter form over the former? And, is either stringWithString or stringValue preferred over the other?

    Read the article

  • recommendations for firestorm dao replacement

    - by Casey
    I have taken over some code that has been using the Firestorm DAO code generator from CodeFutures. I believe that the license for this is going to be up soon, and was wondering if anyone could recommend any alternatives, open source or not, so that I can get an idea of what's out there to better make a decision.

    Read the article

  • DAO design pattern and using it across multiple tables

    - by Casey
    I'm looking for feedback on the Data Access Object design pattern and using it when you have to access data across multiple tables. It seems like that pattern, which has a DAO for each table along with a Data Transfer Object (DTO) that represents a single row, isn't too useful for when dealing with data from multiple tables. I was thinking about creating a composite DAO and corresponding DTO that would return the result of, let's say performing a join on two tables. This way I can use SQL to grab all the data instead of first grabbing data from one using one DAO and than the second table using the second DAO, and than composing them together in Java. Is there a better solution? And no, I'm not able to move to Hibernate or another ORM tool at the moment. Just straight JDBC for this project.

    Read the article

  • How to overwrite an array of char pointers with a larger list of char pointers?

    - by Casey
    My function is being passed a struct containing, among other things, a NULL terminated array of pointers to words making up a command with arguments. I'm performing a glob match on the list of arguments, to expand them into a full list of files, then I want to replace the passed argument array with the new expanded one. The globbing is working fine, that is, g.gl_pathv is populated with the list of expected files. However, I am having trouble copying this array into the struct I was given. #include <glob.h> struct command { char **argv; // other fields... } void myFunction( struct command * cmd ) { char **p = cmd->argv; char* program = *p++; // save the program name (e.g 'ls', and increment to the first argument glob_t g; memset(&g, 0, sizeof(g)); g.gl_offs = 1; int res = glob(*p++, GLOB_DOOFFS, NULL, &g); glob_handle_res(res); while (*p) { res = glob(*p, GLOB_DOOFFS | GLOB_APPEND, NULL, &g); glob_handle_res(res); } if( g.gl_pathc <= 0 ) { globfree(&g); } cmd->argv = malloc((g.gl_pathc + g.gl_offs) * sizeof *cmd->argv); if (cmd->argv == NULL) { sys_fatal_error("pattern_expand: malloc failed\n");} // copy over the arguments size_t i = g.gl_offs; for (; i < g.gl_pathc + g.gl_offs; ++i) cmd->argv[i] = strdup(g.gl_pathv[i]); // insert the original program name cmd->argv[0] = strdup(program); ** cmd->argv[g.gl_pathc + g.gl_offs] = 0; ** globfree(&g); } void command_free(struct esh_command * cmd) { char ** p = cmd->argv; while (*p) { free(*p++); // Segfaults here, was it already freed? } free(cmd->argv); free(cmd); } Edit 1: Also, I realized I need to stick program back in there as cmd-argv[0] Edit 2: Added call to calloc Edit 3: Edit mem management with tips from Alok Edit 4: More tips from alok Edit 5: Almost working.. the app segfaults when freeing the command struct Finally: Seems like I was missing the terminating NULL, so adding the line: cmd->argv[g.gl_pathc + g.gl_offs] = 0; seemed to make it work.

    Read the article

  • Flash builder 4 - change output filename using external build-config.xml (not Ant)

    - by Casey
    I'm trying to change the output filename with a config file loaded via the compiler option -load-config. It looks like this in my compiler arguments: -load-config+=build-config.xml. I've tried the following: <flex-config> <o>absolute/path/to/filename</o> </flex-config> and <flex-config> <output>absolute/path/to/filename</output> </flex-config> and <flex-config> <compiler> <o>absolute/path/to/filename</o> </compiler> </flex-config> and <flex-config> <compiler> <output>absolute/path/to/filename</output> </compiler> </flex-config> but none have worked. I'm on a PC using Flash Builder 4. Has anyone else done this? Also, ideally, I want to use a relative path instead of absolute. I can't get this to work either, even if I do so in the "additional compiler arguments" field of the Project configuration. Thanks in advance!

    Read the article

  • Facebook JS SDK FB.logout() doesn't terminate user session

    - by Casey Flynn
    I'm attempting to log a user out of facebook with the Facebook JS SDK, however calling: FB.logout(function(response){ console.log(response); }); returns: response.status == "connected" And only after refreshing the page does the SDK realize that the session has ended. Anyone know what could be causing this behavior? This code previously worked in my application and has recently started behaving this way. Another example using FireBug:

    Read the article

  • Is it possible to restrict instantiation of an object to only one other (parent) object in VB.NET?

    - by Casey
    VB 2008 .NET 3.5 Suppose we have two classes, Order and OrderItem, that represent some type of online ordering system. OrderItem represents a single line item in an Order. One Order can contain multiple OrderItems, in the form of a List(of OrderItem). Public Class Order Public Property MyOrderItems() as List(of OrderItem) End Property End Class It makes sense that an OrderItem should not exist without an Order. In other words, an OrderItem class should not be able to be instantiated on its own, it should be dependent on an Order class to contain it and instantiate it. However, the OrderItem should be public in scope so that it's properties are accessible to other objects. So, the requirements for OrderItem are: Can not be instantiated as a stand alone object; requires Order to exist. Must be public so that any other object can access it's properties/methods through the Order object. e.g. Order.OrderItem(0).ProductID. OrderItem should be able to be passed to other subs/functions that will operate on it. How can I achieve these goals? Is there a better approach?

    Read the article

  • How do you Remove an Invalid Remote Branch Reference from Git?

    - by Casey
    In my current repo I have the following output: $ git branch -a * master remotes/origin/master remotes/public/master I want to delete 'remotes/public/master' from the branch list: $ git branch -d remotes/public/master error: branch 'remotes/public/master' not found. Also, the output of 'git remote' is strange, since it does not list 'public': $ git remote show origin How can I delete 'remotes/public/master' from the branch list? Update, tried the 'git push' command: $ git push public :master fatal: 'public' does not appear to be a git repository fatal: The remote end hung up unexpectedly Solution: The accepted answer had the solution at the bottom! git gc --prune=now

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >