I love doing this sort of thing in Perl: $foo = $bar || $baz to assign $baz to $foo if $bar is empty or undefined. You also have $foo ||= $bletch which will only assign $bletch to $foo if $foo is not defined or empty. The ternary operator in this situation is tedious and tiresome. Surely there's a simple, elegant method available in PHP? Or is the only answer a custom function that uses isset()?
I'm writing a fairly low-level driver for a wireless card, and while most of the spec is fairly straightforward, I haven't wrapped my head around a single question yet: If my station is in power-save mode and its receiver is turned off for an extended period (say, 10 seconds) between DTIM frames, and the access point is rebooted in the meantime so my association is lost, how can I detect this? I'm aware that the most common case will be that synchronisation is lost thoroughly enough that I will miss a number of beacons and simply go back to the AP search afterwards, but if by some lucky chance
in my c # project, I put this piece of code : initially, I recovered from the certificate that I created with bouncy castle, the key pair, then I extract the private key, my goal is that , it is in a format. pem, AsymmetricKeyParameter private_RSA = keyPair2.Private; PrivateKeyInfo k_RSA = PrivateKeyInfoFactory.CreatePrivateKeyInfo(private_RSA); byte[] serializedKey_priv_RSA = k_RSA.ToAsn1Object().GetDerEncoded(); // byte[] clé = Org.BouncyCastle.Utilities.Encoders.Hex.Decode(serializedKey); string data_priv_RSA = Convert.ToBase64String(serializedKey_priv_RSA); using (fluxInfos2 = new StreamWr
How to verify whether links are present or not? eg. I have 10 links in a page, I want to verify the particular link Is it possible? I am using selenium with Java. Does i can write inside the selenium code eg selenium.click("searchimage-size"); selenium.waitForPopUp("dataitem", "3000"); selenium.selectWindow("name=dataitem"); foreach(var link in getMyLinkTextsToTest()) { var elementToTest = driver.findElement(By.linkText(link)); Assert.IsNotNull(elementToTest); }
I have an android project that targets Android 2.2 (developing in Eclipse). Exporting the android project to the Droid Incredible works perfectly. Is it possible to export the project to a file suitable for installing on an iphone? I know that most iPhone apps are developed using xCode, but I'm not sure if xCode packages into a .apk or other file format that's equivalent. Thanks in advance.
What exactly is the difference between mod and rem in Haskell? Both seems to give the same results *Main> mod 2 3 2 *Main> rem 2 3 2 *Main> mod 10 5 0 *Main> rem 10 5 0 *Main> mod 1 0 *** Exception: divide by zero *Main> rem 1 0 *** Exception: divide by zero *Main> mod 1 (-1) 0 *Main> rem 1 (-1) 0
I'm trying to compare Calendars with JPA2. The query looks somewhat like that: TypedQuery<X> q = em.createQuery("select r from Record r where r.calendar= :calendar", X.class); Calendar c = foo(); // setting fields and stuff q.setParameter("calendar", c); This, however, compares the date + time. I want to know if MM:DD:YYYY is equal and do not care about the time. Is there a nice way to do that in JPA2 or do I have to create a native query? I tried setting HH:MM:SS:... to zero before saving it in the db but I don't know if this is very wise, regarding time zones and daylight saving and stuff.
I am using JavaScriptSerializer for serializing objects to the file to the JSON format. But the result file has no readable formatting. How can I allow formating to get a readable file?
I have a PHP script that may be placed on a windows system or a linux system. I need to run different commands in either case. How can I detect which environment I am in? (preferably something PHP rather than clever system hacks) Update To clarify, the script is running from the command line.
I'm attempting to run the following code: ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_Processor"); // This line throws the exception ManagementObjectCollection moc = mos.Get(); and I get the following excpetion: System.Management.ManagementException: Invalid class at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext() at LicenseCheckThingy.Form1.button1_Click(Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick(EventArgs e
I have a server setup running apache2. There are 2 public ip addresses pointing to the server each assigned a different domain name. I set up the virtual host to manage these domains. The first domain is working fine. The second on the the other hand is not. The request times out when I ping it from the outside and when I ping it from the inside I get a 'Destination host unreachable message' Here's the virtual host setup fro the site that works: <IfModule mod_ssl.c> <VirtualHost 200.46.83.210:443> ServerName creditlinefast.com ServerAlias www.creditlinefast.com ServerAdmin webmaster@localhost
Say I have a module with the following: def main(): pass if __name__ == "__main__": main() I want to write a unit test for the bottom half (I'd like to achieve 100% coverage). I discovered the runpy builtin module that performs the import/__name__-setting mechanism, but I can't figure out how to mock or otherwise check that the main() function is called. This is what I've tried so far: import runpy import mock @mock.patch('foobar.main') def test_main(self, main): runpy.run_module('foobar', run_name='__main__') main.assert_called_once_with()
I need to make a stored procedure to insert employees monthly salary in there payroll table. Can anybody give example? There are two tables Employees (EmployeeID, EmployeeName, EmployeeStatus, BasicSalary) and EmployeePayroll (PayrollID, EmployeeID, VoucherNo, BasicSalary, SalaryMonth) Get Total Employees From Employees Table WHERE EmployeeStatus IN ('Active')............for example let's say (50 employees) Make a Loop for all these 50 employees and Insert salary payment voucher in table (EmployeePayroll). In EmployeePayroll table it will be inserted with auto generated voucher no for example:
#include <string> std::string input; std::cin >> input; The user wants to enter "Hello World". But cin fails at the space between the two words. How can I make cin take in the whole of Hello World? I'm actually doing this with structs and cin.getline doesn't seem to work. Here's my code: struct cd { std::string CDTitle[50]; std::string Artist[50]; int number_of_songs[50]; }; std::cin.getline(library.number_of_songs[libNumber], 250); This yields an error. Any ideas?
I am using a jQuery slidetoggle on a single page website. I have been trying to figure out where I went wrong in my script but can't seem to resolve this issue. I am trying to get the slide toggle effect to start off closed when the page opens and open/close only on click. Right now, when the page opens each section of the slide toggle is already open. <script type="text/javascript"> jQuery(function($) { var openText = 'Open'; var closeText = 'Close'; $('.item-util .more-toggle').toggle( function() { $(this).html(closeText); $(this).parent().siblings('div').slideToggle('slow'); }, function() {
I want to discard all changes done after commit <commit-hash> . So I did: git reset --hard <commit-hash> Now I want to do the same with my remote. How can I do this? I have done some commits (and pushes) after <commit-hash> and I just want to discard them all. Is just something went terribly wrong in the way and I don't want to make it worse than it is already. ;( I basically want to rewind my origin/master to <commit-hash>
my confusion related to this matter is that how we can use a previously created transaction? or in other words how many threads a transaction could be related to?
Our webapp is able to download files from Sharepoint and surface them to the user, but only if I provide my personal username and password to the process. I received a suggestion that: we "should use the credentials of the AppPool (UseDefaultCredentials=True.)" What changes do I make to for this to work with UseDefaultCredentials=True? And what is UseDefaultCredentials=true? string documentName = null; string contentType = "unknown"; // We don't want to use this method of credentials System.Net.NetworkCredential cred = new System.Net.NetworkCredential("USERNAME", "PASSWORD"); ClientContext cli
I am trying to use SVM for News article classification. I created a table that contains the features (unique words found in the documents) as rows. I created weight vectors mapping with these features. i.e if the article has a word that is part of the feature vector table that location is marked as 1 or else 0. Ex:- Training sample generated... 1 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:1 10:1 11:1 12:1 13:1 14:1 15:1 16:1 17:1 18:1 19:1 20:1 21:1 22:1 23:1 24:1 25:1 26:1 27:1 28:1 29:1 30:1 As this is the first document all the features are present. I am using 1, 0 as class labels. I am using svm.Ne
Following on from my other question, Help optimising this C (AVR) code? :), I just realised that I don't really know the mechanics of how to implement an ISR in assembly within my C program. I googled, but I didn't find anything too useful. Basically, I want to set up everything else in my C project (including the registers to get the interrupt to fire), but I want the interrupt to execute some assembly code that I've written. I'm using AVR Studio 6 on Windows if that helps. I've been told I need to use .s files, but apart from that I'm not really sure what to do. Is the basic structure just t
This might be a duplicate question. I wish to know how the memory map of a windows process look like? I am looking for details. Kindly provide links to blogs, articles and other relevant literature.
Could some one please provide how to write following sql query using joins. I do not want use not in as well as if possible I would like to replace where condition as well. SELECT d1.Short_Code FROM domain1 d1 WHERE d1.Short_Code NOT IN ( SELECT d2.Short_Code FROM Domain2 d2 ) I am using SQL Server 2008
The scenario is. A database secondary server are for different reason out of sync or is suspected that is not sync. Someone has made the secondary databases online by mistake or other mishaps. If you now want to make sure that they are set back on track. How do you do that? Preferably swiftly and for many databases at once. When you set up a log shipping between two servers using the guide it takes care of the initial backup and copying of backup file and then the initial restore. If I have to redo that I have to unable/enble and redo the loghipping and fill all the parameters again. Is there
I've been trying to connect Dreamweaver to a MySQL Database for a while. These are the login data: $mysql_host = "mysql16.000webhost.com"; $mysql_database = "a7426xxx_xxxxx"; $mysql_user = "a7426xxx_xxxxx"; $mysql_password = "xxxxxxxxxx"; I click dynamic text in DW, then create a recordset. Then define connection. Then New. Then I enter the data. Connection name: I just give it a random name. MySQL server: I fill in the $mysql_host data above. User name: I fill in the $mysql_user name above. Password: I fill in the $mysql_password above. Then I click select database but DW can't find the datab
This sounds so simple, but I just can't figure it out. I made an experimental branch a while ago, and now I'd like to pull in all the changes that happened on master since I made it. This is all local. I want to pull from local master into local my_branch, but I can't do it. This doesn't seem to work, telling me that master isn't a git repository: git pull master
I've been musing about this for some time: how exactly is Object.GetHashCode implemented in the CLR or Java? The contract for this method is that if it is called on the same object instance, it should always return the same value. Note that I'm talking about the default implementation of GetHashCode(). Derived classes are not required to override this method. If they choose not to do so, they will in essence have reference semantics: equality equals "pointer equality" by default when used in hash tables &c. This means that somehow, the runtime has to provide a constant hashcode for the object
There are several ways to write to stderr: print >> sys.stderr, "spam" # Python 2 only. sys.stderr.write("spam\n") os.write(2, b"spam\n") from __future__ import print_function print("spam", file=sys.stderr) What are the differences between these methods? Which method should be preferred?
The btr instruction is simple and it can lock its shared resource. (Same for bts) Why does the instruction cmpxchg exist? What is the difference between these instructions?
I've made a cocoa mac application which needs to check if a serial number/license key is correct, i'm unsure what type of algorithms would be the best for this. Lets say i have this serial number: 4829-1234-4321-1234-4326-5232 or any set of 4 numbers. I was thinking about using an algorithm like if the first set of the license key is divisible by 5, second by 10, third by 24.... but i'm not sure if this is the best way to go about it. I would also need to generate the keys in PHP. Any help is appreciated
I am trying to redirect my page after successful login to a new url.. <?php include_once "fbmain.php"; $config['baseurl'] = "http://localhost:8080/index.php";; // login or logout url will be needed depending on current user state. if ($fbme) { $logoutUrl = $facebook->getLogoutUrl( array( 'next' => $config['baseurl'], ) ); } else { $loginUrl = $facebook->getLoginUrl( array( 'display' => 'popup', 'next' => $config['baseurl'] . '?loginsucc=1', 'cancel_url'=> $config['baseurl'] . '?cancel=1', 'req_perms' => 'email,user_birthday', ) ); } // if user click cancel in the popup window if (isset($_REQUE