what is the problem if program is crash, when click save button?

Question: I have a simple todo list embedded in my main app,
I had established it in a separate project, then I add it to my main project carefully, everything is good but, when I write the todo and click save button the program is crash! what is the problem?
my code:
<code>self.navigationItem.rightBarButtonItem =
[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
                                               target:self
                                               action:@selector(save_Clicked:)]
 autorelease];
</code>
then the save_Clicked implementation is :
<code>- (void) save_Clicked:(id)sender {
    HomeAppDelegate *appDelegate =
    (HomeAppDelegate *)[[UIApplication sharedApplication] delegate];

    //Create a todo Object.
    todo *todoObj = [[todo alloc] initWithPrimaryKey:0];
    todoObj.todotitle = txttodotitle.text;
    todoObj.tododes = txttododes.text;
    /*
     NSString *temp = [[NSString alloc] initWithString:txttododes.text];
     todoObj.tododes = temp;
     [temp release];
     */
    todoObj.isDirty = NO;
    todoObj.isDetailViewHydrated = YES;

    //Add the object
    [appDelegate addtodo:todoObj];

    //Dismiss the controller.
    [self.navigationController dismissModalViewControllerAnimated:YES];
}
</code>
and the error massages output in console is:

2010-06-03 17:12:45.720 Home[29728:207] No Errors
  2010-06-03 17:12:45.726 Home[29728:207] WARNING: Using legacy cell layout due to delegate implementation of tableView:accessoryTypeForRowWithIndexPath: in .  Please remove your implementation of this method and set the cell properties accessoryType and/or editingAccessoryType to move to the new cell layout behavior.  This method will no longer be called in a future release.
  2010-06-03 17:12:59.447 Home[29728:207] * Assertion failure in -[todo addtodo], /Users/HOME/Desktop/withretriveAnn/Home copy 5-ToDO/Classes/todo.m:90
  2010-06-03 17:12:59.448 Home[29728:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error while creating add statement. 'no such table: todo''

for sure I used iPhone Database to save the ToDo list.
Comment: It appears that you're using Core Data and didn't create a 'todo' entity. In your XCode project, under Resources, double click on the xcdatamodel file and either add a 'todo' entity or check to see if it is misspelled or capitalized differently.
Comment: Might help to post the code...
Comment: Supply your code, or at the very least, the error messages output in the Xcode console when your app crashes.
Comment: …it can be anywhere.  Without seeing code, this question is impossible to answer. Without seeing the crash message this problem is impossible to answer. Please update your question
Comment: ok sorry, I update my question with code and error messages, help me please with thanks.
Comment: I doesn't have something with xcdatamodel name in resources! :(
just "mytodo.sqlit" that what I copied from old project,
I know that I have something wrong but I don't know what is it?!
Answer: Check typos in your table names.  Entities (and thus tables) start with a capital letter and your error has a lower case.  I suspect this is a simple typo of Todo.


not detecting the windows after partitioning

Question: I'm trying to install Ubuntu 16.04 in dual-boot with Windows 10.
My C: drive in Windows 10 had 120G and I divided it to three drives (the Windows drive 50G, a drive for swap 17G and another drive). Before I did this, the Linux installation detected my Windows, but afterwards it didn't.
So now I can't see any of my partition when I am selecting the "Something Else" option in the installer. Windows is still booting and running fine.
My laptop is a hp probook450 g2 and I don't know how to disable UEFI.
Comment: Post this from terminal in live installer. `sudo parted -l` Also similar model? http://askubuntu.com/questions/244261/how-do-i-get-my-hp-laptop-to-boot-into-grub-from-my-new-efi-file
Answer: I'm no expert by any means but I did have some problems with dual-booting a UEFI laptop which I finally resolved.
The latest installers are able to cope with UEFI disks and secure boot so in my view trying to disable UEFI is an unnecessary complication.
I found these two articles very worthwhile the study when I was doing my dual boot and  commend them to you.
https://help.ubuntu.com/community/UEFI
Allowing boot of Ubuntu on a Acer Aspire v5-531 with UEFI
I think they supersede a lot of commonly available advice because boot processes compatible with UEFI and secure boot have now been developed.
Good luck with them. If you come across more difficulties I'd be happy to try to help but with the heads-up that, as I said above, I'm no expert!


locate package libffi6 - Kivy app to APK Colab

Question: I am using Kivy to develop mobile applications, but run into issues when converting main.py to an .apk file.
I have tried various approaches, all without succes. The closest I have gotten is to use this colab notebook:
https://colab.research.google.com/drive/1b9gMzs6XAtxCtahxei4N0fWZk7xiPlVw?usp=sharing#scrollTo=elrRZQ-fHUF1
After running all the cells I do obtain an apk file, but the app crashes on startup.
I suspect the issue has to do with cell5 in the colab notebook:
!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6
I get the following output:
 - Reading package lists... Done
 - Building dependency tree
 - Reading state information... Done
 - E: Unable to locate package libffi6

Why am I getting this error, and how can I solve it?
My main.py:
from kivy.app import App
from kivy.uix.button import Button

class HelloWorld(App):
    def build(self):
        main_window = Button(text="hello world")
        return main_window

if __name__ == "__main__":
    app = HelloWorld()
    app.run()

and in the buildozer.spec file, I have added requirements: python3,kivy==2.0.0,kivymd,pillow
I tried following all tutorials I could find. But even if I copy their steps exactly, I still get different output in the google colab cells. I also tried to obtain a logcat, but I did not manage because I work with kivy and do not use android studio.
Comment: adb & logcat is essential when developing Android apps, without you are more or less blind. Therefore I strongly recommend to install at last minimal adb from Android SDK. Also check your Linux distributions package manger, often it already provides an adb version that should be sufficient for adb and logcat.
Answer: Try changing !pip install cython==0.29.19 to !pip install cython==0.29.32, the latest cython version is !pip install cython==0.29.34 so you can try either of these. If that doesn't work the only way to know why the app keeps crashing on startup is to use a logcat.
Answer: E: Unable to locate package libffi6

you can do:
  !sudo apt-get install libffi7
  !sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi7

Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: I was also experiencing the same issue using the same colab notebook.
To get it working, edit the requirements in your buildozer.spec file to look something like:
requirements = android, hostpython3==3.9.6, python3==3.9.6,kivy==2.1.0,kivymd==1.1.1,camera4kivy,gestures4kivy

Then, use the below variant of the colab notebook to build the app. It should build the apk file without any issues, i've already tested it multiple times for different complex builds.
https://colab.research.google.com/drive/11wLisDBglKDLZlSHydoQtSEcUTQXhyJ-#scrollTo=sbL2gpx8HZ7t


How can I round up MyBB View count format

Question: Am Using MyBB for my forum,
My post view always display as e.g 31344, 211313
How can I round it up to something like 31k, 21k
And when it reach million or billions it should be 31M, 21B
You Get The Idea?, please how can I fixed that
Remember am using MyBB
Answer: For that, you need to edit the function my_number_format in stats.php file in global directory.
It responsibility is to parse the number in a given format.


LinQ query where date and group by

Question: Hey all i am trying my best to get the follow query:
SELECT     Client, Code, COUNT(SessionID) AS Count
FROM       dbo.vw_TrackingAppsCompleteDistinctDate
WHERE      (Date > CONVERT(DATETIME, '2012-12-01 00:00:00', 102) AND Date < CONVERT(DATETIME, '2013-01-01 00:00:00', 102))
GROUP BY   URL, Code, Client
ORDER BY   Client, Code

converted into an LinQ in ASP.net.
So far i have:
Public Shared Function SelectByID(ByVal start_date As String, ByVal end_date As String) As vw_TrackingAppsCompleteDistinctDate
    Dim db As New MasterDataContext()
    Dim query = From r In db.vw_TrackingAppsCompleteDistinctDates Where r.Date > "1/1/2013"
    Group r By r.URL, r.Code, r.Client Into g
    Select g.All
End Function

Any suggestions?
Comment: I find Linqpad invaluable in these situations, with its ability to show the resulting generated SQL for a LINQ statement.
Answer: I was trying to create the corresponding query with grouping for practice. I'm not 100% sure that this linq will get you the result you are hoping for, because i cannot test it.
The orderby can be different i guess, because i don't know if the SQL orders the result before or after the grouping.
var result = from record in dbo.vw_TrackingAppsCompleteDistinctDate
             where record.Date.CompareTo( new DateTime( 2012, 12, 1, 0, 0, 0 ) ) > 0
             where record.Date.CompareTo( new DateTime( 2013, 1, 1, 0, 0, 0 ) ) < 0
             group record by new { record.URL, record.Code, record.Client } into grp
             orderby grp.Key.Client, grp.Key.Code
             select new
             {
                 Client = grp.Key.Client,
                 Code = grp.Key.Code,
                 Count = grp.Select( item => item.SessionID ).Count( )
             };

Answer: Got it using SQL to LinQ converter:
Dim query = From
              Vw_TrackingAppsCompleteDistinctDates In db.vw_TrackingAppsCompleteDistinctDates
            Where
              Vw_TrackingAppsCompleteDistinctDates.Date > CDate("2012-12-01 00:00:00")
            And Vw_TrackingAppsCompleteDistinctDates.Date < CDate("2013-01-01 00:00:00")
            Group Vw_TrackingAppsCompleteDistinctDates By
              Vw_TrackingAppsCompleteDistinctDates.URL,
              Vw_TrackingAppsCompleteDistinctDates.Code,
              Vw_TrackingAppsCompleteDistinctDates.Client
            Into g = Group
            Order By Client, Code
            Select
              Client, Code, Count = CType(g.Count(Function(p) p.SessionID <> Nothing), Int64?)

LinQ query where date and group by


Azure DevOps Pipeline: Set version per branch

Question: I am new to Azure DevOps Pipeline, so I'm still learning. I need some help in creating a workaround in setting the versions of the packages that we'd like to run through the pipeline.
On our repository, we have DEV branch, UAT branch, and Main (which serves as our PROD branch). So what we plan is every time there's a pull request sent to UAT branch, a package will be published and deployed to our UAT environment. Same way when a pull request is created on Main (ideally always be coming from UAT branch), a package will be published and deployed to our PROD environment.
What we'd like to happen is to have set the patch version every time a pull request is created.
For example, there were currently 4 pull request approved on UAT branch, so the version should be 1.0.4.
At 1.0.4, the code was approved to proceed to PROD environment, so a pull request was created, and we are expecting the 1.0.1 version to be published since it was the first time to merge it on Main.
Thank you!
What I currently have is this, but it's just making 1.0.5 version published on PROD env:
Answer: Automating the correct semantic version for packages is definitely tricky. Especially when factoring in when to increment the major/minor.
I'm not sure if i'd follow your PR count method, but if it works for you then you can leverage the Azure DevOps CLI in your pipeline to count how many PR's have merged to main.


Is there a limit in the body of a request to an api in React native?Because i cant send large base64 to server

Question: It says me syntax error: JSON Parse error. unrecognized token '<'
Iam using Fetch to do the request.It let me send short base64 strings i tried so what can i do?
This is my call to the api:
export function uploadPost(post) {
    let data = {
        body: post.body,
        picture: post.picture,
        type: post.type,
        user: {
            _id: post.user._id,
            name: post.user.name,
            picture: post.user.picture
        }
    }

    var headers = {
        'Content-Type': 'application/json',
        'Access-Control-Origin': '*'
    }

    return fetch(URL + "/uploadPost", {
        method: "post",
        headers: headers,
        body: JSON.stringify(data)
    })
        .then(response => Promise.resolve(response.json()))
        .catch(err => {
            return Promise.reject(err);
        })
}

Comment: I guess it's the response. Can you log the response to see what it is?
Comment: @dvnguyen its enter in the catch and gives that error
Comment: Why can be the response? I send a small base64 and all good
Comment: Franco, the catch show the error of the conversion from response to json. That probably means that the response itself isn't a correctly formatted json object. Try to console.log(response) at the before response.json() to see what happens.
Comment: @dvnguyen I understand.But it should be appearing in the database the object, because the .then is after the api call and is not appearing.Am i right?
Comment: @dvnguyen I cut the base 64 string in two and it let me send the first part alone but not second alone it says  unexpected token '>'
Answer: I finally solved it. The problem was that the response was returning a 413 status and I found out that means payload too large. So I added to my node js express server this lines:
var app = express();
//after
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));


How do I stop myself from being slowed down in the Sea?

Question: So apparently being underwater makes it hard to move, and it is slowing me down. I know this because I get a message at the end of every fight telling me so. How do I stop from being slowed down? What effects does being slowed down have on me?
Answer: Adventuring underwater takes longer, so each adventure you go on costs 2 turns.
This can be temporarily removed with the fishy buff so that underwater adventuring only takes the normal single turn. With that said, unless you want to spend a lot of real time and meat tracking down sources of fishy (most of which have per day limits), you are better off just dealing with the turn loss.
Underwater adventuring has some other effects in addition to the double turns, including lower item and meat drops because of pressure penalties. These penalties are reduced by using equipment that "makes you a better diver". There are also specific gear and buffs that drastically improve underwater meat and item drops to counter the penalties as well. Most of that gear can be found in underwater zones, but you can also pick it up for meat at the mall.
Comment: The most affordable sources of the Fishy buff ought to be fishy paste (spleen item), the Herringtini and Flaming Caipiranha (booze). You can also get a fishy pipe from The Old Man, which is usable once per day.


Any representation of U(1) admits an invariant Hermitian inner product

Question: Let $R: U(1) \to \mathrm{GL}(n, \mathbb C)$ be a representation, let $e^{i\theta} \in U(1)$, and let $\langle \cdot , \cdot \rangle$ be the standard inner product on $\mathbb{C}^n$. Then, the Hermitian inner product on $\mathbb{C}^n$ $$\langle u,v \rangle_R := \frac{1}{2\pi}\int_0^{2\pi} \langle R(e^{i\theta})u,R(e^{i\theta})v \rangle \,  \mathrm{d}\theta $$ is invariant under the action of $R$ on $\mathbb{C}^n$, meaning $\langle u,v \rangle_R = \langle R(e^{i\phi})u,R(e^{i\phi})v \rangle_R$.
Proof
It should be really easy to prove, but I am getting stuck on the last step. $$\langle R(e^{i\phi})u,R(e^{i\phi})v \rangle_R = \frac{1}{2\pi}\int_0^{2\pi} \langle R(e^{i\phi})R(e^{i\theta})u,R(e^{i\phi})R(e^{i\theta})v \rangle \,  \mathrm{d}\theta = \frac{1}{2\pi}\int_0^{2\pi} \langle R(e^{i(\theta+\phi)})u,R(e^{i(\theta+\phi)})v \rangle \,  \mathrm{d}\theta = \frac{1}{2\pi}\int_{\phi}^{\phi+2\pi} \langle R(e^{i\theta'})u,R(e^{i\theta'})v \rangle \,  \mathrm{d}\theta'$$ Where I used the fact that $R$ is a representation and a change of variable $\theta' = \theta + \phi$. This is almost $\langle u, v \rangle_R$, except for the boundaries of integration shifted by $\phi$. Is this still equivalent to the original inner product? I should also note that I can't use the classification of the representations of $U(1)$ with $\mathrm{GL}(n, \mathbb C) \ni R(e^{i\theta}) = diag(e^{im_k\theta})_n$ with $k=1,...,n$ and $m_k \in \mathbb Z$ since this lemma is supposed to be used to prove it.
Answer: So you have the right idea, you just missed a crucial fact. $d\theta$ is a Haar measure, so it's almost by definition that
$$ \int_{[0,2\pi]} f(\theta+\phi) \,d\theta = \int_{[0,2\pi]} f(\theta)\,d\theta.$$
This trick works for any compact abelian group actually. Given a compact abelian group $G$ with Haar measure $dg$, Hilbert space $H$ with inner product $\langle\cdot,\cdot\rangle$, and representation $\rho$ of $G$ on $\mathcal{B}(H)$, the inner product
$$ \langle f_1,f_2\rangle_{\rho} = \int_G \langle \rho(g)f_1, \rho(g)f_2\rangle\,dg$$
is invariant under actions by $\rho$, i.e.
$$ \langle \rho(g')f_1,\rho(g')f_2\rangle_{\rho} = \langle f_1,f_2\rangle_{\rho}.$$
This lets you work with unitary representations. It's called a group averaging trick.
Comment: Indeed. I'd emphasize that the interval $[0,2\pi]$, while an elementary thing, is _not_ a group, while the circle (obtained by sticking the endpoints together, and/or as quotient $\mathbb R/\mathbb Z$) _is_ a group... and periodic functions _descend_ to that group. And that group has no boundary to mar "integration by parts". :)
Comment: @Siupa look up Folland's *A Course in Abstract Harmonic Analysis.* But really all you need to know is that your group operation is really mod $2\pi$, so that $[\phi, \phi+2\pi]$ is actually $[\phi, 2\pi]\cup [2\pi,2\pi+\phi]$. This last bit mod $2\pi$ is the same as $[0,\phi]$. When you put the pieces together, you get $[0,2\pi]$ all over again. You should think of this as integrating over the circle. If you multiple a circle by $e^{i\phi}$, it's the same circle, so your integration is over the same set, regardless of start and end point.
Comment: Yes! The group operations are really all mod $2\pi$. (But really better thought of as $\mathbb{R}/\mathbb{Z}$ (or $\mathbb{R}/2\pi\mathbb{Z}$ depending on where you want to put $2\pi$'s) since that connects to other things we know and love.)
Comment: Unfortunately, I don't know what a Haar measure is. Can you elaborate a bit more with an intuitive example of what is going on, or provide a reference where I can look it up? Thank you!


Do the Double Shot and Bloonjtsu upgrades pierce more bloons?

Question: The upgrades increase the number of shurikens,
so do they pierce more bloons, add more popping power, or both?
Answer: Each projectile can hit up to four bloons (the Sharp Shurikens tier two upgrade), reducing each by one layer.  So a 2/* can reduce four bloon layers total across four bloons.  If it hits just one bloon, it can only reduce one layer.  Same thing for two or three bloons is two and three layers respectively.
A 3/* (Double Shot) can reduce up to eight bloon layers across four to eight bloons.  I.e. each projectile can hit up to four bloons and a given projectile can only reduce a bloon by one layer.  Since there are two projectiles, together they can reduce a bloon by two layers if both hit.
A 4/* (Bloonjitsu) can reduce up to twenty bloon layers across four to twenty bloons.  Again each projectile can hit up to four bloons and only reduce a bloon by one layer.  This time, there are five projectiles which can reduce a single bloon by five layers if all five hit the same bloon.
They have much the same impact as an increase in popping power if they hit the same bloon.  Or the same impact as pierce if they hit different bloons.  But they work by increasing the number of projectiles rather than increasing popping power or pierce.
Answer: This upgrade means that more shurikens are thrown, so it can pop more balloons at once. It doesn't pierce through more balloons.
Comment: does it increase popping power though?
Comment: @sensiwoo No, it just increases the number of projectiles.


How should I handle multiple links ot the same page with different Query Strings

Question: In the website I am working on, there is a product page with 8 tabs on it, showing different aspects of the product.  There are quick links on other pages within the site that take you to the page and to a specific link specified by a query string.
For example the base page would be www.example.com/Product1.  And then there are links like this:
www.example.com/Product1?tab=CADDrawing
www.example.com/Product1?tab=Schematics
www.example.com/Product1?tab=Reviews
My concern is that Google sees each of these links as a different URL but they aren't and the data on the page is 100% the same.  Is there any easy way to make it so Google either knows that www.example.com/Product1 is the base page or doesn't follow the links with Query Strings?
I thought about using rel="nofollow" but that seems like it would actually hurt my page ranking.  Most of the websites, including Googles on webmaster pages, is unclear.
The other option is to add the rel="canonical" to the pages that have a query string but not to the base page.  Does that succeed in stopping all of the noisy links?
Comment: How is the data on each 100% the same? Aren't you showing or hiding different data based on which tab is selected?
Answer: Using a link tag with a canonical URL in the head of the product page should do the trick:
<link rel="canonical" href="www.example.com/Product1" />

Comment: What page(s) would I want this on. Every one of them with a Query String, all of them, or the one without a Query String?
Comment: @RandomBen - You would put this on the product page itself, not the pages that link to it.  All it does is tell Google "this page could be linked to in multiple ways, but this is the preferred url for the page"
Comment: Right but do I put it on the page with this URL www.example.com/Product1?tab=CADDrawing or this one www.example.com/Product1 or both?
Comment: @RandomBen - Sorry, I assumed they were the same (aspx) page.  If they aren't, you would want to put it on all of them.
Answer: There is a base-tag in html:

  <base>www.example.com/Product1</base>

Maybe that will indicate to google that its all the same page? This is just a wild assumption though, no idea how google will handle it.
Comment: `base` is actually a very dangerous tag, as many user agents have no clue as to how to handle it, resulting in (sometimes) DoS attacks on your webserver.
Comment: I just read up on the base tag and this is what I found:
 tells the browser to pretend that the current page is located at some URL other than where the browser found it. Any relative reference will be calculated from the URL given by   instead of the actual URL.  goes in the   section.

So I don't think that it will do what I want.


Azure SQL Server database failed to connect from Power BI Dashboard

Question: I  am facing the Problem while connecting the Azure SQL Database from Power BI dashboard. I am getting the error as "We couldn't authenticate with the credentials provided. Please try again". I am using the Alternate Credentials.
I have done the Firewall rules in Azure SQL Server as below :
Rule : for Everyone
Start IPv4 address : 0.0.0.0
End IPv4 Address  : 255.255.255.255
Its working fine with SQL Server Manager on same machine but fail from Power BI Dashbaord.
I have already googled it but no solution

Thanks
ST
Comment: Is "circa" a SQL authenticated login? Choose Database tab if so (not Windows) - and if it is AAD you will need "Microsoft Account"
Comment: Try with database authentication instead of windows authentication.
Comment: Thanks its working now by Database authentication instead of windows authentication
Answer: I reproduced your issue in my environment I got the same error:

I changed authentication process from windows to database and entered the credentials.

It connected successfully without any error.
Answer: Connecting MS power BI to Postgre SQL.
I'm facing the same problem. please try this, it will work.
To connect PostgreSQL to Power BI, you should use the appropriate username and password combination for the specific user you want to connect with. If you have not created any additional users, you can try using the default superuser "postgres" with the password you set during installation.


How to enter file path in open file

Question: I want to deploy a war file, to my tomcat manage, and the path is quite long, so I want to enter the path, but whenever I go into open file, I can only select the files manually, by going through the folder. Is there a way to enter the file path, I have attached a picture to show the UI I get
(BTW I'm using 16.04)
Answer: Ctrl + L in the open file dialog will allow you to edit the path.
I normally have a file browser in the destination folder. I use
Ctrl + L  and Ctrl + C
to copy the path. Then, in the open file dialog,
Ctrl + L  and Ctrl + V
to paste it. Finally
Enter
So the open file dialog goes to that folder.

How to enter file path in open file


How to discover network devices with Cocoa Touch?

Question: I want to be able to enumerate the names of devices on a local network from a device running iPhone OS 3.x (iPhone/iPad).
I have tried using NSNetServiceBrowser to find all services like so:
[serviceBrowser searchForServicesOfType:@"_services._dns-sd._udp." inDomain:@"local."];

this returns results but when I try and resolve the addresses I get the following errors back
NSNetServicesErrorCode = -72004;
NSNetServicesErrorDomain = 10;

I have looked up the error and it appears there is a bad argument?
[kCFNetServiceErrorBadArgument
A required argument was not provided or was not valid.]

if I do a service specific search like
[serviceBrowser searchForServicesOfType:@"_ipp._tcp." inDomain:@""]; resolutions works fine.
So, am I on the right track with NSNetServiceBrowser or is there some other method that will allow me to enumerate the names of devices connected to my network?
Comment: any news on that? I'd be very interested how you managed to solve said issues.
Comment: I am having exactly same issue. What was the remedy?
Answer: This is the correct approach.  Potentially, the reason you have a NSNetServicesBadArgumentError is because your serviceType string @"_services._dns-sd._udp." is invalid try @"_services._dns-sd._udp" instead i.e. without the trailing period.
Apple's documentation is confusing on this point.  In the NSNetServiceBrowser Class Reference it states that:

The serviceType argument must contain both the service type and transport layer information. To ensure that the mDNS responder searches for services, rather than hosts, make sure to prefix both the service name and transport layer name with an underscore character ("_"). For example, to search for an HTTP service on TCP, you would use the type string "_http._tcp.". Note that the period character at the end is required.

However, in the NSNetServices and CFNetServices Programming Guide, the example for Initializing the Browser and Starting a Search clearly doesn't use a period at the end:
serviceBrowser = [[NSNetServiceBrowser alloc] init];
[serviceBrowser setDelegate:delegateObject];
[serviceBrowser searchForServicesOfType:@"_music._tcp" inDomain:@""];

Try it without & see if ou have any luck.
Comment: I am having exactly same issue and removing the 'trailing' period is not solving it in my case. What to do?


Cordova emulate not running on Genymotion after SDK update

Question: Using Genymotion version 2.2.2, Android SDK Tools 23(current), virtual box 4.3 installed and phone image Nexus 4 - android 4.4.2 installed.
So I was using SDK Tools 20(I guess) with eclipse. Genymotion was acting perfectly by then. Cordova was emulating the app in Genymotion. Then I installed android studio and update my sdk tools to 23. Installed selected packages. 4.4 is also installed.
Now Genymotion emulator opens perfectly but cordova isn't opening app in Genymotion. Rather it's searching for ADT for default SDK emulators.
<code> Cordova emulate android
</code>
This failed to open the app in Genymotion. I also tried to tweak the Genymotion SDK settings. Nothing helped.
What went wrong?? How to fix it?
Answer: Got the answer from Genymotion team, cordova is treating Genymotion as an individual device(not emulator). So to install the app following command need to be given.
<code>cordova run android
</code>
Comment: when i executed "cordova run android" i get this errror message "Error executing "adb devices": ADB server didn't ACK
* failed to start daemon *
error:"
Comment: guess: you didn't start the emulator first. you need to start genymotion first, then run those lines.


Warehouse Lighting Wire Size Calculation

Question: Warehouse Lighting Wiring Size Question
Total distance from panel to end of the longest line is 310 feet.  Each fixture is 42 watts, and there will be up to 30 fixtures on each circuit.  The first fixture on the longest line will be at the 150 foot from panel point.  All lighting fixtures will be run in parallel (pigtailed at each fixture, a.k.a., plug-in fixtures).
Each circuit is 20 AMP, 120V, single phase AC
What size wiring is needed for these longest runs?
Comment: Will your circuits provision at least 0.25 watts per square foot?  How are you switching these lights?  Do you have 120/240V split-phase, 208V 3-phase, or 277V 3-phase wye available?  Hauling power these long distances is better done at higher voltages.  Even if you can't do that, tell me if they are multi-voltage 120-277 lamps (because those draw *more current* when the voltage sags, and that must be allowed for.)
Comment: There will be (12) 20A circuits for lights, in a 24,000 square foot warehouse.  We are considering a change from the current 'using breakers as switches', to a nicely laid out and labeled and diagramed warehouse switch grid / array of 12 switches.
Answer: Thirty 42-watt fixtures are nominally 1260 watts, which is 10.5 amps at 120V.
Your longest run has the lights evenly spaced between 150' and 310' and the halfway point between is 230'.
Hit a voltage drop calculator
Set it for 5% voltage drop, as your lamps can handle that... and ask it for at least 3 points:

10.5 amps (max) at the 150' (start) distance
8 amps (3/4) at the 190' (1/4 way) distance
5.25 amps (half) at the 230' (halfway) distance

TLDR: I get 12AWG for each of those calcs.
For each test, the calculator will recommend a wire size and give you the expected voltage drop to be found there. Its recommendation is applicable from the panel to the point you asked about.
They say to use 3% voltage drop, but that is silly, 5-6% will work fine. But don't push it to 10% (unless you really want to) because if you upgrade to multivoltage lamps, those will answer voltage drop by drawing more current in proportion, throwing calculations off.
Is voltage drop OK?
It's not unsafe to have high voltage drop.  The 20A breaker definitively protects your 12 AWG wire if your wiring methods are legal. (an example of "illegal" would be more than 9 conductors in a single conduit without derate). Of course the voltage drop is heating the building.  Electric heat is a fairly expensive heating method, especially if you're trying to air-condition the place!  So get out the sharp pencil and figure out the voltage drop, multiply by amps to get watts, figure the cost of the power and additional A/C load, and see if you can cost-justify thicker wires.
The voltage drop calc will keep you legal -- however it doesn't know about your 20A breaker.  14AWG wire is never legal downstream of a 20A breaker, 12 is your minimum.
Did you catch the part about "9 conductors per conduit"?
That's kind of an issue.  If you want to cram 12 circuits in a single conduit, that is 24 conductors. That requires a 45% conduit derate, forcing you to 8 AWG wire.  Don't do that, unless you would anyway for other reasons.
It might help to re-label your circuits as 15A circuits and fit 15A breakers. 10-20 wires per conduit would be legal with 12AWG wire on a 15A circuit.**  You can only have 12A of continuous loads on a 15A circuit, but you are under 12A.
How do big warehouses work around this?

Multi-wire branch circuits.  In an MWBC, the neutral does not count as a conductor since it only carries differential current. With 120/240 split-phase, you can get 4 split-phase MWBCs (8 hots) in a single conduit without derate.
Three-phase "wye" MWBCs such as 120/208 "wye". This adds a third "hot" conductor.  With 3-phase, you can fit three MWBCs (9 hots) before hitting the derate limit.
277V voltage.  With 277/480 3-phase, you can get more than double the power in the same conduit.

Combine all these tricks, and a single 1/2" conduit with twelve 12AWG wires can carry 39,888 watts** - enough power to light up an entire CostCo.  (that being 9 circuits x 277V x 20A x 80%, the latter the continuous derate).

** why is this? The 50% derate comes off the 90 degree C column in the table, so 12AWG is 30A@90C. 10-20 wires calls for a 50% derate, or 15A.  (and just so you know, 7-9 wires does require a 70% derate, but 70% of 30A is 21A... and 12AWG is limited to 20A for other reasons.)
Comment: Is running 10AWG for the first 150', and then 12AWG the rest of the way help reduce voltage drop?
Comment: Yes, that will help a lot.   10 AWG will also satisfy the derate requirement for up to 20 (not 24, sorry) conductors in the same conduit.
Comment: On the first 150 feet, when using 10AWG, is the return also required to be 10AWG, or can the return be down graded to 12AWG?
Comment: Depends. Your minimum is 12AWG owing to the 20A breaker. Upsizing of any conductor is completely optional on any wire, unless it is made mandatory by conduit derate rules (>9 conductors).  If you expect an MWBC to be evenly loaded, don't bother upsizing the neutral any more than required. It only carries imbalance current.


Unlocking Heroic Dungeons in LFD Tool

Question: How do I unlock Heroic dungeons for previous expansions in the LFD Tool? I currently own Cataclysm, but I'd like to be able to do the Heroic dungeons in WotLK. I have a level 84 character. Am I too high in level to run dungeons from previous expansion? I can only find dungeons for Cataclysm at normal difficulty in LFD.
Answer: You're only able to queue for heroic dungeons at the level that they originally required using the LFD tool, with the exception of TBC heroics.
TBC Heroics are available at level 70-72, while WotLK heroics are only available to level 80 players. See this page for a full reference.
Source: http://wow.gamepedia.com/Dungeon_Finder#Level_restrictions
You can still go there and enter the dungeon by yourself, without the help of the Dungeon Finder. There's no upper level restriction for any dungeon as far as I know.

Unlocking Heroic Dungeons in LFD Tool


Finish infinite iterations cycle and stop the animation with CSS

Question: I have an animation that has an infinite iterations count:
.spinner {
  animation: spinnerAnimation 2s linear infinite;
}

What I want is to make the animation finish the current animation cycle and stop it on a button click (not really on a button click, but this is to make things easier to understand):
$("button").click(function() {
  $(".spinner").addClass("stop");
})

This will add a stop class to the spinner:
.spinner.stop {
  -webkit-animation-iteration-count: 1;
  animation-iteration-count: 1;
}

It doesn't work really smooth, but I don't care about smoothness much in this case:
http://codepen.io/Deka87/pen/OXZvdm
The only problem is that this won't stop the animation in IE edge, i.e. things don't work in IE (versions that support animations). Any ideas?
PS: animation-play-state: pause; is not what I need, because this won't make the animation finish the current animation cycle, but pause it in its current position instead.
PSS: I am really looking for a CSS only solution, i.e. make it work inside .spinner.stop{}.
Comment: U can try to add the style attribute inside the element
Comment: @Deka87, did you check the answer?
Comment: @Dekel, thanks for the answer, Dekel! Yeah, that's what I need!
Comment: You are more than welcome :) a voteup will also be appreciated!
Answer:
You had a problem with the name of your keyframe name - spinnerAnimation vs preloaderAnimation
The only way I was able to set IE to stop the animation was to set animation: none; inside the .stop class:

$("button").click(function() {
  $(".spinner").addClass("stop");
})
.spinner {
  width: 30px; height: 30px;
  background: green;
  animation: spinnerAnimation 2s linear infinite;
}

.spinner.stop {
  -webkit-animation-iteration-count: 1;
  animation: none;
}

button {
  margin-top: 20px;
}
@-webkit-keyframes spinnerAnimation {
  0% {
    -webkit-transform: rotate(0);
  }
  100% {
    -webkit-transform: rotate(360deg);
  }
}

@keyframes spinnerAnimation {
  0% {
    transform: rotate(0);
  }
  100% {
    transform: rotate(360deg);
  }
}

<button>Stop spinner</button>


What is the windows batch command to remove a path regardless it is file or folder?

Question: Let's say we have a file or a folder named c:\temp and we need to remove it if it exists.
What is the command to do it?
Answer: Err, have you tried
rd c:\temp /q /s

Comment: @BugFinder I think `rd` is not applicable for files
Comment: the /s does, its a little like the old deltree.
Comment: Yes it is. Sorry. But how can we do it quietly?
Comment: Thats what /q does. It doesnt ask
Comment: I've tried and the command fails to remove a file `temp` stored at c:\temp using your command BugFinder. It thinks `temp` is a folder
Comment: Well, it would only fail if something was still in use. Which would apply to anything. It more than certainly works - I ran it on a test directory
Comment: @BugFinder Then you should create a file named `tmp` without extension stored at `c:`. You'll see my error.
Comment: I did. As I said, mine deleted. As I said, only reason it is likely to fail would be files in use. What exact error are you getting?
Answer:
C:\>rmdir /?
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

    /S      Removes all directories and files in the specified directory
            in addition to the directory itself.  Used to remove a directory
            tree.

    /Q      Quiet mode, do not ask if ok to remove a directory tree with /S
Comment: I have similar comment to BugFinder answer since yours is similar to his.
Comment: @Nam Gi VU: I have updated your question to make clear you want to delete a file, not a folder
Comment: I want to delete either a file or a folder. Thanks
Answer: Err... why not do both? :)
rd /q /s c:\temp
del /q c:\temp

One of them will succeed if C:\temp is either a file or a folder and the other one will fail. If both fails, it means that it couldn't be deleted or not found. You can even make it a batch file if you don't want to type both commands in all the time.
Answer: It is del c:\temp. Sorry I thought it was only used for files and not applicable for folders
Comment: It is applicable for folders but it doesn't delete the folder itself (if `c:\temp` is a folder, that is). And it doesn't remove the subfolders either, only clears them from files.


How to draw many textured quads faster, and retain glScissor (or something like it)?

Question: I'm using OpenGL 4 and C++11.
Currently I make a whole bunch of individual calls to glDrawElements using separate VAOs with a separate VBO and an IBO.
I do this because the texture coords change for each, and my Vertex data features the texture coords. I understand that there's some redundent position information in this vertex data; however, it's always -1,-1,1,1 because I use a translation and a scale matrix in my vertex shader to then position and scale the vertex data.
The VAO, VBO, IBO, position and scale matrix and texture ID are stored in an object. It's one object per quad.
Currently, some of the drawing would occur like this:

Draw a quad object via (glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT,0)). The bound VBO is just -1,-1,1,1 and the IBO draws me a quad. The bound VBO contains the texture coords of a common texture (same texture used to texture all drawn quads). Matrix transformations on shader position it.
Repeat with another quad object
glEnable(GL_SCISSOR_TEST) is called and the position information of the preview quad is used in a call to glScissor
Next quad object is drawn; only the parts of it visible from the previous quad are actually shown.
Draw another quad object

The performance I'm getting now is  acceptable but I want it faster because I've only scratched the surface of what I have in mind. So I'm looking at optimizing. So far I've read that I should:

Remove the position information from my vertex data and just  keep texture coords. Instead bind a single position VBO at the start of drawing quads so it's used by all of them.
But I'm unsure how this would work? Because I can only have one VBO active at any one time.
Would I then have to call glBufferSubData and update the texture coordinates prior to drawing each quad? Would this be better performance or worse (a call to glBindVertexArray for every object or a call to glBufferSubData?)
Would I still pass the position and scale as matrices to the shader, I would I take that opportunity to also update the position info of the vertices as well as the texture coords? Which would be faster?
Create one big VBO with or without an IBO and update the vertex data for the position (rather than use a transformation and scale matrix) of each quad within this. It seems like this would be difficult to manage.
Even if I did manage to do this; I would only have a single glDraw call; which sounds fast. Is this true? What sort of performance impact does a single glBindVertexArray call have over multiple?
I don't think there's any way to use this method to implement something like the glScissor call that I'm making now?
Another option I've read is instancing. So I draw the quad however many times I need it; which means I would pass the shader an array of translation matrices and an array of texture coords?
Would this be a lot faster?
I think I could do something like the glScissor test by passing an additional array of booleans which defines whether the current quad should be only drawn within the bounds of the previous one. However, I think this means that for each gl_InstanceID I would have to traverse all previous instances looking for true and false values, and it seems like it would be slow.

I'm trying to save time by not implementing all of these individually. Hopefully an expert can point me towards which is probably better. If anyone has an even better idea, please let me know.
Answer:
You can have multiple VBO attached to different attributes!

following seqence binds 2 vbos to attribs 0 & 1, note that glBindBuffer() binds buffer temporarily and actual VBO assignment to attrib is made during glVertexAttribPointer().
glBindBuffer(GL_ARRAY_BUFFER,buf1);
glVertexAttribPointer(0, ...);
glEnableVertexAttribArray(0);

glBindBuffer(GL_ARRAY_BUFFER,buf2);
glVertexAttribPointer(1, ...);
glEnableVertexAttribArray(1);

The fastest way to provide quad positions & sizes is to use texture and sample it inside vertex shader. Of course you'd need at least RGBA (x,y,width,height) 16bits / channel texture. But then you can update quad positions using glTexSubImage2D() or you could even render them via FBO.
Everything other than that will perform slower, of course if you want we can elaborate about using uniforms, attribs in vbos or using attribs without enabled arrays for them.
Putting all together:

use single vbo, store quad id in it (int) + your texturing data
prepare x,y,w,h texture, define mapping from quad id to this texture texcoord ie: u=quad_id&0xFF , v=(quad_id>>8) (for texture 256x256 max 65536 quads)
use vertex shader to sample displacement and size from that texture (for given quad_id stored in attribute (or use vertex_ID/4 or vertex_ID/6)
fill vbo and texture
draw everything with single drawarrays of draw elements
Comment: First, how the hell did you get that username?

Second, please elaborate.

Actually, I see how using texture info would be fastest. What else can you use a texture for?
Comment: I think it was default user name, never bothered to change it :)
Comment: Note that in case of using vbo you need to provide pos & size for every vertex (4 or even 6 per quad). When using texture you need to store in vbo texel address (quad id) where such info can be fetched from texture.
Comment: Thanks for expanding on your suggestion. With this method, couldn't I draw using Instanced Drawing, so I would only need 6 vertices, or 4 and an IBO and then use the `gl_InstanceID` as my QuadID? Would that make it even faster? Because then there's no need to pass anything; I could use two textures, one with positions, the other with UV coords of my actual visible texture?
Comment: Yes, indeed you don't need to pass anything. But many GL implementors don't like it :( So for better compatibility pass at least 1 attrib :) From my experience it is wise to use this unwanted attrib for locating your primitive on {pos,size} texture so you are not quad order dependent (gl_PrimitiveID).
Comment: Using this technique may not be faster than using pure vbo originals but greatly simplifies & speeds up pos&size updates. Also it makes possible to accelerate these updates using rendering via FBO (for quad animations - similary to 100% gpu particle systems).
Comment: wouldn't one of the needed attributes be my original 4 vertices? And for the other commend (from someone else?) which technique may not be faster?
Comment: Sure you can use this attrib as you wish, good GL implementations won't need it. And yes, you can use it as vertex displacement from quad center which will be moved additionally by position sampled from texture. PS: saying 'may not be faster' i mean that any performance gains can be measurable if total number of rendered pixels (samples) is not too big, otherwise bottle neck would be located in fragment pipeline rather than vertex/geometry.


Attach multiple PDFs to an email - do loop skips first PDF for second and subsequent iterations

Question: I want to scan through a folder to pick relevant PDFs belonging to a person, such as AAA, and attach them to an email to be sent to AAA. Then move on to pick up PDFs belonging to BBB and attach them to an email to be sent to BBB so on.
My folder containing the PDFs looks like this:

AAA_111111.pdf
AAA_222222.pdf
AAA_333333.pdf
BBB_111111.pdf
BBB_222222.pdf
BBB_333333.pdf
CCC_777777.pdf
CCC_888888.pdf
CCC_999999.pdf
CCC_444444.pdf

The person is identified by the letters before the underscore (initials) and there is a list on another Excel tab that the initials are looked up against to return their email address.
The code below will generate the email for person AAA and attach all three files listed above.
On the next pass of the main (outer) "do while" loop it comes to person BBB but the inner "do while mfe=" loop attaches the second and third files, but doesn't attach BBB_111111.pdf.
For the third loop, the "do while mfe=" loop attaches the latter three files for CCC but doesn't attach CCC_777777.pdf.
Sub emailreports()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim OMail As Object, signature, mfe, sto As String
    Dim emaillastrow, x, a As Long
    Dim fso As Scripting.FileSystemObject
    Set fso = New FileSystemObject
    Dim folder, strfile As String
    Dim rundate As Date

    Application.ScreenUpdating = False
    Application.Calculation = xlManual
    Application.AutoRecover.Enabled = False

    folder = Worksheets("START").Range("A14")
    strfile = Dir(folder)
    rundate = Worksheets("TEMPLATE").Range("E7")
    b = Worksheets("START").Range("H25")

    Sheets("EMAIL").Select
    emaillastrow = Worksheets("EMAIL").Range("A1000000").End(xlUp).Row

    If Dir(folder, vbDirectory) = "" Then
        MsgBox "PDF destination file path doesn't exist.", vbcritial, "Path error"
        Exit Sub
    End If

    Do While Len(strfile) > 0
        Filename = fso.GetBaseName(folder & strfile)
        mfe = Left(Filename, InStr(Filename, "_") - 1)

        For x = 2 To emaillastrow
            If mfe = Worksheets("EMAIL").Range("A" & x) Then
                sto = sto & ";" & Worksheets("EMAIL").Range("B" & x)
            End If
        Next

        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)

        On Error Resume Next
        With OutMail
            .Display
        End With
        With OutMail
            .To = LCase(sto)
            .CC = ""
            .BCC = ""
            .Subject = "Test subject text"
            Do While mfe = Left(Filename, InStr(Filename, "_") - 1)
                .Attachments.Add (folder & Filename)
                Filename = Dir
                If Filename = "" Then
                    Exit Do
                End If
            Loop
            .signature.Delete
            .HTMLBody = "" & "Test email body text" & .HTMLBody
            .Display
        End With
        On Error GoTo 0

        With Application
            .EnableEvents = True
            .ScreenUpdating = True
        End With

        Set OutMail = Nothing
        Set OutApp = Nothing
        Set OutAccount = Nothing

Skip:
        sto = ""
        strfile = Filename

    Loop

    Application.StatusBar = False
    Application.ScreenUpdating = True
    Application.Calculation = xlAutomatic
    Application.AutoRecover.Enabled = True
End Sub

I thought, at the end of generating the email, to take a step back but being a Do loop this is not possible.
My code seems to ignore the PDF that it stopped at as part of the previous email generation and when generating the next email starts from that PDF file but only picks up and attaches subsequent PDFs.
Answer: You could use a dictionary object to group together the filenames by prefix with one pass of the directory and then iterate the dictionary keys to create the emails with corresponding attachments. For example (outlook methods untested)
Option Explicit

Sub emailreports()

    Dim dict As Scripting.Dictionary, key
    Set dict = New Scripting.Dictionary

    Dim folder As String, strfile As String, mfe As String
    Dim sTo As String, arPDF, arAddr, f
    Dim ws As Worksheet, r As Long, emaillastrow As Long

    folder = Worksheets("START").Range("A14")
    strfile = Dir(folder & "*.pdf")
    If strfile = "" Then
        MsgBox "PDF destination file path doesn't exist.", vbCritical, "Path error " & folder
        Exit Sub
    Else
        ' group files by prefix
        Do While strfile <> ""
            mfe = Left(strfile, InStr(strfile, "_") - 1)
            If dict.Exists(mfe) Then
                dict(mfe) = dict(mfe) & vbTab & strfile
            Else
                dict.Add mfe, strfile
            End If
            strfile = Dir ' get next pdf
        Loop
    End If

    Set ws = Worksheets("EMAIL")
    emaillastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

    ' read email address lookup into array
    arAddr = ws.Range("A2:B" & emaillastrow)

    ' prepare one email per key
    Dim OutApp As Object, OutMail As Object, OMail As Object
    'Set OutApp = CreateObject("Outlook.Application")
    For Each key In dict.Keys

        ' build array of file names for one key
        mfe = Trim(key)
        arPDF = Split(dict(mfe), vbTab)

        ' get email addresses
        sTo = ""
        For r = 1 To UBound(arAddr)
            If mfe = arAddr(r, 1) Then
                sTo = sTo & arAddr(r, 2) & ";"
            End If
        Next
        Debug.Print key, sTo

        'Set OutMail = OutApp.CreateItem(0)
        'With OutMail

            '.To = LCase(sTo)
            '.cc = ""
            '.BCC = ""
            '.Subject = "Test subject text"
            ' attach pdfs
            For Each f In arPDF
                '.Attachments.Add folder & f
                Debug.Print , folder & f
            Next
            '.signature.Delete
            '.HTMLBody = "" & "Test email body text" & .HTMLBody
            '.Display

        'End With
    Next

    'OutApp.quit
End Sub

Comment: Thank you so much CDP1802, this works perfectly for me! I've never used dictionary before and will go away and read up to understand the code.
Answer: On Error Resume Next seems to mask errors and hide skip reason. Try to use more specialized filename mask:
...
folder = Worksheets("START").Range("A14")
If Dir(folder, vbDirectory) = "" Then
    MsgBox "PDF destination file path doesn't exist.", vbcritial, "Path error"
    Exit Sub
End If
strfile = Dir(fso.BuildPath(folder, "*_*.pdf")
rundate = Worksheets("TEMPLATE").Range("E7")
b = Worksheets("START").Range("H25")
'Sheets("EMAIL").Select 'no need to select a sheet
emaillastrow = Worksheets("EMAIL").Range("A1000000").End(xlUp).Row

...


Error in an XML file reported and aborting build

Question: When i edited the res/layout/main.xml and tried to re-run the application build. the following error message appears:
[2011-05-28 08:56:04 - MyWebApps1] res\layout\main.xml:0: error: Resource entry main is already defined.
[2011-05-28 08:56:04 - MyWebApps1] res\layout\main.out.xml:0: Originally defined here.
[2011-05-28 08:56:04 - MyWebApps1] C:\Users\Toshiba\Documents\android\MyWebApps1\res\layout\main.out.xml:1: error: Error parsing XML: no element found
[2011-05-28 08:56:07 - MyWebApps1] Error in an XML file: aborting build.

the main.xml file was edited correctly. No syntax error. Anyone has idea?
Answer: You pressed F11 to run the app but while being on the main.xml and due to your Eclipse configuration it ran the xml file, generating the .out.xml. Just delete it.
Comment: I can't up vote this enough. This cost me two hours as the problem would go away and then come back. Thank you!
Answer: You need to delete the main.out.xml in your res/layout/ , and then clean your project.
If you work on Eclipse IDE , do like this : Project ==> Clean ==> check your project , and press OK.
Comment: it is working now. I need to delete main.out.xml, clean the project and relaunch Eclipse IDE
Comment: i said , delete the file Main.OUT.xml ; and not the main.xml ; and then clean your project :)
Comment: Glad to hear it :), vote the question if it resolve the problem
Answer: You must open "MainActivity.java" file, and try run again
Answer: Stop deleting your .out.xml!
While it's true that will "fix" your issue it will cause other issues, especially if you're designing and working on the UI with the 'graphical layout' tab in Eclipse. What's happening is that you're run configuration is messed up, you go to run it but it's trying to run .out.xml so it fails. The solution is not to start deleting files.
Click to the right of your green circle "run" button to bring down the options list and select "Run Configurations." Configure one for an emulated Android device. When you run the code use this custom configured run. Also, run from your main java file.


GNU make: How to modify a file without re-executing rules?

Question: Suppose I want to make an extremely minor (i.e. commenting, whitespace cleanup, etc) change to a file but I don't want Make to go through the time-consuming (>24hrs) rebuild process. Is there a way to do this?
I know you can do the opposite (i.e. rebuild without editing a file) using "touch", but that doesn't really help here.
Answer: You can also do the opposite with touch as well.  One way I do it that's pretty easy is:
 $ cp -a foo.c foo.c.bak
 $ <fix up foo.c>
 $ touch foo.c -r foo.c.bak

Since cp -a should preserve the modification timestamp.  Another way something similar can be done is to note the modification timestamp (e.g. stat -c "%y" foo.c or something like that) and use the -m and -t arguments to touch instead of copying the file.
Comment: Looks like you and I came up with almost identical solutions. I will have to vote for this as 'useful'...
Comment: This seems like it will work, though I'm not currently on a Linux machine to test it. PS I often use gnu make on Windows as well... anybody know of the easiest Windows solution? All of the Win touch alternatives I see seem wordy/hackish/inelegant.
Answer: After editing the file, you can change the "modification time" to whatever you want with
touch -m -r filename

Where filename is the name of a file with the time you want to copy (another untouched file from the build).  See http://www.computerhope.com/unix/utouch.htm
Answer: touch is still the answer you just need to use it backwards.

Copy the file (preserving modification times, -p).
Edit the original file.
Use touch to reset the modification/etc. times back to what they were before (touch -r file.copy file).

That should be enough to do what you want.
And remember you can always ask make -q to see whether it thinks it will have any work to do to make sure you got it right.


constant pixel width for any scale

Question: I have a standard 3d camera/projection/model setup that renders rectangles with a WebGL shader.
Users can zoom out and fly anywhere.
I want to make sure that regardless of the scale, width of the rendered rectangles is a constant value (e.g. 2 pixels).
What is the most efficient way to do so?
This is very similar to SVG's non-scaling-stroke vector effect: https://www.w3.org/TR/SVGTiny12/painting.html#NonScalingStroke
Answer: Found a solution.
In the vertex shader I project position from model to the clip-space, then from clip-space to screen space, adjust the width in screen pixels, and the project back to clip-space, which ultimately becomes gl_Position value.

constant pixel width for any scale


Bounded, tight sets of measures are compact?

Question: In Prokhorov's 1956 paper "Convergence of Random Processes..." it states the following.

Where $\mathcal{R}$ is a complete, separable, metric space.
Additionally, it says that any weakly convergent sequence of measures satisfies conditions 1,2. This would give that any sequence is compact.
Isn't a counterexample to this the set of Dirac probability measures $\delta_{(1/n)}$ for $n\geq1$ on $\mathbb{R}$? Every element in the sequence has measure 1, and the set $[-2,2]$ is a compact set giving the tightness bound, but the limit $\delta_{(0)}$ is not in the sequence.
This seems to be in contradiction to results stated elsewhere, e.g. (https://mathoverflow.net/questions/140760/prokhorovs-theorem-for-finite-signed-measures).
Should it be the case that it should say relatively compact instead?
Thanks.
Answer: Yes, he means the set of measures $\mathfrak N$ is relatively compact if the two conditions are met.  I don't have access to the Russian original, so cannot tell if the mistake is Prohorov's or his translator's.


Actionscript 3 number drawing recognition

Question: I am working on a game to compare a kid drawing (with mouse or gesture) to numbers from 1 to 9, is converting the drawing to bitmap and compare it with number converted to bitmap a good idea?
and how to handle the difference in size (width-height) between the 2 images?
Thanks
Comment: Stackoverflow is not the place to ask people to write code for you.  Try doing it yourself first, then ask about any problems you encountered.
Comment: Really!? Sorry but no...
Comment: what's wrong with my question?
Comment: i did not ask for code, i said help me with the idea like where to start
Comment: i got the question edited, maybe this looks better, and sorry if it was not in a proper shape first time
Comment: why everyone is so aggressive? i am asking if it is a good idea or not
Comment: this could help: [link](http://stackoverflow.com/questions/13401773/compare-two-images-and-check-equality) and concerning your second question, you'd scale one of the images to be the same size as the other image, then compare.
Comment: Thanks, sorry for the mistaken question , it is my first question here so i still have alot to learn here
Comment: And I apologize for my aggresive comments earlier. But you should look into the [FAQ](http://stackoverflow.com/help/how-to-ask) to see what type of questions get better responses.
Answer: You can try Mouse Gesture Recognition
<code>var gesture:MouseGesture  = new MouseGesture(stage);
gesture.addGesture('B','260123401234');
gesture.addEventListener(GestureEvent.MATCH,matchHandler);

function matchHandler(event:GestureEvent):void
{
     trace (event.datas + ' matched !')
}
</code>
Comment: i gave it a try earlier and it is good but needs more work on the recognition
Comment: Of course, it's necessary to improve the recognition, but this class gives you everything necessary to be able to achieve your goal.
Answer: You can do it with image comparison, but it's pretty tricky to get it right.What I would suggest is:

Pre-generate small (10x10 pixels or even smaller) grayscale images of the numbers and blur them a little
Convert drawing to grayscale
Blur drawing a bit
Crop borders from drawing
Resize drawing down to the size of your number images;
Compare the small drawing image with the generated number images, pixel by pixel and be lenient to what you accept as a match.
Comment: this sounds a very good way to do it, i will give it a try, thanks alot
Comment: Hi @HamadaSamir if this or any answer has solved your question please consider [accepting it](http://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this.
Comment: As I said, there is no obligation to do this. Computer vision problems are challenging, but satisfying when you get right.


do not submit form until function returns true

Question: i have this javascript code which has a function that calls other functions. The problem is the input.html form is getting submitted even if the fields are empty.. if I dont provide any input in the fields, the error messages are being shown but at the same time form gets submitted. there are numerous questions like this available but none is helping as they are not calling function within the function.. what can be the possible solution for this?

function blankos() {
  var p = document.getElementById("windows");
  var q = document.getElementById("linux");

  if ((p.checked == false) && (q.checked == false)) {
    document.getElementById("enteros").innerHTML = "Select an option";
    return false;
  } else if ((p.checked == true) || (q.checked == true)) {
    document.getElementById("enteros").innerHTML = "";
    return true;
  }

}

function blankfreq() {
  var r = document.getElementById("biannual");
  var s = document.getElementById("monthly");

  if ((r.checked == false) && (s.checked == false)) {
    document.getElementById("enterfreq").innerHTML = "Select an option";
    return false;
  } else if ((r.checked == true) || (s.checked == true)) {
    document.getElementById("enterfreq").innerHTML = "";
    return true;
  }
}

function blankhour() {
  var i = document.getElementById("one");
  var ii = document.getElementById("two");
  var iii = document.getElementById("four");

  if ((i.checked == true) || (ii.checked == true) || (iii.checked == true)) {
    document.getElementById("enterhour").innerHTML = "";
    return true;
  }
  return false;

}

function blank() {
  blankos();
  blankfreq();
  blankhour();
  checkselect();

}
<form onSubmit="return blank()" name="input" id="input" method="post" action="cgi-bin/review.cgi" >
Comment: try to return `false` from `blank` function if there is a validation error
Answer: blank() doesn't return anything. Try:
function blank() {
    return blankos() && blankfreq() && blankhour() && checkselect();
}

This will only report the first error that's detected. If you want all of them to be reported, assign them to variables first.
function blank() {
  var ok1 = blankos();
  var ok2 = blankfreq();
  var ok3 = blankhour();
  var ok4 = checkselect();
  return ok1 && ok2 && ok3 && ok4;
}

I haven't looked at all the individual validation functions, though. You probably have bugs there that need to be fixed as well.
Comment: ...and fix bugs in the various functions it's calling.
Answer: You can use preventDefault() to restrict your form from submitting. Change your HTML from
<form onSubmit="return blank()" name="input" id="input" method="post" action="cgi-bin/review.cgi" >

to
<form name="input" id="input" method="post" action="cgi-bin/review.cgi" >

Then add this block of code
//id of the form is 'input'
$("#input").submit(function(e){
//if any of the inner functions return false then prevent from form submit
   if( !blankos() || !blankfreq() || !blankhour() || !checkselect()){
      e.preventDefault();
      return  false;
   }
});


Evaluating the integral $ \int_0^{\pi/2}\cos(2\theta)\log(\cos\theta) d\theta $

Question: How may I compute the following integral?
$$ \int_0^{\pi/2}\cos(2\theta)\log(\cos\theta) d\theta $$
Comment: Sorry, that's what I meant. I'll fix it.
Answer: $u=\log(\cos\theta)$ and $dv=\cos2\theta d\theta$ then partial integration comes like this
$$\log(\cos\theta).\frac{\sin2\theta}{2}-\int\frac{\sin2\theta}{2}.\frac{-\sin\theta}{\cos\theta}d\theta=\log(\cos\theta).\frac{\sin2\theta}{2}+\int \sin^2(\theta)d\theta.$$ Then it follows as $$\begin{align}\int \log(\cos\theta)\cos2\theta d\theta&=\log(\cos\theta).\frac{\sin2\theta}{2}+\int \frac{1-\cos2\theta}{2}d\theta\\ \\ &=\log(\cos\theta).\frac{\sin2\theta}{2}+\frac{\theta-\sin2\theta/2}{2}\end{align}$$
Answer: \begin{align}
&\int^{\pi/2}_{0}\cos2\theta\log\cos\theta\,d\theta\\
&=\int^{\pi/2}_{0}\log\cos\theta\,d\frac{\sin2\theta}{2}\\
&=\left.\log\cos\theta\frac{\sin2\theta}{2}\right|^{\pi/2}_{0}-\frac12\int^{\pi/2}_{0}\sin2\theta d\log\cos\theta\\
&=-\int^{\pi/2}_{0}\sin\theta\cos\theta \frac{-\sin\theta}{\cos\theta}\\
&=\int^{\pi/2}_{0}\sin^2\theta d\theta\\
&=\frac{\pi}{4}.
\end{align}


If $A$ is a real diagonalizable matrix and $B$ is real symmetric and positive definite, is the matrix $B^{-1}A$ real diagonalizable?

Question: This problem is from a generalized eigenvalue problem. I can only proof it when $A$ is symmetric:
Let $G$ be the square root of $B$ and $G = G^T$, then $B^{-1}A = G^{-1}(G^{-1}AG^{-T})G$ is similar to $G^{-1}AG^{-T}$, which is again symmetric and thus diagonalizable.
However, this method fails when $A$ is just real diagonalizable. Are there any tricks to modify the proof, or is there a counterexample?
Answer: Hint: for a counterexample, start with a matrix $C$ that is not diagonalizable,
and see if you can find a symmetric positive definite matrix $B$ so that $A = BC$ is
diagonalizable. Almost any one will do.
Answer: The statement is not true. Take
\begin{align*}
A = \begin{pmatrix}
0 & 1 \\
0 & -1/2
\end{pmatrix}, \quad
B = \begin{pmatrix}
1 & -1/2 \\
-1/2 & 1
\end{pmatrix} > 0,
\end{align*}
then
\begin{align*}
B^{-1}A = \begin{pmatrix}
0 & 1 \\
0 & 0
\end{pmatrix}
\end{align*}
is not diagonalizable. But $A$ is clearly diagonalizable because it has two distinct eigenvalues.


Getting rates from an array - json

Question: I am trying to get the rates from this website.
So I connect with website = Faraday.get('https://bitpay.com/api/rates')).status == 200 and then try to parse this.
A segment of the response I get is:
 #<Faraday::Response:0x007fcf1ce25688
  @env=
  #<struct Faraday::Env
  method=:get,
  body=
  "[{\"code\":\"BTC\",\"name\":\"Bitcoin\",\"rate\":1},      {\"code\":\"USD\",\"name\":\"US Dollar\",\"rate\":586.66},{\"code\":\"EUR\",\"name\":\"Eurozone Euro\",\"rate\":528.991322},{\"code\":\"GBP\",\"name\":\"Pound Sterling\",\"rate\":449.441986},{\"code\":\"JPY\",\"name\":\"Japanese Yen\",\"rate\":59907.95922},{\"code\":\"CAD\",\"name\"

When I do a website.body I get a String class of all these values found on that website. I want to parse them though (JSON?) so that I can get each rate as a float.
I tried something JSON.parse(website.body)["GBP"]["rate"].to_f but yet again it cannot work in a string.
The return I get is TypeError: no implicit conversion of String into Integer
I was having a similar (but not the same) format from a different rates website and this is how I was handling it. Do I need to change its format first or is there a different way around it?
Answer: You're trying to access to the parsed JSON with the key "GBP" but you have an array. It's like if you did
a = [1,2,3,4,5]
a['foo']

Try out
currencies = JSON.parse(website.body)
currencies.each { |currency| puts currency['rate'] }

and change it like you need

Getting rates from an array - json


Multithreading in Python with the threading and queue modules

Question: I have a file with hundreds of thousands of lines, each line of which needs to be undergo the same process (calculating a co-variance). I was going to multithread because it takes pretty long as is. All the examples/tutorials I have seen have been fairly complicated for what I want to do, however. If anyone could point me to a good tutorial that explains how to use the two modules together that would be great.
Answer: Whenever I have to process something in parallel, I use something similar to this (I just ripped this out of an existing script):
<code>#!/usr/bin/env python2
# This Python file uses the following encoding: utf-8

import os, sys, time
from multiprocessing import Queue, Manager, Process, Value, Event, cpu_count

class ThreadedProcessor(object):
  def __init__(self, parser, input_file, output_file, threads=cpu_count()):
    self.parser = parser

    self.num_processes = threads
    self.input_file = input_file
    self.output_file = output_file

    self.shared_proxy = Manager()

    self.input_queue = Queue()
    self.output_queue = Queue()

    self.input_process = Process(target=self.parse_input)
    self.output_process = Process(target=self.write_output)

    self.processes = [Process(target=self.process_row) for i in range(self.num_processes)]

    self.input_process.start()
    self.output_process.start()

    for process in self.processes:
      process.start()

    self.input_process.join()

    for process in self.processes:
      process.join()

    self.output_process.join()

  def parse_input(self):
    for index, row in enumerate(self.input_file):
      self.input_queue.put([index, row])

    for i in range(self.num_processes):
      self.input_queue.put('STOP')

  def process_row(self):
    for index, row in iter(self.input_queue.get, 'STOP'):
      self.output_queue.put([index, row[0], self.parser.parse(row[1])])

    self.output_queue.put('STOP')

  def write_output(self):
    current = 0
    buffer = {}

    for works in range(self.num_processes):
      for index, id, row in iter(self.output_queue.get, 'STOP'):
        if index != current:
          buffer[index] = [id] + row
        else:
          self.output_file.writerow([id] + row)
          current += 1

          while current in buffer:
            self.output_file.writerow(buffer[current])
            del buffer[current]
            current += 1
</code>
Basically, you have two processes managing the reading/writing of the file. One reads and parses the input, the other reads from the "done" queue and writes to your output file. The other processes are spawned (in this case the number is equal to the number of total processor cores your CPU has) and they all process elements from the input queue.


Propositional formula which is satisfiable if theres a graph homomorphism?

Question: I was wondering, how could I define a propositional formula $\varphi_{G, H}$, which, given two finite graphs $G$ and $H$, is satisfiable exactly if theres a graph homomorphism from $G$ to $H$.
A graph homomorphism is defined like this:
$h : V(G) \to V (H)$
$\{u, v\} \in E(G) \to  \{h(u), h(v)\} \in E(H)$
Comment: @TheHolyJoker you sure about that? I just need to define a propositional formula that evaluates to 1 <=> theres a gaph homomorphism from two finite graphs G to H.
Answer: Well, what I said in the comment was not precise.
It is unknown, if for every two graphs $G,H$ CNF formula $\varphi_{G,H}$ with polynomial length in $G,H$, such that:
there is some isomorphism from $G$ to $H\iff\varphi_{G,H}$ is satisfiable.
This is conjectured to be false.
As for your question, for graph homomorphism, this is possible, since deciding if two graphs are homomorphic, is an NP-Complete problem.
See Lectures note by Reinhard Pichler page 28, for the reduction to $3\text{-SAT}$ problem.
Comment: this is exactly what I was looking for, thank you so much


Is it possible to adjust the sizes of square and circle inside a unit circle so the combined area is half of that unit circle.

Question: A square and a circle fits together inside an unit circle symmetrically. Is it possible to adjust the sizes of circle and the square so that their combined area is half of the area of that unit circle ?
I tried it like this : As the circle is of unit radius so radius is equal to 1 and so its area is irrational. Now let the length of the square be $a$ and that radius of circle be $r$  and now the question becomes is it possible such that $a^2$+$πr^2$ = $π/2$ since the combined area is half of the unit circle. There I got stuck as RHS is irrational . Any help would be appreciated.
Comment: Hint: let $x$ be the distance between the center of the big circle and the intersection point of the square with the small circle. Do you see why $x+2r=1$ and $(\frac a2)^2+(a-x)^2=1$? Can you use those equations to reduce the problem to a problem in one unknown?
Answer: Trying to Proving the Existence ( Answering the Question in the title ) :
Where-ever we take the Centre $X$ of the Inner Circle , we can get the Combined total Area by Drawing the Square beside it.
We can move the Point $X$ from right Extreme to left Extreme.
In the Image , we can Draw the largest Square ( Blue ) inside the Circle & then Draw the Small Circle ( Blue ) beside it. Here $X$ is right Extreme.
Area of outer Circle is $\pi \approx 3.14$
Here , the Combined Blue total Area is more than half the outer Circle.
Diagonal of Square is $2$ , Area is $2$ , Combined Area will be a little more than $2$.
Now , the Purple Circle can be almost the whole Outer Circle, with a very small Purple Square. Here $X$ is left Extreme.
Hence , Combined Purple total Area is more than half the outer Circle.

Combined Area varies continuously from more than half to some minimum to more than half. Is there a Point $X$ where Combined Area is Exactly half ?
If YES , Where is that Point $X$ ?
We can figure that out by making a Equation.
Let the Inner Circle have Diameter $x$ , & the Square have Side $y$.
Combined Area is $ y^2 + \pi x^2 / 4 = \pi / 2 $ [[ EQ1 ]]

The left most Part $ z = 1 - \sqrt {1-y^2/4} $
Hence the Outer Circle Diameter is $ 2 = x+y+z $
$ 2 = x + y + 1 - \sqrt {1-y^2/4} $
$ x+y-1 = \sqrt {1-y^2/4} $
$ (x+y-1)^2 = 1-y^2/4 $ [[ EQ2 ]]
Solving  [[ EQ1 ]] &  [[ EQ2 ]] will give the necessary Point $X$.
Value will be cumbersome , involving square root , $\pi$ , square , Etc.
$ y^2 + \pi x^2 / 4 = \pi / 2 $
$ (x+y-1)^2 = 1-y^2/4 $
$ y^2 = \pi / 2 - \pi x^2 / 4 $
$ y = \sqrt { \pi / 2 - \pi x^2 / 4 } $
$ (x+\sqrt { \pi / 2 - \pi x^2 / 4 }-1)^2 = 1-\sqrt { ( \pi / 2 - \pi x^2 / 4 ) }^2/4 $
$ (x+\sqrt { \pi / 2 - \pi x^2 / 4 }-1)^2 = 1- ( \pi / 2 - \pi x^2 / 4 )/4 $
$ (x-1)^2+ ( \pi / 2 - \pi x^2 / 4 ) + 2(x-1)\sqrt { \pi / 2 - \pi x^2 / 4 } = 1- ( \pi / 2 - \pi x^2 / 4 )/4 $
$ 2(x-1)\sqrt { \pi / 2 - \pi x^2 / 4 } =  -(x-1)^2 - ( \pi / 2 - \pi x^2 / 4 ) + 1- ( \pi / 2 - \pi x^2 / 4 )/4 $
$ 4(x-1)^2 ( \pi / 2 - \pi x^2 / 4 ) = [ -(x-1)^2 - \pi / 2 + \pi x^2 / 4 + 1 - \pi / 8 + \pi x^2 / 16 ] ^2 $
We can use Wolfram to get the answer $x ≈ 0.995126$ & hence $y ≈ 0.890525$ . We can then verify this :
Combined Area is $ 0.890525^2 + \pi 0.995126 / 4  = 1.57460...$ which is quite close to half the Outer Circle Area.
Comment: The area of the unit circle is just $\pi$ and $2 > \pi/2,$ so both of your "extreme" cases have area greater than half the outer circle. But there is a minimum in between these two cases.
Comment: @Prem , I think the equation $[[EQ1]]$  must be $y^2+πx^2/4 = π/2$. There is a mistake in $[[EQ1]]$ I think.
Comment: @Prem , I think in the last statement it will '' Solving $[[EQ1]]$ and $[[EQ2]]$'' instead of ''Solving $[[EQ2]]$ and $[[EQ2]]$'' . A writing mistake I think.
Comment: I have updated the answer , thanks for the Pointer  , @DavidK
Comment: I have updated that Point , thank you , @nickgard , hope no other "simple bloopers" !!!
Comment: And can you please elaborate your solution of how you found point $X$ after solving $[[EQ1]]$ and $[[EQ2]]$.
Comment: I have updated the corrections , thank you , @Adam100 , I will try solving it tomorrow.
Comment: An intersection of two conics? That's equivalent to solving some polynomial of degree 4.
Comment: There were Square terms & Square root terms hence we will eventually get a Degree 4 Polynomial , which will be even more cumbersome due to $\pi$ here & there ! @IvanNeretin
Comment: I have added the Solution now , @Adam100 , hope it is useful !!
Comment: The last equation squares both sides of the previous line. Evaluating that penultimate line at $x\approx0.995126$ gives the LHS as negative and the RHS as positive, but with the same absolute value (about $0.0087$). A false solution has been introduced by squaring. The penultimate line doesn't have a positive real solution for $x$. $EQ1$ is implicitly seeking the value for $x$ where the combined area of the square and small circle is $\pi/2$, but I think there is no such value.
Comment: What you observed could be true , that is why I tried to "verify" the Wolfram Solution , where I did get somewhere close to the half ratio , @nickgard [[ My own Concern/Problem with this Solution is : We have Area more than half at Extremes & somewhere Area is minimum , then Either (1) minimum is less than half & there must be at least  2 Cases where Area is Exactly half , yet we got Single Solution Or (2) minimum is more than half & Area is never half Or (3) minimum is Exactly half , which is very unlikely. Currently , I do not have to the tools to Plot that Curve to check the minimum. ]]


how to add package dependencies to stack project

Question: how to add package dependencies to stack project. for example lets say I want to add Parsec dependencies to my project so I can import it in a given module and use it
I have added the package name the cable file and I have got the following error :
Unable to parse cabal file /Users/lambda/development/blog-post/blog-post.cabal: NoParse "build-depends" 19
my cabal file is as per the below
 build-depends:       base >= 4.7 && < 5
                      ,parsec-3.1.11

Comment: you have to add the dependency to the `build-depends` section in your `cabal`-file.
Comment: If you come across any issues please post the errors - otherwise helping you will be difficult.
Answer: the syntax you use in your cabal file is not valid
build-depends:       base >= 4.7 && < 5
             ,       parsec >= 3.1.11 && < 4

should be correct
update
the syntax parsec >= 3.1.11 && < 4 is not mere convention but a way to constrain the used library to the bounds, where your package works.
parsec >= 3.1.11 && < 4 means that the version of parsec needs to be larger or equal to version 3.1.11 and strictly less than 4.
Comment: I am not sure, but I think `parsec` is not developed anymore and `mega-parsec` is the de-facto successor.
Comment: It works actually, is it a convention to write the package name and `>> current version && <... `


Too many arguments for function

Question: I'm starting to learn Lisp with a Java background. In SICP's exercise there are many tasks where students should create abstract functions with many parameters, like
 (define (filtered-accumulate combiner null-value term a next b filter)...)

in exercise 1.33. In Java (language with safe, static typing discipline) - a method with more than 4 arguments usually smells, but in Lisp/Scheme it doesn't, does it? I'm wondering how many arguments do you use in your functions? If you use it in production, do you make as many layers?
Comment: What's wrong with a method with 4 more than 4 arguments?
Comment: Those don't sound like reasons to arbitrarily restrict yourself to 4 arguments.
Comment: @Falmarri, usually it's hard to keep in mind such API + you can make mistake in order of arguments.
Comment: @Falmarri, Off course. But I think it's some "best-practice" too avoid such methods.
Answer: SICP uses a subset of Scheme
SICP is a book used in introductory computer science course. While it explains some advanced concepts, it uses a very tiny language, a subset of the Scheme language and a sub-subset of any real world Scheme or Lisp a typical implementation provides. Students using SICP are supposed to start with a simple and easy to learn language. From there they learn to implement more complex language additions.
Only positional parameters are being used in plain educational Scheme
There are for example no macros developed in SICP. Add that standard Scheme does have only positional parameters for functions.
Lisp and Scheme offer also more expressive argument lists
In 'real' Lisp or Scheme one can use one or more of the following:

objects or records/structures (poor man's closures) which group things. An object passed can contain several data items, which otherwise would need to be passed 'spread'.
defaults for optional variables. Thus we need only to pass those that we want to have a certain non-default value
optional and named arguments. This allows flexible argument lists which are much more descriptive.
computed arguments. The value or the default value of arguments can be computed based on other arguments

Above leads to more complicated to write function interfaces, but which are often easier to use.
In Lisp it is good style to have descriptive names for arguments and also provide online documentation for the interface. The development environment will display information about the interface of a function, so this information is typically only a keystroke away or is even display automatically.
It's also good style for any non-trivial interface which is supposed to be used interactively by the user/developer to check its arguments at runtime.
Example for a complex, but readable argument list
When there are more arguments, then Common Lisp provides named arguments, which can appear in any order after the normal argument. Named arguments provide also defaults and can be omitted:
(defun order-product (product
                      &key
                      buyer
                      seller
                      (vat   (local-vat seller))
                      (price (best-price product))
                      amount
                      free-delivery-p)
  "The function ORDER-PRODUCT ..."   ; documentation string
  (declare (type ratio vat price)    ; type declarations
           (type (integer 0) amount)
           (type boolean free-delivery-p))
  ...)

We would use it then:
(order-product 'sicp
               :seller 'mit-press
               :buyer  'stan-kurilin
               :amount  1)

Above uses the seller argument before the buyerargument. It also omits various arguments, some of which have their values computed.
Now we can ask whether such extensive arguments are good or bad. The arguments for them:

the function call gets more descriptive
functions have standard mechanisms to attach documentation
functions can be asked for their parameter lists
type declarations are possible -> thus types don't need to be written as comments
many parameters can have sensible default values and don't need to be mentioned

Several Scheme implementations have adopted similar argument lists.

Too many arguments for function


Error "Could not find PyAudio; check installation" on Windows

Question: I have simple code in python to recognise my voice and convert it in text. I am using speech recognition.
But I am getting error "Could not find PyAudio; check installation". How to fix?
Here is my code:
import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone() as source:
    print('Speak anything')
    audio = r.listen(source)

    try:
        global command
        command = r.recognize_google(audio)
        print('You said : {}'.format(text))
    except:
        print('Sorry,coud not recognize')

Comment: You have to install it separately [Pyaudio](https://github.com/intxcc/pyaudio_portaudio/releases)
Comment: I install it and that doesnt fix anything
Comment: Possible duplicate of [pyaudio installtion error in windows](https://stackoverflow.com/questions/32160102/pyaudio-installtion-error-in-windows)
Answer: Install pyaudio.
if you are using jupyter notebook on anaconda prompt then
conda install pyaudio

if you are using jupyter notebook using cmd then on jupyter cell,
import sys
!{sys.executable} -m pip install pyaudio

if you are running python file on cmd then,
pip3 install pyaudio #for python3

Answer: even i faced py-audio error so you can install py-audio with the help of unofficial libraries  install it with the help of powershell in windows
python unoffical libraries
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31059009)


Mail sending issue, asp.net

Question: Im having issue with mail sending
In web.config file
<mailSettings>
    <smtp from="email@example.com">
    <network host="mail.authsmtp.com" port="25" userName="firstname.lastname@example.com" password="****" defaultCredentials="false"/>
            </smtp>
        </mailSettings>
</system.net>

I used mail sending code to send mail
but im getting exception as, The server response was: 5.0.0 Your email system must authenticate before sending mail:XM_ERR:xxx.xxx.xxx.xxx(my ip addr)
Please let me know how to solve this issue.
Thank you
Comment: The answer provided is the solution to this problem. You need to put defaultSettings to true for these settings to work. It should be marked as accepted!
Answer: Do you want to use credentials from web.config file?
If yes, than change defaultSettings to true.
If not, than you must supply valid credentials in code.

Mail sending issue, asp.net


Is there a tool or trick to help with quoting madness?

Question: When doing server maintenance, I often find myself writing multi-level nested commands, so as:
for server in A B C; do sh -c "ssh $server 'mysql db -e \"select where line like \\\"%abc%\\\"\"'&"; done

This may be a contrived example, but it's really the kind of thing I have to do sometimes for some odd, ad-hoc task.
The problem is the quotes. As you go to deeper levels, you have to start escaping the quotes, escaping dollar signs, and escaping the escaping. Using single quotes helps avoid one level, but that's it.
I began working on a solution for myself, inspired by the qq() function in perl, but I thought I'd ask around first: is there a tool, method or framework that will make it easier to write these nested commands without getting bogged down with backslashes?
Comment: Why did you wrap the whole thing in `sh -c ""` that just adds yet another layer of quoting.
Comment: @geirha Note the `&` at the end there. This makes all the ssh commands run in parallel.
Comment: @geirha Oh, sorry, I see your point now.
Comment: @geirha If I don't use sh -c, I get a bunch of job notifications in the console.
Comment: only if you run it from an interactive shell. If you put it in a file and run it as a script, you should not get job control notifications, since job control is only enabled for interactive shells.
Answer: You can avoid most layers of quoting by passing the mysql commands via stdin instead of via argv:
for server in A B C; do
    ssh "$server" 'mysql db' <<< "select * from foo where line like '%abc%';" &
done
wait

For a more generic answer, see http://mywiki.wooledge.org/BashFAQ/096
Answer: Try this:
echo "ssh $server 'mysql db....'" | sh

It decreases the nesting level, and also makes it much easier for you because you can just run the echo command until you get the exact command you want run after all escaping.
Comment: This looks like it has the exact same level of nesting.


How to generate download .pdf for Internet Explorer?

Question: I'm working on a website in which a user enters a name and then presses a button that prompts the server to create a pdf file according to the information provided, and then sends the file to the user.
I'm testing the website on my laptop without IIS.
I needed the pdf to be hebrew and couldn't find a pdfwrite with vb on hebrew; instead, I create a MS Word document and then convert it to pdf using the code below.
This  works fine on Firefox, Chrome, and Safari, but on Internet Explorer the page disconnects before the download.  It disconnects when the create word statement is executed.
Can anyone help me?
<code>      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles      Button1.Click
      Dim strname As String
      strname = TextBox1.Text.Trim

      Dim oword As New word.Application
      Dim odoc As New word.Document
      oword = CreateObject("word.Application")

      odoc = oword.Documents.Add("C:\documents\tamp.dotx")

      odoc.Bookmarks.Item("name1").Range.Text = strname
      odoc.Bookmarks.Item("name2").Range.Text = strname
      odoc.Bookmarks.Item("name3").Range.Text = strname
      odoc.Bookmarks.Item("name4").Range.Text = strname
      odoc.Bookmarks.Item("name5").Range.Text = strname
      odoc.Bookmarks.Item("name6").Range.Text = strname

      odoc.ExportAsFixedFormat(Server.MapPath("\neshume.pdf"), 17)
      Response.Redirect(Server.MapPath("\neshume.pdf"))
      end sub
</code>
Comment: What does Event Log say?
Comment: My guess is that it is failing on the next line where you create a file.Obviously the security levels in the IE browser is different from the others and is not allowing access to the path C:\documents\tamp.dotx
Comment: Chiwda so what can i do to correct this?
Comment: I think that page headers are not set correctly to be accepted by IE. Would you try to narrow the problem removing all code except
Response.Redirect(Server.MapPath("\neshume.pdf"))? Would you try to download the .pdf only (address should be something as http: //localhost:port/neshume.pdf)? I recommend using @name to address a comment response to appropriate person.
Comment: @IvanH i tried with out any other code and it failed
Answer: turns out the problem was not in the code something was wrong with my machine i tested it on a different computer and it worked perfectly
Comment: Even though the problem did come from your code, it might help others with similar issues if you explained what was wrong with your machine that caused this problem.
Answer: Replace
<code>Response.Redirect(Server.MapPath("\neshume.pdf"))
</code>
with
<code> Response.Redirect("neshume.pdf")
</code>
You can't redirect to full path (Maybe it was accepted by ff because it is running on the same computer).
Comment: it does not seem that this is the problem the website crashes when it process the code  oword = CreateObject("word.Application")
Comment: It crashes on CreateObject in ff and not in ie? It is strange. Would you publish exact message? Do you tried to put the breakpoint to the place?
Comment: it closes in ie and not firefox i tried the breakpoint at each point and it happens at the above statemet
Comment: Would you make your code as simple as possible (document, no parameters fixed path)? I try to copy/paste it and we'll see.


jarsigner error: java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0

Question: I get this error when signing an Ionic android apk, I'm on Kubuntu 17.04, using Ionic 3, java 8 installed
The error I get:
<code>Enter Passphrase for keystore:
updating: META-INF/MANIFEST.MF
adding: META-INF/TEST2.SF
adding: META-INF/TEST2.RSA
signing: AndroidManifest.xml
jarsigner error: java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0
</code>
java version
<code>$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.17.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
</code>
javac
<code>$ javac -version
javac 1.8.0_131
</code>
I have Android Studio installed and it's working fine, I tested the app source code and it ran on the emulator no problems.
Comment: were you able to get this fixed?
Answer: This issue could be solved on Debian 9 by setting the correct update-alternative for jarsigner that matches the version of java and javac.
Version of java
<code>$ java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-1~deb9u1-b15)
OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode)
</code>
Version of javac
<code>$ javac -version
javac 1.8.0_141
</code>
Version of jarsigner
<code>$ sudo update-alternatives --get-selections | grep jarsigner
jarsigner   manual   /usr/lib/jvm/java-8-openjdk-amd64/bin/jarsigner
</code>
To set the version of jarsigner
<code>$ sudo update-alternatives --config jarsigner
There are 4 choices for the alternative jarsigner (providing /usr/bin/jarsigner).

  Selection    Path                                             Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-9-openjdk-amd64/bin/jarsigner   1091      auto mode
  1            /usr/bin/gjarsigner-4.9                           1049      manual mode
  2            /usr/bin/gjarsigner-6                             1060      manual mode
* 3            /usr/lib/jvm/java-8-openjdk-amd64/bin/jarsigner   1081      manual mode
  4            /usr/lib/jvm/java-9-openjdk-amd64/bin/jarsigner   1091      manual mode
</code>
Comment: I had the same issue with version 9, after updating to 10, the problem is gone. Here you can find how to install/update version 10 or later: https://stackoverflow.com/a/49507161/6053654
Answer: I had the same error. But my java version is 9.0.1,after switched my jdk version to 1.8.xx, the error was gone.
So, change the jdk version may solve the problem.