Daily Archives

Articles indexed Sunday June 13 2010

Page 10/73 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • How come string.maketrans does not work in Python 3.1?

    - by ShaChris23
    I'm a Python newbie. How come this doesn't work in Python 3.1? from string import maketrans # Required to call maketrans function. intab = "aeiou" outtab = "12345" trantab = maketrans(intab, outtab) str = "this is string example....wow!!!"; print str.translate(trantab); When I executed the above code, I get the following instead: Traceback (most recent call last): File "<pyshell#119>", line 1, in <module> transtab = maketrans(intab, outtab) File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/string.py", line 60, in maketrans raise TypeError("maketrans arguments must be bytes objects") TypeError: maketrans arguments must be bytes objects What does "must be bytes objects" mean? Could anyone please help post a working code for Python 3.1 if it's possible?

    Read the article

  • Serve external template in Django

    - by AlexeyMK
    Hey, I want to do something like return render_to_response("http://docs.google.com/View?id=bla", args) and serve an external page with django arguments. Django doesn't like this (it looks for templates in very particular places). What's the easiest way make this work? Right now I'm thinking to use urllib to save the page to somewhere locally on my server and then serve with the templates pointing to there. Note: I'm not looking for anything particularly scalable here, I realize my proposal above is a little dirty.

    Read the article

  • Convert string to variable in Javascript

    - by waiwai933
    Is there any way to convert a string to a variable in Javascript? Right now, what I have is a script that updates data based on the values of the select box: <script type="text/javascript"> var a = new Array(); a[0] = 'Name'; a[1] = 'Description'; var b = new Array(); b[0] = 'Name 2'; b[1] = 'Description 2'; function changeSystem(){ var selectedAccount=document.getElementById('selected_option').value; document.getElementById('name').innerHTML = selectedAccount[0]; document.getElementById('description').innerHTML = selectedAccount[1]; } </script> <form method="POST"> <select onchange="changeSystem()" id="selected_option"> <option>A</option> <option>B</option> </select> </form> <span id="name"></span><br> <span id="description"></span><br> selectedAccount is the string of the chosen element in <select>. However, for it to access the array, it needs to be a variable, i.e. a[0] instead of 'a'[0]. What solutions are there to this?

    Read the article

  • PHP extensions won't load on Apache startup

    - by WebDevHobo
    I've added php as a module for Apache 2.2.11: LoadModule php5_module "c:/php/php5apache2_2.dll" And also added AddType application/x-httpd-php .php And in PHP.ini, my extension dir is set to: extension_dir = "C:\php\ext" And yes, the directories are correct and all files do exist. But when I start apache, I get these errors: PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pdo_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0 [Sun May 17 03:46:01 2009] [notice] Apache/2.2.11 (Win32) PHP/5.2.9-2 configured -- resuming normal operations [Sun May 17 03:46:01 2009] [notice] Server built: Dec 10 2008 00:10:06 [Sun May 17 03:46:01 2009] [notice] Parent: Created child process 4652 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pdo_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0 [Sun May 17 03:46:01 2009] [notice] Child 4652: Child process is running [Sun May 17 03:46:01 2009] [notice] Child 4652: Acquired the start mutex. [Sun May 17 03:46:01 2009] [notice] Child 4652: Starting 64 worker threads. [Sun May 17 03:46:01 2009] [notice] Child 4652: Starting thread to listen on port 80. So I'm probably forgetting something simple here, can someone tell me what I'm forgetting?

    Read the article

  • Encoding a string as an integer .NET

    - by Paul Knopf
    I have a string that I would like represented uniquely as an integer. For example: A3FJEI = 34950140 How would I go about writing a EncodeAsInteger(string) method. I understand that the amount of characters in the string will make the integer increase greatly, forcing the value to become a long, not an int. Since I need the value to be an integer, I don't need the numerical representation to be entirely unique to the string. Maybe I can foreach through all the characters of the string and sum the numerical keycode of the character.

    Read the article

  • How do I build mDNSResponder?

    - by Alex
    I have tried checking out the mDNSResponder source from Apple's SVN host, with the thought of compiling it and tweaking it. This failed miserably. Here is the last line of the output of cd trunk SRCROOT=. make I get the same error for several tags in the SVN tree, so I'm not sure if there is something on my end wrong? The following build commands failed: mDNSResponder: CompileC mDNSResponder.build/mDNSResponder.build/Objects-normal/i386/mDNSMacOSX.o /Users/myname/Desktop/mDNSResponder/trunk/mDNSMacOSX/mDNSMacOSX.c normal i386 c com.apple.compilers.gcc.4_2 PhaseScriptExecution "Run Script" /Users/myname/Desktop/mDNSResponder/trunk/mDNSMacOSX/mDNSResponder.build/mDNSResponder.build/Script-D284BE6C0ADD80740027CCDF.sh mDNSResponder debug: CompileC "mDNSResponder.build/mDNSResponder debug.build/Objects-normal/i386/mDNSMacOSX.o" /Users/myname/Desktop/mDNSResponder/trunk/mDNSMacOSX/mDNSMacOSX.c normal i386 c com.apple.compilers.gcc.4_2 Build Some: PhaseScriptExecution "Run Script" "/Users/myname/Desktop/mDNSResponder/trunk/mDNSMacOSX/mDNSResponder.build/Development/Build Some.build/Script-FF045B6A0C7E4AA600448140.sh" (4 failures)

    Read the article

  • Calculate the size of a folder...

    - by iphone_developer
    Just a quick one... I'm creating a folder to cache images inside Documents with my iPhone App. I want to be able to keep the size of this folder down to 1MB, so I need to to check the size in bytes of my folder. I have code to calculate the size of file, but I need the size of the folder. What would be the best way to do this? Will I need to loop through each file? Cheers

    Read the article

  • ActionScript Drag and Drop Display Objects With Mask And Filter?

    - by TheDarkIn1978
    i've created a sprite to drag and drop around the stage. the sprite is masked and has it's mask as it's child so that it too will drag along with the sprite. everything works fine until i add a drop shadow filter to the sprite. when the drop shadow is added, i can only mousedown to drag and mouseup to drop the sprite if the mouse events occur within the original location of the sprite when it was added to the stage. how can i fix this problem? could this be an issue with 10.1? if not what am i doing wrong? var thumbMask:Sprite = new Sprite(); thumbMask.graphics.beginFill(0, 1); thumbMask.graphics.drawRoundRect(0, 0, 100, 75, 25, 25); thumbMask.graphics.endFill(); var thumb:Sprite = new Sprite(); thumb.graphics.beginFill(0x0000FF, 1); thumb.graphics.drawRect(0, 0, 100, 75); thumb.graphics.endFill(); thumb.addEventListener(MouseEvent.MOUSE_DOWN, drag); thumb.addEventListener(MouseEvent.MOUSE_UP, drop); thumb.filters = [new DropShadowFilter(0, 0, 0, 1, 20, 20, 1.0, 3)]; thumb.addChild(thumbMask); thumb.mask = thumbMask; addChild(thumb) function drag(evt:MouseEvent):void { evt.target.startDrag(); trace("drag"); } function drop(evt:MouseEvent):void { evt.target.stopDrag(); trace("drop"); }

    Read the article

  • Need help implementing an Android service that does http long polling

    - by Erdal
    I've seen persistent TCP connections implemented (http://devtcg.blogspot.com/2009/01/push-services-implementing-persistent.html), but my needs are a little different. I need an Android service that always runs in the background and keeps a long polling connection to an HTTP server and communicates with it using JSON over POST method. Does anyone have anything similar to this?

    Read the article

  • How set opacity on QGraphicsItem

    - by La Chamelle
    Hello, i have a inherited from QGraphicsScene and QGraphicsItem to create my own classes. I use Qt 4.6. I want to set a specific opacity on each items of my scene. I use setOpacity : setOpacity method, but its not the result i hope. I want to have for example one item opaque and an other transparent (to see the desktop, or the other application). But if i dont set the opacity of the QGraphicsView to 0.5, i have not the transparancy. And if the QGraphicsView is set to 0.5, the item is not real opaque. What should i do ? Thanks you.

    Read the article

  • ReverseGeoCoder Fail Error in Mapkit

    - by Biranchi
    Hi All, I am making the ReverseGeoCoder request with the following latitude and longitude Latitude = 37.296740 Longitude = -122.001878 I am getting an error as "/SourceCache/ProtocolBuffer/ProtocolBuffer-19/Runtime/PBRequester.m:446 server returned error: 503" With the ReverseGeoCoder fail message as "Error Domain=PBRequesterErrorDomain Code=6001 "Operation could not be completed. (PBRequesterErrorDomain error 6001.)" What is this error due to ?? Any ideas ?? Thanks

    Read the article

  • How do I selectively round UITableViewCell corners?

    - by Michael Yang
    I'm trying to recreate the feel of the upper part of the iPhone Stocks application. Using cornerRadius I have been able to round all the corners of the UITableView, but when the user drags too far down or up the rectangular edges of the first and last cells show. How can I round only the top or bottom part of the UITableViewCell?

    Read the article

  • Overload the equals method in java

    - by fastcodejava
    Does anyone overload the equals method in java? The overloaded method will be public boolean equals(final MyClass myClass) This will have the benefit of having the relevant comparison part (guts of the method) in another method. Details are in this blog.

    Read the article

  • heroku corrupted object, git fsck fails in rails

    - by Ryan Max
    Hello. I am trying to push an app to heroku and I am getting the error detailed here. So I am trying to determine the corrupt objects using git fsck -full but it isn't returning anything. Nothing happens: Ryan@Ryan-PC ~ $ git fsck --full Ryan@Ryan-PC But I get the object error when I try to push the object to heroku. Is there anyway I can go about repairing the corrupt repository, or can I just delete it and start over? How do I go about doing this?

    Read the article

  • Why are my RSpec specs running twice?

    - by James A. Rosen
    I have the following RSpec (1.3.0) task defined in my Rakefile: require 'spec/rake/spectask' Spec::Rake::SpecTask.new(:spec) do |spec| spec.libs << 'lib' << 'spec' spec.spec_files = FileList['spec/**/*_spec.rb'] end I have the following in spec/spec_helper.rb: require 'rubygems' require 'spec' require 'spec/autorun' require 'rack/test' require 'webmock/rspec' include Rack::Test::Methods include WebMock require 'omniauth/core' I have a single spec declared in spec/foo/foo_spec.rb: require File.dirname(__FILE__) + '/../spec_helper' describe Foo do describe '#bar' do it 'be bar-like' do Foo.new.bar.should == 'bar' end end end When I run rake spec, the single example runs twice. I can check it by making the example fail, giving me two red "F"s. One thing I thought was that adding spec to the SpecTask's libs was causing them to be double-defined, but removing that doesn't seem to have any effect.

    Read the article

  • Creating new tags in StackOverflow [closed]

    - by Biranchi
    Hi, Earlier users with more than 300 reputations or so (don't remeber exactly) had the ability to create new tags which is tagged to their Questions , so that it was easier to search for similar questions with the tags. And also the tags helped to identify the context of the Questions asked for. I had also created few new tags for the questions that i ask for. But now it seems the Stackover team without prior notice to the users or any intimation has revoked the permission for creating new tags and also has set the reputation to more that 1500 for creating new tags. Isn't this a bully act or did they feel its useless/unnecessary not required to inform all the registered users before making the changes ? thoughts....

    Read the article

  • CakePHP: Action runs twice, for no good reason.

    - by tehstu
    Greetings everyone! I have a strange problem with my cake (cake_1.2.0.7296-rc2). My start()-action runs twice, under certain circumstances, even though only one request is made. The triggers seem to be : - loading an object like: $this-Questionnaire-read(null, $questionnaire_id); - accessing $this-data If I disable the call to loadAvertisement() from the start()-action, this does not happen. If I disable the two calls inside loadAdvertisement(): $questionnaire = $this-Questionnaire-read(null, $questionnaire_id); $question = $this-Questionnaire-Question-read(null, $question_id); ... then it doesn't happen either. Why? See my code below, the Controller is "questionnaires_controller". function checkValidQuestionnaire($id) { $this->layout = 'questionnaire_frontend_layout'; if (!$id) { $id = $this->Session->read('Questionnaire.id'); } if ($id) { $this->data = $this->Questionnaire->read(null, $id); //echo "from ".$questionnaire['Questionnaire']['validFrom']." ".date("y.m.d"); //echo " - to ".$questionnaire['Questionnaire']['validTo']." ".date("y.m.d"); if ($this->data['Questionnaire']['isPublished'] != 1 //|| $this->data['Questionnaire']['validTo'] < date("y.m.d") //|| $this->data['Questionnaire']['validTo'] < date("y.m.d") ) { $id = 0; $this->flash(__('Ungültiges Quiz. Weiter zum Archiv...', true), array('action'=>'archive')); } } else { $this->flash(__('Invalid Questionnaire', true), array('action'=>'intro')); } return $id; } function start($id = null) { $this->log("start"); $id = $this->checkValidQuestionnaire($id); //$questionnaire = $this->Questionnaire->read(null, $id); $this->set('questionnaire', $this->data); // reset flow-controlling session vars $this->Session->write('Questionnaire',array('id' => $id)); $this->Session->write('Questionnaire'.$id.'currQuestion', null); $this->Session->write('Questionnaire'.$id.'lastAnsweredQuestion', null); $this->Session->write('Questionnaire'.$id.'correctAnswersNum', null); $this->loadAdvertisement($id, 0); $this->Session->write('Questionnaire'.$id.'previewMode', $this->params['named']['preview_mode']); if (!$this->Session->read('Questionnaire'.$id.'previewMode')) { $questionnaire['Questionnaire']['participiantStartCount']++; $this->Questionnaire->save($questionnaire); } } function loadAdvertisement($questionnaire_id, $question_id) { //$questionnaire = array(); $questionnaire = $this->Questionnaire->read(null, $questionnaire_id); //$question = array(); $question = $this->Questionnaire->Question->read(null, $question_id); if (isset($question['Question']['advertisement_id']) && $question['Question']['advertisement_id'] > 0) { $this->set('advertisement', $this->Questionnaire->Question->Advertisement->read(null, $question['Question']['advertisement_id'])); } else if (isset($questionnaire['Questionnaire']['advertisement_id']) && $questionnaire['Questionnaire']['advertisement_id'] > 0) { $this->set('advertisement', $this->Questionnaire->Question->Advertisement->read(null, $questionnaire['Questionnaire']['advertisement_id'])); } } I really don't understand this... it don't think it's meant to be this way. Any help would be greatly appreciated! :) Regards, Stu

    Read the article

  • Help with Jquery + Masonry Plugin: How to expand/collapse boxes to reveal content

    - by Jam
    I'm using the masonry jquery plugin on a project: (http://desandro.com/resources/jquery-masonry) Basically I have a set of boxes (thumbnails) in a grid. When one is clicked, I want it to expand to a larger size to show more content (additional images and text). I'm struggling with how to make the thumbnail dissappear and then have new content appear in the expanded box. I don't know how to make the new content appear or where to store it on my page--and it needs to have a close button? The creator of the plugin gave me a quick tip for the expanding part, but the code I'm using has a set height and width and I want them to be variable depending on how much content is in the expanded state. Here's my jquery code so far: http://pastie.org/1002101 This is a similar example of the behaviour I want to achieve (except my boxes will have have varying expanded sizes): (http://www.learnsomethingeveryday.co.uk) You'll also notice from that example that it only allows 1 box to be expanded at a time--I would also like to have that functionality. Sorry for all the questions--I'm pretty new to jquery, any help would be amazing!

    Read the article

  • how to return comma seperated values in oracle SP

    - by john
    If I have a simple query like: OPEN cursor FOR SELECT USER_ID FROM USER_TABLE WHERE USER_ID = V_SOME_USER; this will return records in different rows but how can I return the rows in the following format: 'userid1', 'userid2', 'userid3'.....'useridN' I want to do this because I want to send this off as a parameter to another stored procedure...Also, what is the limit on how big the string can be when passed to the SP as parameter

    Read the article

  • Using jQuery ajax response data

    - by Theopile
    Hi again, I am using ajax post and am receiving data in the form of html. I need to split up the data and place pieces of the data all over the page. I built my response data to be something like <p id='greeting'> Hello there and Welcome </p> <p id='something'>First timer visiting our site eh'</p> It is a little more complicated and dynamic but I can figure it out if get this question answered. Thanks $.ajax({ type:'POST', url: 'confirm.php', data: "really=yes&sure=yes", success:function(data){ //Need to split data here } });

    Read the article

  • process csv in scala

    - by portoalet
    I am using scala 2.7.7, and wanted to parse CSV file and store the data in SQLite database. I ended up using OpenCSV java library to parse the CSV file, and using sqlitejdbc library. Using these java libraries makes my scala code looks almost identical to that of Java code (sans semicolon and with val/var) As I am dealing with java objects, I can't use scala list, map, etc, unless I do scala2java conversion or upgrade to scala 2.8 Is there a way I can simplify my code further using scala bits that I don't know? val filename = "file.csv"; val reader = new CSVReader(new FileReader(filename)) var aLine = new Array[String](10) var lastSymbol = "" while( (aLine = reader.readNext()) != null ) { if( aLine != null ) { val symbol = aLine(0) if( !symbol.equals(lastSymbol)) { try { val rs = stat.executeQuery("select name from sqlite_master where name='" + symbol + "';" ) if( !rs.next() ) { stat.executeUpdate("drop table if exists '" + symbol + "';") stat.executeUpdate("create table '" + symbol + "' (symbol,data,open,high,low,close,vol);") } } catch { case sqle : java.sql.SQLException => println(sqle) } lastSymbol = symbol } val prep = conn.prepareStatement("insert into '" + symbol + "' values (?,?,?,?,?,?,?);") prep.setString(1, aLine(0)) //symbol prep.setString(2, aLine(1)) //date prep.setString(3, aLine(2)) //open prep.setString(4, aLine(3)) //high prep.setString(5, aLine(4)) //low prep.setString(6, aLine(5)) //close prep.setString(7, aLine(6)) //vol prep.addBatch() prep.executeBatch() } } conn.close()

    Read the article

  • Deep freeze alternative for Ubuntu

    - by Nrew
    I made some research and found out that Deep freeze is not available for ubuntu. Is there a software like deep freeze for Ubuntu 10.04. To prevent writing data on the disk. I need this so that I could try all sorts of stuff on Ubuntu without worrying if I could damage the Windows installation that is installed along side with it. Virtual box is good. But the performance is not. Because I only have 2gb of ram.

    Read the article

  • Android audio manager method causing a force close

    - by AnSan
    Hi All, New to this and a bit confused as to why calling the following method creates a force close: AudioManager myaudiomanager; public void toggleSilent() { myaudiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT); } I don't see any blatant errors and I have added permissions to the manifest regarding the audio manager. Anyone able to direct me further?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >