Search Results

Search found 38 results on 2 pages for 'pistacchio'.

Page 2/2 | < Previous Page | 1 2 

  • PHP preg_match to get function-like string

    - by pistacchio
    Hi to all, if I have a string like 'foo(bar)', with the following code i can almost parse it the way i want: $results = array(); preg_match( "/\w*(?=(\(.*\))?)/", 'foo(bar)', &$results ); print_r($results); /* Array ( [0] => foo [1] => (bar) ) */ How can I modify the regex to have bar instead of (bar)? Thanks

    Read the article

  • Django: remove all m2m relations

    - by pistacchio
    Hi, if I have two simple models: class Tag(models.Model): name = models.CharField(max_length=100) class Post(models.Model): title = models.CharField(max_length=100) tags = models.ManyToManyField(Tag, blank=True) given a Post object with a number of Tags added to it, I know hot to remove any of them, but how to do a mass remove (remove all)? Thanks

    Read the article

  • Django: automatically import MEDIA_URL in context

    - by pistacchio
    Hi, like exposed here, one can set a MEDIA_URL in settings.py (for example i'm pointing to Amazon S3) and serve the files in the view via {{ MEDIA_URL }}. Since MEDIA_URL is not automatically in the context, one have to manually add it to the context, so, for example, the following works: #views.py from django.shortcuts import render_to_response from django.template import RequestContext def test(request): return render_to_response('test.html', {}, context_instance=RequestContext(request)) This means that in each view.py file i have to add from django.template import RequestContext and in each response i have to explicitly specify context_instance=RequestContext(request). Is there a way to automatically (DRY) add MEDIA_URL to the default context? Thanks in advance.

    Read the article

  • Php dynamic class construction

    - by pistacchio
    Hi to all, I'm trying to avoid the use of eval. I can dynamically instantiate a class like this: class myclass {} $my_class_name = 'myclass'; $obj = new $myclass(); If the constructor is like follows: class myclass { public function __construct( $argument1, $argument2 ) {} } and i have the values of the arguments in an array, how can i dynamically instantiate the class and pass it dynamic arguments? Mind that I have no way to modify the class, so I have to work on the way of using it. Thanks

    Read the article

  • Django: saving pickled object

    - by pistacchio
    Hi, i have a large dictionary I'd like to save. I have pickled it using cPickle.dumps and saved the result into a TextField. When trying to retrieve it (cPicle.loads) i get the following error: loads() argument 1 must be string, not unicode Does anybody have any experience in serializing python objects and storing them in a DB using Django? Thanks in advance.

    Read the article

  • MySql returning multiple rows from stored procedure / function

    - by pistacchio
    Hi, I need to make a stored procedure or function that returns a set of rows. I've noted that in a stored procedure i can SELECT * FROM table with success. If i fetch rows in a loop and SELECT something, something_other FROM table once per loop execution, I only get one single result. What I need to do is looping, doing some calculations and returning a rowset. What's the best way to do this? A temporary table? Stored functions? Any help appreciated.

    Read the article

  • .htacess windows problem

    - by pistacchio
    Hi, In the root directory of a small site i'm developing i have the following .htacess file: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-F RewriteRule .$ index.php that basically allows me to have pretty urls as it remaps every path that does not exists on the server (eg : /user/details/145 ) as a call to index.php where I handle it MVC-style. While this works ok on MacOs, this morning I have to work on another machine that has Windows (the apache server is run by xampp) and it does not work as it seems to redirect all the calls (eg those to static files like images) to index.php Any help?

    Read the article

  • C#: String.IndexOf to FileStream.Seek

    - by pistacchio
    Hi, having a FileStream that I read with a StreamReader (it is a very large file), how can I set the Seek position of the FileStream to the first occurrence of a certain substring so that I can start reading this large file from a given point? Thanks

    Read the article

  • Php static variables across sessions

    - by pistacchio
    Hi, In ASP.NET if I declare a variable (or object) static (or if I make a singleton) I can have it persist across multiple sessions of multiple users (it it registered in a server scope) so that I don't have to initialize it at every request. Is there such a feature in PHP? Thanks

    Read the article

  • php array_filter without key preservation

    - by pistacchio
    Hi, if i filter an array with array_filter to eliminate null values, keys are preserved and this generated "holes" in the array. Eg: The filtered version of [0] => 'foo' [1] => null [2] => 'bar' is [0] => 'foo' [2] => 'bar' How can i get, instead [0] => 'foo' [1] => 'bar' ? Thanks

    Read the article

< Previous Page | 1 2