Search Results

Search found 14624 results on 585 pages for 'static'.

Page 26/585 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • C#/.NET Little Wonders: The Timeout static class

    - by James Michael Hare
    Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. When I started the “Little Wonders” series, I really wanted to pay homage to parts of the .NET Framework that are often small but can help in big ways.  The item I have to discuss today really is a very small item in the .NET BCL, but once again I feel it can help make the intention of code much clearer and thus is worthy of note. The Problem - Magic numbers aren’t very readable or maintainable In my first Little Wonders Post (Five Little Wonders That Make Code Better) I mention the TimeSpan factory methods which, I feel, really help the readability of constructed TimeSpan instances. Just to quickly recap that discussion, ask yourself what the TimeSpan specified in each case below is 1: // Five minutes? Five Seconds? 2: var fiveWhat1 = new TimeSpan(0, 0, 5); 3: var fiveWhat2 = new TimeSpan(0, 0, 5, 0); 4: var fiveWhat3 = new TimeSpan(0, 0, 5, 0, 0); You’d think they’d all be the same unit of time, right?  After all, most overloads tend to tack additional arguments on the end.  But this is not the case with TimeSpan, where the constructor forms are:     TimeSpan(int hours, int minutes, int seconds);     TimeSpan(int days, int hours, int minutes, int seconds);     TimeSpan(int days, int hours, int minutes, int seconds, int milliseconds); Notice how in the 4 and 5 parameter version we suddenly have the parameter days slipping in front of hours?  This can make reading constructors like those above much harder.  Fortunately, there are TimeSpan factory methods to help make your intention crystal clear: 1: // Ah! Much clearer! 2: var fiveSeconds = TimeSpan.FromSeconds(5); These are great because they remove all ambiguity from the reader!  So in short, magic numbers in constructors and methods can be ambiguous, and anything we can do to clean up the intention of the developer will make the code much easier to read and maintain. Timeout – Readable identifiers for infinite timeout values In a similar way to TimeSpan, let’s consider specifying timeouts for some of .NET’s (or our own) many methods that allow you to specify timeout periods. For example, in the TPL Task class, there is a family of Wait() methods that can take TimeSpan or int for timeouts.  Typically, if you want to specify an infinite timeout, you’d just call the version that doesn’t take a timeout parameter at all: 1: myTask.Wait(); // infinite wait But there are versions that take the int or TimeSpan for timeout as well: 1: // Wait for 100 ms 2: myTask.Wait(100); 3:  4: // Wait for 5 seconds 5: myTask.Wait(TimeSpan.FromSeconds(5); Now, if we want to specify an infinite timeout to wait on the Task, we could pass –1 (or a TimeSpan set to –1 ms), which what the .NET BCL methods with timeouts use to represent an infinite timeout: 1: // Also infinite timeouts, but harder to read/maintain 2: myTask.Wait(-1); 3: myTask.Wait(TimeSpan.FromMilliseconds(-1)); However, these are not as readable or maintainable.  If you were writing this code, you might make the mistake of thinking 0 or int.MaxValue was an infinite timeout, and you’d be incorrect.  Also, reading the code above it isn’t as clear that –1 is infinite unless you happen to know that is the specified behavior. To make the code like this easier to read and maintain, there is a static class called Timeout in the System.Threading namespace which contains definition for infinite timeouts specified as both int and TimeSpan forms: Timeout.Infinite An integer constant with a value of –1 Timeout.InfiniteTimeSpan A static readonly TimeSpan which represents –1 ms (only available in .NET 4.5+) This makes our calls to Task.Wait() (or any other calls with timeouts) much more clear: 1: // intention to wait indefinitely is quite clear now 2: myTask.Wait(Timeout.Infinite); 3: myTask.Wait(Timeout.InfiniteTimeSpan); But wait, you may say, why would we care at all?  Why not use the version of Wait() that takes no arguments?  Good question!  When you’re directly calling the method with an infinite timeout that’s what you’d most likely do, but what if you are just passing along a timeout specified by a caller from higher up?  Or perhaps storing a timeout value from a configuration file, and want to default it to infinite? For example, perhaps you are designing a communications module and want to be able to shutdown gracefully, but if you can’t gracefully finish in a specified amount of time you want to force the connection closed.  You could create a Shutdown() method in your class, and take a TimeSpan or an int for the amount of time to wait for a clean shutdown – perhaps waiting for client to acknowledge – before terminating the connection.  So, assume we had a pub/sub system with a class to broadcast messages: 1: // Some class to broadcast messages to connected clients 2: public class Broadcaster 3: { 4: // ... 5:  6: // Shutdown connection to clients, wait for ack back from clients 7: // until all acks received or timeout, whichever happens first 8: public void Shutdown(int timeout) 9: { 10: // Kick off a task here to send shutdown request to clients and wait 11: // for the task to finish below for the specified time... 12:  13: if (!shutdownTask.Wait(timeout)) 14: { 15: // If Wait() returns false, we timed out and task 16: // did not join in time. 17: } 18: } 19: } We could even add an overload to allow us to use TimeSpan instead of int, to give our callers the flexibility to specify timeouts either way: 1: // overload to allow them to specify Timeout in TimeSpan, would 2: // just call the int version passing in the TotalMilliseconds... 3: public void Shutdown(TimeSpan timeout) 4: { 5: Shutdown(timeout.TotalMilliseconds); 6: } Notice in case of this class, we don’t assume the caller wants infinite timeouts, we choose to rely on them to tell us how long to wait.  So now, if they choose an infinite timeout, they could use the –1, which is more cryptic, or use Timeout class to make the intention clear: 1: // shutdown the broadcaster, waiting until all clients ack back 2: // without timing out. 3: myBroadcaster.Shutdown(Timeout.Infinite); We could even add a default argument using the int parameter version so that specifying no arguments to Shutdown() assumes an infinite timeout: 1: // Modified original Shutdown() method to add a default of 2: // Timeout.Infinite, works because Timeout.Infinite is a compile 3: // time constant. 4: public void Shutdown(int timeout = Timeout.Infinite) 5: { 6: // same code as before 7: } Note that you can’t default the ShutDown(TimeSpan) overload with Timeout.InfiniteTimeSpan since it is not a compile-time constant.  The only acceptable default for a TimeSpan parameter would be default(TimeSpan) which is zero milliseconds, which specified no wait, not infinite wait. Summary While Timeout.Infinite and Timeout.InfiniteTimeSpan are not earth-shattering classes in terms of functionality, they do give you very handy and readable constant values that you can use in your programs to help increase readability and maintainability when specifying infinite timeouts for various timeouts in the BCL and your own applications. Technorati Tags: C#,CSharp,.NET,Little Wonders,Timeout,Task

    Read the article

  • Lots of static/crackling noises after ALSA HDA DKMS installation

    - by MartinB
    I am using a Samsung Chronos 7 laptop with the following sound setup: $ head -n 1 /proc/asound/card0/codec* ==> /proc/asound/card0/codec#0 <== Codec: Realtek ALC269VC ==> /proc/asound/card0/codec#3 <== Codec: Intel CougarPoint HDMI With the stock ALSA that comes with Ubuntu 12.04, I do not get any sound out of the headphones when I plug them into the headphone jack. After plugging the headphones in, I have to manually use Alsamixer to increase the volume, so that the headphones become usable. I have been told that this issue is due to my sound chip not being supported in the ALSA version that ships with Precise. A similar question at AskUbuntu and the Ubuntu Community Documentation point me to the ALSA DKMS installation. After installing the dkms module of yesterday's ALSA snapshot and rebooting, the headphone issue is indeed solved. I can now plug my headphones into the jack and instantly have sound on them. However, now I have tons of static noises and crackling when playing sound in VLC player or Skype (Firefox HTML5 playback seems to be fine, unless a Skype sound interferes with it). Is there a fix for this? I tried adding the Alsa PPA and installing the latest ALSA package proper, but that didn't have any effect, only the Alsa DKMS package seems to solve the headphone issue.

    Read the article

  • SEO: Make hashtag links look static

    - by elias94xx
    So I have a website which displays all my content vertically. (like modern websites often do these days). Thus I can't create static links to each section. I'm currently handling the scrolling with javascript. My navigation looks like this. <ul> <li><a href="#services">Services</a></li> <li><a href="#references">References</a></li> <li><a href="#blog">Blog</a></li> <li><a href="#contact">Contact</a></li> </ul> I also created 301 redirect links with htaccess. E.g. /services which leads to /#services. If I were to use them in my navigation, I'd have to trigger the scrolling with the onpopstate event. Thats not really a problem, but would searchengines accept that kind of setup ? I also created a sitemap and submitted it to google, but the indexing is still pending.

    Read the article

  • Moving from a static site to a CMS with new URLs and meta-data for pages

    - by Chris J
    Hi I am in the process of rebuilding a site from static pages to a CMS which will be using mod_rewrite to generate new page URLs. In this process our marketing people and myself have decided to tidy up the descriptions, keywords and titles. Eg: a page which who's URL is currently "website-name/about_us.html" and has a title of "website-name - something not quite page specific" will change to "website-name/about-us/" and title: "about us - website-name" and may have a few keywords and the description changed. Our goal with updating the meta data is to improve our page rankings and try to keep in line with some best practices for SEO. Though our current page rankings are quite good in many aspects, there is room for improvement. All of the pages will also have content changes (like rearranging heading tags, new menu on all pages, new content in footer, extra pieces of dynamic content relating to other pages). In this new site process I plan to use 301 redirects for all the old URLs pointing to the new URLs. My question is what can I expect to happen to the page rankings in Google, in the sort term and long term? Will this be like kicking off a new site which will have to build up trust over time or will the original page rankings have affect?

    Read the article

  • Strategy for hosting 700+ domains, each with static HTML site

    - by jonschlinkert
    I have a portfolio of more than 700 domain names, and ideally I'd like to put up a single-page HTML/CSS/JavaScript webpage for each domain. Is there a system/strategy/workflow that will allow me to: Automate the deployment of new websites, quickly and easily without having to manually initiate each new website in an admin panel. For instance, I've seen dropbox-based solutions that claim to make it simple to setup new websites on your dropbox account, but you still have to set each one up in an admin interface first. It would be so much easier to have a folder naming convention that allowed the user to easily clone/copy/duplicate sites inside their Dropbox App folder (https://www.dropbox.com/developers/blog/23) to create new ones. Sounds interesting, however... It's easy to managing CNAMEs on the registrar-side, is there a way to quickly associate CNAMEs with new websites, maybe gh-pages-style (https://help.github.com/articles/setting-up-a-custom-domain-with-pages)? With GitHub's gh-pages, all you have to do is drop a file called CNAME into your repo, with the domain name you want associated with the repo inside the file. gh-pages isn't a good solution for what I'm doing though unfortunately. I'm also a front-end developer, specializing in rapid web development and "front-end build systems", so I building and maintaining static assets for hundreds of sites is no problem. It's the hosting-side that I really struggle with. Any suggestions?

    Read the article

  • Strategy for hosting 700+ domains names, each with a static HTML site

    - by jonschlinkert
    I have a portfolio of more than 700 domain names, and ideally I'd like to put up a single-page HTML/CSS/JavaScript webpage for each domain. Is there a system/strategy/workflow that will allow me to: Automate the deployment of new websites, quickly and easily without having to manually initiate each new website in an admin panel. For instance, I've seen dropbox-based solutions that claim to make it simple to setup new websites on your dropbox account, but you still have to set each one up in an admin interface first. It would be so much easier to have a folder naming convention that allowed the user to easily clone/copy/duplicate sites inside their Dropbox App folder (https://www.dropbox.com/developers/blog/23) to create new ones. Sounds interesting, however... It's easy to manage CNAMEs on the registrar-side, but is there a way to quickly associate CNAMEs with new websites (on the hosting side), maybe using the method offered by gh-pages-style (https://help.github.com/articles/setting-up-a-custom-domain-with-pages)? With GitHub's gh-pages, all you have to do is drop a file called CNAME into your repo, with the domain name you want associated with the repo inside the file. gh-pages isn't a good solution for what I'm doing though unfortunately. I'm also a front-end developer, specializing in rapid web development and "front-end build systems", so I building and maintaining static assets for hundreds of sites is no problem. It's the hosting-side that I really struggle with. Any suggestions?

    Read the article

  • Run Sinatra via a Rake Task to Generate Static Files?

    - by viatropos
    I'm not sure I can put this correctly but I'll give it a shot. I want to use Sinatra to generate static html files once I am ready to deploy an application, so the resulting final website would be pure static HTML. During development, however, I want everything to be dynamic so I can use Haml and straight Ruby code to make things fast/dry/clear. I don't want to use Jekyll or some of the other static site generators out there because they don't have as much power as Sinatra. So all I basically need to be able to do is run a rake task such as: rake sinatra:generate_static_files. That would run the render commands for Haml and everything else, and the result would be written to files. My question is, how do I do that with Sinatra in a Rake task? Can I do it in a Rake task? The problem is, I don't know how to include the Sinatra::Application in the rake task... The only other way I could think of doing it is using net/http to access a URL that does all of that, but that seems like overkill. Any ideas how on to solve this?

    Read the article

  • error in implementing static files in django

    - by POOJA GUPTA
    my settings.py file:- STATIC_ROOT = '/home/pooja/Desktop/static/' # URL prefix for static files. STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( '/home/pooja/Desktop/mysite/search/static', ) my urls.py file:- from django.conf.urls import patterns, include, url from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^search/$','search.views.front_page'), url(r'^admin/', include(admin.site.urls)), ) urlpatterns += staticfiles_urlpatterns() I have created an app using django which seraches the keywords in 10 xml documents and then return their frequency count displayed as graphical representation and list of filenames and their respective counts.Now the list has filenames hyperlinked, I want to display them on the django server when user clicks them , for that I have used static files provision in django. Hyperlinking has been done in this manner: <ul> {% for l in list1 %} <li><a href="{{STATIC_URL}}static/{{l.file_name}}">{{l.file_name}}</a{{l.frequency_count</li> {% endfor %} </ul> Now when I run my app on the server, everything is running fine but as soon as I click on the filename, it gives me this error : Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^search/$ ^admin/ ^static\/(?P<path>.*)$ The current URL, search/static/books.xml, didn't match any of these. I don't know why this error is coming, because I have followed the steps required to achieve this. I have posted my urls.py file and it is showing error in that only. I'm new to django , so Please help

    Read the article

  • Static content not displayed with Zend FW

    - by shin
    I am trying to display a static content with Zend framework. When I go to http://square.localhost/content/services, I get an error message. Could anyone tell me how to fix this please? Thanks in advance. application.ini .... .... resources.layout.layoutPath = APPLICATION_PATH "/layouts" resources.layout.layout = "master" resources.router.routes.home.route = /home resources.router.routes.home.defaults.module = default resources.router.routes.home.defaults.controller = index resources.router.routes.home.defaults.action = index resources.router.routes.static-content.route = /content/:page resources.router.routes.static-content.defaults.module = default resources.router.routes.static-content.defaults.controller = static-content resources.router.routes.static-content.defaults.action = display application/modules/default/controllers/StaticContentController.php class StaticContentController extends Zend_Controller_Action { public function init() { } // display static views public function displayAction() { $page = $this->getRequest()->getParam('page'); if (file_exists($this->view->getScriptPath(null) . "/" . $this->getRequest()->getControllerName() . "/$page." . $this->viewSuffix)) { $this->render($page); } else { throw new Zend_Controller_Action_Exception('Page not found', 404); } } } application/modules/default/views/scripts/static-content/services.phtml some html ... ... Error message An error occurred Page not found Exception information: Message: Page not found Stack trace: #0 /var/www/square/library/Zend/Controller/Action.php(513): StaticContentController->displayAction() #1 /var/www/square/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('displayAction') #2 /var/www/square/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #3 /var/www/square/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #4 /var/www/square/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #5 /var/www/square/public/index.php(26): Zend_Application->run() #6 {main} Request Parameters: array ( 'page' => 'services', 'module' => 'default', 'controller' => 'static-content', 'action' => 'display', )

    Read the article

  • Creation of Objects: Constructors or Static Factory Methods

    - by Rachel
    I am going through Effective Java and some of my things which I consider as standard are not suggested by the book, for instance creation of object, I was under the impression that constructors are the best way of doing it and books says we should make use of static factory methods, I am not able to few some advantages and so disadvantages and so am asking this question, here are the benefits of using it. Advantages: One advantage of static factory methods is that, unlike constructors, they have names. A second advantage of static factory methods is that, unlike constructors, they are not required to create a new object each time they’re invoked. A third advantage of static factory methods is that, unlike constructors, they can return an object of any subtype of their return type. A fourth advantage of static factory methods is that they reduce the verbosity of creating parameterized type instances. I am not able to understand this advantage and would appreciate if someone can explain this point Disadvantages: The main disadvantage of providing only static factory methods is that classes without public or protected constructors cannot be subclassed. A second disadvantage of static factory methods is that they are not readily distinguishable from other static methods.I am not getting this point and so would really appreciate some explanation. Reference: Effective Java, Joshua Bloch, Edition 2, pg: 5-10 Also, How to decide to use whether to go for Constructor or Static Factory Method for Object Creation ?

    Read the article

  • How can a static class be resolved by the Unity Framework?

    - by user213988
    I wold like the unity framework to resolve a static class "MyStaticObject" specified in my config file. As my class is static, I am getting an error "The type StaticObject does not have an accessible constructor." My config file looks as below: <unity> <typeAliases> <typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" /> <typeAlias alias="StaticObject" type="MyStaticAssembly.MyStaticObject, MyStaticAssembly, Version=1.0.0.0" /> <typeAlias alias="staticobject" type="MyStaticAssembly.MyStaticObject, MyStaticAssembly" /> </typeAliases> <containers> <container> <types> <type type="StaticObject" mapTo="staticobject" name="My Static Object"> <lifetime type="singleton"/> </type> </types> </container> </containers> </unity> I would highly appreciate any help.

    Read the article

  • Using static variables for Strings

    - by Vivart
    below content is taken from Best practice: Writing efficient code but i didn't understand why private static String x = "example"; faster than private static final String x ="example"; Can anybody explain this. Using static variables for Strings When you define static fields (also called class fields) of type String, you can increase application speed by using static variables (not final) instead of constants (final). The opposite is true for primitive data types, such as int. For example, you might create a String object as follows: private static final String x = "example"; For this static constant (denoted by the final keyword), each time that you use the constant, a temporary String instance is created. The compiler eliminates "x" and replaces it with the string "example" in the bytecode, so that the BlackBerry® Java® Virtual Machine performs a hash table lookup each time that you reference "x". In contrast, for a static variable (no final keyword), the String is created once. The BlackBerry JVM performs the hash table lookup only when it initializes "x", so access is faster. private static String x = "example"; You can use public constants (that is, final fields), but you must mark variables as private.

    Read the article

  • C++: Static variable inside a constructor, are there any drawbacks or side effects?

    - by doc
    What I want to do: run some prerequisite code whenever instance of the class is going to be used inside a program. This code will check for requiremts etc. and should be run only once. I found that this can be achieved using another object as static variable inside a constructor. Here's an example for a better picture: class Prerequisites { public: Prerequisites() { std::cout << "checking requirements of C, "; std::cout << "registering C in dictionary, etc." << std::endl; } }; class C { public: C() { static Prerequisites prerequisites; std::cout << "normal initialization of C object" << std::endl; } }; What bothers me is that I haven't seen similar use of static variables so far. Are there any drawbacks or side-effects or am I missing something? Or maybe there is a better solution? Any suggestions are welcome.

    Read the article

  • Windows CE: Changing Static IP Address

    - by Bruce Eitman
    A customer contacted me recently and asked me how to change a static IP address at runtime.  Of course this is not something that I know how to do, but with a little bit of research I figure out how to do it. It turns out that the challenge is to request that the adapter update itself with the new IP Address.  Otherwise, the change in IP address is a matter of changing the address in the registry for the adapter.   The registry entry is something like: [HKEY_LOCAL_MACHINE\Comm\LAN90001\Parms\TcpIp]    "EnableDHCP"=dword:0    "IpAddress"="192.168.0.100"     "DefaultGateway"="192.168.0.1"    "Subnetmask"="255.255.255.0" Where LAN90001 would be replace with your adapter name.  I have written quite a few articles about how to modify the registry, including a registry editor that you could use. Requesting that the adapter update itself is a matter of getting a handle to the NDIS driver, and then asking it to refresh the adapter.  The code is: #include <windows.h> #include "winioctl.h" #include "ntddndis.h"   void RebindAdapter( TCHAR *adaptername ) {       HANDLE hNdis;       BOOL fResult = FALSE;       int count;         // Make this function easier to use - hide the need to have two null characters.       int length = wcslen(adaptername);       int AdapterSize = (length + 2) * sizeof( TCHAR );       TCHAR *Adapter = malloc(AdapterSize);       wcscpy( Adapter, adaptername );       Adapter[ length ] = '\0';       Adapter[ length +1 ] = '\0';           hNdis = CreateFile(DD_NDIS_DEVICE_NAME,                   GENERIC_READ | GENERIC_WRITE,                   FILE_SHARE_READ | FILE_SHARE_WRITE,                   NULL,                   OPEN_ALWAYS,                   0,                   NULL);         if (INVALID_HANDLE_VALUE != hNdis)       {             fResult = DeviceIoControl(hNdis,                         IOCTL_NDIS_REBIND_ADAPTER,                         Adapter,                         AdapterSize,                         NULL,                         0,                         &count,                         NULL);             if( !fResult )             {                   RETAILMSG( 1, (TEXT("DeviceIoControl failed %d\n"), GetLastError() ));             }             CloseHandle(hNdis);       }       else       {             RETAILMSG( 1, (TEXT("Failed to open NDIS Handle\n")));       }   }       int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR    lpCmdLine, int       nCmdShow) {     RebindAdapter( TEXT("LAN90001") );     return 0; }   If you don’t want to write any code, but instead plan to use a registry editor to change the IP Address, then there is a command line utility to do the same thing.  NDISConfig.exe can be used: Ndisconfig adapter rebind LAN90001    Copyright © 2012 – Bruce Eitman All Rights Reserved

    Read the article

  • Inspection, code review - is it really testing?

    - by user970696
    ISTQB, Wikipedia or other sources classify verification acitivities (reviews etc.) as a static testing, yet other do not. If we can say that peer reviews and inspections are actually a kind of a testing, then a lot of standards do not make sense (consider e.g. ISO which say that validation is done by testing, while verification by checking of work products) - it should at least say dynamic testing for validation, shouldn't it? I am completing master thesis dealing with QA and I must admit that I have never seen worse and more ambiguous and contradicting literature than in this field :/ Do you think (and if so, why) that static testing is a good and justifiable term or should we stick to testing and static checks/analysis?

    Read the article

  • C++ Static Initializer - Is it thread safe

    - by Yan Cheng CHEOK
    Usually, when I try to initialize a static variable class Test2 { public: static vector<string> stringList; private: static bool __init; static bool init() { stringList.push_back("string1"); stringList.push_back("string2"); stringList.push_back("string3"); return true; } }; // Implement vector<string> Test2::stringList; bool Test2::__init = Test2::init(); Is the following code thread safe, during static variable initialization? Is there any better way to static initialize stringlist, instead of using a seperate static function (init)?

    Read the article

  • Enabling OUD Entry Cache for large static groups

    - by Sylvain Duloutre
    Oracle Unified Directory can take advantage of several caches to improve performances. especially the so-called database cache and the file system cache. In addition to that, it is possible to use an entry cache to cache LDAP entries. By default, the entry cache is not used. In specific deployements involving large static groups, it may worth loading the group entries to the entry cache to speed up group membership and group-based aci evaluation. To do so, run the following commands: First, specify which entries should reside in the entry cache. In the commad below, only entries matching the LDAP filter " (|(objctclass=groupOfNames)(objectclass=groupOfUniqueNames)) " will be stored in the entry cache. dsconfig set-entry-cache-prop \          --cache-name FIFO \          --add include-filter:\(\|\(objctclass=groupOfNames\)\(objectclass=groupOfUniqueNames\)\)          --port <ADMIN_PORT> \          --bindDN cn=Directory\ Manager \          --bindPassword ****** \          --no-prompt Then enable the entry cache: dsconfig set-entry-cache-prop \          --cache-name FIFO \          --set enabled:true \          --port <ADMIN_PORT> \          --bindDN cn=Directory\ Manager \          --bindPassword ****** \          --no-prompt In addition to that, you can control how much memory the entry cache can use: oud@s96sec1d0-v3:/application/oud : dsconfig -X -n -p <ADMIN PORT> -D "cn=Directory Manager" -w <password> get-entry-cache-prop --cache-name FIFO Property           : Value(s) -------------------:----------------------------------------------------------- cache-level        : 1 enabled            : true exclude-filter     : - include-filter     : (|(objctclass=groupOfNames)(objectclass=groupOfUniqueNames)) max-entries        : 2147483647 max-memory-percent : 90 You can change the max-entries amd max-memory-percent properties to control the entry cache size using the dsconfig set-entry-cache-prop command.

    Read the article

  • Facebook: Sending private messages to FB profile from a static website [migrated]

    - by Frondor
    I need to setup a static website for people to: Complete a form. And using anything from Facebook API, GET the form output via message to a Facebook Profile. I've been punching my head against "facebook developers" page all night long and can't find out how to do it. Seems quite easy, but the problem is that I don't know if you'll get my point :) Like the Send Dialog feature, you can set a certain user as recipient which will be displayed on the "To:" field once the dialog appears. FB.ui({ method: 'send', to: 'UserID', link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html', }); Ok, All I need is to be able to use the same behavior but instead of setting a "to:" parameter, I'd like to set a "message:" parameter. I don't know how I can solve this becuase there's no parameter like this on the API actually. This is what I need to build (It's a prototype, this code won't work) <form action="mysite.com" id="order"> <input type="radio" name="chocolate" value="white">White <br/> <input type="radio" name="chocolate" value="black">Black <br/> <input type="submit" value="Order" /> </form> jQuery gets the values $(document).ready(function() { $("#order").on("submit", function(e) { e.preventDefault(); var formOutput = $(this).serialize(); var order = "I'd like to eat" + formOutput + "chocolate"; }); }); Facebook sdk sends this output ('order' string) FB.ui({ method: 'send', //or whatever to: 'UserID', message: order, //Its just an example, note the variable coming from the form link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html', }); As we all know, what I wrote isn't possible, so I'm asking for any alternative solution if somebody can give me, I'm not very friendly with facebook APIs :) I though in another solution which consist in using the form output directly on the 'link:' parameter of FB.ui and then reading it with jQuery on some landing page. For example, on the message sent, the linked content redirects to this URL: http://mysite.com/dashboard.html?chocolate=white and the dashboard page source code: <script> var choco = getUrlParameter('chocolate'); $("#dashboard").text("This person wants" + choco + "chocolate") </script> <div id="dashboard"></div> And this way, I will be able to see which kind of chocolate the person selected by parsing some parameters on the URL when clicking on the link section of the message: using a code like this: FB.ui({ method: 'send', //or whatever to: 'MyUserID', link: 'http://mysite.com/dashboard.html?chocolate=white', }); But no this try, my biggest problem is that I don't know how to dynamically "customize" that "link:" paramenter with jQuery. I think the best solution is to use a code like this along with the dashboard page in order to "translate" the shared URLs and see what kind of chocolate people are demanding xD FB.ui({ //declaring a variable (example) var string = getFormData().serialize; var orderString = "mysite.com/dashboard.html?" + string; // end the variables // start facebook API code method: 'send', //or whatever to: 'MyUserID', link: orderString, }); I was working here until I gave up and started to post this http://jsfiddle.net/Frondor/sctepn06/2/ Thanks in advance, I'll love you for ever if you help me solving this :D

    Read the article

  • Why is it preferable to call a static method statically from within an instance of the method's clas

    - by javanix
    If I create an instance of a class in Java, why is it preferable to call a static method of that same class statically, rather than using this.method()? I get a warning from Eclipse when I try to call static method staticMethod() from within the custom class's constructor via this.staticMethod(). public MyClass() { this.staticMethod(); } vs public MyClass() { MyClass.staticMethod(); } Can anyone explain why this is a bad thing to do? It seems to me like the compiler should already have allocated an instance of the object, so statically allocating memory would be unneeded overhead.

    Read the article

  • Finding out if an IP address is static or dynamic?

    - by Joshua
    I run a large bulletin board and I get spammers every now and again. My moderation team does a good job filtering them out but every time I IP ban them they seem to come back (I'm pretty sure it's the same person on some occasions, as the post patterns are exactly the same as are the usernames) but I'm afraid to ban them by IP address every time. If they are on a dynamic IP address, I could be banning innocent users later down the line when they try to get to my forum through SERPs, but if I ban only via static IPs I know that I'm only banning that one person. So, is there a way to properly determine if an IP address is static or dynamic? Thanks.

    Read the article

  • Which format does static library (*.lib) files use? Where can I find "Official" specifications of *.

    - by claws
    Just now I found that static libraries in *nix systems, in other words *.a libraries are nothing but archives of relocatables(*.o files) in ar fromat. What about static libraries(*.lib files) in windows? Which format are they in? I found an article: http://www.microsoft.com/msj/0498/hood0498.aspx which explains *.lib file structure. But Where can I find "Official" specifications of *.lib file structure/format? Other than ar.exe of mingw is there any tool from Microsoft which extracts relocatable objects of *.lib & *.a files? EDIT: I wonder why I'm unable to get to this question. If there are no official specifications. Then how does the compiler ('linker' to be more correct) writers work with *.LIB files?

    Read the article

  • What does static linking against a library actually do?

    - by Salgar
    Say I had a library called libfoo which contained a class, a few static variables, possibly something with 'C' linkage, and a few other functions. Now I have a main program which looks like this: int main() { return 5+5; } When I compile and link this, I link against libfoo. Will this have any effect? Will my executable increase in size? If so, why? Do the static variables or their addresses get copied into my executable? Apologies if there is a similar question to this or if I'm being particularly stupid in any way.

    Read the article

  • Does a static object within a function introduce a potential race condition?

    - by Jeremy Friesner
    I'm curious about the following code: class MyClass { public: MyClass() : _myArray(new int[1024]) {} ~MyClass() {delete [] _myArray;} private: int * _myArray; }; // This function may be called by different threads in an unsynchronized manner void MyFunction() { static const MyClass _myClassObject; [...] } Is there a possible race condition in the above code? Specifically, is the compiler likely to generate code equivalent to the following, "behind the scenes"? void MyFunction() { static bool _myClassObjectInitialized = false; if (_myClassObjectInitialized == false) { _myClassObjectInitialized = true; _myClassObject.MyClass(); // call constructor to set up object } [...] } ... in which case, if two threads were to call MyFunction() nearly-simultaneously, then _myArray might get allocated twice, causing a memory leak? Or is this handled correctly somehow?

    Read the article

  • How to define a static array without a contant size in a constructor of a class? (C++)

    - by Keand64
    I have a class defined as: class Obj { public: int width, height; Obj(int w, int h); } and I need it to contain a static array like so: int presc[width][height]; however, I cannot define within the class, so it it possible to create a pointer to a 2D array (and, out of curiosity, 3, 4, and 5D arrays), have that as a member of the class, and intitalize it in the constructor like: int ar[5][6]; Obj o(5, 6, &ar); If that isn't possible, is there any way to get a static array without a contant size in a class, or am I going to have to use a dynamic array? (Something I don't want to do because I don't plan on ever changing the size of the array after it's created.)

    Read the article

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