Search Results

Search found 15137 results on 606 pages for 'global state'.

Page 39/606 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • Application start in global.asax

    - by Zerotoinfinite
    Hi experts, I am developing my application in asp.net 3.5 and sql server 2005, and I want to record the visitor info into my database, like once the visitor enter my website, I'll insert his browser details to the database. [It's not necessary that visitor login my website]. Now I am confused where to put my code, If I put insert function in every page_load then on every page it will execute and I'll not be able to get the exact number of visitor, visited my website. Shall I go with application_start in Global.asax ?? Please help.

    Read the article

  • Path Inclusion/Global variable not working?

    - by Dan LaManna
    Simply put, my config file includes my database class, and the config file has in it: global $db; $db = new database(DB_HOST, DB_NAME, DB_USER, DB_PASS); That file is root/config.php Moving on to root/functions/func.newpage.php doesn't have any includes/requires, and uses $db-classfunction since the file I'm working with: root/newpage.php - requires the config file, as well as func.newpage.php. However I still come up with: Undefined variable db. Anything you guys are seeing I'm not? Thanks! Let me know if more details are needed.

    Read the article

  • A global login (many sites)

    - by John
    We are a growing network but we figured we want to keep that the User only would need one account in order to access the network different sites. (Similar to Stackoverflow's login, If you login in to another "site" you use your account credentials and than your account is created). We want our own login system (Username, password) and not OpenId, as we'd probably have that in the future, but the main focus right now is the global login. How can I do this? Do a Curl request and send back a cookie? Have a "database" just for the login procedure and on first login also create a new "User" in the site specified database? Suggestions?.

    Read the article

  • GridView doesn't remember state between postbacks

    - by Ryan
    Hi, I have a simple ASP page with databound grid (bound to an object source). The grid is within the page of a wizard and has a 'select' checkbox for each row. In one stage of the wizard, I bind the GridView: protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e) { ... // Bind and display matches GridViewMatches.EnableViewState = true; GridViewMatches.DataSource = getEmailRecipients(); GridViewMatches.DataBind(); And when the finish button is clicked, I iterate through the rows and check what's selected: protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e) { // Set the selected values, depending on the checkboxes on the grid. foreach (GridViewRow gr in GridViewMatches.Rows) { Int32 personID = Convert.ToInt32(gr.Cells[0].Text); CheckBox selected = (CheckBox) gr.Cells[1].FindControl("CheckBoxSelectedToSend"); But at this stage GridViewMatches.Rows.Count = 0! I don't re-bind the grid, I shouldn't need to, right? I expect the view-state to maintain the state. (Also, if I do rebind the grid, my selection checkboxes will be cleared) NB: This page also dynamically adds user controls in OnInit method. I have heard that it might mess with the view state, but as far as I can tell, I am doing it correctly and the viewstate for those added controls seems to work (values are persisted between postbacks) Thanks a lot in advance for any help! Ryan UPDATE: Could this be to do with the fact I am setting the datasource programatically? I wondered if the asp engine was databinding the grid during the page lifecycle to a datasource that was not yet defined. (In a test page, the GridView is 'automatically' databound'. I don't want the grid to re-bound I just want the values from the viewstate from the previous post! Also, I have this in the asp header: ViewStateEncryptionMode="Never" - this was to resolve an occasional 'Invalid Viewstate Validation MAC' message Thanks again Ryan

    Read the article

  • Integration tests in Continuous Integration environment: Database and filesystem state

    - by dario_ramos
    I'm trying to implement automated integration tests for my application. It's a very complex monster. You could say that its database and part of the filesystem are part of its state, because it saves image files in the hard drive, and references to those in the DB. The software needs all those, in a coherent state, to work properly. Back to writing tests: To run any relevant test, I need some image files in the filesystem, and certain records filled in the database. I thought of putting all of these in a separate folder called TestEnvironmentData in the repository, and retrieving them from the Continuous Integration Server (Team City), but a colleague said the repo is quite full as it is, and that I should set up a special directory, and databases, only in the Continuous Integration server. I don't like that because the tests success depend on me manually mantaining stuff in the server, and restoring initial state before every test becomes cumbersome. What do you guys do when you need to write integration tests for an app like this? The main goal is having an automated test harness to approach a large scale refactoring. There's lots of spaghetti code and the app's current architecture is hardly unit testable, that's why I decided on integration tests first. Any alternative approach is welcome.

    Read the article

  • JQUERY: Setting Active state on animated menu tabs

    - by Tony
    I have image sprites that use JQuery to set the BG position on mouseover and mouseout events. When I set the active state BG position using JQUERY it works fine until I move my cursor away from the active 'tab' which then fires the mouseout event animation. What I want is the mouseClick event to stop the animation on the active tab but still allow the animation effect to work on the other tabs, and when another tab is clicked for the active state to be removed from the current tab to the new 'active' tab. JQuery $(function(){ /* This script changes main nav links hover state*/ $('.navigation a') .css( {backgroundPosition: "-1px -120px"} ) .mouseover(function(){ $(this).stop().animate({backgroundPosition:"(-1px -240px)"}, {duration:400}) }) .mouseout(function(){ $(this).stop().animate({backgroundPosition:"(-1px -120px)"}, {duration:400, complete:function (){ $(this).css({backgroundPosition: "-1px -120px"}) }}) }) }); $(document).ready(function(){ $("a").click(function(){ $(this).css({backgroundPosition: "-1px -235px"}); }); }); HTML <ul class="navigation"> <li><a href="#index" tabindex="10" title="Home" id="homeButton"></a></li> <li><a href="#about" tabindex="20" title="About us" id="aboutButton"></a></li> <li><a href="#facilities" tabindex="30" title="Our facilities and opening Times" id="facilitiesButton"></a></li> <li><a href="#advice" tabindex="40" title="Advice and useful links" c id="adviceButton"></a></li> <li><a href="#find" tabindex="50" title="How to find Us" id="findButton"></a></li> <li><a href="#contact" tabindex="60" title="Get in touch with us" id="contactButton"></a></li> </ul> You can see what I've got so far here Thanks in advance for any help

    Read the article

  • Flex 4 Button state in a HGroup

    - by chchrist
    Hi all, I have a HGroup with some buttons inside which is my application's menu. <s:HGroup id="nav"> <s:Button id="homeButton" label="Home" /> <s:Button id="showroomButton" label="Showroom" /> <s:Button label="Catalogue" /> <s:Button label="Offers" /> <s:Button label="My Account" /> <s:Button label="My Orders" /> </s:HGroup> What I want is when I click for example the #homeButton to change it's state to "over", become disabled and reset all other buttons to the "up" state. I've written this function private function resetNavState():void { for(var i:int = 0,ii:int = nav.numChildren-1;i<ii;i++) { Button(nav.getChildAt(i)).mouseEnabled = true; Button(nav.getChildAt(i)).skin.setCurrentState("up",true); } } And then on the homeButton click handler for example i use protected function homeButton_clickHandler(event:MouseEvent):void { resetNavState(); currentState = "home"; homeButton.skin.setCurrentState("over",true); homeButton.mouseEnabled = false; } I resets the states of the #nav buttons but it doesn't change the state of the pressed button. Any ideas? Thanx in advance

    Read the article

  • jCarousel - achieving an active state AND wrap:circular

    - by swisstony
    Hey folks A while back I implemented the jCarousel image solution for a client that required a numbered active state. After a bit of googling a found the answer but noticed that the preferred circular option would not work. What would happen is that once the carousel had cycled through all its (5) images, upon the return to the first, the active state would be lost, because, according to jcarousel it was actually the 6th (the index just keeps on incrementing). I just went ahead and instead used wrap:'both' which at least had a correctly functioning active state. However now the client says they dont like this effect and simply want the animation to return to position 1 after the final image. This means I need to get'wrap: 'both' working somehow. Below is my current code. Can someone please solve this one, as its a little above my head! function highlight(carousel, obejctli,liindex,listate){ jQuery('.jcarousel-control a:nth-child('+ liindex +')').attr("class","active"); }; function removehighlight(carousel, obejctli,liindex,listate){ jQuery('.jcarousel-control a:nth-child('+ liindex +')').removeAttr("class","active"); }; jQuery('#mycarousel').jcarousel({ initCallback: mycarousel_initCallback, auto: 5, wrap: 'both', vertical: true, scroll: 1, buttonNextHTML: null, buttonPrevHTML: null, animation: 1000, itemVisibleInCallback: highlight, itemVisibleOutCallback: removehighlight }); }); Thanks in advance

    Read the article

  • Use Zip to Pre-Populate City/State Form with jQuery AJAX

    - by Paul
    I'm running into a problem that I can solve fine by just submitting a form and calling a db to retrieve/echo the information, but AJAX seems to be a bit different for doing this (and is what I need). Earlier in a form process I ask for the zip code like so: <input type="text" maxlength="5" size="5" id="zip" /> Then I have a button to continue, but this button just runs a javascript function that shows the rest of the form. When the rest of the form shows, I want to pre-populate the City input with their city, and pre-populate the State dropdown with their state. I figured I would have to find a way to set city/state to variables, and echo the variables into the form. But I can't figure out how to get/set those variables with AJAX as opposed to a form submit. Here's how I did it without ajax: $zip = mysql_real_escape_string($_POST['zip']); $q = " SELECT city FROM citystatezip WHERE zip = $zip"; $r = mysql_query($q); $row = mysql_fetch_assoc($r); $city = $row['city']; Can anybody help me out with using AJAX to set these variables? Thanks!

    Read the article

  • Concrete examples of state sharing between multiple viewmodels (WPF MVVM)

    - by JohnMetta
    I have a WPF/Entity Framework (4.0) project with many objects. I'd like to build the application so that that I can have object selection state shared across viewmodels. For Example: We have Cars, Drivers, Passengers, and Cargo classes. We also have UserControls for CarList, DriverList, etc. and editor windows for CarEditor, DriverEditor, etc. Furthermore, we have viewmodels for all of these (CarListViewModel, DriverListViewModel, CargoEditorViewModel, etc). This all composes a dockable interface where the user can have multiple object lists, editors, and viewers open. What I want is a concrete code example of how to wireup multiple viewmodels so that selecting a car in the CarList will cause that car to go live in the CarEditorView, but also be selected in any other view for which the context is valid (such as a DriverByCarView- or just DriverList if there is a filter predicate). There are a number of suggestions and discussions based on this question. The two methods that seem to dominate are: 3018307: Discusses state sharing by mentioning a messaging subsystem 1159035: Discusses state sharing by using an enclosing viewmodel Is one of these approaches better than the other? Does anyone have a concrete example of either/both of these methods in the form of a write-up or small code project? I'm still learning WPF, so pointers to entry points for reading API fundamentals are appreciated, but looking at code examples is where I usually go. Thanks In case anyone is interested, here are some other similar discussions: 3816961: Discusses returning multiple viewmodels depending on object type (i.e. a collection of arbitrary types adhering to a specific interface) 1928130: Discusses whether it is a good idea to aggregate viewmodels as properties of other viewmodels (e.g. a MainWindow viewmodel composed of panel viewmodels) 1120061: Essentially discusses whether to have use a viewmodel-per-model strategy or a viewmodel-per-view-element strategy. 4244222: Discusses whether or not to nest the viewmodels when using a nested object hierarchy. 4429708: Discusses sharing collections between viewmodels directly, but doesn't go into detail. List item: Discusses managing multiple selections within a single viewmodel.

    Read the article

  • Active State Image Display

    - by fmz
    I have some images that need to change, based not only on hover, but also on active state. If you look at the page here: http://site427.mysite4now.net/tazthedog/site1/ There are some tabs with Screen Printing Quick Links, etc. The tab image is associated with the link and displays properly. The icon in tabs defaults to the gray and turns blue on mouse over, however, I also need it to be blue on the "active" state. Here is the css: .quick-links em:hover { background: transparent url(../images/quick-links.png) 10px 9px no-repeat ; display: block ; float: left; } Here is the html: <ul class="tabs"> <li class="quick-links"> <a href="#quickLinks" id=""> <em> <span>Screen Printing Quick Links</span> </em> </a> </li> <li class="distributor-ql"> <a href="#distributorQL" id=""> <em> <span>Dealer &amp; Distributor Quick Links</span> </em> </a> </li> </ul> I tried adding a .quick-links em:active... but that doesn't maintain it. I know there is a way to keep the icon blue while in the active state, I just need a little help to understand what that is. Thanks!

    Read the article

  • .NET port with Java's Map, Set, HashMap

    - by Nikos Baxevanis
    I am porting Java code in .NET and I am stuck in the following lines that (behave unexpectedly in .NET). Java: Map<Set<State>, Set<State>> sets = new HashMap<Set<State>, Set<State>>(); Set<State> p = new HashSet<State>(); if (!sets.containsKey(p)) { ... } The equivalent .NET code could possibly be: IDictionary<HashSet<State>, HashSet<State>> sets = new Dictionary<HashSet<State>, HashSet<State>>(); HashSet<State> p = new HashSet<State>(); if (!sets.containsKey(p)) { /* (Add to a list). Always get here in .NET (??) */ } However the code comparison fails, the program think that "sets" never contain Key "p" and eventually results in OutOfMemoryException. Perhaps I am missing something, object equality and identity might be different between Java and .NET. I tried implementing IComparable and IEquatable in class State but the results were the same. Edit: What the code does is: If the sets does not contain key "p" (which is a HashSet) it is going to add "p" at the end of a LinkedList. The State class (Java) is a simple class defined as: public class State implements Comparable<State> { boolean accept; Set<Transition> transitions; int number; int id; static int next_id; public State() { resetTransitions(); id = next_id++; } // ... public int compareTo(State s) { return s.id - id; } public boolean equals(Object obj) { return super.equals(obj); } public int hashCode() { return super.hashCode(); }

    Read the article

  • Relay Access Denied (State 13) Postfix + Dovecot + Mysql

    - by Pierre Jeptha
    So we have been scratching our heads for quite some time over this relay issue that has presented itself since we re-built our mail-server after a failed Webmin update. We are running Debian Karmic with postfix 2.6.5 and Dovecot 1.1.11, sourcing from a Mysql database and authenticating with SASL2 and PAM. Here are the symptoms of our problem: 1) When users are on our local network they can send and receive 100% perfectly fine. 2) When users are off our local network and try to send to domains not of this mail server (ie. gmail) they get the "Relay Access Denied" error. However users can send to domains of this mail server when off the local network fine. 3) We host several virtual domains on this mailserver, the primary domain being airnet.ca. The rest of our virtual domains (ex. jeptha.ca) cannot receive email from domains not hosted by this mailserver (ie. gmail and such cannot send to them). They receive bounce backs of "Relay Access Denied (State 13)". This is regardless of whether they are on our local network or not, which is why it is so urgent for us to get this solved. Here is our main.cf from postfix: myhostname = mail.airnet.ca mydomain = airnet.ca smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no smtpd_sasl_type = dovecot queue_directory = /var/spool/postfix smtpd_sasl_path = private/auth smtpd_sender_restrictions = permit_mynetworks permit_sasl_authenticated smtp_sasl_auth_enable = yes smtpd_sasl_auth_enable = yes append_dot_mydomain = no readme_directory = no smtp_tls_security_level = may smtpd_tls_security_level = may smtp_tls_note_starttls_offer = yes smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_auth_only = no alias_maps = proxy:mysql:/etc/postfix/mysql/alias.cf hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = mail.airnet.ca, airnet.ca, localhost.$mydomain mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + local_recipient_maps = $alias_maps $virtual_mailbox_maps proxy:unix:passwd.byname home_mailbox = /var/virtual/ mail_spool_directory = /var/spool/mail mailbox_transport = maildrop smtpd_helo_required = yes disable_vrfy_command = yes smtpd_etrn_restrictions = reject smtpd_data_restrictions = reject_unauth_pipelining, permit show_user_unknown_table_name = no proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps $virtual_uid_maps $virtual_gid_maps virtual_alias_domains = message_size_limit = 20971520 transport_maps = proxy:mysql:/etc/postfix/mysql/vdomain.cf virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql/vmailbox.cf virtual_alias_maps = proxy:mysql:/etc/postfix/mysql/alias.cf hash:/etc/mailman/aliases virtual_uid_maps = proxy:mysql:/etc/postfix/mysql/vuid.cf virtual_gid_maps = proxy:mysql:/etc/postfix/mysql/vgid.cf virtual_mailbox_base = / virtual_mailbox_limit = 209715200 virtual_mailbox_extended = yes virtual_create_maildirsize = yes virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql/vmlimit.cf virtual_mailbox_limit_override = yes virtual_mailbox_limit_inbox = no virtual_overquote_bounce = yes virtual_minimum_uid = 1 maximal_queue_lifetime = 1d bounce_queue_lifetime = 4h delay_warning_time = 1h append_dot_mydomain = no qmgr_message_active_limit = 500 broken_sasl_auth_clients = yes smtpd_sasl_path = private/auth smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous smtpd_sasl_authenticated_header = yes smtp_bind_address = 142.46.193.6 relay_domains = $mydestination mynetworks = 127.0.0.0, 142.46.193.0/25 inet_interfaces = all inet_protocols = all And here is the master.cf from postfix: # ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ========================================================================== smtp inet n - - - - smtpd #submission inet n - - - - smtpd # -o smtpd_tls_security_level=encrypt # -o smtpd_sasl_auth_enable=yes # -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING #smtps inet n - - - - smtpd # -o smtpd_tls_wrappermode=yes # -o smtpd_sasl_auth_enable=yes # -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING #628 inet n - - - - qmqpd pickup fifo n - - 60 1 pickup cleanup unix n - - - 0 cleanup qmgr fifo n - n 300 1 qmgr #qmgr fifo n - - 300 1 oqmgr tlsmgr unix - - - 1000? 1 tlsmgr rewrite unix - - - - - trivial-rewrite bounce unix - - - - 0 bounce defer unix - - - - 0 bounce trace unix - - - - 0 bounce verify unix - - - - 1 verify flush unix n - - 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap smtp unix - - - - - smtp # When relaying mail as backup MX, disable fallback_relay to avoid MX loops relay unix - - - - - smtp -o smtp_fallback_relay= # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 showq unix n - - - - showq error unix - - - - - error retry unix - - - - - error discard unix - - - - - discard local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - - - - lmtp anvil unix - - - - 1 anvil scache unix - - - - 1 scache maildrop unix - n n - - pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} # # See the Postfix UUCP_README file for configuration details. # uucp unix - n n - - pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) # # Other external delivery methods. # ifmail unix - n n - - pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) bsmtp unix - n n - - pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient scalemail-backend unix - n n - 2 pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension} mailman unix - n n - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user} spfpolicy unix - n n - - spawn user=nobody argv=/usr/bin/perl /usr/sbin/postfix-policyd-spf-perl smtp-amavis unix - - n - 4 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes #127.0.0.1:10025 inet n - n - - smtpd dovecot unix - n n - - pipe flags=DRhu user=dovecot:21pever1lcha0s argv=/usr/lib/dovecot/deliver -d ${recipient Here is Dovecot.conf protocols = imap imaps pop3 pop3s disable_plaintext_auth = no log_path = /etc/dovecot/logs/err info_log_path = /etc/dovecot/logs/info log_timestamp = "%Y-%m-%d %H:%M:%S ". syslog_facility = mail ssl_listen = 142.46.193.6 ssl_disable = no ssl_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem ssl_key_file = /etc/ssl/private/ssl-cert-snakeoil.key mail_location = mbox:~/mail:INBOX=/var/virtual/%d/mail/%u mail_privileged_group = mail mail_debug = yes protocol imap { login_executable = /usr/lib/dovecot/imap-login mail_executable = /usr/lib/dovecot/rawlog /usr/lib/dovecot/imap mail_executable = /usr/lib/dovecot/gdbhelper /usr/lib/dovecot/imap mail_executable = /usr/lib/dovecot/imap imap_max_line_length = 65536 mail_max_userip_connections = 20 mail_plugin_dir = /usr/lib/dovecot/modules/imap login_greeting_capability = yes } protocol pop3 { login_executable = /usr/lib/dovecot/pop3-login mail_executable = /usr/lib/dovecot/pop3 pop3_enable_last = no pop3_uidl_format = %08Xu%08Xv mail_max_userip_connections = 10 mail_plugin_dir = /usr/lib/dovecot/modules/pop3 } protocol managesieve { sieve=~/.dovecot.sieve sieve_storage=~/sieve } mail_plugin_dir = /usr/lib/dovecot/modules/lda auth_executable = /usr/lib/dovecot/dovecot-auth auth_process_size = 256 auth_cache_ttl = 3600 auth_cache_negative_ttl = 3600 auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@ auth_verbose = yes auth_debug = yes auth_debug_passwords = yes auth_worker_max_count = 60 auth_failure_delay = 2 auth default { mechanisms = plain login passdb sql { args = /etc/dovecot/dovecot-sql.conf } userdb sql { args = /etc/dovecot/dovecot-sql.conf } socket listen { client { path = /var/spool/postfix/private/auth mode = 0660 user = postfix group = postfix } master { path = /var/run/dovecot/auth-master mode = 0600 } } } Please, if you require anything do not hesistate, I will post it ASAP. Any help or suggestions are greatly appreciated! Thanks, Pierre

    Read the article

  • Could you give me an example of how to attach an object in Deleted state – I keep getting an exception [migrated]

    - by carewithl
    From MSDN : An object in the Deleted state can only be attached when the ObjectStateManager is already tracking the relationship instance. Could you give me an example of how to attach an object in the Deleted state. I tried the following and got "System.InvalidOperationException: The object being attached is in an added or deleted state. Relationships cannot be created for objects in this state". var contact = context.Contacts.First(); Console.WriteLine(contact.Addresses.Count()); // 2 var address = contact.Addresses.First(); context.Addresses.DeleteObject(address); contact.Addresses.Attach(address); // InvalidOperationException thank you

    Read the article

  • game state singleton cocos2d, initWithEncoder always returns null

    - by taber
    Hi, I'm trying to write a basic test "game state" singleton in cocos2d, but for some reason upon loading the app, initWithCoder is never called. Any help would be much appreciated, thanks. Here's my singleton GameState.h: #import "cocos2d.h" @interface GameState : NSObject <NSCoding> { NSInteger level, score; Boolean seenInstructions; } @property (readwrite) NSInteger level; @property (readwrite) NSInteger score; @property (readwrite) Boolean seenInstructions; +(GameState *) sharedState; +(void) loadState; +(void) saveState; @end ... and GameState.m: #import "GameState.h" #import "Constants.h" @implementation GameState static GameState *sharedState = nil; @synthesize level, score, seenInstructions; -(void)dealloc { [super dealloc]; } -(id)init { if(!(self = [super init])) return nil; level = 1; score = 0; seenInstructions = NO; return self; } +(void)loadState { @synchronized([GameState class]) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *saveFile = [documentsDirectory stringByAppendingPathComponent:kSaveFileName]; Boolean saveFileExists = [[NSFileManager defaultManager] fileExistsAtPath:saveFile]; if(!sharedState) { sharedState = [GameState sharedState]; } if(saveFileExists == YES) { [sharedState release]; sharedState = [[NSKeyedUnarchiver unarchiveObjectWithFile:saveFile] retain]; } // at this point, sharedState is null, saveFileExists is 1 if(sharedState == nil) { // this always occurs CCLOG(@"Couldn't load game state, so initialized with defaults"); sharedState = [self sharedState]; } } } +(void)saveState { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *saveFile = [documentsDirectory stringByAppendingPathComponent:kSaveFileName]; [NSKeyedArchiver archiveRootObject:[GameState sharedState] toFile:saveFile]; } +(GameState *)sharedState { @synchronized([GameState class]) { if(!sharedState) { [[GameState alloc] init]; } return sharedState; } return nil; } +(id)alloc { @synchronized([GameState class]) { NSAssert(sharedState == nil, @"Attempted to allocate a second instance of a singleton."); sharedState = [super alloc]; return sharedState; } return nil; } +(id)allocWithZone:(NSZone *)zone { @synchronized([GameState class]) { if(!sharedState) { sharedState = [super allocWithZone:zone]; return sharedState; } } return nil; } ... -(void)encodeWithCoder:(NSCoder *)coder { [coder encodeInt:level forKey:@"level"]; [coder encodeInt:score forKey:@"score"]; [coder encodeBool:seenInstructions forKey:@"seenInstructions"]; } -(id)initWithCoder:(NSCoder *)coder { CCLOG(@"initWithCoder called"); self = [super init]; if(self != nil) { CCLOG(@"initWithCoder self exists"); level = [coder decodeIntForKey:@"level"]; score = [coder decodeIntForKey:@"score"]; seenInstructions = [coder decodeBoolForKey:@"seenInstructions"]; } return self; } @end ... I'm saving the state on app exit, like this: - (void)applicationWillTerminate:(UIApplication *)application { [GameState saveState]; [[CCDirector sharedDirector] end]; } ... and loading the state when the app finishes loading, like this: - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [GameState loadState]; ... } I've tried moving around where I call loadState too, for example in my main CCScene, but that didn't seem to work either. Thanks again in advance.

    Read the article

  • Global Hotkey in Mono and Gtk#

    - by Zach Johnson
    I'm trying to get a global hotkey working in Linux using Mono. I found the signatures of XGrabKey and XUngrabKey, but I can't seem to get them working. Whenever I try to invoke XGrabKey, the application crashes with a SIGSEGV. This is what I have so far: using System; using Gtk; using System.Runtime.InteropServices; namespace GTKTest { class MainClass { const int GrabModeAsync = 1; public static void Main(string[] args) { Application.Init(); MainWindow win = new MainWindow(); win.Show(); // Crashes here XGrabKey( win.Display.Handle, (int)Gdk.Key.A, (uint)KeyMasks.ShiftMask, win.Handle, true, GrabModeAsync, GrabModeAsync); Application.Run(); XUngrabKey( win.Display.Handle, (int)Gdk.Key.A, (uint)KeyMasks.ShiftMask, win.Handle); } [DllImport("libX11")] internal static extern int XGrabKey( IntPtr display, int keycode, uint modifiers, IntPtr grab_window, bool owner_events, int pointer_mode, int keyboard_mode); [DllImport("libX11")] internal static extern int XUngrabKey( IntPtr display, int keycode, uint modifiers, IntPtr grab_window); } public enum KeyMasks { ShiftMask = (1 << 0), LockMask = (1 << 1), ControlMask = (1 << 2), Mod1Mask = (1 << 3), Mod2Mask = (1 << 4), Mod3Mask = (1 << 5), Mod4Mask = (1 << 6), Mod5Mask = (1 << 7) } } Does anyone have a working example of XGrabKey? Thanks!

    Read the article

  • Using singleton instead of a global static instance

    - by Farstucker
    I ran into a problem today and a friend recommended I use a global static instance or more elegantly a singleton pattern. I spent a few hours reading about singletons but a few things still escape me. Background: What Im trying to accomplish is creating an instance of an API and use this one instance in all my classes (as opposed to making a new connection, etc). There seems to be about 100 ways of creating a singleton but with some help from yoda I found some thread safe examples. ..so given the following code: public sealed class Singleton { public static Singleton Instance { get; private set; } private Singleton() { APIClass api = new APIClass(); //Can this be done? } static Singleton() { Instance = new Singleton(); } } How/Where would you instantiate the this new class and how should it be called from a separate class? EDIT: I realize the Singleton class can be called with something like Singleton obj1 = Singleton.Instance(); but would I be able to access the methods within the APIs Class (ie. obj1.Start)? (not that I need to, just asking) EDIT #2: I might have been a bit premature in checking the answer but I do have one small thing that is still causing me problems. The API is launching just fine, unfortunately Im able to launch two instances? New Code public sealed class SingletonAPI { public static SingletonAPI Instance { get; private set; } private SingletonAPI() {} static SingletonAPI() { Instance = new SingletonAPI(); } // API method: public void Start() { API myAPI = new API();} } but if I try to do something like this... SingletonAPI api = SingletonAPI.Instance; api.Start(); SingletonAPI api2 = SingletonAPI.Instance; // This was just for testing. api2.Start(); I get an error saying that I cannot start more than one instance.

    Read the article

  • Global.asax Event: Application_OnPostAuthenticateRequest

    - by Hemant Kothiyal
    Hi, I am using Application_OnPostAuthenticateRequest event in global.asax to get roles and permissions of authenticated user also i have made my custom principal class to get user detail and roles and permission. To get some information which remain same for that user. following are the code void Application_OnPostAuthenticateRequest(object sender, EventArgs e) { // Get a reference to the current User IPrincipal objIPrincipal = HttpContext.Current.User; // If we are dealing with an authenticated forms authentication request if ((objIPrincipal.Identity.IsAuthenticated) && (objIPrincipal.Identity.AuthenticationType == "Forms")) { CustomPrincipal objCustomPrincipal = new CustomPrincipal(); objCustomPrincipal = objCustomPrincipal.GetCustomPrincipalObject(objIPrincipal.Identity.Name); HttpContext.Current.User = objCustomPrincipal; CustomIdentity ci = (CustomIdentity)objCustomPrincipal.Identity; HttpContext.Current.Cache["CountryID"] = FatchMasterInfo.GetCountryID(ci.CultureId); HttpContext.Current.Cache["WeatherLocationID"] = FatchMasterInfo.GetWeatherLocationId(ci.UserId); Thread.CurrentPrincipal = objCustomPrincipal; } } My question is as following This event fires every time for every request. Hence for each request the code execute? My approach is right or not? Is it right to add HttpContext.Current.Cache in this event or we should move it on session start

    Read the article

  • extern and global in c

    - by JPro
    Can anyone please tell me is there any special requirement to use either EXTERN or GLOBAL variables in a C program? I do not see any difference in a program like below, if I change from gloabl to extern. #include <stdio.h> #include <stdlib.h> int myGlobalvar = 10; int main(int argc, char *argv[]) { int myFunc(int); int i; i = 12; myGlobalvar = 100; printf("Value of myGlobalvar is %d , i = %d\n", myGlobalvar, i); i = myFunc(10); printf("Value of passed value : %d\n",i); printf("again Value of myGlobalvar is %d , i = %d\n", myGlobalvar, i); system("PAUSE"); return 0; } int myFunc(int i) { i = 20 + 1000; //extern int myGlobalvar; myGlobalvar = 20000; // printf("Value of passed value : %d",i); return i; } If uncomment extern int myGlobalvar, the value does not change. Is there any correct difference between both? Can anyone please correct me?

    Read the article

  • Rails - handling global site settings

    - by egarcia
    I'm developing a new rails application which is supposed to be installed several times in order to implement several sites. There are some things, like the "Site Title" or the "Default Number of Items per Page" that clearly belong to a "global settings" table / config file. I've made a list of the things I think I'll need: ActiveRecord model that is capable of: Storing different kinds of data. I suppose this would be accomplished encoding the values on a string on the db, probably with a "type" field. Indexing settings by name Validations based on a "type" attribute (i.e. don't accept invalid dates on "date" settings) Validations based on a allows_nil property. A controller that allows me to change settings via views. I'm pretty sure I could implement this myself, but I'm not willing to reinvent the wheel. I've done some searching, but I could only find rails-settings, which doesn't really serve me: I need a proper model & controller so I can use declarative-authorization, and it does not provide any controller or view facilities. Is there a gem or plugin out there that implements what I want, or any library I should look at? Thanks a lot.

    Read the article

  • CUDA Kernel Not Updating Global Variable

    - by Taher Khokhawala
    I am facing the following problem in a CUDA kernel. There is an array "cu_fx" in global memory. Each thread has a unique identifier jj and a local loop variable ii and a local float variable temp. Following code is not working. It is not at all changing cu_fx[jj]. At the end of loop cu_fx[jj] remains 0. ii = 0; cu_fx[jj] = 0; while(ii < l) { if(cu_y[ii] > 0) cu_fx[jj] += (cu_mu[ii]*cu_Kernel[(jj-start_row)*Kernel_w + ii]); else cu_fx[jj] -= (cu_mu[ii]*cu_Kernel[(jj-start_row)*Kernel_w + ii]); ii++; } But when I rewrite it using a temporary variable temp, it works fine. ii = 0; temp = 0; while(ii < l) { if(cu_y[ii] > 0) temp += (cu_mu[ii]*cu_Kernel[(jj-start_row)*Kernel_w + ii]); else temp -= (cu_mu[ii]*cu_Kernel[(jj-start_row)*Kernel_w + ii]); ii++; } cu_fx[jj] = temp; Can somebody please help with this problem. Thanking in advance.

    Read the article

  • Global resources can't be resolved after publishing Website in VS2008

    - by Scoregraphic
    Hi there I have a web-project running in VS 2008. We have some global resource files (*.resx) in the App_GlobalResources folder for internationalisation. All this works like a charm on my local IIS installation out of VS. But when I publish my web-project to the local filesystem and/or another server, all the resources can no longer be found. So I guess the pre-compilation is somehow corrupting stuff. When I call the pre-compiled web, I get an error that the resource object with key xyz cannot be found, although it could be found before. I checked with .NET reflector if the resource stuff made it into the *.dlls. All those identifiers are there (bin/Web.dll, bin/<culture>/Web.resources.dll). The identifiers are loaded like this: <asp:MenuItem NavigateUrl="~/OrderNew.aspx" Text="<%$ Resources:MyProject, MenuNewOrder %>" Value="NewOrder"> The resource files are called MyProject.resx and MyProject.<culture>.resx where <culture> corresponds the the specific culture (i.e. MyProject.de-DE.resx). Any ideas how to solve this? I really appreciate any help. Thanks Edit: If I copy the App_GlobalResources folder manually to the output, the resources may be loaded normally. So I really really wonder what this pre-compilation is all about. I'm still interested in solving the issue "the right way".

    Read the article

  • Firefox add-on development: Register global dynamic custom keyboard shortcuts

    - by dezwart
    I have been tasked with developing a Firefox add-on that is capable of registering global keyboard shortcuts (ones that will work throughout all areas of Firefox) that will open up the side-bar and execute an XMLRPC request based on previously recorded input. The idea here is that there will be many potential XMLRPC requests that the user will want to execute via a keyboard shortcut. Currently, the add-on is capable of handling pre-defined static keyboard shortcuts via the Firefox overlay. What I would like to achieve, is to allow the user to register their own dynamic custom keyboard shortcut. There is an add-on that currently has some of this functionality, called Keyconfig. I'm not keen on having to ask users to install a second add-on to define their own shortcuts. It also seems that using the dynamic keyboard shortcut registration method in Keyconfig would require the user to close all Firefox windows before the dynamic shortcut is made available. What I would like to know is: Is an XPCOM component the best way to register dynamic keyboard shortcuts from within a Firefox add-on? Is there a way to register the keyboard shortcut so that it is immediately available to all Firefox windows, without having to close the windows beforehand?

    Read the article

  • Accessing global variables of custom controls in ASP.NET

    - by CL4NCY
    Hi, I have built lots of custom asp.net controls which work really well separately but I want to somehow allow global access to all their variables from anywhere on the page. I have a central control called the ContentManager which I can use to store these variables. The problem I have is that all the controls are bound at different times so I only want the variables available after they're bound. For example I have many custom repeaters on the page which when bound I want to add a reference in the content manager so all their variables are then available to use. <Custom:ContentManager ID="cm" runat="server"/> <Custom:Repeater ID="r1" runat="server"/> <Custom:Repeater ID="r2" runat="server"/> <Custom:Repeater ID="r3" runat="server"/> Then I want a tag which can access all variables from any of these controls. <%= cm.controls["r1"].Items[0]["name"] %> The problem with this is that the variable isn't available until the repeater is bound so I might need to use events to push out the value to tags on the page like so: <Custom:Var ID="v1" control="r1" value="Items[0]["name"]" runat="server"/> Is this possible or can you recommend a better approach?

    Read the article

  • Global mouseMove

    - by Jacob Kofoed
    I have made the following javascript to be used in my jQuery based website. What it does, is to move a slider up/down, and scale the item above higher/smaller. Everything works fine, but since the slider is only a few pixels in height, and the move event is a bit slow (it does not trigger for every pixel) so when I move the mouse fast, the slider can't hold on and the mouse get's out of the slider item. The mouseMove event won't be triggered no more since it is bound to the slider. I guess everything could be fixed by setting the mouseMove global to the whole site, but it won't work, or at least I don't know how to make that work. Should it be bound to document, or body? here is my current code for the slider: $.fn.resize = function (itemToResize) { MinSize = 100; MaxSize = 800; pageYstart = 0; sliderMoveing = false; nuskriverHeight = 0; this.mousedown(function(e) { pageYstart=e.pageY; sliderMoveing = true nuskriverHeight = parseFloat((itemToResize).css('height')); }); this.mouseup(function() { sliderMoveing = false }); this.mousemove(function(e) { if (sliderMoveing) { (itemToResize).css('height', (nuskriverHeight + (e.pageY - pageYstart))); if (parseFloat( (itemToResize).css('height')) > MaxSize) { (itemToResize).css('height', MaxSize) }; if (parseFloat( (itemToResize).css('height')) < MinSize) { (itemToResize).css('height', MinSize) }; }; }); }; Thanks for any help, is much appreciated

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >