Search Results

Search found 335 results on 14 pages for 'gary garside'.

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

  • Problem with between join for sqlalchemy orm relation.

    - by Gary van der Merwe
    I'm trying to create a relation that has a between join. Here is a shortish example of what I'm trying to do: #!/usr/bin/env python import sqlalchemy as sa from sqlalchemy import orm from sqlalchemy.engine.base import Engine from sqlalchemy.ext.declarative import declarative_base metadata = sa.MetaData() Base = declarative_base(metadata=metadata) engine = sa.create_engine('sqlite:///:memory:') class Network(Base): __tablename__ = "network" id = sa.Column(sa.Integer, primary_key=True) ip_net_addr_db = sa.Column('ip_net_addr', sa.Integer, index=True) ip_broadcast_addr_db = sa.Column('ip_broadcast_addr', sa.Integer, index=True) # This can be determined from the net address and the net mask, but we store # it in the db so that we can join with the address table. ip_net_mask_len = sa.Column(sa.SmallInteger) class Address(Base): __tablename__ = "address" ip_addr_db = sa.Column('ip_addr', sa.Integer, primary_key=True, index=True, unique=True) Network.addresses = orm.relation(Address, primaryjoin=Address.ip_addr_db.between( Network.ip_net_addr_db, Network.ip_broadcast_addr_db), foreign_keys=[Address.ip_addr_db]) metadata.create_all(engine) Session = orm.sessionmaker(bind=engine) Network() I you run this, you get this error: ArgumentError: Could not determine relation direction for primaryjoin condition 'address.ip_addr BETWEEN network.ip_net_addr AND network.ip_broadcast_addr', on relation Network.addresses. Do the columns in 'foreign_keys' represent only the 'foreign' columns in this join condition ? The answer to that question is Yes, but I cant figure out how to tell it that

    Read the article

  • m2crypto aes-256-cbc not working against encoded openssl files.

    - by Gary
    $ echo 'this is text' > text.1 $ openssl enc -aes-256-cbc -a -k "thisisapassword" -in text.1 -out text.enc $ openssl enc -d -aes-256-cbc -a -k "thisisapassword" -in text.enc -out text.2 $ cat text.2 this is text I can do this with openssl. Now, how do I do the same in m2crypto. Documentation is lacking this. I looked at the snv test cases, still nothing there. I found one sample, http://passingcuriosity.com/2009/aes-encryption-in-python-with-m2crypto/ (changed to aes_256_cbc), and it will encrypted/descrypt it's own strings, but it cannot decrypt anything made with openssl, and anything it encrypts isn't decryptable from openssl. I need to be able enc/dec with aes-256-cbc as have many files already encrypted with this and we have many other systems in place that also handle the aes-256-cbc output just fine. We use password phrases only, with no IV. So setting the IV to \0 * 16 makes sense, but I'm not sure if this is also part of the problem. Anyone have any working samples of doing AES 256 that is compatible with m2crypto? I will also be trying some additional libraries and seeing if they work any better.

    Read the article

  • hibernate order by association

    - by Gary Kephart
    I'm using Hibernate 3.2, and using criteria to build a query. I'd like to add and "order by" for a many-to-one association, but I don't see how that can be done. The Hibernate query would end up looking like this, I guess: select t1.a, t1.b, t1.c, t2.dd, t2.ee from t1 inner join t2 on t1.a = t2.aa order by t2.dd <-- need to add this I've tried criteria.addOrder("assnName.propertyName") but it doesn't work. I know it can be done for normal properties. Am I missing something?

    Read the article

  • Postergres could not connect to server

    - by Gary Lai
    After I did brew update and brew upgrade, my postgres got some problem. I tried to uninstall postgres and install again, but it didn't work as well. This is the error message.(I also got this error message when I try to do rake db:migrate) $ psql psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? How can I solve it? Mac version: Mountain lion. homebrew version: 0.9.3 postgres version: psql (PostgreSQL) 9.2.1 And this is what I did. 12:30 ~/D/works$ brew uninstall postgresql Uninstalling /usr/local/Cellar/postgresql/9.2.1... 12:31 ~/D/works$ brew uninstall postgresql Uninstalling /usr/local/Cellar/postgresql/9.1.4... 12:31 ~/D/works$ psql --version bash: /usr/local/bin/psql: No such file or directory 12:33 ~/D/works$ brew install postgresql ==> Downloading http://ftp.postgresql.org/pub/source/v9.2.1/postgresql-9.2.1.tar.bz2 Already downloaded: /Library/Caches/Homebrew/postgresql-9.2.1.tar.bz2 ...... ...... ==> Summary /usr/local/Cellar/postgresql/9.2.1: 2814 files, 38M, built in 2.7 minutes 12:37 ~/D/works$ initdb /usr/local/var/postgres -E utf8 The files belonging to this database system will be owned by user "laigary". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF-8". The default text search configuration will be set to "english". initdb: directory "/usr/local/var/postgres" exists but is not empty If you want to create a new database system, either remove or empty the directory "/usr/local/var/postgres" or run initdb with an argument other than "/usr/local/var/postgres". 12:39 ~/D/works$ mkdir -p ~/Library/LaunchAgents 12:39 ~/D/works$ cp /usr/local/Cellar/postgresql/9.2.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/ 12:39 ~/D/works$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist homebrew.mxcl.postgresql: Already loaded 12:39 ~/D/works$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start server starting 12:39 ~/D/works$ env ARCHFLAGS="-arch x86_64" gem install pg Building native extensions. This could take a while... Successfully installed pg-0.14.1 1 gem installed 12:42 ~/D/works$ psql --version psql (PostgreSQL) 9.2.1 12:42 ~/D/works$ psql psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

    Read the article

  • Creating a list of most popular posts of the past week - Wordpress

    - by Gary Woods
    I have created a widget for my Wordpress platform that displays the most popular posts of the week. However, there is an issue with it. It counts the most popular posts from Monday, not the past 7 days. For instance, this means that on Tuesday, it will only include posts from Tuesday and Monday. Here is my widget code: <?php class PopularWidget extends WP_Widget { function PopularWidget(){ $widget_ops = array('description' => 'Displays Popular Posts'); $control_ops = array('width' => 400, 'height' => 300); parent::WP_Widget(false,$name='ET Popular Widget',$widget_ops,$control_ops); } /* Displays the Widget in the front-end */ function widget($args, $instance){ extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? 'Popular This Week' : $instance['title']); $postsNum = empty($instance['postsNum']) ? '' : $instance['postsNum']; $show_thisweek = isset($instance['thisweek']) ? (bool) $instance['thisweek'] : false; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; ?> <?php $additional_query = $show_thisweek ? '&year=' . date('Y') . '&w=' . date('W') : ''; query_posts( 'post_type=post&posts_per_page='.$postsNum.'&orderby=comment_count&order=DESC' . $additional_query ); ?> <div class="widget-aligned"> <h3 class="box-title">Popular Articles</h3> <div class="blog-entry"> <ol> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <li><h4 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4></li> <?php endwhile; endif; wp_reset_query(); ?> </ol> </div> </div> <!-- end widget-aligned --> <div style="clear:both;"></div> <?php echo $after_widget; } /*Saves the settings. */ function update($new_instance, $old_instance){ $instance = $old_instance; $instance['title'] = stripslashes($new_instance['title']); $instance['postsNum'] = stripslashes($new_instance['postsNum']); $instance['thisweek'] = 0; if ( isset($new_instance['thisweek']) ) $instance['thisweek'] = 1; return $instance; } /*Creates the form for the widget in the back-end. */ function form($instance){ //Defaults $instance = wp_parse_args( (array) $instance, array('title'=>'Popular Posts', 'postsNum'=>'','thisweek'=>false) ); $title = htmlspecialchars($instance['title']); $postsNum = htmlspecialchars($instance['postsNum']); # Title echo '<p><label for="' . $this->get_field_id('title') . '">' . 'Title:' . '</label><input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></p>'; # Number of posts echo '<p><label for="' . $this->get_field_id('postsNum') . '">' . 'Number of posts:' . '</label><input class="widefat" id="' . $this->get_field_id('postsNum') . '" name="' . $this->get_field_name('postsNum') . '" type="text" value="' . $postsNum . '" /></p>'; ?> <input class="checkbox" type="checkbox" <?php checked($instance['thisweek'], 1) ?> id="<?php echo $this->get_field_id('thisweek'); ?>" name="<?php echo $this->get_field_name('thisweek'); ?>" /> <label for="<?php echo $this->get_field_id('thisweek'); ?>"><?php esc_html_e('Popular this week','Aggregate'); ?></label> <?php } }// end AboutMeWidget class function PopularWidgetInit() { register_widget('PopularWidget'); } add_action('widgets_init', 'PopularWidgetInit'); ?> How can I change this script so that it will count the past 7 days rather than posts from last Monday?

    Read the article

  • How do I ensure that SOAP requests from a flash client to my ASP server are coming from the flash cl

    - by Gary Benade
    I have a flash based game that has a high score system implemented with a SOAP service. There are prizes involved and I want to prevent someone from using FireBug or similar to discover the webservice path and submit fake scores. I considered using some kind of encryption on the data but am aware that someone could decompile the swf and work out how I did it. I also considered using an IP whitelist but since the incoming data will come from the users IP and not the servers that won't work. (I'm sure I'm missing something obvious here...) I know that there is a tried and tested solution for this, but I don't seem to be asking google the right questions to get to it. Any help and suggestions will be appreciated, thank you

    Read the article

  • [Iphone] - Problem in saving file using NSCoding

    - by Matte Gary
    Hi everybody, I've a problem with Iphone programming... I've a NSMutableArray containing object of type "MyClass". MyClass has some parameters, like NSNumber and NSString. I've followed the Apple Tutorial about coding and decoding object using NSCoding, but when I try to decode the file I've stored, the NSMutableArray contain object of type "MyClass", but with wrong parameters. I think i've done all I've to do (including protocol, including methods like initwithencode etc), but it's still not working... Any suggestions? Thanks a lot! And sorry for my English XD

    Read the article

  • Working with processes in C

    - by Gary
    Hi, just a quick question regarding C and processes. In my program, I create another child process and use a two-directional pipe to communicate between the child and parent. The child calls execl() to run yet another program. My question is: I want the parent to wait n amount of seconds and then check if the program that the child has run has exited (and with what status). Something like waitpid() but if the child doesn't exit in n seconds, I'd like to do something different.

    Read the article

  • Efficient splitting of elements in a field

    - by Gary
    I have a field in a text file exported from a database. The field contains addresses but sometimes they are quite long and the database allows them to contain multiple lines. When exported, the newline character gets replaced with a dollar sign like this: first part of very long address$second part of very long address$third part of very long address Not every address has multiple lines and no address contains more than three lines. The length of each line is variable. I'm massaging the data for import into MS Access which is used for a mailmerge. I want to split the field on the $ sign if it's there but if the field only contains 1 line, I want to set my two extra output fields to a zero length string so that I don't wind up with blank lines in the address when it gets printed. I have an awk file that's working correctly on all the other data in the textfile but I need to get this last bit working. I tried the below code. Aside from the fact that I get a syntax error at the else, I'm not sure this is a good way to do what I want. This is being done with gawk on Windows. BEGIN { FS = "|" } $1 != "HEADER" { if ($6 ~ /\$/) split($6, arr, "$") address = arr[1] addresstwo = arr[2] addressthree = arr[3] addressLength = length(address) addressTwoLength = length(addresstwo) addressThreeLength = length(addressthree) else { address = $6 addressLength = length($6) addresstwo = "" addressTwoLength = length(addresstwo) addressthree = "" addressThreeLength = length(addressthree) } printf("%*s\t%*s\t\%*s\n", addressLength, address, addressTwoLength, addresstwo, addressThreeLength, addressthree) }

    Read the article

  • JQuery plugin to animate overlay

    - by Gary
    I'm looking for a JQuery plugin to animate the appearance and disappearance of an overlay div. Something like what Rackspace has here: http://www.rackspacecloud.com/ After staring at the page for 30 seconds or so, a div comes sliding down from the top asking you whether you want to chat with a rep. If you ignore the div for a period of time it slides back up. I know I could hand code all this using timers and animate() and such, but hoping someone has done it for us already. Any ideas?

    Read the article

  • algorithm to find overlaps

    - by Gary
    Hey, Basically I've got some structs of type Ship which are going to go on a board which can have a variable width and height. The information about the ships is read in from a file, and I just need to know the best way to make sure that none of the ships overlap. Here is the structure of Ship: int x // x position of first part of ship int y // y position of first part of ship char dir // direction of the ship, either 'N','S','E' or 'W' int length // length of the ship Also, what would be a good way to handle the directions. Something cleaner than using a switch statement and using a different condition for each direction. Any help would be greatly appreciated!

    Read the article

  • Find what unknown function does in C using gdb

    - by Gary
    Hi, I have a function m(int i, char c) which takes and returns a char between "-abc...xyz" and also takes an integer i. Basically I have no way to see the source code of the function but can call it and get the return value. Using gdb/C, what's the best way to decipher what the function actually does? I've tried looking for patterns using consecutive chars and integer inputs but have come up with nothing yet. If it helps, here are some results of testing the return values, with the first two bits being the arguments and the last bit being the return value: 0 a i 0 b l 0 c t 0 d x 0 e f 0 f v 1 a q 1 b i 1 c y 1 d e 2 a a 2 b y 2 c f 2 d n

    Read the article

  • How do I delete a file from depot, but leave local copy in tact?

    - by Gary
    I'm trying to learn Perforce and want to delete a file from the depot(easy to do with p4 delete, p4 submit), but that deletes it from the client machine dir structure as well. I want to keep my local file in my directory intact. The only way I can see to do this would be to move it out of the hierarchy that is under Perforce control before deleting. I was able to get my file back by syncing an earlier version. Maybe I set up my client workspace wrong? Or am I misunderstanding a fundamental concept of source control? The client workspace is /home/user and I did it this way so I could add any file under my home directory without getting an error about the file not being under client's root. FYI - Linux client and server running P4D/LINUX26X86/2009.1/222893 (2009/11/12) Any advice appreciated. Thanks.

    Read the article

  • C# - How can i open a second winform asynchronously but still behave as a child to the parent form?

    - by Gary Willoughby
    I am creating an application and i would like to implement a progress window that appears when a lengthy process is taking place. I've created a standard windows form project to which i've created my app using the default form. I've also created a new form to use as a progress window. The problem arises when i open the progress window (in a function) using: ProgressWindow.ShowDialog(); When this command is encountered, the focus is on the progress window and i assume it's now the window who's mainloop is being processed for events. The downside is it blocks the execution of my lengthy operation in the main form. If i open the progress window using: ProgressWindow.Show(); Then the window opens correctly and now doesn't block the execution of the main form but it doesn't act as a child (modal) window should, i.e. allows the main form to be selected, is not centered on the parent, etc.. Any ideas how i can open a new window but continue processing in the main form?

    Read the article

  • Update mapping table in Linq

    - by Gary McGill
    I have a table Customers with a CustomerId field, and a table of Publications with a PublicationId field. Finally, I have a mapping table CustomersPublications that records which publications a customer can access - it has two fields: CustomerId field PublicationId. For a given customer, I want to update the CustomersPublications table based on a list of publication ids. I want to remove records in CustomersPublications where the PublicationId is not in the list, and add new records where the PublicationId is in the list but not already in the table. This would be easy in SQL, but I can't figure out how to do it in Linq. For the delete part, I tried: var recordsToDelete = dataContext.CustomersPublications.Where ( cp => (cp.CustomerId == customerId) && ! publicationIds.Contains(cp.PublicationId) ); dataContext.CustomersPublications.DeleteAllOnSubmit(recordsToDelete); ... but that didn't work. I got an error: System.NotSupportedException: Method 'Boolean Contains(Int32)' has no supported translation to SQL So, I tried using Any(), as follows: var recordsToDelete = dataContext.CustomersPublications.Where ( cp => (cp.CustomerId == customerId) && ! publicationIds.Any(p => p == cp.PublicationId) ); ... and this just gives me another error: System.NotSupportedException: Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator Any pointers? [I have to say, I find Linq baffling (and frustrating) for all but the simplest queries. Better error messages would help!]

    Read the article

  • Can I use the auto-generated Linq-to-SQL entity classes in 'disconnected' mode?

    - by Gary McGill
    Suppose I have an automatically-generated Employee class based on the Employees table in my database. Now suppose that I want to pass employee data to a ShowAges method that will print out name & age for a list of employees. I'll retrieve the data for a given set of employees via a linq query, which will return me a set of Employee instances. I can then pass the Employee instances to the ShowAges method, which can access the Name & Age fields to get the data it needs. However, because my Employees table has relationships with various other tables in my database, my Employee class also has a Department field, a Manager field, etc. that provide access to related records in those other tables. If the ShowAges method were to invoke any of those methods, this would cause lots more data to be fetched from the database, on-demand. I want to be sure that the ShowAges method only uses the data I have already fetched for it, but I really don't want to have to go to the trouble of defining a new class which replicates the Employee class but has fewer methods. (In my real-world scenario, the class would have to be considerably more complex than the Employee class described here; it would have several 'joined' classes that do need to be populated, and others that don't). Is there a way to 'switch off' or 'disconnect' the Employees instances so that an attempt to access any property or related object that's not already populated will raise an exception? If not, then I assume that since this must be a common requirement, there might be an already-established pattern for doing this sort of thing?

    Read the article

  • Add wordwrap to decoded json text

    - by Gary
    Hi, I am using a simple script on my PHP webpage to decode and output JSON as text. However, what ever I try I can't get it to wordwrap the output. $file = file_get_contents('sample.txt'); $out = (json_decode($file)); echo $out->mainText; How can I get this script to wordwrap at 600 characters without chopping words in half? If possible, can you show me the whole script please as I am slowly learning. Thanks

    Read the article

  • Cocoa Core Data - Efficient Related Entities Counts

    - by Gary
    I am working on my first iPhone application and I've hit a wall. I'm trying to develop a 'statistics' page for a three entity relationship. My entities are the following: Department - Name, Address, Building, etc. People - Name, Gender (BOOL), Phone, etc If I have fetched a specific department how do I filter those results and only return people that are Male (Gender == 0)? If I do NSLog(@"%d", [department.people count]); I get the correct number of people in that department so I know I'm in the neighborhood. I know I could re-fetch and modify the predicate each time but with 20+ stats in my app that seems inefficient. Thanks for any advice!

    Read the article

  • INSERT INTO in MS Access 2010 SOMETIMES GETS ERROR: 3073 Operation must use an updateable query

    - by Gary
    I get the ERROR: 3073 Operation must use an updateable query SOMETIMES, while performing an INSERT statment. I have no problem on my windows 7 PC, but the person I am writing this for sometimes gets the error. She also has MS Access 2010 on Windows 7. As I said I have never got it on my PC, and she only gets it sometimes. The code will insert a number of rows and then through the error, and other times not through the erro at all. The error occurs if I have the code and data in one .mdb file or seperate files. Here a snippet of code: OrderHdrInsertStmnt = " INSERT INTO ORDER_HDR " _ & "(ORDER_ID, SOURCE_CODE, ORDER_DATE, SHIP_FNAME, SHIP_LNAME, SHIP_EMAIL, SHIP_COMP, SHIP_PHONE, SHIP_ADDR, SHIP_CITY, SHIP_STATE, SHIP_ZIP, SHIP_CNTRY, " _ & " BILL_FNAME, BILL_LNAME, BILL_EMAIL, BILL_COMP, BILL_PHONE, BILL_ADDR, BILL_CITY, BILL_STATE, BILL_ZIP, BILL_CNTRY, " _ & " TAX, SHIPPING, TOTAL, MOD_DATE, INSERT_DATE) " _ & " VALUES (" _ & "'" & OrderId & "','" & SourceCode & "','" & Orderdate & "','" & ShipFName & "','" & ShipLName & "','" & ShipEmail & "','" & ShipComp & "','" & ShipPhone & "','" & ShipAddr & "','" & ShipCity & "','" & ShipState & "','" & ShipZip & "','" & ShipCntry _ & "','" & BillFName & "','" & BillLName & "','" & BillEmail & "','" & BillComp & "','" & BillPhone & "','" & BillAddr & "','" & BillCity & "','" & BillState & "','" & BillZip & "','" & BillCntry _ & "','" & OrderTax & "','" & OrderShipping & "','" & OrderTotal & "','" & ImportDate & "','" & ImportDate & "');" then I use dbsCurrent.Execute OrderHdrInsertStmnt, dbFailOnError Any assistance would be great!

    Read the article

  • Double Buffering for Game objects, what's a nice clean generic C++ way?

    - by Gary
    This is in C++. So, I'm starting from scratch writing a game engine for fun and learning from the ground up. One of the ideas I want to implement is to have game object state (a struct) be double-buffered. For instance, I can have subsystems updating the new game object data while a render thread is rendering from the old data by guaranteeing there is a consistent state stored within the game object (the data from last time). After rendering of old and updating of new is finished, I can swap buffers and do it again. Question is, what's a good forward-looking and generic OOP way to expose this to my classes while trying to hide implementation details as much as possible? Would like to know your thoughts and considerations. I was thinking operator overloading could be used, but how do I overload assign for a templated class's member within my buffer class? for instance, I think this is an example of what I want: doublebuffer<Vector3> data; data.x=5; //would write to the member x within the new buffer int a=data.x; //would read from the old buffer's x member data.x+=1; //I guess this shouldn't be allowed If this is possible, I could choose to enable or disable double-buffering structs without changing much code. This is what I was considering: template <class T> class doublebuffer{ T T1; T T2; T * current=T1; T * old=T2; public: doublebuffer(); ~doublebuffer(); void swap(); operator=()?... }; and a game object would be like this: struct MyObjectData{ int x; float afloat; } class MyObject: public Node { doublebuffer<MyObjectData> data; functions... } What I have right now is functions that return pointers to the old and new buffer, and I guess any classes that use them have to be aware of this. Is there a better way?

    Read the article

  • Quick question. Html.ActionLink and creating Internal Links ( #home, #about, etc. )

    - by Gary '-'
    Hi there, quick question... How can I best create internal links? This is the markup I want to achieve: <h3>Title</h3> <ul> <li><a href="#prod1">Product 1</li> <li><a href="#prod2">Product 2</li> <li><a href="#prod3">Product 3</li> ... <li><a href="#prod100">Product 100</li> </ul> <div id="prod1"> <!-- content here --> </div> Using MVC 2 I'm using, what's the best Html Helper to use? <h3><%= Html.Encode(Model.Title) %> <ul> <% foreach ( var item in Model.Categories ) {%> <li><%= Html.RouteLink( item.Description, ???? ) %></li> <%} %> </ul> What's the best way to get a url to an internal link? String.Format a link from scratch? There's gotta be a better way.

    Read the article

  • resizing an array with C

    - by Gary
    So I need to have an array of structs in a game I'm making - but I don't want to limit the array to a fixed size. I'm told there is a way to use realloc to make the array bigger when it needs to, but can't find any working examples of this. Could someone please show me how to do this? Thanks!

    Read the article

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