text:
Q: How to down-convert songs on-the-fly while syncing from iTunes to my iPod? Is there a way to down-convert songs on-the-fly while syncing from iTunes to my iPod?
Most of my music library is in Apple Lossless format, which obviously takes a large amount of space - not suitable for a mobile audio player.
I want to be able to convert songs from Apple Lossless to MP3/AAC on-the-fly, without needing to convert them manually prior to syncing. Thus I will have more space on my iPod, and the lower sound quality is negligible when using normal headphones.
I know this feature is available for iPod Shuffles, but how can I enable it for other iPod types?

A: I have the exact same issue and the exact same request of iTunes. It does not exist for other iPods/iPhones. (And since I don't have a Shuffle I'm not exactly how good the feature is.) It really does surprise me that this feature hasn't been built out for other devices.
My only advice is to let Apple know that you want this feature, that's what I did.
http://www.apple.com/feedback/itunesapp.html

A: That is a long standing request with iTunes/iPod, and the answer looks like a no. Do send your feedback to apple!
I also have mostly ALAC files and settled on using smart playlists to auto-sync my ipod with various music without having concerns for disk usage management. I divided my ipod into fixed-size 'chunks' such as : most recently added albums (up to xGB) + most often played or top rated (up to xGB), etc.
Still, a downside is that battery usage remains quite higher with bigger files, especially on the HDD-based ones.
A last resort is to abandon iTunes. MediaMonkey is a pretty good paying alternative to iTunes that have supported portable device on-the-fly transcoding for a long while (it works great, tested it). But some specific features I like, such as embedded lyrics, were not supported the last time I checked.

A: Of course such on the fly conversion is possible since iTunes 10, at least with the iPod Touch models. I was doing this in late 2010 I believe with an iPod Touch 3rd gen and with the iPhone 3gs after that. The downside of course being the conversion takes some time.
If other models of the iPod, Nano and so one support this I don't know.
Unless your device have IOS 5 on it, this script by Doug Adams could also work:
Lossless to AAC Workflow v2.2:
"Makes a converted AAC copy of each Apple Lossless or AIFF track selected in iTunes
Adds the AAC file to iPod, deleting the original AAC from iTunes."
I haven't tried as my 3gs is on IOS 5.1.1 and except for FLACs I already have conversion support.


text:
Q: acknowledge + to infinitive or + verb ing According to engVid 'acknowledge' is always followed by a gerund. However, these examples below are from highly reputed dictionaries.

*

*It is generally acknowledged to be true.

*She is usually acknowledged to be one of our best artists.

I'm confused. Is it correct to use either to+verb and gerund after 'acknowledge'? Would it be incorrect to write 'She is usually acknowledged being one of our best artists' ?

A: Obviously, your source is misleading. I do not say wrong, but "circumstances alter cases."
Your source is talking about a gerund, which is a participle used as a noun.

The governor acknowledged pardoning his former wife, but …

I agree that

The governor acknowledged to pardon his wife, but …

is not idiomatic.
Present participles are tricky. They can be used as the lexically significant part of a compound verb, as an adjective, or as a noun.
Your source was focused on only the use of a participle as a stand-alone gerund

The female governor barely acknowledged him as lieutenant governor

can also be rendered idiomatically as

The female governor barely acknowledged him to be lieutenant governor

or

The female governor barely acknowledged him being lieutenant governor

or

The female governor barely acknowledged his being lieutenant governor

The point is that the object of the verb is now a noun phrase introduced by a pronoun, not a bare gerund. Indeed, in the second example, "being" is not even a gerund because the pronoun is not possessive.
You got a piece of advice that is correct in the narrow case of a gerund acting as the introduction of a noun phrase or a gerund standing alone, but is incorrect more generally.
EDIT In response to the comment below by the original poster, one common way to define participle is

a form of a verb used as an adjective.

This definition implies that there is no name to analyze "cooking" grammatically in this sentence.

He was cooking supper when she got home.

Clearly "cooking" in this example is not an adjective.
A common way to define "gerund" is

a form of a verb used as a noun

These common definitions may be perfect definitions in linguistics generally, but they are confusing when applied to English grammar because the same form based on a verb may be used as any one of three parts of speech. Is the word "cooking" to be designated as the nameless part of a compound verb or as a participle or as a gerund? You cannot tell if you define a participle as a form derived from a verb. Here is a definition that applies to English.

In modern English, a "participle" means one of two inflected forms of a verb, one designated "present" and the other designated as "perfect" or "passive." Each form may be used as part of a compound verb or as an adjective. In addition, the present participle may be used as a noun. When used as a noun, a participle is also known as a "gerund."

In short, it is more useful to define a participle in English as an inflected form of a verb that can be used as multiple parts of speech rather than as an adjective. Separate form and function.
I said at the beginning of my answer that your source was misleading rather than wrong. I'd add that the definition of "participle" that you are using is not as helpful as it could be.

A: So we're talking here about the catenative construction, where the catenative verb "acknowledge" has a non-finite clause as its complement.
The admissibilty of the non-finite clause depends on the type of catenative complement: to-infinitival clauses occur only in the complex type, gerund-participials only in the simple type. Reversing the complementation results in a loss of grammaticality, so we have [1] and [2] but not [3]:

[1] He acknowledges it to have been a mistake. ........ [complex]
[2] He acknowledges making a mistake. ........................[simple]
[3] *He acknowledges to have made a mistake. ..........[hybrid - ungrammatical]

(Note: the complex catenative construction has an intervening NP between the matrix and dependent verbs, while the simple construction never does).

redpajama_set_name: RedPajamaStackExchange


text:
Q: Check whether advice is applied Consider I wrote AOP pointcut and made a misprint in it:
@Pointcut("within(com.example.servic..*)")
public void serviceMethod() {}

There is "servic" instead of "service".
I am going to use this pointcut to apply security check before service method invocation.
Due to the misprint the security check won't be applied but there will be no error message also.
It seems to be very easy to make such mistakes during refactoring for example.
The question is: how do you check that advices are really applied in your projects?
Thanks in advance!

A: Perfect candidate for a unit test.

A: The most elegant solution is to use a good IDE.
If you are using Eclipse, install the AJDT plugin and you will see an orange arrow to the left of all lines that is matched by an Spring AOP/AspectJ advice and all advices have information on how many matches it has in the code.
Another advantage with a plugin like AJDT is that it also weaves automatically for you everytime Eclipse compiles a class.
An example with the AJDT plugin activated:

(source: espenberntsen.net)


text:
Q: Acceleration logic with Vector3 I'm trying to get this Vector3 to accelerate when it's to the right and decelerate when it's not. This is my update method. Why doesn't it accelerate? It has a constant speed. I know you could just add -5 to vel.xif it's to the left and +5 if it's to the right and then stop it when vel.x is 0 but I'm trying to make this work. I really don't understand what it is I'm doing wrong.
In the class I have declared two Vector3s (used in update)
    public void update(float delta) {
        timePassed += Gdx.graphics.getDeltaTime(); //irrelevant

        if (pos.x > Kiwi.WIDTH / 2)
            vel.add(-5, 0, 0);

        vel.x *= 0.8f;

        vel.scl(delta);
        pos.add(vel.x, 0, 0);
        vel.scl(1 / delta);
    }

A: New answer
public void update(float delta) {
    if (pos.x > Kiwi.WIDTH / 2)
        vel.add(-5, 0, 0);
    vel.x *= 0.8f;
    vel.scl(delta);
    pos.add(vel.x, 0, 0);
    vel.scl(1 / delta);
}

The update method is called once for every frame. So what happens with your code above is that you reduce the velocity by 20% every frame, meaning if you have 60FPS, you will reduce your velocity to 0.8^60 = 1.eE-6 or practically zero in one second when you're to the left half of the screen.
You also want to to accelerate when it is to the right... Accelerate in which direction?  What you're doing now is that if the position is to the RIGHT half of the screen, then it accelerates to the LEFT meaning as soon as you get to the RIGHT half it moves back to the LEFT! Change -5 to +5 and then it will fly off because you're increasing speed by 5*60=300 px/s^2. You need to scale the acceleration by the time delta.
Also you will need to scale the deacceleration by the time delta too. The divide by delta (1/delta) doesn't make any sense either so try this:
public void update(float delta) {
    if (pos.x > Kiwi.WIDTH / 2)
        vel.add(5*delta, 0, 0); // Acceleration is now 5 px/s^2 to the right
    vel.x -= vel.x*0.2f*delta; // Decay speed by 20% every second
    pos.add(vel.x*delta, 0, 0); // Move position by speed.
}

Old answer below
Without more code to go on, all I can do is show you the correct way to do the calculations in the general case.
If you want to use a Euler's method for solving the motion ODEs this is how you do it:
// Object state
speed = ...; // Unit is [m/s]
position = ...; // Unit is [m]

// Inputs
frameDelta = ...; // Unit is [s]
acceleration = ...; // Unit is [m/s^2]

// Update step
speed += acceleration * frameDelta; // Unit [m/s^2 * s] = [m/s];
position += speed * frameDelta; // Unit [m/s * s] = [m]

If you want the speed to "decay" you can do it by adding a suitable deacceleration (or drag/wind resistance/friction whatever you want to call it):
decayRate = ...; // Unit is [m/(m*s^2) = 1/s^2] ((de)acceleration per meter)
acceleration -= speed * decayRate * frameDelta; // Unit is [m/s*1/s^2*s = m/s]

Note: that you do not store the acceleration, you compute it each frame from other inputs (keyboard, mouse, forces, collisions etc).
Note2: Euler's method is the easiest solver you can use to compute the position and speed from acceleration. It comes with some problems, it is not as accurate as for example Runge-Kutta and it can also exhibit some stability issues with the oscillation.
You know when you see something shaking like it's crazy when it is stuck in a game? Yeah, that's probably Euler's method becoming unstable.


text:
Q: Issue accessing the TFS server though the web I have TFS 2010 set up on TESTServer.
If I am on the server (logged in as administrator) I can access the web portal for TFS using the following
http://TESTServer:8080/tfs/web/

but when I am on my own computer still in the same network, when I try the same URL, I get challenged for a username and password.  Even when I enter the administrator details, it does not accept them.
Also I tried the following
http://TESTServer:8080/services/v1.0/ServerStatus.asmx?op=CheckAuthentication

Which says the resource can not be found
* update***
I got it to work with the IP address... but if I ping the name it gets the correct IP address??
Any ideas?
Thanks

A: Since you cannot connect to http://TFSSERVER:8080/services/v1.0/ServerStatus.asmx?op=CheckAuthentication it could be that you have incorrect proxy settings in your organization. Could it be the proxy settings have changed?
Have you checked your host file for any entries regarding your TFS server?
Can you open a telnet session to port 8080 on your TFS Server?
Grant Holliday wrote a couple of steps you can do to troubleshoot TFS connection issues.


text:
Q: Plot a function for different values of parameters I have a function:
u[r_] := 1/2*(uj + u∞) -
  1/2*(uj - u∞)*Tanh[1/4*Rθ*(r/R - R/r)]

Where:
uj = 1;
u∞ = 0;
R = 1;

I want to plot:
Plot[(u[r/R] - u∞)/(uj - u∞), {r, 0, 3},
 PlotRange -> All]

But for three different values of parameters Rθ, some like that:
Plot[(u[r/R] - u∞)/(uj - u∞), {r, 0, 3},
 PlotRange -> All] /.{Rθ->10,Rθ->5,Rθ->2.5}

How to do that?

A: Plot[Evaluate[(u[r/R] - u∞)/(uj - u∞) /. {{Rθ -> 10}, {Rθ ->  5}, {Rθ -> 2.5}}], {r, 0, 3},
 PlotRange -> All]

Also:
Plot[Evaluate[Table[(u[r/R] - u∞)/(uj - u∞), {Rθ, {10, 5, 2.5}}]], {r, 0, 3},
   PlotRange -> All]

same picture

A: Here is another way to get the desired result as pointed out in the comment,
uj = 1; u\[Infinity] = 0; R = 1;

u[r_, R\[Theta]_] :=  1/2*(uj + u\[Infinity]) -
  1/2*(uj - u\[Infinity])*Tanh[1/4*R\[Theta]*(r/R - R/r)]

Plot[Evaluate[u[r, #] & /@ {10, 5, 2.5}], {r, 0, 3}]


text:
Q: Parse Cloud - Manual Entry for Installation (Push Notifications) I'm using the Javascript SDK and Appccelerator Titanium. The Javascript SDK doesn't have a function to save deviceToken's for enabling push. I've tried various methods but the one that should work (does not) is saving via a Cloud Function. What am I doing wrong?
Parse.Cloud.define("subscribeToPush", function(request, response) {
    Parse.Cloud.useMasterKey();
    var Installation = Parse.Object.extend("Installation");
    var membership = new Installation();

    membership.set("deviceType", request.params.os);
    membership.set("deviceToken", request.params.deviceToken);
    membership.set("channels", ["general"]);
    membership.save(null,{
      success:function(membership) {
        response.success(membership);
      },
      error:function(error) {
        response.error(error);
      }
    });
});

After running this function Cloud Log shows that it was created, yet, I don't see it in the data browser.
I2014-10-22T01:29:30.319Z] v51: Ran cloud function subscribeToPush for user rCzHEXY5hN with:
Input: {"deviceType":"ios","deviceToken":"xxxXXXxxx","channels":["general"]}
Result: {"deviceToken":"xxxXXXxxx","channels": "general"],"objectId":"KCWtpcwy4i","createdAt":"2014-10-22T01:29:30.383Z","updatedAt":"2014-10-22T01:29:30.383Z","__type":"Object","className":"Installation"}


text:
Q: necessity of braces for accent commands Many resources on LaTeX teach that "é" and "ä" are typeset with (respectively) \'{e} and \"{a}; and it is similar for other accent symbols. Are the braces really needed? Aren't \'e and \"a shorter but identical in functionality?

A: The manuals usually insist teaching a uniform syntax: all arguments will be braced. However, as far as TeX is concerned, a one letter (one token, to be precise) argument can in most cases be left without braces:
\"{a} \"a

will give exactly the same result. Not that I recommend it, but also
\begin{tabular}c

will result in a one column tabular, just like \begin{tabular}{c}. The braces for accented letters are really handy for \c or \v: writing
gar\c con

is clumsy and gar\c{c}on is better. However, accents are more easily input using inputenc facility. It's way easier to encode our documents with UTF-8, declaring
\usepackage[utf8]{inputenc}

and then writing
garçon élève flügel čaj

The precise rule is:

when TeX is looking for an argument to a macro defined with \newcommand, if it finds a left brace {, then the argument will be whatever is between this brace and the corresponding } (at the same level); otherwise the first token (character or control sequence) will be the argument.

This explains why one can omit the first pair of braces in
\newcommand\foo{something}

which is perfectly equivalent to
\newcommand{\foo}{something}

Of course this is not valid for optional arguments, which always need to be enclosed in brackets [...].
Note: for BibTeX the situation is different (as nicely explained by Mico).

A: For bibliographies at least -- more specifically, for files that will be processed by BibTeX at some point -- it's very important to write the accented characters as {\'e} and {\"a} rather than as \'{e} and \"{a} (or, for that matter, as \'e and \"a).
For other examples of how to render accented characters in a manner that's robust to BibTeX's requirements see, e.g., this answer (shameless self-citation alert!).


text:
Q: rails 3 breadcrumbs_on_rails I'm trying to configure breadcrumbs_on_rails with rails 3 application
I have added
gem 'breadcrumbs_on_rails'

into my gemfile
also, I have placed include BreadcrumbsOnRails::ControllerMixin
require File.expand_path('../boot', __FILE__)

require 'rails/all'

include BreadcrumbsOnRails::ControllerMixin

if defined?(Bundler)
....

into application.rb
But anyway I constantly getting error:
runnerw.exe C:\Ruby\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /script/rails server -b 127.0.0.1 -p 3000 -e development
/config/application.rb:1:in `<top (required)>': uninitialized constant BreadcrumbsOnRails (NameError)
    from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
    from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:53:in `block in <top (required)>'
    from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
    from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>'
    from /script/rails:6:in `require'
    from /script/rails:6:in `<top (required)>'

How to solve this error ? Thanks

A: Hi friend the constant BreadcrumbsOnRails::ControllerMixin will be available after bundler loads your gem 'breadcrumbs_on_rails'.
But you are used BreadcrumbsOnRails::ControllerMixin before bundler loads you gem.
The gems are loaded after execution of the following lines.so you have to use
require 'rails/all'

if defined?(Bundler)
 # If you precompile assets before deploying to production, use this line
   Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
 # Bundler.require(:default, :assets, Rails.env)
end
include BreadcrumbsOnRails::ControllerMixin

Here is the doc for your gem.
https://github.com/weppos/breadcrumbs_on_rails
Good luck.

A: Looking through the docs provided by @soundar, I don't see ControllerMixin anywhere in the source or documentation.  Nor do I see any need to put anything in config/application.rb


text:
Q: A probability question on cards Given a pack of $52$ cards of classes hearts, spades, diamonds and clubs. Each of this class has an Ace, numbers $2,\space 3, \space \cdots, \space 10$, a Knave, a Queen and a King.
$5$ cards are selected successively returning each card after selection before selecting the next one.

What is the probability of having at least an Ace and at least a Knave?

My approach:
We are trying to choose $i$ Ace(s) and $j$ Knave(s) such that $1\le i,j \le 4$  and $i+j \le 5$ and then choose $(5-i-j)$ card(s) from the remaining $44$ cards. And the probability will be $$\displaystyle
 \sum_{\substack{
   1\le i,j \le 4 \\
   i+j\le 5
  }}\cfrac{5!}{i!j!(5-i-j)!}
 \left(\cfrac 1{13}\right)^{i+j} \left(\cfrac {11}{13}\right)^{5-i-j}$$ $$ = \sum_{\substack{
   1\le i \le 4 \\
  }}\sum_{\substack{
   1\le j \le 5-i \\
  }}\cfrac{5!}{i!j!(5-i-j)!}
 \left(\cfrac 1{13}\right)^{i+j} \left(\cfrac {11}{13}\right)^{5-i-j}$$
I am having problems computing this sum and I'm very sure that I'm missing something.

A: When working on the probability of having at least one Ace, it is easier to calculate the probability of having no aces and subtract from 1.  In this case, each draw has $\frac {12}{13}$ chance of not being an ace, so the chance you have no aces is $1-\left(\frac{12}{13}\right)^5$
Now that you have to have at least one ace and at least one jack, the ways you can fail are to have no aces and at least one jack, no jacks and at least one ace, or none of either.  If you just subtract $1-2\left(\frac{12}{13}\right)^5$ to account for not having aces or not having jacks, you have double subtracted the no aces and no jacks case.  You need the inclusion-exclusion principle to deal with this.  The chance of having no aces and no jacks is $\left(\frac{11}{13}\right)^5$, so the final answer is $1-2\left(\frac{12}{13}\right)^5+\left(\frac{11}{13}\right)^5$


text:
Q: PHP: passing array elements into class function in fpdf Working on a project and need to generate pdf of the product details using FPDF. The product details are passed into an array and I need the following to get each of the variable elements in the array '$prod_details' into the functions within the class 'PDF' as shown below:
Examples of how I tried passing the variable array elements:
    $this->Cell(30,8,$prod_data['prod_name'],0,0,'C');
    $this->Cell(30,10,$prod_data['company_name']);
    $this->Cell(20,8,$prod_data['prod_cost'],0,0,'C');

I have tried running this script but I keep getting an error message 'Cannot access empty property'...
find the codes below
<?php

@include_once("includes/db.php");
require('fpdf/fpdf.php');
@include_once("includes/class_product_info.php");

$obj = new allProducts();
$prod_data = array();
if(isset($_GET['c_id'])){
        $prod_data = $obj->getProdDetails($_GET['c_id']);

class PDF extends FPDF
{

public $prod_data;

public function createData($input){
    $this->prod_data = $input;
}

function Header()
{
    // Logo
    $this->Image('big_logo.png',10,6,30);
    // Arial bold 15
    $this->SetFont('Arial','B',20);
    // Move to the right
    $this->Cell(40);
    // Title
    $this->Cell(30,10,$this->prod_data['company_name']);
    // Draw an header line
    $this->Line(10,26,200,26);
    // Line break
    $this->Ln(20);
}

function Footer()
{
    // Position at 1.5 cm from bottom
    $this->SetY(-15);

    // Begin with regular font
    $this->SetFont('Arial','',9);
    // Then put a blue underlined link
    //$this->SetTextColor(0,0,255);
    $this->SetFont('','U');
    $this->Write(10,$this->prod_data['company_name'],'http://www.skills.com');
    // Arial italic 8
    $this->SetFont('Arial','I',9);
    // Page number
    $this->Cell(0,10,'Page '.$this->PageNo().' ',0,0,'R');
}

function prodDetailTop()
{
// Course title cell
$this->Cell('',10,'',0,0,'C');
$this->Ln();

/* Build cells for the first row */

$this->SetFont('Arial','',10);
$this->SetY(40);

// First Row
$this->Cell(35,8,'Product Name : ',0,0,'L');
$this->Cell(30,8,$this->prod_data['prod_name'],0,0,'C');
$this->SetX(150);
$this->Cell(25,8,'Product Cost : ',0,0,'L');
$this->Cell(20,8,$this->prod_data['prod_cost'],0,0,'C');
$this->Ln();

// Second Row
$this->Cell(35,8,'Discount : ',0,0,'L');
$this->Cell(30,8,$this->prod_data['disc_amt'],0,0,'L');
$this->SetX(150);
$this->Cell(25,8,'No Purchased : ',0,0,'L');
$this->Cell(20,8,$this->prod_data['items_count'].' product(s)',0,0,'L');
$this->Ln();
}

function prodDetailBtm()
{

$this->SetY(80);

$this->Write(10,$this->prod_data['prod_desc']);

}

function generatePageData()
{
    $this->AddPage();
    $this->prodDetailTop();
    $this->prodDetailBtm();
}
}

$pdf = new PDF();
$pdf->createData($prod_data);
//$pdf->Header();

$pdf->generatePageData();
$pdf->Output();

}
else {

?>
    <script language="javascript">
    window.location = "prod_invoice_err.php";
    </script>
<?php
}
?>

Hope to get some help.

A: Your question is a little vague. It would be helpful it you asked specifically what you're trying to accomplish.
But the first thing I see is that your subclass of the fpdf class, you don't need to write functions to do each and everything you want to do with the pdf. You only need to extend the parts of the class you are overriding (or extending), like header and footer.
So extend it, manipulate header and footer, then close the class. Create your $pdf instance of your new fpdf class, then manipulate that object with your data. You don't need to 'pass in' that data at all.
for instance:
$pdf->Ln(10);
$pdf->Cell($w,9,$title,1,1,'C',true); //from fpdf tutorial

Or, if that doesn't accomplish what you want (although I can't see why it wouldn't, I've done this lots of times), you can always override the constructor. Pass in an array (or event a custom object that you create), and store that in a private variable.


text:
Q: Making AngularJS service dynamic with input I am new to AngularJS development. I am trying to build a dynamic service, which updates the output with input elements. But, I am getting error every time.
What am I doing wrong in declaring the service functions.
Here is my html code

A custom service with a method that converts a given number into a hexadecimal number.

    input a number
    <input ng-init="m5=0" ng-model="m5"></input>

The hexadecimal value of {{m5}} is:

{{hex}}

my angularJS app is as follows:
var app = angular.module('myApp', []);
app.service('hexafy', function() {
    this.myFunc = function (x) {
        return x.toString(16);
    }
});
app.controller('myCtrl', function($scope, hexafy) {
    $scope.hex = hexafy.myFunc(parseInt($scope.m5));
});

But my output of {{hex}} is not dynamic. It shows static value NaN.
Thanks in advance

A: Try below-given service code:
app.service('hexafy', function() {
    this.myFunc = function (x) {
        return Number(x).toString(16);
    }
});
app.controller('myCtrl', function($scope, hexafy) {
    $scope.hex = hexafy.myFunc($scope.m5);
});

Hope this will work fork for you.
But I prefer to use filter option for this. You can try filter like:
AngulrJS
var app = angular.module('myApp', []);

//Filter to conver input number into hexadecimal number
app.filter('hexafy', function () {
  return function(x) {
    return Number(x).toString(16);
  };
});
app.controller('myCtrl', ['$scope', 'hexafyFilter', function($scope, hexafyFilter) {
    $scope.m5 = 0;
}]);

HTML

A custom service with a method that converts a given number into a hexadecimal number.

    input a number
    <input type="number" ng-model="m5"></input>

The hexadecimal value of {{m5}} is:

{{ m5 | hexafy }}

Enjoy solution. :)

A: One approach is to use the ng-change directive:

A custom service with a method that converts a given number into a hexadecimal number.

    input a number
    <input ng-init="m5=0" ng-model="m5"
           ng-change="hex=toHex(m5)" />  ̶<̶/̶i̶n̶p̶u̶t̶>̶

The hexadecimal value of {{m5}} is:

{{hex}}

JS
app.service('hexafy', function() {
    this.myFunc = function (x) {
        return parseInt(x).toString(16);
    }
});
app.controller('myCtrl', function($scope, hexafy) {
    $scope.toHex = hexafy.myFunc;
});

On each change of the input value, $scope.hex will be updated.
For more information, see AngularJS ng-change Directive API Reference.


text:
Q: nginx sub-domain mapping I want to open xyz.abc.com in the browser but internally(using python-django), I want to map this to abc.com/xyz
The following nginx conf code works, but I don't want to redirect the user to this new url (abc.com/xyz)
server {
    listen   80;
    server_name xyz.abc.com;

    location / {
        rewrite ^ http://abc.com/xyz;
        break;
}

I have tried a lot of things including using proxy_pass but it's not working.
How can I solve this?
Thanks.

A: You can convert any 3rd level domain to 2nd level:
server {
    listen   80;
    server_name ~^(?<domain>.*)\.abc\.com;

    location / {
        proxy_pass http://abc.com/$domain$request_uri;
        break;
}

In your case try the next:
server {
    listen   80;
    server_name xyz.abc.com;

    location / {
        proxy_pass http://abc.com/xyz$request_uri;
        break;
}

About the request_uri: http://wiki.nginx.org/HttpCoreModule


text:
Q: Hibernate cannot close connection for Postgresql I am using a heroku remote PostgreSQL database, and in my application, I also use hibernate and c3p0. Already set max connection, and close connection after use, but all of these failed to close idle connection in database. Errors in my code? Since if I only change url and connect to a local MySQL, it works. So I am thinking PostgreSQL is special. Or it is because the heroku remote db restriction?
hibernate.cfg.xml is like this. I change it to adapt local mysql, and it does close connections.
<session-factory>

    <!-- hibernate connection configuration -->
    <property name="connection.url">jdbc:mysql://localhost/website</property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.username">root</property>
    <property name="connection.password">root</property>

    <!-- hibernate performance configuration -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="format_sql">true</property>
    <property name="hbm2ddl.auto">update</property>
    <property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
    <property name="show_sql">true</property>

    <!-- c3p0 configuration -->
    <property name="c3p0.acquire_increment">1</property>
    <property name="c3p0.idle_test_period">10</property>
    <property name="c3p0.max_statements">3</property>
    <property name="c3p0.max_size">2</property>
    <property name="c3p0.min_size">1</property>
    <property name="c3p0.timeout">90</property>
    <property name="transaction.auto_close_session">true</property>
    <property name="idleConnectionTestPeriod">60</property>
    <property name="maxIdleTime">30</property>

    <!-- presistance objects -->
    <mapping class="pojo.WebSiteCommentPOJO"/>

</session-factory>

HibernateUtil is like this:
    public class HibernateUtils {

private static SessionFactory sessionFactory;

public static SessionFactory getSessionFactory() {
        if (sessionFactory != null) {
            return sessionFactory;
        }
    Configuration conf = new Configuration().configure();

    StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();

    serviceRegistryBuilder.applySettings(conf.getProperties());

    /*ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();*/

    SessionFactory sf = conf.buildSessionFactory();
    return sf;
}

public static Session getSession() {
    return getSessionFactory().openSession();
}

}
And the following code is how I use hibernate.
public WebSiteComment getSingle(int id) {
    Session ss = HibernateUtils.getSession();
    ss.beginTransaction();
    WebSiteCommentPOJO w = ss.get(WebSiteCommentPOJO.class,id);
    ss.getTransaction().commit();

    return new WebSiteComment(w.getId(), w.getComment(), w.getEmail(), w.getDate());
}

A: You need to close the session to close a connection. When transaction is committed session and connection are not closed because of you can begin a new transaction or do something else with a session. Probable, MySQL have a large number of connections that can be opened. Heroku, of course, has a limited number of connections.
Use finally block to close the session in any way. You can use this pattern to work with a session.
Just do this to configure a session factory
SessionFactory sf = new Configuration().configure().buildSessionFactory();
And you need to rollback transaction in case of error.
Update
My answer, probably, is not very correct because of using
<property name="transaction.auto_close_session">true</property>

A: Finally I fixed my errors. I found a standard HibernateUtil.java from here Now my code is like this.
private static final SessionFactory sessionFactory;

static {
    try {
        sessionFactory = new Configuration().configure().buildSessionFactory();
    } catch (Throwable ex) {
        System.err.println("Initial SessionFactory creation failed." + ex);
        throw new ExceptionInInitializerError(ex);
    }
}

public static SessionFactory getSessionFactory(){
return sessionFactory;
}

The crucial difference maybe the final of sessionFactory; But I think in my previous version, after initialization, I still return the same sessionFactory object.
Besides, I use some different method to get SessionFactory.
Spend 2 days on this, and thanks v.ladynev's help. Hope my solution will help.


text:
Q: Display output messages after execution of each stored procedure? Preferably without editing the stored procedure, is it possible that the output messages are displayed after every stored procedure completes execution, instead of at the very end?
For example, the following script (that calls an SP to insert 300K+ rows per day) will display the 4 output messages (300230 rows affected) once all SPs execute or if the process is cancelled.
exec usp_UpdateSales '11/21/2022'
exec usp_UpdateSales '11/22/2022'
exec usp_UpdateSales '11/23/2022'
exec usp_UpdateSales '11/24/2022'

Instead of showing the output messages at the end, is it possible that is displays the messages after the execution of each call?
I was reading about RAISERROR, but I'm not certain how to implement it into an SP call.

A: The SSIS Execute SQL Task does not hook the InfoMessage event. What you want from a problem statement, is to capture the messages printed to the screen in other applications.
As @AlwaysLearning points out, the approach is to create your own Script Task that runs your statement and then "does the thing" with the feedback from your stored procedure https://learn.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient.sqlconnection.infomessage
Some related sample bits of code to give you a solid shove in the right direction

*

*c# - SqlConnection InfoMessage triggering only at end of execution

*Accessing InfoMessages for SQL Server queries in C#

*Ado.net Fill method not throwing error on running a Stored Procedure that does not exist


text:
Q: How do I delete my commands quickly? I use terminal for almost all tasks. Let's say I have entered a huge command like this:
sudo a-huge-command

What is the easiest way to delete the whole command with a single shortcut, rather than keep on hitting backspace key?
I'm a Ubuntu newbie looking to use Ubuntu in a professional way.

A: The Bash readline shortcut Ctrl+X+E is very useful indeed when you are working on the command-line. If you are in the process of entering a long command and decide that you want to instead open it in your default text editor, all you have to do is use the shortcut.
It makes use of Bash's readline library and this particular shortcut is called the edit-and-execute-command.  You can set your default editor by placing export EDITOR="/usr/bin/vi" in ~/.bashrc or ~/.bash_aliases.
Enter bind -P to see your current readline bindings and refer to man readline or the Ubuntu manpages online for more information.

A: I also use Esc+Backspace to delete all previous characters until a special character. This is same is Alt+Backspace.  Handy if you're just deleting a few words at a time.

A: I'm usually using Alt+Backspace. If you are using bash, this will let you delete untill the previous special character (/, ;, , etc.). If you are using zsh, it will remove the slashes and semicolons as well. It is a lot faster than just hitting Backspace.
In bash, this is different from Ctrl+w in the sense that Ctrl+w deletes the previous word wheres Alt+Backspace deletes until the previous special character is found. In zsh, both key combinations do the same thing

A: Here is a listing of keyboard shortcuts that can be used with the bash shell.
Ctrl + A    Go to the beginning of the line you are currently typing on
Ctrl + E    Go to the end of the line you are currently typing on
Ctrl + L    Clears the Screen, similar to the clear command
Ctrl + U    Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H    Same as backspace
Ctrl + R    Lets you search through previously used commands
Ctrl + C    Kill whatever you are running or start a new prompt
Ctrl + D    Exit the current shell
Ctrl + Z    Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W    Delete the word before the cursor
Ctrl + K    Clear the line after the cursor
Ctrl + T    Swap the last two characters before the cursor
Esc + T     Swap the last two words before the cursor
Alt + F     Move cursor forward one word on the current line
Alt + B     Move cursor backward one word on the current line
Tab         Auto-complete files and folder names

What you are wanting to do is achieved by either Ctrl+C or Ctrl+U at the end of the line.

A: For vi key bindings
When usin a vi key map like in bash with set -o vi or in zsh with bindkey -v:
Insert mode
It is just the same keystroke as in default/emacs mode:
Ctrl+U
deleting form the current position to the start of line. So it deletes the whole line if the cursor is at the end.
Normal mode
There are multiple ways to delete the line in two keystrokes:
Delete linewise dd, with the default count of one line:
dd
which is the simplest in terms of keys touched.
Another way is: Go to start of line with ^, and delete to the end of line with D:
^D
These both delete the entire line, not only to the left, like Ctrl+U in insert mode, or the variant bleow.
If you are at the end of line currently, so you do not need to delete anything to the right, this would also do:
Delete from here d, to start of line ^:
d^
You can use these all from inset mode, you need the usual escape first to go to normal mode. For example to delete the whole line from insert mode, use:
Escdd

A: Alt+# (i.e., Alt+Shift+3) will comment out the current command and continue on the next line.
For example, if you type t, e, s, t, Alt+#, you'll get:
you@computer$ #test
you@computer$

If you want to get your old command back, you can press the up arrow and delete the hash character (Up, Home, Delete or Up, Ctrl+A, Delete).
I think it's a feature of GNU Readline, since it works in Bash, Python, and MySQL.

A:  Ctrl + C - in addition to interrupting running commands, it may be used to "interrupt" your command line input as well.
In contrast to the  Ctrl + U, you will still see what you have typed but your cursor will jump to the new line and you will get an empty command line prompt.

A: Use Ctrl+U to cut text from cursor position to the beginning of the command line. Later, if you want, use Ctrl+Y to paste the cut text.
If you just want to discard the current command line and get a new clean prompt hit Ctrl+C.
For more reference please check the Ubuntu  documentation for Using The Terminal

A: Ctrl +  U should help you.
Below are the rest of the options available.
Grabbed from here
UNIX understands several control-key commands, commands you enter by holding down the control key (ctrl) while striking a second key
CTRL +  S - freezes the screen and stops any display on the screen from continuing
(equivalent to a no-scroll key) (sometimes takes a moment to work)
CTRL + Q - un-freezes the screen and lets screen display continue
CTRL +  C - interrupts a running program
CTRL +  \ - same as CTRL -  C but stronger (used when terminal doesn't respond)
CTRL +  Z - suspends a running program (use the fg command to continue the program, see s$
CTRL +  H - deletes last character typed
CTRL +  W - deletes last word typed
CTRL +  U - deletes last line typed
CTRL +  R - searches text from history
CTRL +  D - ends text input for many UNIX programs, including mail and write.
Note:
When we delete using CTRL + W or CTRL + U, we are also performing a (edit) "cut" (yank in) operation (delete and store in buffer/clipboard). To paste (yank out) the string in buffer/clipboard, use CTRL + Y.


text:
Q: Quick answer/question editing?
Possible Duplicate:
Is there a grace period for correction of edits?

Oftentimes, I need to edit my question or answer because of a spelling mistake, a typo, etc. I find it handy how comments can be quickly edited to make up for the small mistake. Wouldn't it be better to have a way to do this for questions and answers too?
The quick edit would not appear in the version history, nor would the answer or question be marked as editted. This would bring several advantages if I am correct, namely:

*

*The question will not get bumped

*Less history data needs to be stored

*The version history will be more brief if a lot of a "real" edits are also present.

Of course, a limit in changes need to be set, take 16 characters total change for example, so that a relatively long word may be replaced, and add extra rules like no extra paragraph allowed etc.
Edit: It's not only because of the version history (I didn't know about the 5 minutes period), but also for not being taken to another page to edit it when using quick-edit.

A: *

*You can edit any post within 5 minutes of posting it or making the last edit, without an extra entry in the revision history.

*Once you get editing privileges (at 2000 rep on SO), you will be able to edit all posts inline (not just your own).
You can see here how it works.
I suspect the threshold is needed, since there's no space for the How to Edit and How to Format help boxes when editing inline.

*Bumping edited posts to the front page is fundamental to prevent vandalism.
Even with a 16 character limit, you could just make several trivial edits to alter a post's meaning, introduce spam or erase it completely.
Since an edited post currently gets bumped, chances are that someone will detect the vandalism and rollback the edit.

A: This is already implemented. When you make a new post or make an edit, you will always be able to make additional edits to that post (without showing them separately in the revision history) until either: a. 5 minutes has passed since the post or edit was made; b. someone else makes an edit to the post.
Additionally, for suggested edits, you can make any changes to the suggested edit up until the point that the edit gets approved (or rejected).


text:
Q: Detect when memory moves in an external .NET process? I wrote the indie MMORPG, Pixel Champions. I'm wondering, after seeing this trainer appear, if it's possible for an external process to reliably read my game-client's memory. I know that users can PInvoke ReadProcessMemory to read whatever memory location they desire, but in a .NET application that memory moves around, and so the results wouldn't be very reliable.
Is there a way a user could know when a memory location was moved in an external .NET process? Specifically, is there any APIs exposed by the .NET GC that would allow an external application to be notified when a memory pointer needed to be updated?

A: An attacker can use the CLR Profiling API to receive callbacks when the GC moves objects around, which can be used to reliably track moving references.
http://msdn.microsoft.com/en-us/library/hh361123.aspx


text:
Q: onResume of new Fragment called before onPause in Android Oreo 8.0 I am facing trouble with android Oreo. My MainActivity has 4 fragments, which replace each other whenever the user presses tabs. Now the problem is, I am saving a value in a singleton instance in onPause. Whenever the user presses the next tab, onResume of that fragment is called before onPause, so I am not able to retrieve the value from the singleton correctly.

A: Please use setReorderingAllowed as false to get the normal fragment lifecycle.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
fragmentTransaction.setReorderingAllowed(false);
}

https://developer.android.com/reference/android/app/FragmentTransaction.html#setReorderingAllowed(boolean)

A: There is some problem with Fragment in oreo version.I created a separate app to check what lifecycle functions are called when we replace one fragment with other..Here is the log:
MainActivity onCreate ->
FragmentA oncreate ->
FragmentA oncreateView ->
MainActivity onStart ->
FragmentA onStart ->
MainActivity onResume ->
FragmentA onResume ->
Button Pressed;that replace fragment A with Fragment B
FragmentB onCreate ->
FragmentB onCreateView ->
FragmentB onStart ->
FragmentB onResume ->
FragmentA onPause ->
FragmentA onStop ->
FragmentA onDestroy ->

I was importing import android.app.Fragment.It worked when I replaced it with android.support.v4.app.Fragment .

A: onResume should called before onPause.
If you want to save something before starting fragment do it in onStart. If you want to save something before leaving fragment do it in onStop.
 More info on Fragment lifecycle


text:
Q: Does the sign matter for proportionality? This question arose from Physics, where the force on an object attached on a spring is proportional to the displacement to the equilibrium (that is, the rest position). Also, if the displacement to the equilibrium is positive, the force will be negative, as it tries to pull the object back (i.e. if you pull a string, the force is opposite to your direction of pull).
Therefore, it can be said that:
$$F \propto -x$$
Where $F$ is the force and $x$ is the displacement from equilibrium
Is this the same as:
$$F \propto x$$
According to the relation of proportionality, it should be, but my friend says that putting the second one is not correct.
Both are equivalent right?

A: Mathematically they are equivalent, but physycist may want to differentiate between a force in the same direction as the displacement, and a force opposite to the displacement, as they lead to physically different behavior of the system. Thus the minus sign matters.

A: Yes, proportionality does not tell anything about the sign of the proportionality constant. This is probably done in physics so that the proportionality constant $k$ can be considered to be always positive. This has a physical interpretation , so it is convenient for it to be positive.


text:
Q: How do you keep user.config settings across different assembly versions in .net? Basically the problem is that each time the assembly version changes (i.e. the user installs a new version of the application) all their settings are reset the the defaults (or more accurately a new user.config file is created in a folder with a different version number as the name)
How can I keep the same settings when upgrading versions, since using ini files or the registry seem to be discouraged?
When we used Clickonce it seemed to be able to handle this, so it seems like it should be able to be done, but I'm not sure how.

A: I know it's been awhile...
In a winforms app, just call My.Settings.Upgrade() before you load them. This will get the latest settings, whether the current version or a previous version.

A: ApplicationSettingsBase has a method called Upgrade which migrates all settings from the previous version.
In order to run the merge whenever you publish a new version of your application you can define a boolean flag in your settings file that defaults to true. Name it UpgradeRequired or something similar.
Then, at application start you check to see if the flag is set and if it is, call the Upgrade method, set the flag to false and save your configuration.
if (Settings.Default.UpgradeRequired)
{
    Settings.Default.Upgrade();
    Settings.Default.UpgradeRequired = false;
    Settings.Default.Save();
}

Read more about the Upgrade method at MSDN. The GetPreviousVersion might also be worth a look if you need to do some custom merging.

A: Here's my research in case anyone else is having a hard time with migrating settings that have been changed/removed. Basic problem is that GetPreviousVersion() does not work if you have renamed or removed the setting in the new version of your application. So you need to keep the setting in your Settings class, but add a few attributes/artifacts to it so that you don't inadvertently use it in the code elsewhere, making it obsolete. A sample obsolete setting would look like this in VB.NET (can easily be translated to C#):
<UserScopedSetting(),
DebuggerNonUserCode(),
DefaultSettingValue(""),
Obsolete("Do not use this property for any purpose. Use YOUR_NEW_SETTING_NAME instead."),
NoSettingsVersionUpgrade()>
Public Property OldSettingName() As String
  Get
    Throw New NotSupportedException("This property is obsolete")
  End Get
  Set
    Throw New NotSupportedException("This property is obsolete")
  End Set
End Property

Make sure you add this property to the same namespace/class that has your application settings. In VB.NET, this class is named MySettings and is available in My namespace. You can use partial class functionality to prevent your obsolete settings from mixing up with your current settings.
Full credit to jsharrison for posting an excellent article about this issue. You can read more details about it there.

A: The next short solution works for me when we need to upgrade only once per version. It does not required additional settings like UpgradeRequired:
if (!ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).HasFile)
    Settings.Default.Upgrade();

A: Here's a variation on the solutions presented here that encapsulates the upgrade logic into an abstract class that settings classes can derive from.
Some proposed solutions use a DefaultSettingsValue attribute to specify a value that indicates when previous settings were not loaded. My preference is to simply use a type whose default value indicates this. As a bonus, a DateTime? is helpful debugging information.
public abstract class UserSettingsBase : ApplicationSettingsBase
{
    public UserSettingsBase() : base()
    {
        // Accessing a property attempts to load the settings for this assembly version
        // If LastSaved has no value (default) an upgrade might be needed
        if (LastSaved == null)
        {
            Upgrade();
        }
    }

    [UserScopedSetting]
    public DateTime? LastSaved
    {
        get { return (DateTime?)this[nameof(LastSaved)]; }
        private set { this[nameof(LastSaved)] = value; }
    }

    public override void Save()
    {
        LastSaved = DateTime.Now;
        base.Save();
    }
}

Derive from UserSettingsBase:
public class MySettings : UserSettingsBase
{
    [UserScopedSetting]
    public string SomeSetting
    {
        get { return (string)this[nameof(SomeSetting)]; }
        set { this[nameof(SomeSetting)] = value; }
    }

    public MySettings() : base() { }
}

And use it:
// Existing settings are loaded and upgraded if needed
MySettings settings = new MySettings();
...
settings.SomeSetting = "SomeValue";
...
settings.Save();

A: If your changes to user.settings are done programmatically, how about maintaining a copy of (just) the modifications to user.settings in a separate file, e.g. user.customized.settings?
You probably still want to maintain and load the modified settings in user.settings as well.  But this way when you install a newer version of your application with its newer version of user.settings you can ask the user if they want to continue to use their modified settings by copying them back into the new user.settings.  You could import them wholesale, or get fancier and ask the user to confirm which settings they want to continue to use.
EDIT: I read too quickly over the "more accurately" part about assembly versions causing a new user.settings to be installed into a new version-specific directory.  Thus, the idea above probably doesn't help you, but may provide some food for thought.

A: This is how I handled it:
public virtual void LoadSettings(ServiceFileFormBaseSettings settings = null, bool resetSettingsToDefaults = false)
{
    if (settings == null)
            return;

    if (resetSettingsToDefaults)
        settings.Reset();
    else
    {
        settings.Reload();

        if (settings.IsDefault)
            settings.Upgrade();
    }

    this.Size = settings.FormSize;

}
and in the settings class, I defined the IsDefault property:
// SaveSettings always sets this to be FALSE.
// This will have the default value TRUE when first deployed, or immediately after an upgrade.
// When the settings exist, this is false.
//
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("true")]
public virtual bool IsDefault
{
    get { return (bool)this["IsDefault"]; }
    set { this["IsDefault"] = value; }
}

In the SaveSettings, I set IsDefault to false:
public virtual void SaveSettings(ServiceFileFormBaseSettings settings = null)
{
    if (settings == null) // ignore calls from this base form, if any
        return;

    settings.IsDefault = false;
    settings.FormSize = this.Size;
    settings.Save();
}


text:
Q: Closed immersion property I am having fundamental struggles in understanding the  proof on stacks projects. Ironically, what I don't understand is the "clearly" part of the statement. More precisely:

Lemma 25.4.6 Let $X,Y$ be locally ringed let $I \subseteq O_X$ be a sheaf of ideals locally generated by sections. Let $i:Z \rightarrow X$ be the support of the sheaf of rings $O_X/I$. Then if $f:Y \rightarrow X$ factors through $Z$, the map $f^*I \rightarrow f^* O_X \simeq O_Y$ is zero.

A: Denote $i: Z \to X$ the  closed immersion, assume $f$ factors as $i \circ g$ with $g: Y \to Z$, then $f^* = g^* \circ i^* $. So it suffice to show this with $f = i$, that is, the map $i^*\mathcal{I} \to i^*\mathcal{O}_X = \mathcal{O}_Z$ is zero.
It then suffices to show that $(i^*\mathcal{I})_x = 0$ for every stalk. But $(i^*\mathcal{I})_x = \mathcal{I}_{i(x)}\otimes_{\mathcal{O}_{X,i(x)}}\mathcal{O}_{Z,x}$ (see here). And $O_{Z,x}$ is $\mathcal{O}_{X,i(x)}/\mathcal{I}_{i(x)}$. So this tensor product is null, and $i^*\mathcal{I}$ is zero on every stalk. Hence the map $i^*\mathcal{I} \to i^*\mathcal{O}_X$ must be zero..


text:
Q: Sql Server 2014 - Update to windows 10 and can't connect to the Local Server Recently I updated my Windows from 8 to 10 and suddenly my SQL Server 2014 stopped working. When I open the Management Studio and try to connect to the Server (local) i obtain the following error:

Does any of you had similar problems? Before updating the Windows everything was running just fine.

A: I just had the same issue after upgrading my laptop from Windows 8.1 to Windows 10; however, my solution was slightly different to the one suggested already, I had to:
1) Control Panel
2) Services
3) Right-click, Start, SQL Server service
I had to do this for all the SQL versions I have installed (08R2 up to 14). Somehow the upgrade stopped and didn't restart the SQL service.

A: I had the same problem after upgrading from Windows 8.1 Pro to Windows 10 Pro. I was able to resolve it as follow:

*

*Control Panel

*Administrative Tools

*Services

*The SQL Service Browser was Disabled

*Right click and select Properties

*Change the Startup type to Automatic (Delayed Start)

*Click to Start button to start the service

*And off you go. This should resolve the issue.

A: I also encountered the same issue upgrading from Windows 7.  First thing I did was open the SQL SERVER MANAGER CONSOLE and ensure that the server was still running.  After seeing that it was, I restarted it, and that fixed the problem.
I personally would try these simple steps first... never know could be that easy.

*

*Side note - if you have trouble finding the SQL Manager Console in your Programs list like I did, you can likely find it in your C:Windows/SysWOW folder (open file named SQLServerMananger##.msc).


text:
Q: Correct way of declaring javascript array? I have seen the second way of declaring an array and I want to know what kind of javascript is that because when I try to use that I have syntax errors all over the place. Is the second code used in node.js? Or some other framework of that sort?
var array = [1, 2, 3];

or
int[] array = new int[]{1, 2, 3};

Or even, is the second way javascript?

A:
Or even, is the second way javascript?

No, it is not. Your first version is the correct way to create an array. (You don't declare arrays in JavaScript, because JavaScript is a loosely-typed language.)
The two ways to create an array (other than as a by-product of calling a function like slice or map) are:

*

*An array literal, which is what you've used in your first example:
var a = [];                 // Initially blank
var b = [1, 2, 3];          // Has three entries to start with

*The Array constructor, but it's tricky and verbose, it's rare that you want to use it:
var a = new Array();        // Initially blank
var b = new Array(1, 2, 3); // Has three entries to start with

The reason I say it's "tricky" is that if you give it just one argument, and that argument is a number, you're pre-setting the length, not giving it an entry. So:
var c = new Array(7);       // Empty array with length of 7!

This discrepancy between new Array(7) and new Array(7, 7) sometimes trips people up.
For completeness I should mention that JavaScript now (as of ECMAScript 2015) has other kinds of arrays as well, called typed arrays, such as Int32Array; many JavaScript engines supported them well before the specification as a whole was complete. You create those via the new operator, e.g. var a = new Int32Array(7). The constructors for them don't have the tricky ambiguity of new Array, fortunately (they do have various different potential arguments, but not in the same way).

Side note: Your second example, int[] array = new int[]{1, 2, 3};, is valid syntax for both Java and C#, possibly some other languages as well.

A: Its regular Java, and not JavaScript

A: The second way is a C# way to declare an array of integers


text:
Q: "rational points are dense on the unit ciricle". What is meant by the phrase "rational points are dense on the unit ciricle".
I know the definition of a dense set:
In topology and related areas of mathematics, a subset A of a topological space X is called dense (in X) if any point x in X belongs to A or is a limit point of A.
I don't really know any other definitions of dense let alone how to explain dense on a the unit circle.

A: First, note what is not a rational point on the unit circle:  A point whose coordinates cannot be expressed as both rational numbers, eg., $(\sqrt{2}/2, \sqrt{2}/2)$.
All the phrase "rational points are dense on the unit circle" means is that for any point $(x,y)$ on the circle (possibly not rational), and any arbitrarily small distance $0<\delta$, one can find a rational point also on the circle within distance $\delta$ to $(x,y)$.

A: This means that given any point $(x,y)$ with $x^2 + y^2 = 1$, there exists a sequence of points $(x_n,y_n)$ such that $x_n^2 + y_n^2 = 1$ and $x_n, \, y_n \in \mathbb{Q}$ for all $n$ and such that $x_n \to x, \, y_n \to y$ as $n \to \infty$.
To construct such points, consider Pythagorean triples, i.e. integers $a,b,c$ such that $a^2 + b^2 = c^2$, and turn these into rational points $(a/c, b/c)$ on the unit circle.
The statement about density of rational points becomes massively false if you look at points satisfying $x^n + y^n = 1$ with $n > 2$, by Fermat's Last Theorem.

A: In order to understand the geometry of the rational points on $S^1=\{(x,y)\in\Bbb R^2\,|\,x^2+y^2=1\}$ it is important to remark that these can be parametrized effectively.
Consider the lines through the point $P=(1,0)\in S^1$. With the usual exception of the vertical line $x=1$ which is in fact tangent to $s^1$ at $P$, these lines have cartesian equation
$$
y=m(x-1)\qquad\qquad (\ast)
$$
where $m\in\Bbb R$ is the slope.
Each of these lines intersects $S^1$ at a second point $Q$ whose $x$-coordinate can be computed by solving the degree $2$ equation obtained plugging the equation of the line into the equation of the circle, namely
$$
x^2+m^2(x-1)^2=1. \qquad\qquad (\ast\ast)
$$
Recall that in a quadratic equation $x^2+ax+b=0$ we have $a=-\lambda_1-\lambda_2$ where $\lambda_1$ and $\lambda_2$ are the two solutions.
When $m\in\Bbb Q$ the coefficients of the equation $(\ast\ast)$ are in $\Bbb Q$ and since $\lambda_1=1$ by construction we have $\lambda_2\in\Bbb Q$ as well.
The $y$-coordinate of $Q$ can be computed plugging its $x$-coordinate into $(\ast)$ and so also the $y$-coordinate is in $\Bbb Q$.
Therefore the rational points in $S^1\setminus\{P\}$ are in one-to-one correspondence with the lines through $P$ with rational slope, i.e. with $\Bbb Q$. By continuity this shows that the rational points are dense in $S^1$.

By the way, this construction shows that the primitive Pythagorean triples can be parametrized by $\Bbb Q$ as well (see Hans Engler's answer)


text:
Q: Set Python's default numerical representation to "Decimal" I am doing scientific calculations with both very small and large numbers, so obviously if I'm using python the decimal.Decimal() representation is key. The problem is the tedium. Having to type Decimal() around every relevant operation is cumbersome.
Is there a way to set the default numeric representation as Decimal somewhere, anywhere?

A: No, although you can alias the module to a shorter name:
In [1]: from decimal import Decimal as d

In [2]: d(10)
Out[2]: Decimal('10')

A: Not possible. The use of floats is hardcoded all over the place, and many numeric routines literally can't operate on anything else, particularly stuff written in C.


text:
Q: Matching Location.getTime() milliseconds to NMEA sentences I get GPS fix times with millisecond precision on my Nexus 7 (sometimes) as well as my Galaxy S3 (almost always). By this I mean the millis are not "000".
To make sure this was not fake time resolution introduced by the Android system, I am also capturing the NMEA sentences. And I cannot seem to find where the millis are coming from!
First, the Galaxy S3. The fix time is XX.07.55.318 (XX is hours, doesn't matter). You will see this sentence (see below for logs from both Galaxy and Nexus)
$GPGGA,140755.3,3920.030827,N,07721.484989,W,1,07,1.5,165.6,M,-42.0,M,,*66

That explains the "3xx" in the "318" millis. But what about the "x18"?
Next, the Nexus 7. The fix time is XX.16.26.508, and I cannot find where the "508" is coming from. You can trace the 1626
$GPRMC,141626,A,3920.038594,N,07721.487092,W,2.2,11.0,030414,8.1,W,A*2E
$GPGGA,141626,3920.038594,N,07721.487092,W,1,08,1.6,176.0,M,-42.0,M,,*7A

I am looking to use GPS time to achieve millisecond level time sync across distributed devices, so not knowing when the data can be trusted is troubling.
Thanks
PVS
Nexus 7 NMEA log
040314,10:16:22.266: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:22.269: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:22.271: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:22.274: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:22.276: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:22.279: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:22.281: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:22.284: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:23.274: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:23.277: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:23.281: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:23.284: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:23.287: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:23.292: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:23.295: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:23.298: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:23.466: NMEA:$GPGSV,5,1,18,15,26,059,33,03,00,000,,12,03,126,,14,35,253,*79
040314,10:16:23.468: NMEA:$GPGSV,5,2,18,18,77,030,,19,06,310,,21,46,191,,22,48,307,*71
040314,10:16:23.471: NMEA:$GPGSV,5,3,18,24,55,077,,27,08,278,,66,35,074,27,67,56,351,34*72
040314,10:16:23.473: NMEA:$GPGSV,5,4,18,78,11,175,,82,00,000,,77,49,133,,76,39,049,*7D
040314,10:16:23.476: NMEA:$GPGSV,5,5,18,83,21,313,,81,00,000,*70
040314,10:16:23.478: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:23.480: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:23.483: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:23.485: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:23.488: NMEA:$GPGSV,5,1,18,15,26,059,33,03,00,000,,12,03,126,,14,35,253,*79
040314,10:16:23.508: NMEA:$GPGSV,5,2,18,18,77,030,,19,06,310,,21,46,191,,22,48,307,*71
040314,10:16:23.511: NMEA:$GPGSV,5,3,18,24,55,077,,27,08,278,,66,35,074,27,67,56,351,34*72
040314,10:16:23.513: NMEA:$GPGSV,5,4,18,78,11,175,,82,00,000,,77,49,133,,76,39,049,*7D
040314,10:16:23.516: NMEA:$GPGSV,5,5,18,83,21,313,,81,00,000,*70
040314,10:16:23.518: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:23.521: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:23.523: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:23.526: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:23.865: NMEA:$GPGSV,5,1,18,15,26,059,38,03,00,000,,12,03,126,,14,35,253,*72
040314,10:16:23.869: NMEA:$GPGSV,5,2,18,18,77,030,,19,06,310,,21,46,191,,22,48,307,*71
040314,10:16:23.884: NMEA:$GPGSV,5,3,18,24,55,077,,27,08,278,,66,35,074,30,76,39,049,25*77
040314,10:16:23.887: NMEA:$GPGSV,5,4,18,83,21,313,30,67,56,351,36,78,11,175,,82,00,000,*7D
040314,10:16:23.890: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:23.893: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:23.895: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:23.898: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:23.900: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:23.903: NMEA:$GPGSV,5,1,18,15,26,059,38,03,00,000,,12,03,126,,14,35,253,*72
040314,10:16:23.905: NMEA:$GPGSV,5,2,18,18,77,030,,19,06,310,,21,46,191,,22,48,307,*71
040314,10:16:23.908: NMEA:$GPGSV,5,3,18,24,55,077,,27,08,278,,66,35,074,30,76,39,049,25*77
040314,10:16:23.911: NMEA:$GPGSV,5,4,18,83,21,313,30,67,56,351,36,78,11,175,,82,00,000,*7D
040314,10:16:23.913: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:23.932: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:23.935: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:23.937: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:23.940: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:24.473: NMEA:$GPGSV,5,1,18,15,26,059,38,03,00,000,,12,03,126,,14,35,253,*72
040314,10:16:24.476: NMEA:$GPGSV,5,2,18,18,77,030,,19,06,310,,21,46,191,,22,48,307,*71
040314,10:16:24.479: NMEA:$GPGSV,5,3,18,24,55,077,,27,08,278,,66,35,074,30,76,39,049,25*77
040314,10:16:24.483: NMEA:$GPGSV,5,4,18,83,21,313,30,67,56,351,36,78,11,175,,82,00,000,*7D
040314,10:16:24.485: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:24.488: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:24.491: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:24.502: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:24.505: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:24.508: NMEA:$GPGSV,5,1,18,15,26,059,38,03,00,000,,12,03,126,,14,35,253,*72
040314,10:16:24.511: NMEA:$GPGSV,5,2,18,18,77,030,,19,06,310,,21,46,191,,22,48,307,*71
040314,10:16:24.513: NMEA:$GPGSV,5,3,18,24,55,077,,27,08,278,,66,35,074,30,76,39,049,25*77
040314,10:16:24.516: NMEA:$GPGSV,5,4,18,83,21,313,30,67,56,351,36,78,11,175,,82,00,000,*7D
040314,10:16:24.518: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:24.521: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:24.523: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:24.525: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:24.528: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:25.469: NMEA:$GPGSV,5,1,18,15,26,059,39,19,06,310,23,21,46,191,25,22,48,307,32*79
040314,10:16:25.471: NMEA:$GPGSV,5,2,18,24,55,077,27,27,08,278,24,03,00,000,,12,03,126,*74
040314,10:16:25.474: NMEA:$GPGSV,5,3,18,14,35,253,,18,77,030,,66,35,074,35,76,39,049,24*78
040314,10:16:25.476: NMEA:$GPGSV,5,4,18,83,21,313,27,67,56,351,37,78,11,175,,82,00,000,*7A
040314,10:16:25.480: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:25.483: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:25.486: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:25.489: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:25.501: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:25.504: NMEA:$GPGSV,5,1,18,15,26,059,39,19,06,310,23,21,46,191,25,22,48,307,32*79
040314,10:16:25.507: NMEA:$GPGSV,5,2,18,24,55,077,27,27,08,278,24,03,00,000,,12,03,126,*74
040314,10:16:25.509: NMEA:$GPGSV,5,3,18,14,35,253,,18,77,030,,66,35,074,35,76,39,049,24*78
040314,10:16:25.512: NMEA:$GPGSV,5,4,18,83,21,313,27,67,56,351,37,78,11,175,,82,00,000,*7A
040314,10:16:25.514: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:25.517: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E
040314,10:16:25.519: NMEA:$GPVTG,,T,,M,,N,,K,N*2C
040314,10:16:25.522: NMEA:$GPRMC,,V,,,,,,,,,,N*53
040314,10:16:25.540: NMEA:$GPGGA,,,,,,0,,,,,,,,*66
040314,10:16:26.481: onLocationChanged(): gps, hasAccuracy: true, Accuracy: 16.0
040314,10:16:26.540: NMEA:$GPGSV,5,1,18,14,35,253,26,15,26,059,39,18,77,030,24,19,06,310,29*7A
040314,10:16:26.543: NMEA:$GPGSV,5,2,18,21,46,191,25,22,48,307,28,24,55,077,32,27,08,278,20*7F
040314,10:16:26.545: NMEA:$GPGSV,5,3,18,03,00,000,,12,03,126,,66,35,074,37,76,39,049,26*73
040314,10:16:26.546: NMEA:$GPGSV,5,4,18,83,21,313,24,67,56,351,34,78,11,175,,82,00,000,*7A
040314,10:16:26.550: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:26.552: NMEA:$GPGSV,5,1,18,14,35,253,26,15,26,059,39,18,77,030,24,19,06,310,29*7A
040314,10:16:26.554: NMEA:$GPGSV,5,2,18,21,46,191,25,22,48,307,28,24,55,077,32,27,08,278,20*7F
040314,10:16:26.555: NMEA:$GPGSV,5,3,18,03,00,000,,12,03,126,,66,35,074,37,76,39,049,26*73
040314,10:16:26.557: NMEA:$GPGSV,5,4,18,83,21,313,24,67,56,351,34,78,11,175,,82,00,000,*7A
040314,10:16:26.561: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:26.563: NMEA:$GPGSA,A,3,14,15,18,19,21,22,24,27,,,,,2.9,1.6,2.4*38
040314,10:16:26.578: NMEA:$GPVTG,11.0,T,11.0,M,2.2,N,4.0,K,A*27
040314,10:16:26.580: NMEA:$GPRMC,141626,A,3920.038594,N,07721.487092,W,2.2,11.0,030414,8.1,W,A*2E
040314,10:16:26.581: NMEA:$GPGGA,141626,3920.038594,N,07721.487092,W,1,08,1.6,176.0,M,-42.0,M,,*7A
040314,10:16:26.583: NMEA:$GPGSV,5,1,18,14,35,253,26,15,26,059,39,18,77,030,24,19,06,310,29*7A
040314,10:16:26.585: NMEA:$GPGSV,5,2,18,21,46,191,25,22,48,307,28,24,55,077,32,27,08,278,20*7F
040314,10:16:26.586: NMEA:$GPGSV,5,3,18,03,00,000,,12,03,126,,66,35,074,37,76,39,049,26*73
040314,10:16:26.588: NMEA:$GPGSV,5,4,18,83,21,313,24,67,56,351,34,78,11,175,,82,00,000,*7A
040314,10:16:26.589: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:26.591: NMEA:$GPGSV,5,1,18,14,35,253,26,15,26,059,39,18,77,030,24,19,06,310,29*7A
040314,10:16:26.593: NMEA:$GPGSV,5,2,18,21,46,191,25,22,48,307,28,24,55,077,32,27,08,278,20*7F
040314,10:16:26.594: NMEA:$GPGSV,5,3,18,03,00,000,,12,03,126,,66,35,074,37,76,39,049,26*73
040314,10:16:26.608: NMEA:$GPGSV,5,4,18,83,21,313,24,67,56,351,34,78,11,175,,82,00,000,*7A
040314,10:16:26.610: NMEA:$GPGSV,5,5,18,77,49,133,,81,00,000,*75
040314,10:16:26.611: NMEA:$GPGSA,A,3,14,15,18,19,21,22,24,27,,,,,2.9,1.6,2.4*38
040314,10:16:26.613: NMEA:$GPVTG,11.0,T,11.0,M,2.2,N,4.0,K,A*27
040314,10:16:26.615: NMEA:$GPRMC,141626,A,3920.038594,N,07721.487092,W,2.2,11.0,030414,8.1,W,A*2E
040314,10:16:26.616: NMEA:$GPGGA,141626,3920.038594,N,07721.487092,W,1,08,1.6,176.0,M,-42.0,M,,*7A

Samsung Galaxy S3 NMEA log
040314,10:07:16.500: NMEA:$GPGSV,3,1,10,03,01,295,,12,00,129,,14,32,250,,15,29,056,*70

040314,10:07:16.504: NMEA:$GPGSV,3,2,10,18,76,011,,19,06,313,,21,50,194,,22,45,306,*70

040314,10:07:16.508: NMEA:$GPGSV,3,3,10,24,56,084,,27,09,282,*75

040314,10:07:16.516: NMEA:$GLGSV,3,1,10,66,38,068,31,77,45,137,29,83,19,317,37,68,14,296,31*68

040314,10:07:16.519: NMEA:$GLGSV,3,2,10,78,07,175,,82,03,203,,76,41,054,,75,01,018,*69

040314,10:07:16.585: NMEA:$GLGSV,3,3,10,81,04,206,,67,54,343,*69

040314,10:07:16.588: NMEA:$GPGGA,140717.7,,,,,0,,,,,,,,*7B

040314,10:07:16.589: NMEA:$GNGNS,140717.7,,,,,NN,,,,,,*4E

040314,10:07:16.611: NMEA:$GPVTG,,T,,M,,N,,K,N*2C

040314,10:07:16.617: NMEA:$GPRMC,,V,,,,,,,,,,N*53

040314,10:07:16.619: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E

040314,10:07:16.621: NMEA:$GNGSA,A,1,,,,,,,,,,,,,,,*00

040314,10:07:16.743: NMEA:$GPGSV,3,1,10,03,01,295,,12,00,129,,14,32,250,,15,29,056,*70

040314,10:07:16.747: NMEA:$GPGSV,3,2,10,18,76,011,,19,06,313,,21,50,194,,22,45,306,*70

040314,10:07:16.749: NMEA:$GPGSV,3,3,10,24,56,084,,27,09,282,*75

040314,10:07:16.751: NMEA:$GLGSV,3,1,10,66,38,068,31,77,45,137,29,83,19,317,37,68,14,296,31*68

040314,10:07:16.755: NMEA:$GLGSV,3,2,10,78,07,175,,82,03,203,,76,41,054,,75,01,018,*69

040314,10:07:16.764: NMEA:$GLGSV,3,3,10,81,04,206,,67,54,343,*69

040314,10:07:16.784: NMEA:$GPGGA,140718.5,,,,,0,,,,,,,,*76

040314,10:07:16.786: NMEA:$GNGNS,140718.5,,,,,NN,,,,,,*43

040314,10:07:16.788: NMEA:$GPVTG,,T,,M,,N,,K,N*2C

040314,10:07:16.803: NMEA:$GPRMC,,V,,,,,,,,,,N*53

040314,10:07:16.805: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E

040314,10:07:16.815: NMEA:$GNGSA,A,1,,,,,,,,,,,,,,,*00

040314,10:07:17.771: NMEA:$GPGSV,3,1,10,14,32,250,29,15,29,056,34,19,06,313,38,24,56,084,26*70

040314,10:07:17.776: NMEA:$GPGSV,3,2,10,03,01,295,,12,00,129,,18,76,011,,21,50,194,*7E

040314,10:07:17.778: NMEA:$GPGSV,3,3,10,22,45,306,,27,09,282,*78

040314,10:07:17.782: NMEA:$GLGSV,3,1,10,66,38,068,30,77,45,137,31,76,41,054,30,83,19,317,38*6D

040314,10:07:17.784: NMEA:$GLGSV,3,2,10,68,14,296,36,78,07,175,,82,03,203,,75,01,018,*6F

040314,10:07:17.787: NMEA:$GLGSV,3,3,10,81,04,206,,67,54,343,*69

040314,10:07:17.790: NMEA:$GPGGA,140719.5,3920.022524,N,07721.493920,W,1,03,3.2,153.4,M,-42.0,M,,*66

040314,10:07:17.792: NMEA:$GNGNS,140719.5,3920.022524,N,07721.493920,W,AA,08,3.2,153.4,-42.0,,*59

040314,10:07:17.794: NMEA:$GPVTG,36.8,T,36.8,M,2.0,N,3.6,K,A*24

040314,10:07:17.797: NMEA:$GPRMC,140719.5,A,3920.022524,N,07721.493920,W,2.0,36.8,030414,,,A*43

040314,10:07:17.800: NMEA:$GPGSA,A,2,14,15,19,,,,,,,,,,3.3,3.2,1.0*3A

040314,10:07:17.803: NMEA:$GNGSA,A,2,14,15,19,,,,,,,,,,3.3,3.2,1.0*24

040314,10:07:17.807: NMEA:$GNGSA,A,2,66,77,76,83,68,,,,,,,,3.3,3.2,1.0*29

040314,10:07:17.843: onLocationChanged(): gps, hasAccuracy: true, Accuracy: 40.0
040314,10:07:18.771: NMEA:$GPGSV,3,1,10,14,32,250,31,15,29,056,31,18,76,011,30,19,06,313,37*75

040314,10:07:18.774: NMEA:$GPGSV,3,2,10,22,45,306,37,24,56,084,27,27,09,282,31,03,01,295,*7F

040314,10:07:18.776: NMEA:$GPGSV,3,3,10,12,00,129,,21,50,194,*7B

040314,10:07:18.778: NMEA:$GLGSV,3,1,10,66,38,068,27,77,45,137,23,76,41,054,26,83,19,317,37*60

040314,10:07:18.780: NMEA:$GLGSV,3,2,10,67,54,343,31,68,14,296,37,78,07,175,,82,03,203,*62

040314,10:07:18.784: NMEA:$GLGSV,3,3,10,75,01,018,,81,04,206,*67

040314,10:07:18.786: NMEA:$GPGGA,140720.5,3920.035586,N,07721.476384,W,1,07,1.4,143.5,M,-42.0,M,,*6D

040314,10:07:18.788: NMEA:$GNGNS,140720.5,3920.035586,N,07721.476384,W,AA,13,1.4,143.5,-42.0,,*5C

040314,10:07:18.798: NMEA:$GPVTG,36.8,T,36.8,M,0.5,N,0.9,K,A*2F

040314,10:07:18.801: NMEA:$GPRMC,140720.5,A,3920.035586,N,07721.476384,W,0.5,36.8,030414,,,A*4F

040314,10:07:18.805: NMEA:$GPGSA,A,3,14,15,18,19,22,24,27,,,,,,2.3,1.4,1.7*33

040314,10:07:18.815: NMEA:$GNGSA,A,3,14,15,18,19,22,24,27,,,,,,2.3,1.4,1.7*2D

040314,10:07:18.818: NMEA:$GNGSA,A,3,66,77,76,83,67,68,,,,,,,2.3,1.4,1.7*2B

040314,10:07:18.822: onLocationChanged(): gps, hasAccuracy: true, Accuracy: 22.0
040314,10:07:19.744: NMEA:$GPGSV,3,1,10,14,32,250,30,15,29,056,31,18,76,011,32,19,06,313,37*76

040314,10:07:19.748: NMEA:$GPGSV,3,2,10,22,45,306,40,24,56,084,25,27,09,282,34,03,01,295,*78

040314,10:07:19.752: NMEA:$GPGSV,3,3,10,12,00,129,,21,50,194,*7B

040314,10:07:19.757: NMEA:$GLGSV,3,1,10,66,38,068,29,77,45,137,24,76,41,054,24,83,19,317,39*65

040314,10:07:19.817: NMEA:$GLGSV,3,2,10,67,54,343,34,68,14,296,37,78,07,175,,82,03,203,*67

040314,10:07:19.820: NMEA:$GLGSV,3,3,10,75,01,018,,81,04,206,*67

040314,10:07:19.822: NMEA:$GPGGA,140721.5,3920.034010,N,07721.480904,W,1,07,1.4,153.5,M,-42.0,M,,*6D

040314,10:07:19.835: NMEA:$GNGNS,140721.5,3920.034010,N,07721.480904,W,AA,13,1.4,153.5,-42.0,,*5C

040314,10:07:19.837: NMEA:$GPVTG,36.8,T,36.8,M,0.0,N,0.0,K,A*23

040314,10:07:19.842: NMEA:$GPRMC,140721.5,A,3920.034010,N,07721.480904,W,0.0,36.8,030414,,,A*4B

040314,10:07:19.844: NMEA:$GPGSA,A,3,14,15,18,19,22,24,27,,,,,,2.3,1.4,1.7*33

040314,10:07:19.847: NMEA:$GNGSA,A,3,14,15,18,19,22,24,27,,,,,,2.3,1.4,1.7*2D

040314,10:07:19.849: NMEA:$GNGSA,A,3,66,77,76,83,67,68,,,,,,,2.3,1.4,1.7*2B

040314,10:07:19.872: onLocationChanged(): gps, hasAccuracy: true, Accuracy: 15.0
040314,10:07:53.745: NMEA:$GPGSV,3,1,10,22,45,306,34,03,01,295,,12,00,129,,14,32,250,*7F

040314,10:07:53.749: NMEA:$GPGSV,3,2,10,15,29,057,,18,76,012,,19,06,313,,21,50,192,*7C

040314,10:07:53.754: NMEA:$GPGSV,3,3,10,24,56,084,,27,09,282,*75

040314,10:07:53.766: NMEA:$GLGSV,3,1,10,77,45,136,27,67,54,343,28,78,07,175,,82,03,203,*6B

040314,10:07:53.770: NMEA:$GLGSV,3,2,10,66,38,068,,76,41,054,,75,01,018,,83,19,317,*69

040314,10:07:53.831: NMEA:$GLGSV,3,3,10,81,04,206,,68,14,296,*6B

040314,10:07:53.837: NMEA:$GPGGA,140755.5,,,,,0,,,,,,,,*7F

040314,10:07:53.842: NMEA:$GNGNS,140755.5,,,,,NN,,,,,,*4A

040314,10:07:53.847: NMEA:$GPVTG,,T,,M,,N,,K,N*2C

040314,10:07:53.852: NMEA:$GPRMC,,V,,,,,,,,,,N*53

040314,10:07:53.856: NMEA:$GPGSA,A,1,,,,,,,,,,,,,,,*1E

040314,10:07:53.861: NMEA:$GNGSA,A,1,,,,,,,,,,,,,,,*00

040314,10:07:54.006: NMEA:$GPGSV,3,1,10,14,32,250,26,15,29,057,26,18,76,012,26,19,06,313,32*75

040314,10:07:54.010: NMEA:$GPGSV,3,2,10,22,45,306,34,24,56,084,24,27,09,282,30,03,01,295,*7E

040314,10:07:54.013: NMEA:$GPGSV,3,3,10,12,00,129,,21,50,192,*7D

040314,10:07:54.016: NMEA:$GLGSV,3,1,10,77,45,136,27,83,19,317,33,67,54,343,28,68,14,296,30*6B

040314,10:07:54.018: NMEA:$GLGSV,3,2,10,78,07,175,,82,03,203,,66,38,068,,76,41,054,*66

040314,10:07:54.021: NMEA:$GLGSV,3,3,10,75,01,018,,81,04,206,*67

040314,10:07:54.065: NMEA:$GPGGA,140755.3,3920.030827,N,07721.484989,W,1,07,1.5,165.6,M,-42.0,M,,*66

040314,10:07:54.067: NMEA:$GNGNS,140755.3,3920.030827,N,07721.484989,W,AA,11,1.5,165.6,-42.0,,*55

040314,10:07:54.069: NMEA:$GPVTG,294.4,T,294.4,M,2.4,N,4.5,K,A*24

040314,10:07:54.071: NMEA:$GPRMC,140755.3,A,3920.030827,N,07721.484989,W,2.4,294.4,030414,,,A*77

040314,10:07:54.074: NMEA:$GPGSA,A,3,14,15,18,19,22,24,27,,,,,,2.3,1.5,1.8*3D

040314,10:07:54.076: NMEA:$GNGSA,A,3,14,15,18,19,22,24,27,,,,,,2.3,1.5,1.8*23

040314,10:07:54.077: NMEA:$GNGSA,A,3,77,83,67,68,,,,,,,,,2.3,1.5,1.8*24

040314,10:07:54.079: onLocationChanged(): gps, hasAccuracy: true, Accuracy: 12.0


text:
Q: How do I add frames to this class to divide everything up? Im trying to divide this page up. Can anyone help me out understanding how to divide PageOne into frames.  I want to put in a navbar section just for buttons and another section for entry forms
class rhizoApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)

        #tk.Tk.wm_iconbitmap(self, default="rhizo.ico")
        tk.Tk.wm_title(self, "Rhizo Control Center")

        container = tk.Frame(self)
        container.pack(side="top", fill="both", expand = True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for F in (StartPage, PageOne, PageTwo):
            frame = F(container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(StartPage)

    def show_frame(self, cont):
        frame = self.frames[cont]
        frame.tkraise()

class StartPage(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Home Page", font=LARGE_FONT, bd=2, bg='red', width=50, height=5)
        label.grid(row=0, column=0, pady=10, padx=10, sticky='N', columnspan=10)

        button1 = tk.Button(self, text="Testing", relief='raised', command=lambda: controller.show_frame(PageOne))
        button1.grid(row=2, column=0, sticky='w', padx=10, pady=10)
        button2 = tk.Button(self, text="Analysis", command=lambda: controller.show_frame(PageTwo))
        button2.grid(row=2, column=9, sticky='se', padx=10, pady=10)

Im just getting a little lost because I tried doing
frame1=tk.Frame(parent)

also:
frame1=tk.Frame(self)

but python just hangs.


text:
Q: What is the length of a singleton set? Consider a set $\{0\}$, what is its length? It cannot be zero because having infinitely many singletons, we could construct a set $[0,1]$ which is of length one. However assigning an arbitrarily small number to its length would result in a set $[0,1]$ having an infinite length.

A: "Length" is generally a concept that is only going to be countably additive. And since $[0, 1]$ is uncountable, it's not a countable union of singletons, and assigning length $0$ to a singleton leads to no contradictions.


text:
Q: is convertion to DTO like this ok or it is a bad practice? I have Entity that has list of another entities inside. Same for DTO, dto object with a list of another dto.
I need to convert Entity to DTO with the list inside.
Here how it looks with streams ( a bit messy, don't know if it is ok to use ):
public List<RestaurantDto> getAll() {
    List<Restaurant> restaurantList = restaurantRepository.findAll();
    return restaurantList.stream()
            .map(restaurant -> new RestaurantDto(restaurant.getName(), restaurant.getAddress(),
                    restaurant.getDishes().stream()
                            .map(dish -> new DishDto(dish.getId(), dish.getName(), dish.getPrice(), dish.getRestaurant()))
            .collect(Collectors.toList())))
            .collect(Collectors.toList());
}

Here is my DTO
@Getter
@Setter
@NoArgsConstructor
public class RestaurantDto {
    private String name;
    private String address;
    private List<DishDto> dishes;
    private int votes;

    public RestaurantDto(String name, String address) {
        this.name = name;
        this.address = address;
    }

    public RestaurantDto(String name, String address, List<DishDto> dishes) {
        this.name = name;
        this.address = address;
        this.dishes = dishes;
    }

    public void addDish(DishDto dishDto) {
        dishes.add(dishDto);
    }
    public List getDeishes() {
        return Collections.unmodifiableList(dishes);
    }
}

And DTO that is in List
@Getter
@Setter
@NoArgsConstructor
@ToString
public class DishDto {
    private int id;

    @NotBlank
    private String name;
    @Digits(integer = 12, fraction = 2)
    private double price;
    private String restaurantName;
    private String restaurantAddress;
    @Digits(integer = 12, fraction = 0)
    private int restaurantId;

public DishDto(int id, String name, double price, int restaurantId) {
    this.id = id;
    this.name = name;
    this.price = price;
    this.restaurantId = restaurantId;
}

public DishDto(int id, String name, double price, Restaurant restaurant) {
    this.id = id;
    this.name = name;
    this.price = price;
    this.restaurantName = restaurant.getName();
    this.restaurantAddress = restaurant.getAddress();
    this.restaurantId = restaurant.getId();
}

}
I do appreciate your help a lot!

A: In my opinion, retrieving the whole entity and then converting it to DTOs in order to have fewer fields can be considered as an anti-pattern.
You should use projections if you want to retrieve less fields from the entity.
Bringing all the fields to the memory and then using just couple of them is not a good idea.
Take a look at projections. The following resources may help:
https://vladmihalcea.com/the-best-way-to-map-a-projection-query-to-a-dto-with-jpa-and-hibernate/
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections


text:
Q: iPhone CorePlot:error- "CPBarPlotFieldBarLength:" Undeclared Hi I am trying to implement core plot in My iPhone App
for that I use the below code
 -(NSNumber *)numberForPlot:(CPPlot *)plot
                  field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
 {
     if (plot.identifier==@"myBarChart") {
         switch ( fieldEnum ) {
             case CPBarPlotFieldBarLocation:
                return (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger:index];
             case CPBarPlotFieldBarLength:
                 return [self.lockedPercentage objectAtIndex:index];
        }

}
if I use this code in original coreplot code example it works fine for barchart but When I use same code in my App it is giving error
   case CPBarPlotFieldBarLength:Undeclared

What Could be the problem??
Please Help and Suggest
Thanks

A: CPBarPlotFieldBarLength has been renamed to CPBarPlotFieldBarTip.


text:
Q: Surrogate Key in Netezza - SSIS and Netezza sequence I am fetching some data from an Oracle table and inserting into a Netezza table using an SSIS Script Task in Control Flow.
Objective: to populate a surrogate key (like a Landing ID) field in the destination table.
For now the query looks like:
insert into destination_table
(
id, col1, col2, col3
)
select (SELECT NEXT VALUE FOR MY_SEQUENCER), field1, field2, field3
from source_table

I am using a Netezza sequence (MY_SEQUENCER) to generate a unique number but the sequence value doesn't get incremented until the query commits. As a result, after the data is inserted, I am getting:
1, val1, val2, val3
1, val4, val5, val6
...

subsequent run:
2, val1, val2, val3
2, val4, val5, val6
...

and so on.
Is there a way to achieve this without using a sequence?
Thanks a lot for reading and any ideas/tips/suggestions you may provide.

A: I saw the resolution from here ... In Netezza I'm trying to use a sequence in a case statement but the sequence value doesn't increment
insert into destination_table
(
id, col1, col2, col3
)
select (NEXT VALUE FOR MY_SEQUENCER), field1, field2, field3
from source_table

A: Remove the parentheses and redundant select and it will generate a new value for every row.
TESTDB.ADMIN(ADMIN)=> select (select next value for mysequence), col1, col2 from test2 limit 5;
 ?COLUMN? | COL1 | COL2
----------+------+------
        2 |    0 | 0
        2 |    2 | 2
        2 |    4 | 4
        2 |    6 | 6
        2 |    8 | 8
(5 rows)

TESTDB.ADMIN(ADMIN)=> select next value for mysequence, col1, col2 from test2 limit 5;
 NEXTVAL | COL1 | COL2
---------+------+------
  200001 |    1 | 1
  200002 |    3 | 3
  200003 |    5 | 5
  200004 |    7 | 7
  200005 |    9 | 9
(5 rows)


text:
Q: Hibernate implicit entity restrictions Is any way to add implicit restriction to entity in HQL? For example when we query list with hql "from Client" we need select only thouse clients, that have some particular system id. System id itself depends on user session. So we need this query to be actually converted to "from Client where systemId=:systemId" although we didn't specify it in original query

A: Hibernate Filter is what you're after...

In order to ensure that you are
  provided with currently effective
  records, enable the filter on the
  session prior to retrieving employee
  data:
Session session = ...;
session.enableFilter("effectiveDate").setParameter("asOfDate", new Date());
List results = session.createQuery("from Employee as e where e.salary > :targetSalary")
         .setLong("targetSalary", new Long(1000000))
         .list();


text:
Q: Erro em consulta mysql Estou a horas sem perceber o que há de errado com a minha query. Gostaria que me dessem uma ajuda
SELECT
`recargas`.`valor_recarga` as saldo
FROM `contas_pessoais`
INNER JOIN `contas` ON `contas`.`titular` = `contas_pessoais`.`titular`
INNER JOIN `recargas` ON `recargas`.`titular` = `contas_pessoais`.`titular`
INNER JOIN `transaccoes` ON `transaccoes`.`transaccao_id` = `transaccao_carregamento`.`transaccao_id`
WHERE `contas`.`titular` = '12';

Tenho como retorno este erro:
#1054 - Unknown column 'transaccao_carregamento.transaccao_id' in 'on clause'

A: A tabela transaccao_carregamento não está na sua consulta, você precisa incluí-la em um INNER JOIN.


text:
Q: Lectura de archivos en C++. ¿Como funciona un flujo de entrada? Leyendo un código me he encontrado con un ejemplo curioso de lectura de archivo en C++, creo que es curioso porque en el se utilizan hasta cuatro objetos distintos, con distinto nivel de abstracción de la cadena de caracteres. Yo entiendo hasta ahi, que el primer objeto contiene mas información y va tamizando la cadena en cada asignación hasta quedarse con el array puro de caracteres. Pero tengo curiosidad por saber que pasa realmente en cada asignación, ¿que extrae y que elimina?
Vemos la lectura del archivo a un ifstream, de un ifstream lo pasa a un stringstream, del stringstream extrae un string, y del string extrae una cadena de caracteres pura, un array.
// Open file
std::ifstream shaderFile(fileName);
if (shaderFile.is_open())
{
    // Read all the text into a string
    std::stringstream sstream;
    sstream << shaderFile.rdbuf();
    std::string contents = sstream.str();
    const char* contentsChar = contents.c_str();

    // Create a shader of the specified type
    outShader = glCreateShader(shaderType);
    // Set the source characters and try to compile
    glShaderSource(outShader, 1, &(contentsChar), nullptr);
    glCompileShader(outShader);

    if (!IsCompiled(outShader))
    {
        SDL_Log("Failed to compile shader %s", fileName.c_str());
        return false;
    }
}
else
{
    SDL_Log("Shader file not found: %s", fileName.c_str());
    return false;
}

A:
Vemos la lectura del archivo a un ifstream, de un ifstream lo pasa a un stringstream, del stringstream extrae un string, y del string extrae una cadena de caracteres pura, un array.

¿Por qué hace algo tan complicado? Es difícil de decir, cada problema puede ser aproximado de diferentes maneras, en el caso de tu ejemplo "vuelca"1 todo un archivo en un flujo de texto (es decir: stringstream o flujo stream de texto string) porque de leer desde archivo con formato podría sólo leer palabra a palabra usando el operador de extracción con formato (>>) o línea a línea con std::getline.
Una vez tiene el contenido del archivo en un flujo de texto, fuerza la lectura de los datos copiando2 el contenido del flujo en un objeto de texto con la función stringstream::str; dado que el compilador de shaders espera una cadena de caracteres (no un objeto de texto) debe extraerse la cadena de caracteres interna de std::string mediante std::string::c_str, función que devuelve una cadena de caracteres al estilo c3 (justo lo que espera el compilador de shaders).
Personalmente, veo todo esto complicado de más, yo copiaría de archivo a texto con un iterador:
// Si el archivo no se puede abrir, la expresión equivale a 'false'.
if (std::ifstream shaderFile(fileName))
{
    // Leemos todo en un objeto de texto:
    using iterator = std::istreambuf_iterator<char>;
    std::string contents{};
    contents.reserve(1024u * 1024u); // Reservamos espacio para minimizar re-alojamientos.
    std::copy(iterator(test), iterator(), std::back_inserter(contents));

    // Accedemos a la cadena de texto interna:
    const char *const contentsChar = contents.c_str();
    //          ^^^^^
    // Añadido un 'const' adicional, por seguridad.

    // Create a shader of the specified type
    outShader = glCreateShader(shaderType);
    // Set the source characters and try to compile
    glShaderSource(outShader, 1, &(contentsChar), nullptr);
    glCompileShader(outShader);

    if (!IsCompiled(outShader))
    {
        SDL_Log("Failed to compile shader %s", fileName.c_str());
        return false;
    }
}
else
{
    SDL_Log("Shader file not found: %s", fileName.c_str());
    return false;
}

1En realidad no vuelca el archivo en un flujo de texto si no que asigna al flujo de texto el búfer del archivo, el resultado es el mismo, pero es un matiz importante.
2Observa que devuelve una instancia de std::string no una referencia.
3Una cadena de caracteres finalizada con el carácter nulo '\0'.


text:
Q: PouchDB in multiple tab I did't get good example how to handle PouchDB in multiple tabs.
Let me describe my example:

*

*Creating a local PouchDB.

*Continously pulling an array of integers via ajax.

*Concat with old array if present, add/update it with some id.

If we are using indexedDB, here is a good article on that.
Is there anything like this in PouchDB?


text:
Q: Bitbucket SSH Key loading but not working I'm trying to set up two different SSH keys for my bitbucket account, work, and personal. As usual I add my public key to my SSH keys on the server, but for some unusual reason when I open my public key to add it, I see it starts with
---- BEGIN SSH2 PUBLIC KEY ---- and ---- END SSH2 PUBLIC KEY ----.
Bitbucket doesn't like these so instead I copy it from the field at the top of PuttyGen, which doesn't have these fields and then Bitbucket accepts it.
HOWEVER,
When I then load my privaye key into Pageant it works fine, but I then try any operations with my server (clone, push, pull, even viewing remote on existing repos) It says my key isn't authenticated!!
I've also tried the ssh-keygen command from git bash, but these come out the same format and again, BitBucket doesn't like them.
Thanks.

A: This wasn't an issue to do with either SSH or Bitbucket, I didn't realise but over the weekend my workplace proxy had been updated, and it didn't like BitBucket connections. For future reference, the proxy client was 'Cisco AnyConnect', and ALL the proxy locations caused issues.


text:
Q: How to load php file with JS code Since I am new to JS coding and web designing, I have a following doubt:
I have one html page which has onclick function for form text area. If text area remains empty and user clicks submit, it should display message to enter entry and if entry is right one the corresponding file should get open. I have if/else condition in JS file, which is giving appropriate message while text area remains empty but not loading file which I am mentioning when entry is not empty.
Below is the html snippet:
<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset=utf-8>
</head>
<body>
    <form name="drugform" action="#">
        <pre> Drug Name<input type="text" name="name1" value="" /></pre>
        </p>

        <input type="button" value="Enter" onclick='buttoncheck()' />
    </form>
    <script type="text/javascript" src="if-else-button.js"></script>
</body>
</html>

and JS code is:
function buttoncheck() {
    if (Boolean(document.drugform.name1.value)) {
        load(form1.php);
    } else {
        alert('Enter Drug name');
    }
}

How to load file with js code (mentioned in if condition)?

A: if you want to load that form1.php file in existing file then you can use ajax for for reference go  here.
and if you want to redirect to another page then you should use
window.location.href = "form1.php";

A: var url = 'form1.php';
window.location.href = url;

Instead of load(form1.php), substitute the above code snippet!
EDIT:
If you want to load the file without actually redirecting to a new page, you can use jquery's .load()
Check more about it here: http://api.jquery.com/load/

A: try like this,
function buttoncheck() {
    if (document.drugform.name1.value != "") {  // check not empty condition
        load("form1.php"); // passing value to function with quotes
    } else {
        alert('Enter Drug name');
    }
}


text:
Q: Creating flat terrain with triangle strips I am asking for some help with drawing a flat terrain using triangle strips. If this is the correct way to do it?
So far i managed to create vertex and index arrays, debugged it couple of times and it seems to generate correct values.
At first I tried drawing with degenerate triangles, but I read somewhere that it's an outdated way and I should rather switch to a primitive restart option.
NOTE THAT THIS NOT THE EXACT WAY MY PROJECT IS SET UP... I just copied the necessery code
Here is the code for terrain generation:
this->terrainSize = width * height;
unsigned int numRows = height - 1;                        //!NUMBER OF ROWS OF TRIANGLE STRIPS
unsigned int numColumns = width - 1;                      //!Number of columns of strips
unsigned int numVerticiesPerRow = 2 * width;              //!NUMBER OF VERTICIES PER EVERY ROW
unsigned int numIndPerRow = numColumns * 2 + 2;           //!Number of indices per row
unsigned int numOfStrips = numRows - 1;                   //!Number of splits, after every row

this->numVertices = terrainSize * 8;
this->numIndices = numRows * numIndPerRow + numOfStrips;   //!total number of indices

std::vector<float> vertexArray (numVertices);
float* vertexPointer = vertexArray.data();
float* vertexPointer2 = vertexArray.data();
for( int row = 0; row < height; row++ )              //!Z AXIS
{
    for( int col = 0; col < width; col++ )           //!X AXIS
    {
        float x = (float) ( col - width / 2 );
        float z = (float) ( row - height / 2 );

        //?Positions
        *vertexPointer = x; ++vertexPointer;           //?1
        *vertexPointer = 0.0f; ++vertexPointer;       //?2
        *vertexPointer = z; ++vertexPointer;          //?3

        //?Normals (lightning)
        *vertexPointer = 0.0f; ++vertexPointer;        //?4
        *vertexPointer = 1.0f; ++vertexPointer;        //?5
        *vertexPointer = 0.0f; ++vertexPointer;       //?6

        //?Texture Coordinates
        *vertexPointer = x; ++vertexPointer;           //?7
        *vertexPointer = z; ++vertexPointer;          //?8
        }
    }

//?GENERATE INDICIES
std::vector<unsigned int> indexArray (numIndices);
unsigned int* indexPointer = indexArray.data();
unsigned int* indexPointer2 = indexArray.data();
for( int row = 0; row < height - 1; row++ )   //!Z AXIS
{
    for( int col = 0; col < width; col++ )   //!X AXIS
    {
        *indexPointer = ( row * height ) + col; ++indexPointer;
        *indexPointer = (( row + 1 )* height ) + col; ++indexPointer;

    }
    if( row < height - 2 )                   **//!Add 0xFFFF on the end of each row**
    {
        *indexPointer = 0xFFFF; ++indexPointer;
    }
}

//Pack the data into vertex struct
unsigned int i;
for( i = 0; i < this->numVertices; i=i+0 )
{
    Vertex vertex;
    glm::vec3 vector;

    vector.x = vertexArray[i++];
    vector.y = vertexArray[i++];
    vector.z = vertexArray[i++];
    vertex.Position = vector;

    vector.x = vertexArray[i++];
    vector.y = vertexArray[i++];
    vector.z = vertexArray[i++];
    vertex.Normal = vector;

    glm::vec2 vec;

    vec.x = vertexArray[i++];
    vec.y = vertexArray[i++];
    vertex.TexCords = vec;

    this->vertexStruct.push_back( vertex );
}
for( i = 0; i < this->numIndices; i++ )
{
    this->indexVector.push_back( indexArray[i] );
}

//Bind VertexArray
VAO.Create();

//Bind VertexBuffer
VBO.Create( vertexArray, numVertices);

//Bind IndexBuffer
IBO.Create( indexArray, numIndices );

//? DEFINE HOW SHOULD THE GPU SHOULD READ THE DATA FROM VERTEX BUFFER
//Position
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, sizeof( Vertex ), (GLvoid*) offsetof( Vertex, Position ) );
glEnableVertexAttribArray( 0 );
//Normal
glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, sizeof( Vertex ), (GLvoid*) offsetof( Vertex, Normal ) );
glEnableVertexAttribArray( 1 );
//Texcoord
glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, sizeof( Vertex ), (GLvoid*) offsetof( Vertex, TexCords ) );
glEnableVertexAttribArray( 2 );

glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); //?ENABLE WIREFRAME
glEnable( GL_PRIMITIVE_RESTART );
glPrimitiveRestartIndex( 0xFFFF );
glDrawElements( GL_TRIANGLE_STRIP, this->numVertices, GL_UNSIGNED_INT, this->indexArray );
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); //?DISABLE WIREFRAME