Search Results

Search found 8013 results on 321 pages for 'clean urls'.

Page 24/321 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • How can I clean up this SELECT query?

    - by Cruachan
    I'm running PHP 5 and MySQL 5 on a dedicated server (Ubuntu Server 8.10) with full root access. I'm cleaning up some LAMP code I've inherited and I've a large number of SQL selects with this type of construct: SELECT ... FROM table WHERE LCASE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( strSomeField, ' ', '-'), ',', ''), '/', '-'), '&', ''), '+', '') ) = $somevalue Ignoring the fact that the database should never have been constructed to require such a select in the first place, and the $somevalue field will need to be parameterised to plug the gaping security hole, what is my best option for fixing the WHERE condition into something less offensive? If I was using MSSQL or Oracle I'd simply put together a user-defined function, but my experience with MySQL is more limited and I've not constructed a UDF with it before, although I'm happy coding C. Update: For all those who've already raised their eyebrows at this in the original code, $somevalue is actually something like $GET['product']—there are a few variations on the theme. In this case the select is pulling the product back from the database by product name—after stripping out characters so it matches what could be previously passed as a URI parameter.

    Read the article

  • Python: replace urls with title names from a string

    - by Hellnar
    Hello I would like to remove urls from a string replace them with their titles of the original contents. For example: mystring = "Ah I like this site: http://www.stackoverflow.com. Also I must say I like http://www.digg.com" sanitize(mystring) # it becomes "Ah I like this site: Stack Overflow. Also I must say I like Digg - The Latest News Headlines, Videos and Images" For replacing url to the title, I have written this snipplet: #get_title: string -> string def get_title(url): """Returns the title of the input URL""" output = BeautifulSoup.BeautifulSoup(urllib.urlopen(url)) return output.title.string

    Read the article

  • mod_rewrite and relative urls

    - by Davide Gualano
    I'm setting up some simple url rewriting rules using mod_rewrite and a .htacces file, but I've got some problems. If I set up the .htacces this way: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule /index.html /index.php [L] when I call from the browser this url: http://localhost/~dave/mySite/index.html I got a 404 error. Using this .htacces instead Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule /index.html http://localhost/~dave/mySite/index.php [L] everything works fine and I get the index.php page I'm expecting. Am I forced to user absolute urls as the target of a rewrite? Is this a Apache configuration problem? I'm using Max OS X 10.6.2 with its standard Apache installation.

    Read the article

  • Why is GXHC_gx_session_id appended to URLs?

    - by Nariman
    Based on my limited understanding of this parameter [1] it seems to be used in representing cookieless session IDs in java applications... but strangely, we're now noticing that a 3-year-old .NET stack is now appearing in Bing SERPs with GXHC_gx_session_id appended to the domain - and we're not alone: http://www.bing.com/search?q=GXHC_gx_session_id http://www.google.ca/#hl=en&q=GXHC_gx_session_id When comparing Google SERPs to Bing SERPs there are some inconsistencies in whether a particular site carries this parameter - is it then a bing-specific issue only? What else could cause this parameter to be appended to indexed URLs if the target environment (anything behind the load balancers) isn't running java? [1] - http://java.itags.org/java-web-tier-apis/72018/

    Read the article

  • How to replace plain URLs with links?

    - by Sergio del Amo
    I am using the function below to match URLs inside a given text and replace them for HTML links. The regular expression is working great, but currently I am only replacing the first match. How I can replace all the URL? I guess I should be using the exec command, but I did not really figure how to do it. function replaceURLWithHTMLLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i; return text.replace(exp,"<a href='$1'>$1</a>"); }

    Read the article

  • ASP.NET MVC - Organizing Site / URLs

    - by CocoB
    My question is around the best practice for dividing up an asp.net mvc web app. I am building a fairly simple application which has two main sections, public and private. Basically I am running up against the issue of collisions between controllers. What I want is to have urls like /public/portfolio, but also have /private/portfolio. Looking into some options, it seems that areas would work well for this situation. Are there other alternatives, such as some creative routing scheme that I should consider?

    Read the article

  • clean after incomplete / interrupted setup

    - by lm
    I have following question : If setup of some application A was interrupted , and name of it does not appear in Add| Remove program list .I tryed to use Windows Installer CleanUp Utility of Microsoft but if the item does not appear in Add | Remove , the Utility cannot be used . What is right way to remove remaining items from the system ? Your information will be very helpful . Thanks in advance

    Read the article

  • Clean way in GWT/Java to wait for multiple asynchronous events to finish

    - by gerdemb
    What is the best way to wait for multiple asynchronous callback functions to finish in Java before continuing. Specifically I'm using GWT with AsyncCallback, but I think this is a generic problem. Here's what I have now, but surely there is cleaner way... AjaxLoader.loadApi("books", "0", new Runnable(){ public void run() { bookAPIAvailable = true; ready(); }}, null); AjaxLoader.loadApi("search", "1", new Runnable(){ public void run() { searchAPIAvailable = true; ready(); }}, null); loginService.login(GWT.getHostPageBaseURL(), new AsyncCallback<LoginInfo>() { public void onSuccess(LoginInfo result) { appLoaded = true; ready(); } }); private void ready() { if(bookAPIAvailable && searchAPIAvailable && appLoaded) { // Everything loaded } }

    Read the article

  • In what way does Wordpress rewrite page URLs?

    - by Mac Taylor
    Hey Recently I'm interested in post's structure of Wordpress. They use a table named (wp_posts) and in this table they saved 3 related fields such as : post_title post_name guid It's clear that they save title of each story in post_title field , and slugs in post_name , and full url of a post in guild filed . But where the hell, they rewrite these urls in way it appears in browsers : http://localhost/wordpress/about/ There is no htaccess rules for this ! I checked rewrite.php and didn't understand an inch ?! i need to create similar pages , what steps should i take !?

    Read the article

  • automatically rewrite URLs in ASP.NET

    - by Ali_dotNet
    I use VS2010,C# to develop an ASP.NET web site, my customers want me to have their pages like this: mysite.com/customer (in fact they call mysite/customer/default.aspx) so I've manually created several folders for each customer, and inserted a default.aspx file in the folder so that users can view customer page by typing mysite.com/customer is there a better way for performing this scenario? I don't want to have mysite.com/customer1.aspx, I want to have mysite.com/customer1, is there anyway that I can remove folders (and their containing default.aspx files) and generate something automatic using my customers database? should I use URL rewriting? is there anyway that I can create page mysite.com/customer1.aspx, and users can view it by typing mysite.com/customer1? I think it is possible to rewrite URLs in web.config, but I don't want to do it manually in web.config as my pages would increase in a daily basis thanks

    Read the article

  • How to clean up my code

    - by simion
    Being new to this i realy am trying to learn how to keep code as simple as possible, whilst doing the job its supposed to. The question i have done is from project eulur, it says Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Find the sum of all the even-valued terms in the sequence which do not exceed four million. Here is my code below, i was wondering what the best way of simplifying this would be, for a start removing all of the .get(list.length()-1 )..... stuff would be a good start if possible but i dont really no how to? Thanks public long fibb() { ArrayList<Integer> list = new ArrayList<Integer>(); list.add(1); list.add(2); while((list.get(list.size() - 1) + (list.get(list.size() - 2)) < 4000000)){ list.add((list.get(list.size()-1)) + (list.get(list.size() - 2))); } long value = 0; for(int i = 0; i < list.size(); i++){ if(list.get(i) % 2 == 0){ value += list.get(i); } } return value; }

    Read the article

  • Wordpress & Vanity User URLs

    - by st4ck0v3rfl0w
    Hi All, Was wondering if anyone had any smart approaches to creating dynamic vanity user urls upon user registration. My site basically uses emails as usernames. I have the regex to strip the text before the "@" symbol (e.g. "[email protected]" becomes "name") I would then like to take the "name" and create a vanity url (e.g. domain.com/name or name.domain.com) Any thoughts on how to accomplish this with Wordpress? I'm a pretty advanced Wordpress user and my first thoughts were to do the following Verify user registration Upon successful user registration create page name with username as the title (this would help me achieve the www.domain.com/username) Apply preset template to that page with the desired view Any and all thoughts are welcome.

    Read the article

  • Python - a clean approach to this problem?

    - by Seafoid
    Hi, I am having trouble picking the best data structure for solving a problem. The problem is as below: I have a nested list of identity codes where the sublists are of varying length. li = [['abc', 'ghi', 'lmn'], ['kop'], ['hgi', 'ghy']] I have a file with two entries on each line; an identity code and a number. abc 2.93 ghi 3.87 lmn 5.96 Each sublist represents a cluster. I wish to select the i.d. from each sublist with the highest number associated with it, append that i.d. to a new list and ultimately write it to a new file. What data structure should the file with numbers be read in as? Also, how would you iterate over said data structure to return the i.d. with the highest number that matches the i.d. within a sublist? Thanks, S :-)

    Read the article

  • Creating a Simple C# Wrapper to clean up code

    - by Tangopop
    I have this code: public void Contacts(string domainToBeTested, string[] browserList, string timeOut, int numberOfBrowsers) { verificationErrors = new StringBuilder(); for (int i = 0; i < numberOfBrowsers; i++) { ISelenium selenium = new DefaultSelenium("LMTS10", 4444, browserList[i], domainToBeTested); try { selenium.Start(); selenium.Open(domainToBeTested); selenium.Click("link=Email"); Assert.IsTrue(selenium.IsElementPresent("//div[@id='tabs-2']/p/a/strong")); selenium.Click("link=Address"); Assert.IsTrue(selenium.IsElementPresent("//div[@id='tabs-3']/p/strong")); selenium.Click("link=Telephone"); Assert.IsTrue(selenium.IsElementPresent("//div[@id='tabs-1']/ul/li/strong")); } catch (AssertionException e) { verificationErrors.AppendLine(browserList[i] + " :: " + e.Message); } finally { selenium.Stop(); } } Assert.AreEqual("", verificationErrors.ToString(), verificationErrors.ToString()); } My problem is i would like to make it so that i can use the code surrounding the 'try' many many times in the rest of the code. I think it has something to do with wrappers, but i can't get a simple answer for this from the web. So in simple terms the only piece of this code which changes is the bit between the try {} the rest is standard code that i have currently used over 100 times and is turning out to be a pain to maintain. Hope this is clear, many thanks.

    Read the article

  • Looking to clean up a small ruby script.

    - by Badweather
    I'm looking for a much more idiomatic way to do the following little ruby script. File.open("channels.xml").each do |line| if line.match('(mms:\/\/{1}[a-zA-Z\.\d\/\w-]+)') puts line.match('(mms:\/\/{1}[a-zA-Z\.\d\/\w-]+)') end end Thanks in advance for any suggestions.

    Read the article

  • Cleaner method for list comprehension clean-up

    - by Dan McGrath
    This relates to my previous question: Converting from nested lists to a delimited string I have an external service that sends data to us in a delimited string format. It is lists of items, up to 3 levels deep. Level 1 is delimited by '|'. Level 2 is delimited by ';' and level 3 is delimited by ','. Each level or element can have 0 or more items. An simplified example is: a,b;c,d|e||f,g|h;; We have a function that converts this to nested lists which is how it is manipulated in Python. def dyn_to_lists(dyn): return [[[c for c in b.split(',')] for b in a.split(';')] for a in dyn.split('|')] For the example above, this function results in the following: >>> dyn = "a,b;c,d|e||f,g|h;;" >>> print (dyn_to_lists(dyn)) [[['a', 'b'], ['c', 'd']], [['e']], [['']], [['f', 'g']], [['h'], [''], ['']]] For lists, at any level, with only one item, we want it as a scalar rather than a 1 item list. For lists that are empty, we want them as just an empty string. I've came up with this function, which does work: def dyn_to_min_lists(dyn): def compress(x): return "" if len(x) == 0 else x if len(x) != 1 else x[0] return compress([compress([compress([item for item in mv.split(',')]) for mv in attr.split(';')]) for attr in dyn.split('|')]) Using this function and using the example above, it returns: [[['a', 'b'], ['c', 'd']], 'e', '', ['f', 'g'], ['h', '', '']] Being new to Python, I'm not confident this is the best way to do it. Are there any cleaner ways to handle this? This will potentially have large amounts of data passing through it, are there any more efficient/scalable ways to achieve this?

    Read the article

  • Paperclip generating wrong URLs in Heroku

    - by Tony
    Paperclip is generating wrong URLs in Heroku. I have an Audio model which has a mp3 field as follows: class Audio < ActiveRecord::Base has_attached_file :mp3, :storage => :s3, :s3_credentials => S3_CREDENTIALS, :bucket => S3_CREDENTIALS[:bucket], :path => ":rails_root/public/system/:attachment/:id/:style/:filename", :url => "/system/:attachment/:id/:style/:filename" I am calling audio.mp3.url from a controller, and it returns http://s3.amazonaws.com/MyApp/audios/mp3s//original/96a9ae89302fdf8462ee05eb829f2e17578b144e20120908-2-11f61zr.mp3?1347135050 instead of http://s3.amazonaws.com/MyApp/audios/mp3s/000/000/004/original/96a9ae89302fdf8462ee05eb829f2e17578b144e20120908-2-11f61zr.mp3?1347135050 (which works) Why is it missing the '000/000/004' part of the route? The same model is generating the right URL when used in a view. Any help? I am using paperclip 3.2.0 and Rails 3.1.8. Any help?

    Read the article

  • php string search - grabbing specific urls

    - by MEM
    Hello, I have this string that may contain some urls that I need to grab. For instance, if the user does: www.youtube ... or www.vimeo ... or http://www.youtube ... or HttP://WwW.viMeo I need to grab it (until he finds a space perhaps). and store it on a already created array. The need is to separate the vimeo links from the youtube ones and place each of those on the appropriate video object. I'm not sure if this is possible, I mean, if the URL coming from the browser could be used to be placed on a predefined video object. If it is, then this is the way to go (so I believe). If all this is feasible, can I have your help in order to build such a rule? Thanks in advance

    Read the article

  • Joining the same model twice in a clean way, but making the code reusable

    - by Shako
    I have a model Painting which has a Paintingtitle in each language and a Paintingdescription in each language: class Painting < ActiveRecord::Base has_many :paintingtitles, :dependent => :destroy has_many :paintingdescriptions, :dependent => :destroy end class Paintingtitle < ActiveRecord::Base belongs_to :painting belongs_to :language end class Paintingdescription < ActiveRecord::Base belongs_to :painting belongs_to :language end class Language < ActiveRecord::Base has_many :paintingtitles, :dependent => :nullify has_many :paintingdescriptions, :dependent => :nullify has_many :paintings, :through => :paintingtitles end As you might notice, I reference the Language model from my Painting model via both the Paintingtitle model and Paintingdescription model. This works for me when getting a list of paintings with their title and description in a specific language: cond = {"paintingdescription_languages.code" => language_code, "paintingtitle_languages.code" => language_code} cond['paintings.publish'] = 1 unless admin paginate( :all, :select => ["paintings.id, paintings.publish, paintings.photo_file_name, paintingtitles.title, paintingdescriptions.description"], :joins => " INNER JOIN paintingdescriptions ON (paintings.id = paintingdescriptions.painting_id) INNER JOIN paintingtitles ON (paintings.id = paintingtitles.painting_id) INNER JOIN languages paintingdescription_languages ON (paintingdescription_languages.id = paintingdescriptions.language_id) INNER JOIN languages paintingtitle_languages ON (paintingtitle_languages.id = paintingtitles.language_id) ", :conditions => cond, :page => page, :per_page => APP_CONFIG['per_page'], :order => "id DESC" ) Now I wonder if this is a correct way of doing this. I need to fetch paintings with their title and description in different functions, but I don't want to specify this long join statement each time. Is there a cleaner way, for instance making use of the has_many through? e.g. has_many :paintingdescription_languages, :through => :paintingdescriptions, :source => :language has_many :paintingtitle_languages, :through => :paintingtitles, :source => :language But if I implement above 2 lines together with the following ones, then only paintingtitles are filtered by language, and not the paintingdescriptions: cond = {"languages.code" => language_code} cond['paintings.publish'] = 1 unless admin paginate( :all, :select => ["paintings.id, paintings.publish, paintings.photo_file_name, paintingtitles.title, paintingdescriptions.description"], :joins => [:paintingdescription_languages, :paintingtitle_languages], :conditions => cond, :page => page, :per_page => APP_CONFIG['per_page'], :order => "id DESC" )

    Read the article

  • C++: Shortest and best way to "reinitialize"/clean a class instance

    - by Oper
    I will keep it short and just show you a code example: class myClass { public: myClass(); int a; int b; int c; } // In the myClass.cpp or whatever myClass::myClass( ) { a = 0; b = 0; c = 0; } Okay. If I know have an instance of myClass and set some random garbage to a, b and c. What is the best way to reset them all to the state after the class constructor was called, so: 0, 0 and 0? I came up with this way: myClass emptyInstance; myUsedInstance = emptyInstance; // Ewww.. code smell? Or.. myUsedInstance.a = 0; myUsedInstance.c = 0; myUsedInstance.c = 0; I think you know what I want, is there any better way to achieve this?

    Read the article

  • Does redirecting old site's URLs to new site's front page hurt a page's ranking?

    - by Kaivosukeltaja
    An old site that is being rewritten needs to have it's URLs redirected to the new site. There are a few hundred pages that may or may not have corresponding pages on the new site, probably with different slugs, and adding mappings manually will require more hours than we can spare. It was suggested that all old URLs be redirected to the new front page, but I remember reading somewhere that this confers a penalty in page rank because it's what link farmers do. Is this true or can we take the easy way out?

    Read the article

  • Can I Define Exceptions to Eclipse cleanup rules?

    - by Henrik Paul
    Most often the cleanup rules (Preferences Java Code Style Clean Up) in Eclipse work perfectly and create nice-looking code. But sometimes, especially with comments and concatenated string snippets (like inline SQL queries), the cleanup just messes things up, and destroys my formatting. Is there a way to say to Eclipse "Don't touch this block of text! I have formatted it just the way I like, and you would make it just less readable"?

    Read the article

  • Sitecore not resolving rich text editor URLS in page renders

    - by adam
    Hi We're having issues inserting links into rich text in Sitecore 6.1.0. When a link to a sitecore item is inserted, it is outputted as: http://domain/~/link.aspx?_id=8A035DC067A64E2CBBE2662F6DB53BC5&_z=z Rather than the actual resolved url: http://domain/path/to/page.aspx This article confirms that this should be resolved in the render pipeline: in Sitecore 6 it inserts a specially formatted link that contains the Guid of the item you want to link to, then when the item is rendered the special link is replaced with the actual link to the item The pipeline has the method ShortenLinks added in web.config <convertToRuntimeHtml> <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.PrepareHtml, Sitecore.Kernel"/> <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.ShortenLinks, Sitecore.Kernel"/> <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.SetImageSizes, Sitecore.Kernel"/> <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.ConvertWebControls, Sitecore.Kernel"/> <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.FixBullets, Sitecore.Kernel"/> <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.FinalizeHtml, Sitecore.Kernel"/> </convertToRuntimeHtml> So I really can't see why links are still rendering in ID format rather than as full SEO-tastic urls. Anyone got any clues? Thanks, Adam

    Read the article

  • HTTP POST prarameters order / REST urls

    - by pq
    Let's say that I'm uploading a large file via a POST HTTP request. Let's also say that I have another parameter (other than the file) that names the resource which the file is updating. The resource cannot be not part of the URL the way you can do it with REST (e.g. foo.com/bar/123). Let's say this is due to a combination of technical and political reasons. The server needs to ignore the file if the resource name is invalid or, say, the IP address and/or the logged in user are not authorized to update the resource. Looks like, if this POST came from an HTML form that contains the resource name first and file field second, for most (all?) browsers, this order is preserved in the POST request. But it would be naive to fully rely on that, no? In other words the order of HTTP parameters is insignificant and a client is free to construct the POST in any order. Isn't that true? Which means that, at least in theory, the server may end up storing the whole large file before it can deny the request. It seems to me that this is a clear case where RESTful urls have an advantage, since you don't have to look at the POST content to perform certain authorization/error checking on the request. Do you agree? What are your thoughts, experiences?

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >