Daily Archives

Articles indexed Thursday June 3 2010

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

  • Managing Instances in Python

    - by BeensTheGreat
    Hello, I am new to Python and this is my first time asking a stackOverflow question, but a long time reader. I am working on a simple card based game but am having trouble managing instances of my Hand class. If you look below you can see that the hand class is a simple container for cards(which are just int values) and each Player class contains a hand class. However, whenever I create multiple instances of my Player class they all seem to manipulate a single instance of the Hand class. From my experience in C and Java it seems that I am somehow making my Hand class static. If anyone could help with this problem I would appreciate it greatly. Thank you, Thad To clarify: An example of this situation would be p = player.Player() p1 = player.Player() p.recieveCard(15) p1.recieveCard(21) p.viewHand() which would result in: [15,21] even though only one card was added to p Hand class: class Hand: index = 0 cards = [] #Collections of cards #Constructor def __init__(self): self.index self.cards def addCard(self, card): """Adds a card to current hand""" self.cards.append(card) return card def discardCard(self, card): """Discards a card from current hand""" self.cards.remove(card) return card def viewCards(self): """Returns a collection of cards""" return self.cards def fold(self): """Folds the current hand""" temp = self.cards self.cards = [] return temp Player Class import hand class Player: name = "" position = 0 chips = 0 dealer = 0 pHand = [] def __init__ (self, nm, pos, buyIn, deal): self.name = nm self.position = pos self.chips = buyIn self.dealer = deal self.pHand = hand.Hand() return def recieveCard(self, card): """Recieve card from the dealer""" self.pHand.addCard(card) return card def discardCard(self, card): """Throw away a card""" self.pHand.discardCard(card) return card def viewHand(self): """View the players hand""" return self.pHand.viewCards() def getChips(self): """Get the number of chips the player currently holds""" return self.chips def setChips(self, chip): """Sets the number of chips the player holds""" self.chips = chip return def makeDealer(self): """Makes this player the dealer""" self.dealer = 1 return def notDealer(self): """Makes this player not the dealer""" self.dealer = 0 return def isDealer(self): """Returns flag wether this player is the dealer""" return self.dealer def getPosition(self): """Returns position of the player""" return self.position def getName(self): """Returns name of the player""" return self.name

    Read the article

  • SQLce Select query problem

    - by DieHard
    Wrote a Truck show Contest voting app, financial etc using sqlite. decided to write backup app for show day using ce 3.5. Created db moved to data directory, created tables configured dgridviews all is well. Entered some test data started management studio 08 ran select query against table and got null returns. Started app from vs studio and found that test data is gone. Re entered data ran query in MS data gone again. If I use VS Studio can start and enter data, close app restart and data is still there, seems only when using outside tool on select query data deletes. I don't know ce that well but this cannot be right. select * from votes = delete * from votes??????????????

    Read the article

  • IComponentActivator Instance

    - by jeffn825
    How can I use an IComponentActivator instance for a component, not just specifying a type. That is, instead of Component.For<XYZ>.Activator<MyComponentActivator>(); I want to be able say Component.For<XYZ>.Activator(new MyComponentActivator(someImportantRuntimeInfo)); Also, is there a way I can choose an activator dynamically for a non specifically registered component? That is, I want to have an activator that looks at the type being resolved, decides if it can activate it, and if not, responsibility for activation should be passed on to the default activator. So basically I want a global IComponentActivator that has the following logic: Create(Type type){ if (ShouldActivate(type)){ DoActivate(type); } else{ // do default activation here somehow } } Thanks!

    Read the article

  • Monitor file in Java on Linux 64bits

    - by Tim
    I'd like to be notified when a file has been created, deleted or changed, but not using polling mechanism. I have surveyed related Java API that can use.(EX:JNotify, JPathWatch and JXFileWatcher) Those APIs provide file monitor by using native component on OS. But I met the same problem is that they can't run on Linux 64bits, because native component in those APIs donen't support Linux 64bits, and this confused me for a long time. I also know that there'll be a WatchService API as part of NIO2 in JDK7, but JDK7 has not released yet. So, can any one suggest me a better solution? Very Thanks.

    Read the article

  • Simple calculator app crashes when a third number key is punched.

    - by Justin
    Hi , I am a newbie to the iphone app world. So I thought I try my luck with a calculator app. Unfortunately I am running into an issue where if I press a third key in the calculator the app crashes. Sometimes I get this error EXC_BAD_ACCESS. Here is a code in my CalculatorViewController.m file. #import "CalculatorViewController.h" @implementation CalculatorViewController @synthesize screenText; - (IBAction)buttonPressed:(id)sender { NSString *title = [sender titleForState:UIControlStateNormal]; [self collect:title]; } - (void)collect:(NSString *)digitz { NSString * newText = nil; if ([digitz isEqualToString:@"+"]) { [self add:result]; big_digit = nil; } else if ([digitz isEqualToString:@"+"]) { [self sub:result]; } else if ([digitz isEqualToString:@"x"]) { [self multiply:result]; } else if ([digitz isEqualToString:@"="]) { [self equate:result]; } else { if (big_digit != nil && [big_digit isEqualToString:@"0"] == FALSE) big_digit = [big_digit stringByAppendingFormat:@"%@",digitz]; else big_digit = (NSMutableString *) digitz; result = (int) big_digit; newText = [[NSString alloc] initWithFormat: @"%@",big_digit]; } screenText.text = newText; [newText release]; } - (void)add:(int)res { NSString * newText = nil; ans = ans + res; newText = [[NSString alloc] initWithFormat: @"%@",ans]; screenText.text = newText; [newText release]; } Can anyone spot an obvious issue here. Here is the respective header file too. #import <UIKit/UIKit.h> @interface CalculatorViewController : UIViewController { UILabel *screenText; int number; int result; int ans; //NSString *big_digit; NSMutableString * big_digit ; } @property (nonatomic, retain) IBOutlet UILabel *screenText; - (IBAction)buttonPressed:(id)sender; - (void)collect:(NSString *)digitz; - (void)add:(int)num; - (void)sub:(int)num; - (void)multiply:(int)num; - (void)equate:(int)num; @end

    Read the article

  • Variable lenght arguments in log4cxx LOG4CXX_ macros

    - by Horacio
    I am using log4cxx in a big C++ project but I really don't like how log4cxx handles multiple variables when logging: LOG4CXX_DEBUG(logger, "test " << var1 << " and " << var3 " and .....) I prefer using printf like variable length arguments: LOG4CXX_DEBUG(logger, "test %d and %d", var1, var3) So I implemented this small wrapper on top of log4cxx #include <string.h> #include <stdio.h> #include <stdarg.h> #include <log4cxx/logger.h> #include "log4cxx/basicconfigurator.h" const char * log_format(const char *fmt, ...); #define MYLOG_TRACE(logger, fmt, ...) LOG4CXX_TRACE(logger, log_format(fmt, ## __VA_ARGS__)) #define MYLOG_DEBUG(logger, fmt, ...) LOG4CXX_DEBUG(logger, log_format(fmt, ## __VA_ARGS__)) #define MYLOG_INFO(logger, fmt, ...) LOG4CXX_INFO(logger, log_format(fmt, ## __VA_ARGS__)) #define MYLOG_WARN(logger, fmt, ...) LOG4CXX_WARN(logger, log_format(fmt, ## __VA_ARGS__)) #define MYLOG_ERROR(logger, fmt, ...) LOG4CXX_ERROR(logger, log_format(fmt, ## __VA_ARGS__)) #define MYLOG_FATAL(logger, fmt, ...) LOG4CXX_FATAL(logger, log_format(fmt, ## __VA_ARGS__)) static log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger()); int main(int argc, char **argv) { log4cxx::BasicConfigurator::configure(); MYLOG_INFO(logger, "Start "); MYLOG_WARN(logger, log_format("In running this in %d threads safe?", 1000)); MYLOG_INFO(logger, "End "); return 0; } const char *log_format(const char *fmt, ...) { va_list va; static char formatted[1024]; va_start(va, fmt); vsprintf(formatted, 1024, fmt, va); va_end(va); return formatted; } And this works perfectly but I know using that static variable (formatted) can become problematic if I start using threads and each thread logging to the same place. I am no expert in log4cxx so I was wondering if the LOG4CXX macros are handling concurrent thread access automatically? or do I have to implement some sort of locking around the log_format method? something that I wan't to avoid due to performance implications. Also I would like to ask why if I replace the vsprintf inside the log_format method with vsnprintf (that is more secure) then I get nothing printed? To compile and test this program (in Ubuntu) use : g++ -o loggertest loggertest.cpp -llog4cxx

    Read the article

  • What is "Call By Name"?

    - by forellana
    Hi to everyone! I'm working in a homework, and the professor asked me to implement the evaluation strategy called "call by name" in scheme in a certain language that we developed and he gave us an example at http://www.scala-lang.org/node/138 in the scala language, but i don't understand in what consists the call by name evaluation strategy? what differences it has with call by need? thanks, greetings

    Read the article

  • Blueprint CSS overlapping divs

    - by Chetan
    I'm using the Blueprint CSS framework, and I want to know how to create overlapping divs. If I try to use an absolutely positioned div inside of a relatively positioned div, it messes up the rest of the styling of the div by Blueprint. What is the correct way to do this?

    Read the article

  • putting multibinding on a single line in xaml

    - by Adam S
    Is there a way to take this multibinding: <TextBox.IsEnabled> <MultiBinding Converter="{StaticResource LogicConverter}"> <Binding ElementName="prog0_used" Path="IsEnabled" /> <Binding ElementName="prog0_used" Path="IsChecked" /> </MultiBinding> </TextBox.IsEnabled> and put is all on one line, as in <TextBox IsEnabled="" />? If so, where can I learn the rules of this formattiong?

    Read the article

  • SQLAuthority News Training and Consultancy and Travel Story of 30 Last 30 Days

    Today’s blog post is not technical as usual. Here, I present a real story, and I also invite you all to share your thoughts or opinions on this post. I am a professional SQL Server Trainer; I also do consultation in the area of the Performance Tuning and Query Optimizations. In any month, I like [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • 7 Web Design Tutorials from PSD to HTML/CSS

    - by Sushaantu
    Some time back when I was looking for some tutorials to create a website from scratch i.e. the process from designing the PSD to slice it and CSS/XHTML it, then not many quality results appeared. But that was like almost an year back and a lot of water has flown down the river Thanes since then. In this list I will give you links to some wonderful tutorials teaching you in a step by step way to design a website. These tutorials are ideal for someone who is learning web designing and has grasp of basic CSS, XHTML and little designing on Photoshop. How to Design and Code Web 2.0 Style Web Design Design a website from PSD to HTML Designing and Coding a Grunge Web Design from Scratch Creating a CSS layout from scratch Build a Sleek Portfolio Site from Scratch Designing and Coding a web design from scratch Design and Code a Dark and Sleek Web Design

    Read the article

  • How to install Sweetcron on XAMPP

    - by Sushaantu
    This tutorial will take you to the installation steps required to install Sweetcron in the XAMPP. I am taking the liberty to assume that you have already installed XAMPP. I First of all download sweetcron and copy the extracted “sweetcron” folder inside the htdocs folder in the XAMPP directory. You have to get few things in place before installing sweetcron: 1. Create a sweetcron database using Mysql. You can just put a name “sweetcron” and leave all the other settings such as Mysql connection collation as it is. Now that you have the database ready you can configure few settings before making sweetcron to work on XAMPP. 2. Open the config-sample PHP file with your text editor (something like Notepad++ or Komodo Edit is recommended) which is located in Sweetcron/system/application/config. You have to make few changes in it. a. In the first settings you have to edit the value of $config ['base_url']. The default value is             “http://www.your-site.com”; and you have to change that into “http://localhost/sweetcron/”; b. You also have to change the deafult settings of $config ['uri_protocol']. The value that you will see is “REQUEST_URI”; but you need to change that into “AUTO”; c. Now that we have made all the changes you can rename the file from config_sample to just config. 3. Open the database-sample.php in the text editor. You need to make the edits regarding the databse in here. a. The values of the databse at the moment are like this: $db['default']['hostname'] = “localhost”; $db['default']['username'] = “”; $db['default']['password'] = “”; $db['default']['database'] = “”; $db['default']['dbdriver'] = “mysql”; $db['default']['dbprefix'] = “”; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = “”; $db['default']['char_set'] = “utf8″; $db['default']['dbcollat'] = “utf8_general_ci”; You have to change that into $db['default']['hostname'] = “localhost”; $db['default']['username'] = “root”; $db['default']['password'] = “”; $db['default']['database'] = “sweetcron”; $db['default']['dbdriver'] = “mysql”; $db['default']['dbprefix'] = “”; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = “”; $db['default']['char_set'] = “utf8″; $db['default']['dbcollat'] = “utf8_general_ci”; We have written the username as root along with the name of database (sweetcron in my case). Since I was not using any password in xampp for the sweetcron database so I have left the password option empty. You can make suitable changes according to your system. Write down your password in the third line if you are using one in xampp. b. Now that we have made all the edits we can change the file name from database-sample to just database. 4. That leaves us with only one setting and that is editing values in the .htaccess file with our text editor. The default values you will have in the .htaccess file are: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] and you just have to add “sweetcron” after Rewritebase in the third line. Options +FollowSymLinks RewriteEngine On RewriteBase /sweetcron RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] 5. Now you are all set and done. You can access sweetcron in the localhost by going to http://localhost/sweetcron/ you will see some text on the top which would prompt you to click on one script. Click that script and behold, you have your sweetcrom installation on xampp ready. Further it will ask you to add deatils such as Lifestream name, username and email address. Fill those deatils and you will reach the admin panel.

    Read the article

  • 6 PhotoBlog Portfolio WordPress Themes

    - by Sushaantu
    It’s been quite a long time since we showcased the recent free WordPress themes on JustSkins.Some cool WordPress themes have been made in recent times that you may use for your photo portfolio blog. The following list contains both free and the premium WordPress themes. If you happen to be a professional photographer or just one by hobbyist you can expect something in here for you. Amplify 5 in 1 Portfolio Theme Amplify is a paid theme with some amazing features and nice image manipulation. It uses javascript image transition at the main page which supports an unlimited number of images. Grace Grace is a minimalistic WordPress theme which has lightweight jQuery powered rotating banner of featured photos. The theme has a slightly dull background which keeps the focus on the photographs. Free. Photography WordPress theme Photography is a widget ready theme which can be used to showcase your portfolio. Free. Gallery Gallery is an amazing child theme made on the Thematic Wordpress framework. The Gallery theme is extremely flexible and can be customized to individual tastes. The Folio Elements Folio Elements is a a part of Press75 premium themes and it is one of the most impressive Photoblog WordPress themes launched in recent times. All the images can be browsed using the slider on the main page while individual posts corresponding to the images can also be showed just below it. PhotoBlog WordPress Theme PhotoBlog is a premium theme compatible with WordPress 2.7 and above just like all the other themes mentioned in the list.

    Read the article

  • 10 CSS Grid Layout Generators

    - by Jyoti
    There are a lot of online generators which are of no use to any designers, however some can help designers to an extent. Some example of online generators are favicon generators, background generators, button generators, and badge generators. Some of the useful kinds are the ones that solve one purpose with quick and easy steps, especially useful for new designers, following is a list of some useful CSS grid layout generators. Grid Layout Generator By PageColumn: Blueprint Grid CSS Generator: Grid Generator By NetProtozo: Grid Generator By DegisnByGrid: Grid System Generator: YUI CSS Grid Builder: Variable Grid System: Firdamatic: CSS Sourced Ordered Variable Border Columed Page Maker: Grid Designer:

    Read the article

  • How To Backup Of MySQL Database Using PhpMyAdmin

    - by Jyoti
    It is very important to do backup of your MySql database, you will probably realize it when it is too late. A lot of web applications use MySql for storing the content. This can be blogs, and a lot of other things. When you have all your content as html files on your web server it is very easy to keep them safe from crashes, you just have a copy of them on your own PC and then upload them again after the web server is restored after the crash. All the content in the MySql database must also be backed up. If you have spent a lot of time making the content and it is only stored in the Mysql server, you will feel very bad if it gets lost for ever. Backing it up once every month or so makes sure you never loose too much of your work in case of a server crash, and it will make you sleep better at night. It is easy and fast, so there is no reason for not doing it. Step 1: Log into phpMyAdmin on your server. Step2: You can select the database that you would like to backup from the drop-down menu called Database. Step 3: A new page will be loaded in phpMyAdmin showing the selected database. In order to proceed with the backup click on the Export tab. Step 4: The options that you should select apart from the default ones are Save as file which will save the file locally to your computer in an .sql format and Add DROP TABLE which will add the drop table functionality if the table already exists in the database backup as shown below. Step 5: Click on the Go button to start the export/backup procedure for your database. A download window will pop up prompting for the exact place where you would like to save the file on your local computer. It is possible that the download starts automatically. This depends on your browser’s settings.

    Read the article

  • 10 Excellent Icon Sets

    - by Jyoti
    Icons are really useful for web design, application interface and more. Everyone loves good looking icons. In this post you will find 10 fresh new icon packs that you can use for your project. Pixelpress Mixed Icons: Social Media Icons By Studio M6: Now Wooden App Icon: Onebit Icon Pack: Fresh Add On Icon Set: 3D Crystals Icon Pack: Twitter Bird Icon: Wooden RSS Icons: Ganto Vector Icons: Vedro Icon PNG And Vector Pack:

    Read the article

  • 5 Mac Applications For Web And Graphic Design

    - by Jyoti
    In this article free applications useful and effective for the development and creation of websites with your Mac computer. Without further ado, here are 5 Excellent Mac Application for Web and Graphic Design. Fotoflexer : Fotoflexer claims to be “The world’s most advanced online image editor”. It offers completely free access to numerous features such as photo effects, graphics, shapes, morphing, and the creation of collages. You can also integrate and share your art with social sites like MySpace, Flickr, Facebook, and more. This can be an important app if the site you are creating is going to use applications. Simple CSS : With Simple CSS you can create Cascading Style Sheets from scratch or edit them right from the comfort of your desktop. Update styles on multiple pages all at once and reduce the data transfer usage on your page for faster loads. Blender : Blender is an open source software that allows you to create 3D animation with interactive playback leaves you with the option to optimize the style of your site with a few graphics. You can create animations with shades of colors, glossy features, soft shadows and advanced rendering features. JAlbum : Jalbum is a very useful app that allows you to create stylish photo galleries to publish on the web. All you have to do is simply drag selected folders into a pane where any images contained within the folder will automatically be arranged into a photo gallery. You can add several different themes and templates to enhance the appearance of your gallery, later then gain the HTML code and publish the complete gallery onto the web. Colorate : With Colorate you can create harmonized color palettes along with color schemes. Generate these palettes for images, photographs and more.

    Read the article

  • 15 Stylish Navigation Menus For Inspiration

    - by Jyoti
    A site’s navigation menu is one of the most prominent things that users see when they first visit. There are many ways to design a navigation menu  and since almost all websites have some form of navigation designers have to push their creative limits to build one that’s remarkable and outstanding. In this article, you’ll find a showcase of beautiful, creative, and stylish navigation menus for your inspiration. Tennessee Vacation: Alpine Meadows: White House: The Hole In Our Gospel: Navigant Consulting: The Lippincott: Torrance Web Design: Viget Extend: David Hellmann: Candes: Brad Colbow: Cheesetique : Satsu Design: Blue Moon: Africa Oasis Project

    Read the article

  • 5 Useful Wordpress Plugins For Google Adsense

    - by Jyoti
    Google Adsense has become the most popular online contextual advertising program and proper custom integration with Wordpress can help to increase Adsense earnings. Now on this post we have describe 5 useful wordpress plugin for google adsense. Few weeks ago we did a "10 Wordpress Plugins For Google Adsense ". Wordpress allows bloggers to easily integrate Google Adsense inside wordpress using plugins. Adsense Integrator : The Adsense Integrator plugin supports lot of programs other then adsense like AdBrite, AffiliateBOT, SHAREASALE, LinkShare, ClickBank, Oxado, Adpinion, AdGridWork, Adroll, Commission Junction, CrispAds, ShoppingAds, Yahoo!PN so this can be used when you are looking to have adsense as well as other alternatives. The rest of the features of the plugin are same where you give your adsense code into options field and it get inserted into blog posts. All In One Adsense And YPN : This is one of the most powerful adsense plugin for wordpress. Jut like other plugins, you can use this to insert your ads in the post but the plugin has some really good features like randomness which shows ad at random location in your blog which reduces ad blindness for viewers. You can also stop ads being shown on some pages using tags. Adsense Now : Other then the previous plugins , you can also give it a try to Adsense now. I haven’t used it (I have only used the first two) so its difficult to comment on it. It looks to be a lightweight plugin which insert adsense ads between posts and in posts body. Adsense Manager : Adsense Manager is one of the most popular and used plugin to manage adsense in wordpress blogs. Infact its newer version not only supports adsense, it also supports various other programs like adbrite, Commission Junction, YPN etc which makes it very powerful ad management plugin. You can inject adsense code anywhere in your blog posts as well as can put in different regions of your blog. Easy Adsense : Easy adsense is one of the new wordpress adsense plugin and that is why more feature rich. You can have different code for different themes using this plugin. It also support link units. To know all features, check out the plugin page.

    Read the article

  • 10 Useful CSS Tips And Tutorials

    - by Jyoti
    CSS is a technology that web designers use everyday, but yet it is something that most struggle with as well. Whether it’s keeping stylesheets for large sites manageable or creating image effects that are cross browser compatible, there are plenty of things to cause frustration. This article is an attempt to provide you with a few resources that might help you with your CSS or introduce you to a few tricks you didn’t know about. Organizing Your Stylesheet Using CSS Edit: Rob Soule of Viget Labs shows you how to organize your style sheets using CSS Edit, a powerful CSS editor built exclusively for the mac. Tips For Organizing Your CSS: A set of practical tips for organizing your style sheets. Write A Well Structured CSS File: A detailed and well written post about how to write a well structured CSS file. Expandable CSS Tabs Tutorials: A tutorial on creating expandable CSS tabs. Simple Round CSS Buttons: Learn how to create rounded corner buttons with only One Image and One CSS file. Beautiful CSS Buttons With Icons Set: Learn how to create a clean set of buttons with CSS and an icon set. Scalable CSS Buttons Using PNG And Background Colors: Create Resizing Thumbnails Using Overflow Property: Learn how to create a cool resizing thumbnail effect. CSS Decorative Gallery: Decorate your images and photo galleries without editing the source images. Placing Text Over Image Using CSS Position Property: A simple technique for placing text over an image.

    Read the article

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