Search Results

Search found 977 results on 40 pages for 'sean brad'.

Page 19/40 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • NoSuchMethodError in Java using XStream

    - by Brad Germain
    I'm trying to save a database into a file using XStream and then open it again later using XStream and deserialize it back into the objects it was in previously. The database consists of an arraylist of tables, which consists of an arraylist of a data class where the data class contains an arraylist of objects. I'm basically trying to create an sql compiler. I'm currently getting a java.lang.NoSuchMethodError because of the last line in the load method. Here's what I have: Save Method public void save(Database DB){ File file = new File(DB.getName().toUpperCase() + ".xml"); //Test sample DB.createTable("TBL1(character(a));"); DB.tables.getTable("TBL1").rows.add(new DataList()); DB.tables.getTable("TBL1").rows.getRow(0).add(10); XStream xstream = new XStream(); //Database xstream.alias("Database", Database.class); //Tables xstream.alias("Table", Table.class); //Rows xstream.alias("Row", DataList.class); //Data //xstream.alias("Data", Object.class); //String xml = xstream.toXML(DB); Writer writer = null; try { writer = new FileWriter(file); writer.write(xstream.toXML(DB)); writer.close(); } catch (IOException e) { e.printStackTrace(); } } Load Method public void Load(String dbName){ XStream xstream = new XStream(); BufferedReader br; StringBuffer buff = null; try { br = new BufferedReader(new FileReader(dbName + ".xml")); buff = new StringBuffer(); String line; while((line = br.readLine()) != null){ buff.append(line); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } database = (Database)xstream.fromXML(buff.toString()); }

    Read the article

  • How to use bundler gem binaries in path

    - by Sean Chambers
    I just started using bundler for gem packaging in vendor/. The problem is with certain gems (like rspec and cucumber) that have binaries. The binary path that is under my_app/vendor/gems/ruby/1.8/...cucumber-0.6.2/bin/ is not in my path, therefore when I go to run cucumber i get command cannot be found. What is the easiest way to execute the bundled gem binaries from within the app rather than adding a large number of folders to my path? Thanks

    Read the article

  • Using perl to parse a file and insert specific values into a database

    - by Sean
    Disclaimer: I'm a newbie at scripting in perl, this is partially a learning exercise (but still a project for work). Also, I have a much stronger grasp on shell scripting, so my examples will likely be formatted in that mindset (but I would like to create them in perl). Sorry in advance for my verbosity, I want to make sure I am at least marginally clear in getting my point across I have a text file (a reference guide) that is a Word document converted to text then swapped from Windows to UNIX format in Notepad++. The file is uniform in that each section of the file had the same fields/formatting/tables. What I have planned to do, in a basic way is grab each section, keyed by unique batch job names and place all of the values into a database (or maybe just an excel file) so all the fields can be searched/edited for each job much easier than in the word file and possibly create a web interface later on. So what I want to do is grab each section by doing something like: sed -n '/job_name_1_regex/,/job_name_2_regex/' file.txt --how would this be formatted within a perl script? (grab the section in total, then break it down further from there) To read the file in the script I have open FORMAT_FILE, 'test_format.txt'; and then use foreach $line (<FORMAT_FILE>) to parse the file line by line. --is there a better way? My next problem is that since I converted from a word doc with tables, which looks like: Table Heading 1 Table Heading 2 Heading 1/Value 1 Heading 2/Value 1 Heading 1/Value 2 Heading 2/Value 2 but the text file it looks like: Table Heading 1 Table Heading 2Heading 1/Value 1Heading 1/Value 2Heading 2/Value 1Heading 2/Value 2 So I want to have "Heading 1" and "Heading 2" as a columns name and then put the respective values there. I just am not sure how to get the values in relation to the heading from the text file. The values of Heading 1 will always be the line number of Heading 1 plus 2 (Heading 1, Heading 2, Values for heading 1). I know this can be done in awk/sed pretty easily, just not sure how to address it inside a perl script. After I have all the right values and such, linking it up to a database may be an issue as well, I haven't started looking at the way perl interacts with DBs yet. Sorry if this is a bit scatterbrained...it's still not fully formed in my head.

    Read the article

  • VB.Net how to wait for a different form to close before continuing on.

    - by Sean P
    I have a little log in screen that pops up if a user selects a certain item on my main form. How do I get my code to stop executing til my log in form closes? This is what I am doing so far. Basically i want o execute the code after MyLogin closes. BMSSplash.MyLogin.Show() If isLoggedIn Then BMSSplash.MyBuddy.Show() Cursor.Current = Cursors.WaitCursor End If

    Read the article

  • rails override default getter for a relationship (belongs_to)

    - by brad
    So I know how to override the default getters for attributes of an ActiveRecord object using def custom_getter return self[:custom_getter] || some_default_value end I'm trying to achieve the same thing however for a belongs to association. For instance. class Foo < AR belongs_to :bar def bar return self[:bar] || Bar.last end end class Bar < AR has_one :foo end When I say: f = Foo.last I'd like to have the method f.bar return the last Bar, rather than nil if that association doesn't exist yet. This doesn't work however. The reason is that self[:bar] is always undefined. It's actually self[:bar_id]. I can do something naive like: def bar if self[:bar_id] return Bar.find(self[:bar_id]) else return Bar.last end end However this will always make a db call, even if Bar has already been fetched, which is certainly not ideal. Does anyone have an insight as to how I might have a relationship such that the belongs_to attribute is only loaded once and has a default value if not set.

    Read the article

  • How to set default date in date_select helper in Rails

    - by brad
    I'm trying to set up a date of birth helper in my Rails app (2.3.5). At present it is like so. <%= f.date_select :date_of_birth, :start_year => Time.now.year - 110, :end_year => Time.now.year %> This generates a perfectly functional set of date fields that work just fine but.... They default to today's date which is not ideal for a date of birth field (I'm not sure what is but unless you're running a neonatal unit today's date seems less than ideal). I want it to read Jan 1 2010 instead (or 2011 or whatever year it happens to be). Using the :default option has proven unsuccessful. I've tried many possibilities including; <%= f.date_select :date_of_birth, :default => {:year => Time.now.year, :month => 'Jan', :day => 1}, :start_year => Time.now.year - 110, :end_year => Time.now.year %> and <%= f.date_select :date_of_birth, :default => Time.local(2010,'Jan',1), :start_year => Time.now.year - 110, :end_year => Time.now.year %> None of this changes the behaviour of the first example. Does the default option actually work as described? It seems that this should be a fairly straightforward thing to do. Ta.

    Read the article

  • Optimize existing code and need to list alphabetically.

    - by Brad
    I need help optimizing the code to run faster, unless it is optimized the best. I also want to alphabetize the list and I am unsure how to do that. It should be alphabetized by $userinfo[0]["sn"][0] I am using the adLDAP class: http://adldap.sourceforge.net/ <?php require_once('adLDAP.php'); //header('Content-type: text/json'); $adldap = new adLDAP(); $groupMembers = $adldap->group_members('STAFF'); //print_r($groupMembers); $userinfo = $adldap->user_info($username, array("givenname","sn","telephonenumber")); $displayname = $userinfo[0]["givenname"][0]." ".$userinfo[0]["sn"][0]; print "<ul>"; foreach ($groupMembers as $i => $username) { $userinfo = $adldap->user_info($username, array("*")); $displayname = "<strong>".$userinfo[0]["givenname"][0]." ".$userinfo[0]["sn"][0]."</strong> - ".$userinfo[0]["telephonenumber"][0]; if($userinfo[0]["sn"][0] != "" && $userinfo[0]["givenname"][0] != "" && $userinfo[0]["telephonenumber"][0] != "") { print "<li>".$displayname."</li>"; } } print "</ul>"; ?>

    Read the article

  • How to avoid code duplication for one-off methods with a slightly different signature

    - by Sean
    I am wrapping a number of functions from a vender API in C#. Each of the wrapping functions will fit the pattern: public IEnumerator<IValues> GetAggregateValues(string pointID, DateTime startDate, DateTime endDate, TimeSpan period) { // Validate Data // Break up Requesting Time-Span // Make Requests // Read Results (through another method call } 5 of the 6 requests are aggregate data pulls and have the same signature, so it makes sense to put them in one method and pass the aggregate type to avoid duplication of code. The 6th method however follows the exact same pattern with the same result-set, but is not an aggregate, so no time period is passed to the function (changing the signature). Is there an elegant way to handle this kind of situation without coding a one-off function to handle the non-aggregate request?

    Read the article

  • Invalid argument supplied for foreach() using adldap

    - by Brad
    I am using adldap http://adldap.sourceforge.net/ And I am passing the session from page to page, and checking to make sure the username within the session is a member of a certain member group, for this example, it is the STAFF group. <?php ini_set('display_errors',1); error_reporting(E_ALL); require_once('/web/ee_web/include/adLDAP.php'); $adldap = new adLDAP(); session_start(); $group = "STAFF"; //$authUser = $adldap->authenticate($username, $password); $result=$adldap->user_groups($_SESSION['user_session']); foreach($result as $key=>$value) { switch($value) { case $group: print '<h3>'.$group.'</h3>'; break; default: print '<h3>Did not find specific value: '.$value.'</h3>'; } if($value == $group) { print 'for loop broke'; break; } } ?> It gives me the error: Warning: Invalid argument supplied for foreach() on line 15, which is this line of code: foreach($result as $key=$value) { When I uncomment the code $authUser = $adldap-authenticate($username, $password); and enter in the appropriate username and password, it works fine, but I shouldn't have to, since the session is valid, I just want to see if the username stored within the valid_session is apart of the STAFF group. Why would it be giving me that problem?

    Read the article

  • mysql index optimization for a table with multiple indexes that index some of the same columns

    - by Sean
    I have a table that stores some basic data about visitor sessions on third party web sites. This is its structure: id, site_id, unixtime, unixtime_last, ip_address, uid There are four indexes: id, site_id/unixtime, site_id/ip_address, and site_id/uid There are many different types of ways that we query this table, and all of them are specific to the site_id. The index with unixtime is used to display the list of visitors for a given date or time range. The other two are used to find all visits from an IP address or a "uid" (a unique cookie value created for each visitor), as well as determining if this is a new visitor or a returning visitor. Obviously storing site_id inside 3 indexes is inefficient for both write speed and storage, but I see no way around it, since I need to be able to quickly query this data for a given specific site_id. Any ideas on making this more efficient? I don't really understand B-trees besides some very basic stuff, but it's more efficient to have the left-most column of an index be the one with the least variance - correct? Because I considered having the site_id being the second column of the index for both ip_address and uid but I think that would make the index less efficient since the IP and UID are going to vary more than the site ID will, because we only have about 8000 unique sites per database server, but millions of unique visitors across all ~8000 sites on a daily basis. I've also considered removing site_id from the IP and UID indexes completely, since the chances of the same visitor going to multiple sites that share the same database server are quite small, but in cases where this does happen, I fear it could be quite slow to determine if this is a new visitor to this site_id or not. The query would be something like: select id from sessions where uid = 'value' and site_id = 123 limit 1 ... so if this visitor had visited this site before, it would only need to find one row with this site_id before it stopped. This wouldn't be super fast necessarily, but acceptably fast. But say we have a site that gets 500,000 visitors a day, and a particular visitor loves this site and goes there 10 times a day. Now they happen to hit another site on the same database server for the first time. The above query could take quite a long time to search through all of the potentially thousands of rows for this UID, scattered all over the disk, since it wouldn't be finding one for this site ID. Any insight on making this as efficient as possible would be appreciated :) Update - this is a MyISAM table with MySQL 5.0. My concerns are both with performance as well as storage space. This table is both read and write heavy. If I had to choose between performance and storage, my biggest concern is performance - but both are important. We use memcached heavily in all areas of our service, but that's not an excuse to not care about the database design. I want the database to be as efficient as possible.

    Read the article

  • How To Save Spring Security Logged In User In Session

    - by Brad Rhoads
    This code get's the currently logged in user, using the Spring Security Plugin (acegi): def principalInfo = authenticateService.principal() def person = null if (principalInfo != "anonymousUser" && principalInfo.username) { person = Person.findByUsername(principalInfo.username) } I would like then do: session.user = person This needs to be done after the user logs in. I can't figure out where to put my code to do this. It seem like it should be some place in the Login Controller, but I can't see where.

    Read the article

  • How to do case-insensitive order in Rails with postgresql

    - by brad
    I am in the process of switching my development environment from sqlite3 to postgresql 8.4 and have one last hurdle. In my original I had the following line in a helper method; result = Users.find(:all, :order => "name collate NOCASE") which provided a very nice case-insensitive search. I can't replicate this for postgresql. Should be easy - any ideas? Thanks.

    Read the article

  • Is It Possible To Use Javascript/CSS To Swap Style Sheets When A Mobile Device Rotates?

    - by Sean M
    I am working on a site that must be designed with mobile accessibility in mind. As part of our brainstorming, we wondered whether it's possible to detect, for a mobile browser (i.e. Mobile Safari or the Android browser), when the viewing device has changed orientation, and to use that as a trigger to change page content? As the title of this question implies, our best-case scenario is the ability to detect the orientation change and use it to alter the CSS on the fly so as to present a slightly different page for landscape versus portrait. Of course we can just design for a page that looks good one way and make it obvious that it's supposed to be viewed that way, but the cool-stuff factor of a page that looks good either way is pretty appealing. Is this idea implementable? Practical?

    Read the article

  • Raise event from http listener (Async listener handler)

    - by Sean
    Hello, I have created an simple web server, leveraging .NET HttpListener class. I am using ThreadPool.QueueUserWorkItem() to spawn a thread to listen to incoming requests. Threaded method uses HttpListener.BeginGetContext(callback, listener), and in callback method I resume with HttpListener.EndGetContext() as well as raise an even to notify UI that listener received data. This is the question - how to raise that event? Initially I used ThreadPool: ThreadPool.QueueUserWorkItem(state => ReceivedRequest(httpListenerContext, receivedRequestArgs)); But then started to doubt, maybe it should be a dedicated thread (as appose to waiting for a thread from pool): new Thread(() => ReceivedRequest(httpListenerContext, receivedRequestArgs)).Start(); Thoughts? 10X

    Read the article

  • NetBeans not finding JasperReports scriptlet

    - by Sean
    I'm using JasperReports 3.7.6 with NetBeans 6.9.1 and iReport 3.7.6. I have a report that uses scriptlets. When I run it from iReport everything is fine because I can tell iReport where to find the .jar file with the scriptlets. When I run that same report from a JSF-2.0 application the fields that rely on the scriptlet are not being populated correctly - i.e. the scriptlet isn't being called. I've tried putting the scriptlet in the project's library folder and I've tried copying the package containing the scriptlet into the project. Neither has worked. I'm not sure how I can get the report to call the scriptlets when it is run from my JSF project. Can anyone shed some light on this for me?

    Read the article

  • Rails equivalent of respond_to |format| with a straight render

    - by brad
    I'm working with ActiveResource a lot so my service models are only using XML. Thus, I have no need for a respond_to block, I literally just render :xml => @model I can't however figure out how to render a 404 header using this. I've had to resort to respond_to, which I think adds a few unnecessary method calls. Here's what I'm using: respond_to do |format| if (record_found) render :xml => @some_record else format.xml{ head :not_found } end end but I just want something like render :xml => head :not_found which doesn't work. Can anyone tell me the proper syntax?

    Read the article

  • Python - Test directory permissions

    - by Sean
    In Python on Windows, is there a way to determine if a user has permission to access a directory? I've taken a look at os.access but it gives false results. >>> os.access('C:\haveaccess', os.R_OK) False >>> os.access(r'C:\haveaccess', os.R_OK) True >>> os.access('C:\donthaveaccess', os.R_OK) False >>> os.access(r'C:\donthaveaccess', os.R_OK) True Am I doing something wrong? Is there a better way to check if a user has permission to access a directory?

    Read the article

  • Detect Alpha Channel with ImageMagick

    - by brad
    Scenario I would like to save images with alpha transparency as .png and images without alpha transparency as .jpg (even if their original format is .png or .gif). How can I detect whether or not an image has alpha transparency using ImageMagick?

    Read the article

  • Linked List exercise, what am I doing wrong?

    - by Sean Ochoa
    Hey all. I'm doing a linked list exercise that involves dynamic memory allocation, pointers, classes, and exceptions. Would someone be willing to critique it and tell me what I did wrong and what I should have done better both with regards to style and to those subjects I listed above? /* Linked List exercise */ #include <iostream> #include <exception> #include <string> using namespace std; class node{ public: node * next; int * data; node(const int i){ data = new int; *data = i; } node& operator=(node n){ *data = *(n.data); } ~node(){ delete data; } }; class linkedList{ public: node * head; node * tail; int nodeCount; linkedList(){ head = NULL; tail = NULL; } ~linkedList(){ while (head){ node* t = head->next; delete head; if (t) head = t; } } void add(node * n){ if (!head) { head = n; head->next = NULL; tail = head; nodeCount = 0; }else { node * t = head; while (t->next) t = t->next; t->next = n; n->next = NULL; nodeCount++; } } node * operator[](const int &i){ if ((i >= 0) && (i < nodeCount)) throw new exception("ERROR: Invalid index on linked list.", -1); node *t = head; for (int x = i; x < nodeCount; x++) t = t->next; return t; } void print(){ if (!head) return; node * t = head; string collection; cout << "["; int c = 0; if (!t->next) cout << *(t->data); else while (t->next){ cout << *(t->data); c++; if (t->next) t = t->next; if (c < nodeCount) cout << ", "; } cout << "]" << endl; } }; int main (const int & argc, const char * argv[]){ try{ linkedList * myList = new linkedList; for (int x = 0; x < 10; x++) myList->add(new node(x)); myList->print(); }catch(exception &ex){ cout << ex.what() << endl; return -1; } return 0; }

    Read the article

  • String Question. How to count the number of A,a, numeric and special char

    - by Brad
    I have randomly created strings such as H*P2[-%-3:5RW0j*;k52vedsSQ5{)ROkb]P/*DZTr*-UX4sp What I want to do is get a count of all Caps, lower case, numeric and special characters in each string as they are generated. I am looking for an output similar to Caps = 5 Lower = 3 numneric = 6 Special = 4 Fictitious values of course. I have gone through the php string pages using count_char, substr_count etc but cant find what I am looking for. Thank you

    Read the article

  • MVC 2 AntiForgeryToken - Why symmetric encryption + IPrinciple?

    - by Brad R
    We recently updated our solution to MVC 2, and this has updated the way that the AntiForgeryToken works. Unfortunately this does not fit with our AJAX framework any more. The problem is that MVC 2 now uses symmetric encryption to encode some properties about the user, including the user's Name property (from IPrincipal). We are able to securely register a new user using AJAX, after which subsequent AJAX calls will be invalid as the anti forgery token will change when the user has been granted a new principal. There are also other cases when this may happen, such as a user updating their name etc. My main question is why does MVC 2 even bother using symmetric encryption? Any then why does it care about the user name property on the principal? If my understanding is correct then any random shared secret will do. The basic principle is that the user will be sent a cookie with some specific data (HttpOnly!). This cookie is then required to match a form variable sent back with each request that may have side effects (POST's usually). Since this is only meant to protect from cross site attacks it is easy to craft up a response that would easily pass the test, but only if you had full access to the cookie. Since a cross site attacker is not going to have access to your user cookies you are protected. By using symmetric encryption, what is the advantage in checking the contents of the cookie? That is, if I already have sent an HttpOnly cookie the attacker cannot override it (unless a browser has a major security issue), so why do I then need to check it again? After having a think about it it appears to be one of those 'added layer of security' cases - but if your first line of defence has fallen (HttpOnly) then the attacker is going to get past the second layer anyway as they have full access to the users cookie collection, and could just impersonate them directly, instead of using an indirect XSS/CSRF attack. Of course I could be missing a major issue, but I haven't found it yet. If there are some obvious or subtle issues at play here then I would like to be aware of them.

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >