Q: Alternative or replacement firewall for Cisco PIX 501 We use 2 Cisco PIX 501's in front of a couple of our web-servers up at a data-centre (two separate installations on different IP ranges).
Touchwood they're fine but, if we had to replace them - what are our options for an equivalent replacement today? When we bought these I remember the spec saying they would comfortably support 10,000 simultaneous connections. Is the ASA5505 the equivalent today?
[edit] I'm not against other manufacturers - just that the pix is what we have and we know a CCNA(?), albeit certified in 2003, who configures and administers our pixes.

A: As a rule of thumb, Juniper firewalls tend to be cheaper for the same feature set.  I don't have a lot of direct experience with them, though.  If you stick with Cisco, then an ASA 5505 would be your best bet for replacement.  As far as product line goes, the 5505 is the pix501 equivalent.  However, the 5505 is actually closer to spec equivalent with the 515e.  That is, the 5505 supports 150Mbps throughput as opposed to the 170(?) for the pix515e.  Additionally, with the ‘Security Plus’ option the ASA supports more VLANS (with trunking), H/A, and a few more connections.

A: If you are confortable with PIX 501, take an ASA 5505. You will keep the same CLI interface.
ASA 5505 is arround 2 time better than PIX 501, you have a maximum number of connections of 10'000 (7500 on PIX 501), max. throughput of 150 mbps (60 on PIX 501).
I would recommand you to check the CPU usage, number of connection and throughput of your current firewall to check if an 5505 will be enought for a long term usage. If you are near of the maximum capacity of the 501 you may want to take an ASA 5510.
I don't know Juniper firewall but Nokia are better/easier to use (from my point of view) when you have a lots of interface.

A: I have had a great experience with Netgate's M1n1wall and can highly recommend pfSense. The throughput is much better than the Pix's, and the reliability has been perfect. Not a single issue in about a year at my office, where we have a business connection and 5 static external IPs.
I still have a 10-license Pix 501 at home and keep running out of local-host licenses. With my kids having their own laptops now, cell phones connecting through Wifi, the TV on the Internet as well, a Popcorn Hour streaming box, a server, a NAS, and a desktop computer, I have to clear the local-hosts almost daily because I can't get an outbound connection. I am going to replace it with a M1n1wall this week and will include a wireless kit, so that I can throw out the Verizon router and my old Linksys AP. Imagine what good this will do to my electric bill as well.
I will miss the Pix command line interface. Having mastered it made me feel part of an exclusive club, but I also spent many hours troubleshooting. Thankfully, this will be a thing of the past, as the pfSense web interface is complete and easy to use.

A: Changing to Juniper or any other vendor will cost you more in totalt because of the hours spent, so my advice for you is to stay on Cisco products.
We have several ASA5505 spread out at remote offices, they have worked flawlessly and are providing excellent performance. Highly recommended (but dont forget TAC agreement).

A: I would advise against Watchguard Edges.  We went all out on them at our remote sites and either they have poor performance or our vendors have done a poor job on the setup.  Seeing consideraly slower connections afterwards as compared to the PIX501.  A full Watchguard x5500e though is nice and GUI for regular tasks means we only occasionally need the network guy from our vendor for more complex tasks.  We don't use some of the features but it does have the option for load balancing with two and for failover in the event of trouble.

A: If you don't mind OpenSource alternatives: http://www.vyatta.com/downloads/index.php

A: I really like the Fortinet line of firewalls/security devices.
http://davidhazar.blogspot.com/2009/10/why-cisco-fortinet-fortigate.html

A: I've been very impressed with the Juniper line of firewalls recently.
http://www.juniper.net/us/en/products-services/security/ssg-series/
Outstanding price, enterprise class features and performance.

A: BIG fan of Nokia firewalls myself, capable and secure.

A: Don't be afraid of considering alternatives. Vyatta http://www.vyatta.com/ or Juniper could deserve your time, both in terms of functionality and reliability.

A: We have been removing as many old 501s as possible and replacing them with SnapGear 310s or SnapGear 560s. Mostly this has been because the 501s can't handle VOIP well.
The SnapGear line are Linux based devices and use IP tables internally so that can be a plus if you really want to get your hands dirty. They tend to be half as much as Sonicwalls and a third as much as the Cisco stuff (Especially if you factor in yearly support - you do have the support from Cisco right...?) and the web interfaces are much much better than the ASA or Sonicwalls. No IOS goodness of course.
Anywhere you have 501s and the network is not going to grow beyond 10 offices these are a really good choice. The 560s can do fail over or load balancing for up to four lines and can just about everything else you could do with the 501s and can also prioritize VOIP traffic etc.
The Cisco 5505 are great but I think you will find them overkill for your purposes and I don't really know what they can do that the SG560s can't. I think two 560s in high availability mode would work really well and you could even configure them yourself. If anyone has comments on what the ASAs can do that these SnapGears can't I would be interested to hear.


Q: Instalación prestashop 1.7.x que no termina nunca Llevo un par de días intentando instalar cualquiera de las versiones 1.7.x en un VPS con una instalación limpia de Debian GNU/Linux 8.10 (jessie).
Se crea el usuario FTP y se instala VESTACP y todo estupendo, subo por FTP los ficheros y al entrar por url al dominio se abre el instalador, descomprime sus ficheros, pide los datos de la nueva tienda y sus conexiones a la base de datos y todo parece que va bien hasta llegar al último paso, donde debería aparecer la famosa barra de progreso y la lista de las tareas que está haciendo, pero en mi caso no aparece. Por código veo que sí está, pero aparece con "display:none", y aunque la haga visible, obviamente no funciona.

Error instalación prestashop 1.7.x ultimo paso sin barra de progreso

Es como si el disparador que provoca el inicio de la instalación no se disparara (valga la redundancia).
También he visto que por lo que parece, no carga Jquery, aunque en el primero de los pasos tampoco lo carga y me deja llegar al último de los pasos.
Error instalacion prestashop 1.7.x

Total, que no sé por donde tirar ya...

A: Tienes un error 500, es muy probable que el problema sea por permisos de archivo, lo que debes hacer es cambiar todos los archivos de forma recursiva a 0644 y las carpetas a 0755, esto lo puedes conseguir con FileZilla.


Q: I can't find Generate local resource from tools menu in visual studio 2013 When I'm in design view(markup) of a web page, I can't find the Generate Local Resource from my tools menu. Can anyone tell me how to enable this tool?


Q: Level Order Traversal: Deleting a Subtree #include <iostream>

using namespace std;

struct node {
    int item;
    node* l;
    node* r;
    node (int x) {
        item = x;
        l = 0;
        r = 0;
    }
    node(int x, node* l, node* r) {
        item = x;
        this->l = l;
        this->r = r;
    }
};

typedef node* link;

class QUEUE {
private:
    link* q;
    int N;
    int head;
    int tail;
public:
    QUEUE(int maxN) {
        q = new link[maxN + 1];
        N = maxN + 1;
        head = N;
        tail = 0;
    }
    int empty() const {
        return head % N == tail;
    }
    void put(link item) {
        q[tail++] = item;
        tail = tail % N;
    }

    link get() {
        head = head % N;
        return q[head++];
    }
};

link head = 0; // Initial head of the tree

link find(int x) {
    if (head == 0) {
        cout << "\nEmpty Tree\n";
        return 0;
    }
    link temp = head;
    // To find the node with the value x and return its link
    QUEUE q(100);
    q.put(temp);
    while (!q.empty()) {
        temp = q.get();
        if (temp->item == x) {
            return temp;
        }
        if (temp->l != 0) q.put(temp->l);
        if (temp->r != 0) q.put(temp->r);
    }
    return 0;
}

void print(link temp) {
    QUEUE q(100);
    q.put(temp);
    while (!q.empty()) {
        temp = q.get();
        cout << temp->item << ", ";
        if (temp->l != 0) q.put(temp->l);
        if (temp->r != 0) q.put(temp->r);
    }
}

void deleteAll(link h) {
    // This deletes the entire binary tree
    QUEUE q(100);
    q.put(h);
    while (!q.empty()) {
        h = q.get();
        if (h->l != 0) q.put(h->l);
        if (h->r != 0) q.put(h->r);
        delete h;
    }
}

int main() {
    link temp = 0;
    char c;
    int n1, n2;
    cout << "\n\nPlease enter the input instructions (X to exit program) : \n\n";
    do {
        cin >> c;
        switch (c) {
            case 'C':   cin >> n1;
                        if (head == 0) {
                            head = new node(n1);
                            cout << "\nRoot node with item " << n1 << " has been created\n\n";
                        } else {
                            cout << "\nError: Tree is not empty\n\n";
                        }
                        break;

            case 'L':   cin >> n1 >> n2;
                        temp = find(n1);
                        if (temp != 0) {
                            if (temp->l == 0) {
                                temp->l = new node(n2);
                                cout << "\nNode with item " << n2 << " has been added\n\n";
                            }
                            else {
                                cout << "\nError: The specified node already has a left child\n\n";
                            }
                        }
                        else {
                            cout << "\nError: The specified node doesn't exist\n\n";
                        }
                        break;

            case 'R':   cin >> n1 >> n2;
                        temp = find(n1);
                        if (temp != 0) {
                            if (temp->r == 0) {
                                temp->r = new node(n2);
                                cout << "\nNode with item " << n2 << " has been added\n\n";
                            }
                            else {
                                cout << "\nError: The specified node already has a right child\n\n";
                            }
                        }
                        else {
                            cout << "\nError: The specified node doesn't exist\n\n";
                        }
                        break;

            case 'P':   cin >> n1;
                        temp = find(n1);
                        if (head != 0) {
                            cout << "\nLevel-order traversal of the entire tree: ";
                            print(temp);
                        }
                        else {
                            cout << "\nError: No elements to print\n\n";
                        }
                        break;

            case 'D':   cin >> n1;
                        temp = find(n1);
                        deleteAll(temp);
                        temp = 0;
                        break;

            case 'X':   cout << "\nExiting Program\n\n";
                        break;

            default:    cout << "\nInvalid input entered. Try again.\n\n";

        }
    } while (c != 'X');
    system("pause");
    return 0;
}

Sample Input:
C 9
L 9 8
R 9 6
L 8 3
R 8 5
R 6 2
L 3 4
L 4 10
L 5 1
R 5 11
L 1 12
R 1 7

It all works fine until I delete a subtree and print when it prints garbage value before crashing. Please help me figure out the bug because I've been trying in vain for hours now.
It all works fine until I delete a subtree and print when it prints garbage value before crashing. Please help me figure out the bug because I've been trying in vain for hours now.

A: When you delete a node, you call deleteAll(temp) which deletes temp, but it doesn't remove the pointer value from the l or r of temp's parent node.
This leaves you with a invalid pointer, causing garbage printing and crashing.
Unfortunately, the way your find works currently, you don't know what the current temp node's parent is when you get around to checking its value.
One way to fix it is to have a different type of find (called something like remove) that looks in l and r at each iteration for the value and sets l or r to NULL before returning the pointer. You might have to have a special case for when the value is found in the root.
Edit (sample code added):
I am assuming you are not using recursion for some reason, so my code uses your existing queue based code. I only changed enough to get it working.
findAndUnlink find the node with the value given and "unlinks" it from the tree. It returns the node found, giving you a completely separate tree. Note: it is up to the caller to free up the returned tree, otherwise you will leak memory.
This is a drop in replacement for find in your existing code, as your existing code then calls deleteAll on the returned node.
link findAndUnlink(int x) {
    if (head == 0) {
        cout << "\nEmpty Tree\n";
        return 0;
    }
    link temp = head;
    if (temp->item == x) {
        // remove whole tree
        head = NULL;
        return temp;
    }
    // To find the node with the value x and remove it from the tree and return its link
    QUEUE q(100);
    q.put(temp);
    while (!q.empty()) {
        temp = q.get();
        if (temp->l != NULL) {
            if (temp->l->item == x) {
                link returnLink = temp->l;
                temp->l = NULL;
                return returnLink;
            }
            q.put(temp->l);
        }
        if (temp->r != NULL) {
            if (temp->r->item == x) {
                link returnLink = temp->r;
                temp->r = NULL;
                return returnLink;
            }
            q.put(temp->r);
        }
    }
    return 0;
}

A: Try the recursive function:
void Delete(link h)
{
  if(h)
  {
    if(h->l) Delete(h->l);
    if(h->r) Delete(h->r);
    delete(h);
  }
}


Q: Given the matrices $A\in M_{m\times n}, B\in M_{n\times p}: \ B\neq 0$, suppose $AB=0$. Prove: there exists a non-trivial solution for $Ax=0$ Given two matrices: $A_{m\times n}$ and  $B_{n\times p}$, such that $B\neq 0$,
suppose $AB=0$.
Prove: there exists a non-trivial solution for $Ax=0$.
My Attempt:
suppose by contradiction that the only solution for the linear equation system $Ax=0$ is the trivial solution, meaning $Ax=0 \iff x=0$.
$$Ax=0\Longrightarrow\left[\begin{array}{cccc}
a_{11} & \cdots & \cdots & a_{1n}\\
\cdots & \cdots & \cdots & \cdots\\
\cdots & \cdots & \cdots & \cdots\\
a_{m1} & \cdots & \cdots & a_{mn}
\end{array}\right]\left[\begin{array}{c}
x_{1}\\
x_{2}\\
\vdots\\
x_{n}
\end{array}\right]=\left[\begin{array}{c}
0\\
\vdots\\
\vdots\\
0
\end{array}\right]$$
Hence, $$\left[\begin{array}{c}
a_{11}x_{1}+a_{12}x_{2}+\cdots+a_{1n}x_{n}=0\\
a_{21}x_{1}+a_{22}x_{2}+\cdots+a_{2n}x_{n}=0\\
\cdots\\
a_{m1}x_{1}+a_{m2}x_{2}+\cdots+a_{mn}x_{n}=0
\end{array}\right]$$
According to the assumption: $x_{1}=x_{2}=\cdots=x_{n}=0$
Now, Let $B=\left[\begin{array}{cccc}
b_{11} & \cdots & \cdots & b_{1p}\\
\cdots & \cdots & \cdots & \cdots\\
\cdots & \cdots & \cdots & \cdots\\
b_{n1} & \cdots & \cdots & b_{np}
\end{array}\right]$
Let $AB=(t)_{ij}$, as $\begin{array}{c}
1\le i\le m\\
1\le j\le p
\end{array}$
$AB=0\Longrightarrow\left[\begin{array}{cccc}
a_{11} & \cdots & \cdots & a_{1n}\\
\cdots & \cdots & \cdots & \cdots\\
\cdots & \cdots & \cdots & \cdots\\
a_{m1} & \cdots & \cdots & a_{mn}
\end{array}\right]\left[\begin{array}{cccc}
b_{11} & \cdots & \cdots & b_{1p}\\
\cdots & \cdots & \cdots & \cdots\\
\cdots & \cdots & \cdots & \cdots\\
b_{n1} & \cdots & \cdots & b_{np}
\end{array}\right]=\left[\begin{array}{c}
0\\
\cdots\\
\cdots\\
0
\end{array}\right]$
$\Longrightarrow\left[\begin{array}{cccc}
a_{11}b_{11}+\cdots+a_{1n}b_{n1}\  & \cdots\cdots & \cdots\cdots & a_{11}b_{1p}+\cdots+a_{1n}b_{np}\\
\cdots\cdots & \cdots\cdots & \cdots\cdots & \cdots\cdots\\
\cdots\cdots & \cdots\cdots & \cdots\cdots & \cdots\cdots\\
a_{m1}b_{11}+\cdots+a_{mn}b_{n1}\  & \cdots\cdots\  & \cdots\cdots\  & a_{m1}b_{1p}+\cdots+a_{mn}b_{np}
\end{array}\right]$
This means that for every $i,j:\ t{}_{ij}=0$, therefore $$\begin{array}{c}
a_{11}b_{11}+\cdots+a_{1n}b_{n1}=a_{11}x_{1}+a_{12}x_{2}+\cdots+a_{1n}x_{n}=0\\
\cdots\cdots\\
a_{m1}b_{11}+\cdots+a_{mn}b_{n1}=a_{m1}x_{1}+a_{m2}x_{2}+\cdots+a_{mn}x_{n}=0
\end{array}$$
but $x_{1}=\cdots=x_{n}=0$, then  $b_{11}=\cdots=b_{n1}=0$.
this equity applies for every column of $B$, consequently, $B=0$.
But that's a contradiction to the fact that
$B\neq 0$, then we'll get a contradiction to the assumption, therefore there exists a non-trivial solution for
$Ax=0$, as wished.
It this correct?

A: If $B = [b_1,...,b_p] \neq 0$, there is some $i \in \{1,...,p\}$ such that $b_i \neq 0$. Then, by definition of the matrix product, $Ab_i = 0$.


Q: Dotnetnuke 6 Ribbonbar Admin and dropdown gone
Above is the ribbonbar after I have logged in as a super user. The Admin option next to Host is completely gone
The site is running DNN6, the skin is only in the site portal folder, and it seems that all admin modules and options have gone away. Even the header, which I set in Site Settings (under Admin), went away!
Has anyone else had their admin options completely disappear on them? Is it possible that the skin is messing it up (all other sites use the same _default menu files and they work fine)?
Thanks for any replies.

A: We've recently had this exact situation occur in one of our DNN sites. It turn out that one of the site's administrators had accidentally renamed the Admin page from within the "Page Management" section (it's easy to see how that could happen). The fix was to go directly to /Admin/Pages.aspx and change the "Page Name" back to "Admin" ... and it will show up in the ribbon bar again.
As a suggestion to DNN developers, I would recommend making the Admin page and its subpages impossible to rename....

A: Can you check the database to see if those pages exist? What if you try to navigate to http://website/admin.aspx do you see the admin page and all the child pages there?


Q: Is it possible to deploy a background Function "myBgFunctionInProjectB" in "project-b" and triggered by my topic "my-topic-project-a" from "project-a" It's possible to create a topic "my-topic-project-a" in project "project-a" so that it can be publicly visible (this is done by setting the role "pub/sub subscriber" to "allUsers" on it).
Then from project "project-b" I can create a subscription to "my-topic-project-a"  and read the events from "my-topic-project-a". This is done using the following gcloud commands:
(these commands are executed on project "project-b")
gcloud pubsub subscriptions create subscription-to-my-topic-project-a --topic projects/project-a/topics/my-topic-project-a
gcloud pubsub subscriptions pull subscription-to-my-topic-project-a --auto-ack

So ok this is possible when creating a subscription in "project-b" linked to "my-topic-project-a" in "project-a".
In my use case I would like to be able to deploy a background function "myBgFunctionInProjectB" in "project-b" and triggered by my topic "my-topic-project-a" from "project-a"
But ... this doesn't seem to be possible since gcloud CLI is not happy when you provide the full topic name while deploying the cloud function:
gcloud beta functions deploy myBgFunctionInProjectB --runtime nodejs8 --trigger-topic projects/project-a/topics/my-topic-project-a --trigger-event google.pubsub.topic.publish

ERROR: (gcloud.beta.functions.deploy) argument --trigger-topic: Invalid value 'projects/project-a/topics/my-topic-project-a': Topic must contain only Latin letters (lower- or upper-case), digits and the characters - + . _ ~ %. It must start with a letter and be from 3 to 255 characters long.

is there a way to achieve that or this is actually not possible?
Thanks

A: So, it seems that is not actually possible to do this. I have found it by checking it in 2 different ways:

*

*If you try to create a function through the API explorer, you will need to fill the location where you want to run this, for example, projects/PROJECT_FOR_FUNCTION/locations/PREFERRED-LOCATION, and then, provide a request body, like this one:

{
"eventTrigger": {
"resource": "projects/PROJECT_FOR_TOPIC/topics/YOUR_TOPIC",
"eventType": "google.pubsub.topic.publish"
},
"name":
  "projects/PROJECT_FOR_FUNCTION/locations/PREFERRED-LOCATION/functions/NAME_FOR_FUNTION
}

This will result in a 400 error code, with a message saying:

{
"field": "event_trigger.resource",
"description": "Topic must be in the same project as function."
}

It will also say that you missed the source code, but, nonetheless, the API already shows that this is not possible.

*

*There is an already open issue in the Public Issue Tracker for this very same issue. Bear in mind that there is no ETA for it.

I also tried to do this from gcloud, as you tried. I obviously had the same result. I then tried to remove the projects/project-a/topics/ bit from my command, but this creates a new topic in the same project that you create the function, so, it's not what you want.


Q: where can i find metadata of all the amazon cloud services? I searching for what are the metadata that AWS uses for each and every service. For AWS instance it uses ami-id, ami_launch-index, hostname, instance-action and many more as the metadata like wise where i can find metadata for all the services like EBS, VPN....
Reference
Information obtained from Amazon Elastic Compute Cloud User Guide for Microsoft Windows Instances pdf pg no : 232 – 242

A: I believe you are interested in knowing the properties of the each AWS Resource / Service and not the meta-data. I don't think there is a straight answer. The work around what I can recommend is using the AWS CloudFormation's Syntax definition of each AWS Resource.
For Example :
EC2 Instance is represented by the following syntax. Not all of them are mandatory. http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html
Look at the KEYS of the Key:Value pair provided below [ "AvailabilityZone" : String ]
{
   "Type" : "AWS::EC2::Instance",
   "Properties" : {
      "AvailabilityZone" : String,
      "BlockDeviceMappings" : [ EC2 Block Device Mapping, ... ],
      "DisableApiTermination" : Boolean,
      "EbsOptimized" : Boolean,
      "IamInstanceProfile" : String,
      "ImageId" : String,
      "InstanceInitiatedShutdownBehavior" : String,
      "InstanceType" : String,
      "KernelId" : String,
      "KeyName" : String,
      "Monitoring" : Boolean,
      "NetworkInterfaces" : [ EC2 Network Interface, ... ],
      "PlacementGroupName" : String,
      "PrivateIpAddress" : String,
      "RamdiskId" : String,
      "SecurityGroupIds" : [ String, ... ],
      "SecurityGroups" : [ String, ... ],
      "SourceDestCheck" : Boolean,
      "SsmAssociations" : [ SSMAssociation, ... ]
      "SubnetId" : String,
      "Tags" : [ Resource Tag, ... ],
      "Tenancy" : String,
      "UserData" : String,
      "Volumes" : [ EC2 MountPoint, ... ],
      "AdditionalInfo" : String
   }
}

For VPC [http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc.html]
{
   "Type" : "AWS::EC2::VPC",
   "Properties" : {
      "CidrBlock" : String,
      "EnableDnsSupport" : Boolean,
      "EnableDnsHostnames" : Boolean,
      "InstanceTenancy" : String,
      "Tags" : [ Resource Tag, ... ]
   }
}

For EBS Volume [http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html]
{
   "Type":"AWS::EC2::Volume",
   "Properties" : {
      "AutoEnableIO" : Boolean,
      "AvailabilityZone" : String,
      "Encrypted" : Boolean,
      "Iops" : Number,
      "KmsKeyId" : String,
      "Size" : String,
      "SnapshotId" : String,
      "Tags" : [ Resource Tag, ... ],
      "VolumeType" : String
   }
}

The CloudFormation Resource Page has details for most of the items [http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html]. Below is the current list as of today [7 Jan 2016]

*

*AWS::AutoScaling::AutoScalingGroup

*AWS::AutoScaling::LaunchConfiguration

*AWS::AutoScaling::LifecycleHook

*AWS::AutoScaling::ScalingPolicy

*AWS::AutoScaling::ScheduledAction

*AWS::CloudFormation::Authentication

*AWS::CloudFormation::CustomResource

*AWS::CloudFormation::Init

*AWS::CloudFormation::Interface

*AWS::CloudFormation::Stack

*AWS::CloudFormation::WaitCondition

*AWS::CloudFormation::WaitConditionHandle

*AWS::CloudFront::Distribution

*AWS::CloudTrail::Trail

*AWS::CloudWatch::Alarm

*AWS::CodeDeploy::Application

*AWS::CodeDeploy::DeploymentConfig

*AWS::CodeDeploy::DeploymentGroup

*AWS::CodePipeline::CustomActionType

*AWS::CodePipeline::Pipeline

*AWS::Config::ConfigRule

*AWS::Config::ConfigurationRecorder

*AWS::Config::DeliveryChannel

*AWS::DataPipeline::Pipeline

*AWS::DirectoryService::MicrosoftAD

*AWS::DirectoryService::SimpleAD

*AWS::DynamoDB::Table

*AWS::EC2::CustomerGateway

*AWS::EC2::DHCPOptions

*AWS::EC2::EIP

*AWS::EC2::EIPAssociation

*AWS::EC2::Instance

*AWS::EC2::InternetGateway

*AWS::EC2::NetworkAcl

*AWS::EC2::NetworkAclEntry

*AWS::EC2::NetworkInterface

*AWS::EC2::NetworkInterfaceAttachment

*AWS::EC2::PlacementGroup

*AWS::EC2::Route

*AWS::EC2::RouteTable

*AWS::EC2::SecurityGroup

*AWS::EC2::SecurityGroupEgress

*AWS::EC2::SecurityGroupIngress

*AWS::EC2::SpotFleet

*AWS::EC2::Subnet

*AWS::EC2::SubnetNetworkAclAssociation

*AWS::EC2::SubnetRouteTableAssociation

*AWS::EC2::Volume

*AWS::EC2::VolumeAttachment

*AWS::EC2::VPC

*AWS::EC2::VPCDHCPOptionsAssociation

*AWS::EC2::VPCEndpoint

*AWS::EC2::VPCGatewayAttachment

*AWS::EC2::VPCPeeringConnection

*AWS::EC2::VPNConnection

*AWS::EC2::VPNConnectionRoute

*AWS::EC2::VPNGateway

*AWS::EC2::VPNGatewayRoutePropagation

*AWS::ECS::Cluster

*AWS::ECS::Service

*AWS::ECS::TaskDefinition

*AWS::EFS::FileSystem

*AWS::EFS::MountTarget

*AWS::ElastiCache::CacheCluster

*AWS::ElastiCache::ParameterGroup

*AWS::ElastiCache::ReplicationGroup

*AWS::ElastiCache::SecurityGroup

*AWS::ElastiCache::SecurityGroupIngress

*AWS::ElastiCache::SubnetGroup

*AWS::ElasticBeanstalk::Application

*AWS::ElasticBeanstalk::ApplicationVersion

*AWS::ElasticBeanstalk::ConfigurationTemplate

*AWS::ElasticBeanstalk::Environment

*AWS::ElasticLoadBalancing::LoadBalancer

*AWS::IAM::AccessKey

*AWS::IAM::Group

*AWS::IAM::InstanceProfile

*AWS::IAM::ManagedPolicy

*AWS::IAM::Policy

*AWS::IAM::Role

*AWS::IAM::User

*AWS::IAM::UserToGroupAddition

*AWS::Kinesis::Stream

*AWS::KMS::Key

*AWS::Lambda::EventSourceMapping

*AWS::Lambda::Function

*AWS::Lambda::Permission

*AWS::Logs::Destination

*AWS::Logs::LogGroup

*AWS::Logs::LogStream

*AWS::Logs::MetricFilter

*AWS::Logs::SubscriptionFilter

*AWS::OpsWorks::App

*AWS::OpsWorks::ElasticLoadBalancerAttachment

*AWS::OpsWorks::Instance

*AWS::OpsWorks::Layer

*AWS::OpsWorks::Stack

*AWS::RDS::DBCluster

*AWS::RDS::DBClusterParameterGroup

*AWS::RDS::DBInstance

*AWS::RDS::DBParameterGroup

*AWS::RDS::DBSecurityGroup

*AWS::RDS::DBSecurityGroupIngress

*AWS::RDS::DBSubnetGroup

*AWS::RDS::EventSubscription

*AWS::RDS::OptionGroup

*AWS::Redshift::Cluster

*AWS::Redshift::ClusterParameterGroup

*AWS::Redshift::ClusterSecurityGroup

*AWS::Redshift::ClusterSecurityGroupIngress

*AWS::Redshift::ClusterSubnetGroup

*AWS::Route53::HealthCheck

*AWS::Route53::HostedZone

*AWS::Route53::RecordSet

*AWS::Route53::RecordSetGroup

*AWS::S3::Bucket

*AWS::S3::BucketPolicy

*AWS::SDB::Domain

A: Try using AWS CLI.
You can execute the describe commands of the various services to see and understand the metadata


Q: Dot/point in datagridview when updating data So, I have a datagridview (datagridview1) and it's connected to SQL Server. datagridview in column 3 (adhb) can be update by pressing a button and just edit in the specific column. The problem is when I try to update a decimal number (e.g 100.25) it's just change to 10025. How can it be able to update decimal value?
The database (tbl_tahunan), and column 3 (adhb) is set to decimal(18,2)
query for update data
query = "UPDATE tbl_tahunan SET adhb = " + datagridview1.Rows[0].Cells[2].Value + " WHERE id_coicop = 1";

cmd = new SqlCommand(query, conn);

cmd.ExecuteNonQuery();

A: Editing databases with data grids is ridiculously easy if you make life easy. Try doing this:

*

*Make a brand new project, so you don't disturb existing code

*Add a new file of type DataSet

*Open it by double clicking

*Right click anywhere on the surface, choose Add.. TableAdapter

*Fill in the connection details of the db

*Choose "SELECT that produces rows"

*Put a query of SELECT * FROM tbl_tahunan

*Finish the wizard

*Switch to the form

*Open the Data Sources tool panel (View menu, Other Windows submenu)

*Expand the nodes in the name of your dataset

*Drag the tbl_tahunan one onto the form

*Run the program

Yes, that's it, not a single line of code written by you; VS has done it all (and made a better job of it too) and this simple app will download, display, edit and save rows. And I bet it won't have any decimal problems either..
You can look at how it works by reading the code in .Designer.cs files: the datagridview is connected to a datatable (tbl_tahunandatatable) through a bindingSource. When you fill the table with data, you will see the grid show the data automatically. You do not need to interact with the datagridview cells collection. All programmatic editing of data should be done to the datatable. This is a concept called MVC (model- the datatable, view - the datagridview, controller - sometimes the datagridview in editing mode, other times something else) - keeping M separate from VC usually helps build a sensible program structure
You can build on this simple app you've created by e.g.:

*

*opening dataset,

*right clicking on the TableAdapter,

*adding another query,

*add a query with some relevant where clause (llike SELECT * FROM tbl_tahunan WHERE adhb BETWEEN @from AND @to)

*call it a good name, like FillByAdhbBetween

*putting some text boxes in the UI

*putting a button on the ui that calls it:

tbl_tahunanTableAdapter.FillByAdhbBetween(somedatasetname.tbl_tahunan, Convert.ToDecimal(adhbfromTextbox.Text), Convert.ToDecimal(adhbtoTextbox.Text))

Now the grid will only fill with some rows instead of all
Personally I always make the first query in a table adapter have a WHERE clause, that selects by primary key. It is handy for loading related data. We almost never want to select all rows from a db into our program


Q: How do I import a sprite sheet with its JSON file into my phaser game? I am creating a game using the phaser game engine. I created a sprite sheet and downloaded it. It came with the 256 × 384 .png file with my frames and a JSON file which I assume contains information about how to split up the frames. I don't know how to import the sprite sheet with the JSON file into my preload() function. I tried using the following code but it is not working. Any help would be greatly appreciated.
var game = new Phaser.Game(1200, 750, Phaser.AUTO, '', { preload:   preload, create: create, update: update });
function preload(){
    game.load.image('background', 'assets2/background.png');
    game.load.json('robot', 'assets2/VillainSpriteSheet_json.json');
    game.load.spritesheet('robot', 'assets2/VillainSpriteSheet.png');
}

var villain;

function create(){

var villainjson = game.cache.getJSON('robot');

//enable physics
game.physics.startSystem(Phaser.Physics.ARCADE);

//create background
var background = game.add.sprite(0, 0, 'background');

//villain
villain = game.add.sprite(50, 50, 'robot');

//enable phsyics
game.physics.arcade.enable(villain);
villain.body.bounce.y = .2;
villain.body.gravity.y = 300;
villain.body.collideWorldBounds = true;

}

A: I think you are confusing two frameworks, jQuery and Phaser. For loading and displaying sprites you don't need jQuery, just Phaser will do.
The load.spritesheet expects a spritesheet where all sprites have a fixed width and height, so with all sprites in a grid layout.
What you have sounds like a spriteatlas, the difference being that in a spriteatlas each sprite can have a different width and height, and all these widths and heights per sprite are described in the accompanying .JSON file.
So I think you are looking for the load.atlasJSONHash function, something like this:
function preload(){
    //..
    game.load.atlasJSONHash('robot', 'assets2/VillainSpriteSheet.png', 'assets2/VillainSpriteSheet_json.json');

// and then load a sprite like so
// Note: 'myframename1' should be some framename from the .json file
var villain = game.add.sprite(50, 50, 'robot', 'myframename1');

And btw just to clarify, the load.json in Phaser can be used to just load a .json file, for example with for your own customised data like level layouts, dialog/multilanguage texts, highscore data, enemy patterns etc.

A: You don't want jQuery's getJSON(). You want the Phaser one.
It would be something like
p = new Phaser.Game(...);
p.cache.getJSON('foo');
p.load.image(...);


Q: Linux Mint not using full screen, menubar gone I seem to have entered some strange "mode" in Linux Mint 18 Cinnamon that I don't know how to exit. It persists between reboots.
This results in the following changes:

*

*The desktop is only usable in the upper left

*No keyboard shortcuts seem to work

*The menubar is gone

*Window top bars is gone

*A white box appears when typing outside a window

*A strange cursor

I can temporarily fix this with
cinnamon --replace

which gives the following output

Cjs-Message: JS LOG: About to start Cinnamon
  St-Message: cogl npot texture sizes SUPPORTED
  Cjs-Message: JS LOG: Cinnamon started at Wed Sep 21 2016 12:28:46 GMT+0200 (CEST)
  Cjs-Message: JS LOG: network applet: Cannot find connection for active (or connection cannot be read)
  openGL version 3.3 detected (GL3 Cogl Driver)
  MetaSyncRing disabled: couldn't find required GL extensions, or the minimum safe openGL version was not met
  Cjs-Message: JS LOG: Invalid network device type, is 14
  Cjs-Message: JS LOG: network applet: Found connection for active

and reverts if closed.
I think the problem happened when I had some problems with TeamViewer but I've tried uninstalling TeamViewer with sudo dpkg --purge --force-all teamviewer:i386 but that doesn't seem to change anything.
What is this "mode", and how do I fix it?

I couldn't get a good screenshot that fully shows the problem, so I took some photos instead.


Q: how to sum up minutes and seconds ?in oracle I have a column called duration_d which is varchar2 and the data in that table looks like below
duration_d
-----------
12:25
01:35
12:10
04:21
12:18
12:24

I tried below query
SELECT SUM( to_date( duration_d, 'mi:ss' ))
  FROM table
 GROUP BY calling_number;

When I execute it following error is coming
ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"

can any one tell me how to make sum it?

A: To get the total as fractions of a day you can use:
SELECT SUM( TO_DATE( duration_d, 'MI:SS' ) - TO_DATE( '00:00', 'MI:SS' ) ) AS total
FROM   your_table

Which gives the result:
TOTAL
------------------------------------------
0.0383449074074074074074074074074074074074

To convert this to an interval data type you can use NUMTODSINTERVAL:
SELECT NUMTODSINTERVAL(
         SUM( TO_DATE( duration_d, 'MI:SS' ) - TO_DATE( '00:00', 'MI:SS' ) ),
         'DAY'
       ) AS total
FROM   your_table

Which gives the result:
TOTAL
-------------------
+00 00:55:13.000000

A: Please try below:
with x as
(select sum((regexp_substr(YOUR_COLUMN, '[0-9]+', 1, 1)*60) +
             regexp_substr(id, '[0-9]+', 1, 2)) seconds
from YOUR_TABLE)
SELECT
    TO_CHAR(TRUNC(seconds/3600),'FM9900') || ':' ||
    TO_CHAR(TRUNC(MOD(seconds,3600)/60),'FM00') || ':' ||
    TO_CHAR(MOD(seconds,60),'FM00')
FROM x

Will work only if the duration is always [MI:SS].
Also you can add the group by as per your requirement.
Converting Seconds to the required duration format Reference.
Group By
with x as
(select calling_number,sum((regexp_substr(YOUR_COLUMN, '[0-9]+', 1, 1)*60) +
             regexp_substr(id, '[0-9]+', 1, 2)) seconds
from YOUR_TABLE
group by calling_number)
SELECT calling_number,
    TO_CHAR(TRUNC(seconds/3600),'FM9900') || ':' ||
    TO_CHAR(TRUNC(MOD(seconds,3600)/60),'FM00') || ':' ||
    TO_CHAR(MOD(seconds,60),'FM00')
FROM x

A: Use a combination of SUBSTR, to_char, to_date, NVL, INSTR, reverse and SUM.
SELECT "calling_number",
to_char(to_date(SUM(NVL(SUBSTR("duration_d", 0, INSTR("duration_d", ':')-1), "duration_d"))*60 +
SUM(substr("duration_d", - instr(reverse("duration_d"), ':') + 1)),'sssss'),'hh24:mi:ss') AS SUM_DURATION_D
FROM yourtable
GROUP BY "calling_number"

Output
calling_number  SUM_DURATION_D
1               00:26:10
2               00:29:03

SQL Fiddle: http://sqlfiddle.com/#!4/9b0a81/33/0

A: Correct spelling as below
SELECT SUM( TO_DATE( duration_d, 'mi:ss' ) )
 FROM YOURTABLE Group By calling_number


Q: PHP:checked attribute in array of checkboxes I have an array like this
$current_asset = [
    ['name'=>'Land,'id'=>1],
    ['name'=>'Building ,'id'=>2],
    ['name'=>'Machinery','id'=>3],
];

<?php
 foreach($current_asset as $key=>$value){ ?>
 <input type="checkbox" name="current_asset[]" value="<?php echo $value['id'] ?>">

 <?php } ?>

My question how can I add checked attribute in if one of the value is checked when the form populated with the POST data
I am getting the checkbox array like this on form submit
Here are the current checkboxes on form submit (ie values of current_asset)
Array(
    0=>1
    1=>1
   )

A: You would need to do some kind of check before printing
$html=‘’;
foreach($current_asset as $asset) {
 if($asset[‘hasBeenCheckedBefore’]) {
  $checked = ‘checked’;
 } else {
  $checked = ‘’;
 }
 $html .= “$asset[‘name’] <input type=‘checkbox’ name=‘current_asset[]’ value=‘$asset[“id”]’ $checked />”;
}

A: Here is an example of one way to do it.  I have changed your data structure to be easier to use. I was confused initially because you didn't mention any way to store data.  So this is only good for the one page view.
<?php

// initialize data

/**
 * Data structure can make the job easy or hard...
 *
 * This is doable with array_search() and array_column(),
 * but your indexes might get all wonky.
 */
$current_asset = [
    ['name'=>'Land','id'=>1],
    ['name'=>'Building' ,'id'=>2],
    ['name'=>'Machinery','id'=>3],
];

/**
 * Could use the key as the ID.  Note that it is being
 * assigned as a string to make it associative.
 */
$current_asset = [
    '1'=>'Land',
    '2'=>'Building',
    '3'=>'Machinery',
];

/**
 * If you have more information, you could include it
 * as an array.  I am using this setup.
 */
$current_asset = [
    '1'=> ['name' => 'Land',      'checked'=>false],
    '2'=> ['name' => 'Building',  'checked'=>false],
    '3'=> ['name' => 'Machinery', 'checked'=>false],
];

// test for post submission, set checked as appropriate
if(array_key_exists('current_asset', $_POST)) {
  foreach($_POST['current_asset'] as $key => $value) {
    if(array_key_exists($key,$current_asset)) {
      $current_asset[$key]['checked'] = true;
    }
  }
}

// begin HTML output
?>
<html>
  <head>
    <title></title>
  </head>
  <body>

    <!-- content .... -->

    <form method="post">
    <?php foreach($current_asset as $key=>$value): ?>
      <?php $checked = $value['checked'] ? ' checked' : ''; ?>
      <label>
        <input type="checkbox" name="current_asset[<?= $key ?>]" value="<?= $key ?>"<?= $checked ?>>
        <?= htmlentities($value['name']) ?>
      </label>
    <?php endforeach; ?>
    </form>

  <body>
</html>


Q: Vbox Parent, Pane Child overlapping other components javafx Hey all I am new to java and javafx trying to learn them. I am currently trying to do a problem where the user inputs values for two circles (the center and radius of circle). It is supposed to then show the circles, and display what they are doing, such as they are equal, one is contained in the other, etc.
To do this I used a vbox, and I am attempting to draw the circles using a pane, and implementing the pane into the vbox.  Here is my code:
 public class Shapes extends Application {

  @Override
  public void start(Stage stage) {

  createTextField();
  VBox root = new VBox();
  root.setSpacing(10);
  Pane pane = new Pane();
  Color blue = new Color(1,0,0,1);
  Color red = new Color(0,0,1,1);
  Circle circle1 = createCircle(50, 50, 50, red);
  Circle circle2 = createCircle(50, 50, 200, blue);
  pane.getChildren().addAll(circle1, circle2);
  root.getChildren().addAll(label0, label1, label2, tField, label3, label4, pane);
  Scene scene = new Scene(root, 1000 , 1000);
  stage.setTitle("Spatial Relations Demo by");
  stage.setScene(scene);
  stage.show();
  }

  public static void main(String[] args) {
  Application.launch(args);
  }

  Label label0, label1, label2, label3, label4;
  TextField tField;

  public void createTextField()
  {
   label0 = new Label();
   label0.setText("Spatial Relations Demo");

   label1 = new Label();
   label1.setText("                              ");
   label1.setTextAlignment(TextAlignment.CENTER);

   label2 = new Label();
   label2.setText("Input Circles: x1 y1 r1 x2 y2 r2 ");
   label2.setTextAlignment(TextAlignment.CENTER);

   label3 = new Label();
   label3.setTextAlignment(TextAlignment.CENTER);

   label4 = new Label();
   label4.setTextAlignment(TextAlignment.CENTER);

  tField = new TextField();
  tField.setOnAction(new TextFieldHandler());
 }

  public class TextFieldHandler implements EventHandler<ActionEvent> {
  public void handle( ActionEvent e)
  {
  String str = tField.getText();
  int x1, y1, r1, x2, y2, r2;

  Scanner scanner = new Scanner(str);
  x1 = scanner.nextInt();
  y1 = scanner.nextInt();
  r1 = scanner.nextInt();

  x2 = scanner.nextInt();
  y2 = scanner.nextInt();
  r2 = scanner.nextInt();

  tField.setText( "" );
  String str1 = str.format("Input is: " + x1 + " " + y1 + " " + r1 + " " + x2 + " " + y2 + " " + r2);
  label3.setText(str1);

 double d = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

 if ((x1==x2) & (y1==y2) & (r1==r2))
   label4.setText( " The circles are equal.");
 else if (d >= (r1+r2))
   label4.setText( " The circle interiors are disjoint.");
 else if (d <= (r2-r1))
   label4.setText( " Circle1 is inside Circle2.");
 else if (d <= (r1-r2))
   label4.setText( " Circle2 is inside Circle1.");
 else
   label4.setText( " The circles overlap.");
}
}

 public Circle createCircle(int x, int y, int r, Color color)
  {
    Circle circle = new Circle();
    circle.setRadius(r);
    circle.setCenterX(x);
    circle.setCenterY(y);
    circle.setStroke(color);
    circle.setFill(null);

    return circle;
  }

}

As of right now I just have implemented some test numbers to draw the circles, but I am still trying to figure out how to get the user inputted numbers as my circle parameters. I was not sure how to get the pane to work properly. Any tips or advice would be greatly appreciated thanks! I tried to post an image to show my output but I guess I dont have enough reputation for it. My circles are overlapping everything instead of staying below the labels and textfield. I cant seem to figure out how to keep them below those items in the vbox.

A: Your red circle (the one with the color you called blue ;) ) has bounds that extend into negative coordinate ranges in both x- and y-directions (it has center (50, 50) and radius 200). Hence it extends beyond the bounds of the pane.
If you want to make sure the pane doesn't paint outside of its bounds, you can set a clip that is bound to its size:
    Rectangle clip = new Rectangle(0, 0, 0, 0);
    clip.widthProperty().bind(pane.widthProperty());
    clip.heightProperty().bind(pane.heightProperty());
    pane.setClip(clip);

To update the circles, you just have to make them instance variables instead of local to the start method, and update their centers and radii:
import java.util.Scanner;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;

public class Shapes extends Application {

    private Label label0, label1, label2, label3, label4;
    private TextField tField;

    private Circle circle1 ;
    private Circle circle2 ;

    @Override
    public void start(Stage stage) {

        createTextField();
        VBox root = new VBox();
        root.setSpacing(10);
        Pane pane = new Pane();
        Color blue = new Color(1, 0, 0, 1);
        Color red = new Color(0, 0, 1, 1);
        circle1 = createCircle(50, 50, 50, red);
        circle2 = createCircle(50, 50, 200, blue);
        pane.getChildren().addAll(circle1, circle2);

        // If desired:

        // Rectangle clip = new Rectangle(0, 0, 0, 0);
        // clip.widthProperty().bind(pane.widthProperty());
        // clip.heightProperty().bind(pane.heightProperty());
        // pane.setClip(clip);

        root.getChildren().addAll(label0, label1, label2, tField, label3,
                label4, pane);
        Scene scene = new Scene(root, 1000, 1000);
        stage.setTitle("Spatial Relations Demo by");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }

    public void createTextField() {
        label0 = new Label();
        label0.setText("Spatial Relations Demo");

        label1 = new Label();
        label1.setText("                              ");
        label1.setTextAlignment(TextAlignment.CENTER);

        label2 = new Label();
        label2.setText("Input Circles: x1 y1 r1 x2 y2 r2 ");
        label2.setTextAlignment(TextAlignment.CENTER);

        label3 = new Label();
        label3.setTextAlignment(TextAlignment.CENTER);

        label4 = new Label();
        label4.setTextAlignment(TextAlignment.CENTER);

        tField = new TextField();
        tField.setOnAction(new TextFieldHandler());
    }

    public class TextFieldHandler implements EventHandler<ActionEvent> {
        @Override
        public void handle(ActionEvent e) {
            String str = tField.getText();
            int x1, y1, r1, x2, y2, r2;

            Scanner scanner = new Scanner(str);
            x1 = scanner.nextInt();
            y1 = scanner.nextInt();
            r1 = scanner.nextInt();

            x2 = scanner.nextInt();
            y2 = scanner.nextInt();
            r2 = scanner.nextInt();

            circle1.setCenterX(x1);
            circle1.setCenterY(y1);
            circle1.setRadius(r1);
            circle2.setCenterX(x2);
            circle2.setCenterY(y2);
            circle2.setRadius(r2);

            tField.setText("");
            String str1 = String.format("Input is: " + x1 + " " + y1 + " " + r1
                    + " " + x2 + " " + y2 + " " + r2);
            label3.setText(str1);

            double d = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

            if ((x1 == x2) & (y1 == y2) & (r1 == r2))
                label4.setText(" The circles are equal.");
            else if (d >= (r1 + r2))
                label4.setText(" The circle interiors are disjoint.");
            else if (d <= (r2 - r1))
                label4.setText(" Circle1 is inside Circle2.");
            else if (d <= (r1 - r2))
                label4.setText(" Circle2 is inside Circle1.");
            else
                label4.setText(" The circles overlap.");

            scanner.close();
        }
    }

    public Circle createCircle(int x, int y, int r, Color color) {
        Circle circle = new Circle();
        circle.setRadius(r);
        circle.setCenterX(x);
        circle.setCenterY(y);
        circle.setStroke(color);
        circle.setFill(null);

        return circle;
    }

}


Q: Getting ongoing recording data segments from AVAudioRecorder My problem is as follows:
I need to capture every 320 bytes of raw audio data.
I do this by using an NSTimer that fires a method every 0.02 seconds - that is because i need to record 8000Hz and 16bit mono audio, and i've calculated that it should be 50x a second (8000 * 16 / 320 / 8).
So, knowing that the AVAudioRecorder saves to a file, i can get every 320 bytes from that file by [[NSData dataWithContentsOfURL:[audioRecorder url]] subdataWithRange:NSMakeRange(bytesUsed, 320)], but the thing that has confused me, is that the moment i start the recording, the data files size is 4096 bytes and then after 0.5 seconds, it's 9424 bytes and increases by around 5,3k bytes every half a second.
So i'm confused if i'm getting the right data and thinking that the settings might be wrong.
Current settings for AVAudioRecorder are:
[NSNumber numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithInt:16], AVLinearPCMBitDepthKey,
[NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16], AVEncoderBitRateKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithFloat:8000.0], AVSampleRateKey,

So the main problem is:
What settings should i use?
Is this the right way to go about getting segments from an ongoing audio recording?
I apologize for the bad explanation, do ask questions to help me make it more understandable.


Q: Finding an HTTP bottleneck I'm developing a custom Blog application in Ruby on Rails, having load speed as a primary measure of success.
I'm caching (with Redis) both views and models to shorten up queries and rendering of raw HTML. Finally I succeeded loading a single post in under 15ms. Time to deploy.
I bought a Linode 20$/month machine with 2gb ram, 2 cores, ssd storage, 40gbit in, 250mbit out. The machine is hosted in London. I installed Ubuntu 15.04.
I set up Cloudflare free plan for more aggressive caching and minification of assets. I enabled the Full SSL functionality.
I installed nginx as a proxy to the Rails application running on Unicorn. Rails, Redis, PostgreSQL and nginx run on the same server.
I am in Rome, Italy. The nearest Cloudflare datacenter is in Milan, while the origin Linode server is in London. The average request time (as reported by the chrome network panel) is 230ms. Whops...
So first of all I checked out the Rails logs, and the log reported times (and the X-Runtime header) where consistent with my development data (< 20ms).
I edited nginx configuration to add an X-Time header:
add_header X-Time $request_time;

And that shows just a few ms over the Rails timings.
Then I enabled direct access to the server (disabled Cloudflare) and disabled SSL to remove the handshake overhead.
So I finally found that with or without Cloudflare, with or without SSL, load times where always quite random in the range [180-350]ms, with no apparent explaination.
Here's a shot of the Chrome timing panel, without both Cloudflare and SSL. Just a raw HTTP connection directly on port 80 of the nginx server.

Why am I seeing such high times on a blazing fast application? What should I check next? Is the Linode server my bottleneck?
Thanks
Edit
It looks like gzip compression as enabled by default by nginx was slowing the whole thing down by a 30%. I have now disabled it since Cloudflare will gzip it anyway in a second step. Now request times are between 120 and 200ms but I still feel like it could be improved.


Q: Way to slice a string using 2 variable? I m new to programming and came across a question If I have a string where I have 2 variables indexed.. and need the value from the middle.
for example, my string is HeyEveryoneImtryingtolearnpythonandihavequestion
where I have variables
V1 = 'Imtrying'
V2 = 'andihave'

what can I do to get the "learnpython" substring? or is it not valid?

A: You can use index and slicing:
s = 'HeyEveryoneImtryingtolearnpythonandihavequestion'

v1 = 'Imtrying'
v2 = 'andihave'

start = s.index(v1) + len(v1)
end = s.index(v2, start)

output = s[start:end]
print(output) # tolearnpython

A: You can also use regex:
import re

s = "HeyEveryoneImtryingtolearnpythonandihavequestion"
V1 = 'Imtryingto'
V2 = 'andihave'

a = re.search(f"{re.escape(V1)}(.*?){re.escape(V2)}", s).group(1) # 'learnpython'


Q: Symfony: Overriding Symfony service ( compiler pass ) I'm on symfony 2.7 and need to override Symfony\Component\Asset\UrlPackage
I've looked at http://symfony.com/doc/current/cookbook/bundles/override.html
and http://symfony.com/doc/current/cookbook/service_container/compiler_passes.html
but can't get it working.
I have made a file in my bundle MyApp\CoreBundle\Overrides\UrlPackage;
I registered UrlPackage as a service and added a function:
public function process(ContainerBuilder $container)
{
    $definition = $container->getDefinition('assets.url_package');
    $definition->setClass('MyApp\CoreBundle\Overrides\UrlPackage');
}

The weird thing is, if I call $this->has('assets.url_package') in any controller, it returns false.
I did grab it from the services file under Symfony:
<service id="assets.url_package" class="Symfony\Component\Asset\UrlPackage" abstract="true">
        <argument /> <!-- base URLs -->
        <argument type="service" /> <!-- version strategy -->
        <argument type="service" id="assets.context" />
    </service>

If I run php app/console debug:container, the UrlPackage from symfony isn't in there, but, if I change something inside the vendor/*/UrlPackge file, it does work
Can someone point me in the right direction?

A: Decorating the service is the thing you're looking for:
bar:
    public: false
    class: stdClass
    decorates: foo
    arguments: ["@bar.inner"]

You can inject the original service in your own service, and implement the original interface to make them compatible.
http://symfony.com/doc/2.7/service_container/service_decoration.html

A: Symfony 5.1+
Symfony 5.1+ provide a simpler service decoration:

In previous Symfony versions you needed to use the syntax decorating
service ID + .inner to refer to that service. This quickly becomes
cumbersome in YAML/XML when using PHP classes as service IDs. That's
why in Symfony 5.1 we've simplified this feature to always use .inner
to refer to the original service.
@source: https://symfony.com/blog/new-in-symfony-5-1-simpler-service-decoration

# config/services.yaml

services:
    App\MyService: ~

    # Before
    App\SpecialMyService:
        decorates: App\MyService
        arguments: ['@App\SpecialMyService.inner']

    # After
    App\SpecialMyService:
        decorates: App\MyService
        arguments: ['@.inner'] # <--- the service ID is no longer needed


Q: C++ - Are there ways to get current class type with invariant syntax? I want to write a macro which, when expanded within a class, uses that class type (specifically, as template argument). Within class method, I can use this:
#define METHOD_MACRO int sample_method(void)const {\
    return template_struct<this_type<decltype(this)>::type>::index;}

(this_type is my struct, here it's equivalent to remove_pointer<remove_const<T>>)
But when I need class type outside of method (for typedef for class member pointer), this keyword isn't available; I've tried to use auto for some trick with deducing type, but no luck here.
Classes in question are inherited from my class, if this can be of any help. I would like to avoid anyone using my macro having to write obligatory typdedef.
Any ideas?

A: You can use the following trick:
#define SELF \
    static auto helper() -> std::remove_reference<decltype(*this)>::type; \
    typedef decltype(helper()) self

struct A {
    SELF;
};

I declare a helper function using the auto return type, which allows me to use decltype(*this) as a return type, not knowing what is the class name. Then I can use decltype(helper()) to use the class type in the code. Note that the function has to be static, otherwise you can not use it in decltype. Also the function is just declared, not defined; this should not be a problem as you are not going to call it anyway. (You can add an empty body to it, but it will raise a warning that a function has no return. Still you may change the return type to be decltype(this) and return nullptr.)
You may then use the self typedef for further declarations, or just alter the macros to typedef not the class itself, but what you need to. Adjust it to suit your particular need.
UPD: This seems to be a non-standard behavior of GCC. For example, ICC does not allow this in static functions even in trailing return type.


Q: add icon to wpform submit button hi i want to make the form button same like in the image.
the link of the form is this
http://ministerievanlicht.com/contact/
the code is this that will get the button same to same but it not worked.

.button {
  margin: 0 auto;
  text-decoration:none;
  text-align:center;
  display: flex;
  background: #333333;
  color: white;
  justify-content: space-between;
  align-items: center;
  pointer-events:none;
  max-width:660px;
  border-bottom:solid gray 1px
    font-family: DIN pro;
    font-weight: bold;
}
.button .fa {
  padding:1em;
  pointer-events:auto;
  width:1.5em;
}
.button::before {
  content: '';
  padding: 1em
}

and here is the custom css is this
i want to add icon at the end of the button
div.wpforms-container-full .wpforms-form input[type=date], div.wpforms-container-full .wpforms-form input[type=datetime], div.wpforms-container-full .wpforms-form input[type=datetime-local], div.wpforms-container-full .wpforms-form input[type=email], div.wpforms-container-full .wpforms-form input[type=month], div.wpforms-container-full .wpforms-form input[type=number], div.wpforms-container-full .wpforms-form input[type=password], div.wpforms-container-full .wpforms-form input[type=range], div.wpforms-container-full .wpforms-form input[type=search], div.wpforms-container-full .wpforms-form input[type=tel], div.wpforms-container-full .wpforms-form input[type=text], div.wpforms-container-full .wpforms-form input[type=time], div.wpforms-container-full .wpforms-form input[type=url], div.wpforms-container-full .wpforms-form input[type=week], div.wpforms-container-full .wpforms-form select, div.wpforms-container-full .wpforms-form textarea {
    padding: 18px 0px 18px 26px;
}
div.wpforms-container-full .wpforms-form .wpforms-field-label {
    font-family: 'DIN PRO';
    font-style: normal;
    font-weight: normal;
    font-size: 12px;
    line-height: 24px;
    color: #333333;
    opacity: 1.0;
}
div.wpforms-container div.wpforms-uploader {
    width: 330px;
    height: 193px;
}
div.wpforms-container-full .wpforms-form input[type=checkbox], div.wpforms-container-full .wpforms-form input[type=radio] {
    width: 21px;
    height: 21px;
}
div.wpforms-container-full .wpforms-form input[type=submit], div.wpforms-container-full .wpforms-form button[type=submit], div.wpforms-container-full .wpforms-form .wpforms-page-button {
    background-color: #eee;
    border: 1px solid #ddd;
    color: #333;
    font-size: 1em;
    padding: 10px 330px;
    text-decoration: none;
    text-align: center;
    display: flex;
    background: #333333;
    color: white;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
        width: 660px;
    height: 55px;
    border-bottom: solid gray 1px; font-family: DIN pro;
    font-weight: bold;
}

A: I have prepared two icon buttons for you. One works with a hover and the other without a hover.

.btn {
  background-color: #333333;
  border: none;
  color: white;
  padding: 12px 16px;
  font-size: 16px;
  cursor: pointer;
  height: 60px;
  margin: 10px;
  position: relative;
  width: 660px;
  border-bottom: solid gray 1px
}

/* Darker background on mouse-over */

.btn:hover {
  background-color: #444444;
}

.btn .ic-line {
  width: 1px;
  height: 60px;
  background: #ddd;
  float: right;
  position: absolute;
  right: 60px;
  top: 0;
}

.fa-custom {
  float: right;
  position: absolute;
  right: 20px;
  top: 22px;
  font-size: 1.1rem;
  color: #fff;
}

.btn .ic-line1 {
  width: 1px;
  height: 60px;
  background: #ddd;
  float: right;
  position: absolute;
  right: 60px;
  top: 0;
  visibility: hidden;
}

.fa-custom1 {
  float: right;
  position: absolute;
  right: 20px;
  top: 22px;
  font-size: 1.1rem;
  visibility: hidden;
  color: #fff;
}

.btn:hover .ic-line1 {
  visibility: visible;
}

.btn:hover .fa-custom1 {
  visibility: visible;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

Icon Buttons

Icon buttons:

<button class="btn">Send</button>

Icon Buttons When hover

Icon buttons:

<button class="btn">Send</button>


Q: How to add my output from a "FOR" Loop and sum together I am a beginner, so I want to ask that how to sum my "FOR" loop value from my input form? and the GrandTotal is used to change it "readonly" textbox in my form.
let grandTotal = 0;
for(let i = 1; i <= 5; ++i) {
  grandTotal += parseInt(document.getElementById("Total" + i).value);
}
grandTotal = document.getElementById("GrandTotal").value;

This is one part of my HTML\

  1
  <input type="text" id="BookTitle" name="BookTitle" size="30" >
  <input type="text" id="Author" name="Author" size="10">
  <select id="Category" name="Category">
    <option value="Please choose the categoty...">Please choose the Category...</option>
    <option value="Business">Business</option>
    <option value="Fiction">Fiction</option>
    <option value="Mathematics">Mathematics</option>
    <option value="Technology">Technology</option>
    </select>
  <input type="text" class="UnitPrice" id="UnitPrice1" name="Unit Price" step="0.01" value="0.00" placeholder="0.00" onkeypress="return forNumberOnly(event)">
  <input type="text" class="Quantity" id="Quantity1" name="Quantity" value="0" min="0" onkeypress="return forNumberOnly(event)">
  <input type="text" id="Total1" name="Total" value="0.00"  readonly>

A: Have a look at this - I use the selector [name=Total] because it makes more sense than [id^=Total]
I delegate the change to the tbody:

document.getElementById("tb").addEventListener("change", function(e) {
  const tgt = e.target;
  const parent = tgt.closest("tr");
  const up  = +parent.querySelector(".UnitPrice").value || 0
  const qty = +parent.querySelector(".Quantity").value || 0
  parent.querySelector("[name=Total]").value = (up * qty).toFixed(2);

  const grandTotal = [...document.querySelectorAll("[name=Total]")] // all total
    .map(ele => +ele.value) // get each value and convert to number
    .reduce((a, b) => a + b); // sum them
  document.getElementById("GrandTotal").value = grandTotal; // assign to a field
})

      1
      <input type="text" id="BookTitle" name="BookTitle" size="30">
      <input type="text" id="Author" name="Author" size="10">

        <select id="Category" name="Category">
          <option value="Please choose the categoty...">Please choose the Category...</option>
          <option value="Business">Business</option>
          <option value="Fiction">Fiction</option>
          <option value="Mathematics">Mathematics</option>
          <option value="Technology">Technology</option>
        </select>

      <input type="text" class="UnitPrice" id="UnitPrice1" name="Unit Price" step="0.01" value="0.00" placeholder="0.00">
      <input type="text" class="Quantity" id="Quantity1" name="Quantity" value="0" min="0">
      <input type="text" id="Total1" name="Total" value="0.00" readonly>

      1
      <input type="text" id="BookTitle" name="BookTitle" size="30">
      <input type="text" id="Author" name="Author" size="10">

        <select id="Category" name="Category">
          <option value="Please choose the categoty...">Please choose the Category...</option>
          <option value="Business">Business</option>
          <option value="Fiction">Fiction</option>
          <option value="Mathematics">Mathematics</option>
          <option value="Technology">Technology</option>
        </select>

      <input type="text" class="UnitPrice" id="UnitPrice2" name="Unit Price" step="0.01" value="0.00" placeholder="0.00" onkeypress="return forNumberOnly(event)">
      <input type="text" class="Quantity" id="Quantity2" name="Quantity" value="0" min="0" onkeypress="return forNumberOnly(event)">
      <input type="text" id="Total2" name="Total" value="0.00" readonly>

<input type="text" readonly id="GrandTotal" />


Q: What should I type in python to open a file located on my desktop when using a Mac? When I opened a .txt file located in a folder called scripts on my h-drive using Windows I typed this:
F = open('h:\\scripts\\data.txt')

I copied the file to a USB drive (n:) and now I want to access this file by using Python on a macbook. I typed this:
P = open('n:\\data.txt')

But I keep getting the following error:
IOError: [Errno 2] No such file or directory: 'data.txt'

So I guess I need to use a different way of specifying pathways to folders when using Python on a Macbook?
Thank you for the replies, sorry for asking the original question without explaining it properly, but as you can tell I am completely new to coding.

A: If by open you mean that you want to get a file() object back, then:
import os
filename = "Your_file.something"
username = os.environ["USER"]
f = open(os.path.join("/Users", username, "Desktop", filename), <mode>)

But there should be a $HOME variable present which will give you the real home folder even if it is not named as the user:
f = open(os.path.join(os.environ["HOME"], "Desktop/Your_file.something"), <mode>)

That is if shell alias for home folder won't work:
f = open("~/Desktop/Your_file.something", <mode>)

BTW, <mode> is of course the mode you wish to open your file in ("r", "w", "rb", "wb", "a", "ab", etc.)


Q: Writing tab spaced words to a file in Python I have a set of words in a file. I want to add a new character separated by tab to all these words and write to a new file.
The code I wrote is
#file to read is opened as ff and file to write is opened as fw.
count = "X"
x = ff.readlines()
for word in x:
     fw.write('%s\t%s'% (word, count))
     fw.write("\n")

The problem is the new word 'X' is not alignment with the existing words. The sample output i am getting is
 A.
      O
 Mahesh
      O
 Anand
      O
 Anton
      O
 Plot

The output I want is:
Original File
word
word2

New File
word    X
word2    X

I want it to be aligned properly

A: readlines() includes the end of line characters:
In [6]: ff.readlines()
Out[6]: ['word1\n', 'word2']

You need to strip them off:
word = word.rstrip()

count = "X"
with open('data', 'r') as ff, open('/tmp/out', 'w') as fw:
    for word in ff:
        word = word.rstrip()  # strip only trailing whitespace
        fw.write("{}\t{}\n".format(word, count))

A: use str.rstrip() as to remove end of line \n.
use context manager with statement to open the file,
and use str.formate to write in file.
with open('out_file.txt') as ff, open('in_file.txt', 'w+') as r:
    for line in ff:
        r.write('{}\t{!r}\n'.format(line.rstrip(), 'X'))
    r.seek(0)
    print r.read()

>>>
   word1    'X'
   word2    'X'
   word3    'X'
   word4    'X'

A: you should remove '\n':
count = "X"
with open('data', 'r') as ff, open('/tmp/out', 'w') as fw:
    for word in ff.readlines():
        print >> fw, '%s\t%s' % (word.rstrip(), count)


Q: Column name checking null still giving null error I want to insert values in a table. So I have written the below code for that.
create or replace PROCEDURE NEIQC_DATA_DUMP_MST AS
BEGIN

execute immediate 'truncate table TBL_NEIQC_WF_SITE_MST_NEW';

INSERT INTO TBL_NEIQC_WF_SITE_MST_NEW

(
    OBJECTID,
    SAP_ID,
    NETWORK_ENTITY_ID    ,
    SITE_NAME            ,
    SITE_ADDRESS         ,
    MAINTENANCEZONE_CODE ,
    INVENTORY_TYPE       ,
    TYPE_NAME            ,
    SITE_STATUS_CODE     ,
    NE_MODIFIED_DATE     ,
    NE_MODIFIED_BY       ,
    --SERVICE_CODE,
    CREATED_DATE         ,
    CREATED_BY           ,
    STRUCTURE_NAME       ,
    RJ_CITY_CODE         ,
    RJ_R4G_STATE_CODE    ,
    RJ_DISTRICT_CODE     ,
    RJ_TALUK_CODE        ,
    RJ_JC_CODE           ,
    RJ_JIOPOINT_SAPCODE  ,
    RJ_COMPANY_CODE_1    ,
    RJ_COMPANY_CODE_2    ,
    PLACEMENT_DATE,
    SITE_TYPE
)

SELECT

    OBJECTID                      ,
    RJ_SAPID ,
    RJ_NETWORK_ENTITY_ID          ,
    RJ_SITE_NAME                  ,
    RJ_SITE_ADDRESS               ,
    RJ_MAINTENANCE_ZONE_CODE      ,
    CASE when RJ_SAPID LIKE '%ENB%' THEN 'SITE' ELSE 'OTHERS' end as INVENTORY_TYPE,
    TYPE_NAME                     ,
    4,
    RJ_LAST_MODIFIED_DATE,
    RJ_LAST_MODIFIED_BY ,
    --APP_FIBERINV.FUNC_SC(RJ_SAPID),
    SYSDATE,
    'SCHEDULER',
    STRUCTURE_NAME                ,
    RJ_CITY_CODE                  ,
    RJ_R4G_STATE_CODE             ,
    RJ_DISTRICT_CODE              ,
    RJ_TALUK_CODE                 ,
    RJ_JC_CODE                    ,
    RJ_JIOPOINT_SAPCODE           ,
    RJ_COMPANY_CODE_1             ,
    RJ_COMPANY_CODE_2          ,
    PLACEMENT_DATE,
    REGEXP_SUBSTR(TO_CHAR(RJ_SAPID),'[^-]+', 1, 4) AS SITE_TYPE

 from APP_FTTX.ne_structures WHERE RJ_SAPID IS NOT NULL OR RJ_SAPID <> 'NA' AND OBJECTID IS NOT NULL;

COMMIT;

END NEIQC_DATA_DUMP_MST;

But the issue is, even after checking the null condition for OBJECTID I am still getting error as

ORA-01400: cannot insert NULL into ("APP_FIBERINV"."TBL_NEIQC_WF_SITE_MST_NEW"."OBJECTID")

Please suggest what may be wrong here.

A: This is probably down to operator precedence; AND has higher precedence than OR. So your condition:
WHERE RJ_SAPID IS NOT NULL OR RJ_SAPID <> 'NA' AND OBJECTID IS NOT NULL

is interpreted as
WHERE RJ_SAPID IS NOT NULL OR (RJ_SAPID <> 'NA' AND OBJECTID IS NOT NULL)

If you have a source row where OBJECTID is null then it will still pass than condition, and fail on insertion, if RJ_SAPID is anything except 'NA', including if that is null.
I believe you want:
WHERE (RJ_SAPID IS NOT NULL OR RJ_SAPID <> 'NA') AND OBJECTID IS NOT NULL

so you need to include those parentheses in your statement.

A: i think your where condition should be improved. add '()' around your or condition
WHERE (RJ_SAPID IS NOT NULL OR RJ_SAPID <> 'NA') AND OBJECTID IS NOT NULL;


Q: Getting entire POST response in one line I've modified the following code from an example on the internet. Currently it POSTs and returns the response line by line. How can I modify the code so it returns the entire response  in one line, so I can parse it more easily.
static void updateIp() throws MalformedURLException, IOException {
    String urlParameters = "name=sub&a=rec_edit&id=9001";
    URL url = new URL("http://httpbin.org/post");
    URLConnection con = url.openConnection();

    con.setDoOutput(true);

    BufferedReader reader;
    try (OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream())) {
        writer.write(urlParameters);
        writer.flush();
        String line;
        reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
        while ((line = reader.readLine()) != null) {
            System.out.println(line);
        }
    }
    reader.close();
}

Any help would be greatly appreciated!

A: You can't determine how many lines the URL response will be over, so you need to join them all together yourself in one line using StringBuilder:
static void updateIp() throws MalformedURLException, IOException {
    String urlParameters = "name=sub&a=rec_edit&id=9001";
    URL url = new URL("http://httpbin.org/post");
    URLConnection con = url.openConnection();

    con.setDoOutput(true);

    BufferedReader reader;
    try (OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream())) {
        writer.write(urlParameters);
        writer.flush();
        String line;
        StringBuilder urlResponse = new StringBuilder();
        reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
        while ((line = reader.readLine()) != null) {
            urlResponse.append(line);
        }
        String response = urlResponse.toString();
        System.out.println(response);
    }
    reader.close();
}

The response string variable will now contain all the output in a single line.


Q: Cocos2d-x Shaky, Liquid , Wave effect weird behaviour with android I am trying to use the effects like shaky on Sprites and Wave which I guess are heavy process. When I apply this on the sprites they work properly but after If I pause my game and then resume.
Background becomes black and I can not see my bg anymore
Why is this happening I really have no idea ? It happens only when I use these effects
Is there anything I need to take care of after applying this effects on the sprite.
I am not sure is it android bug or my mistake ?


Q: DataTable with childrows (sub-dataTables). How can I create/expand ALL sub-dataTables by default? I have a dataTable with sub dataTables and I can't make them be expanded on every page. I can make them be expanded on the current page, but when I go to another page, the subtables aren't displayed. It appears as though the child row exists but no dataTable has been created. If I collapse and then expand the childrow the dataTable is created.
Here is my fiddle that I forked from gyrocode.com
https://jsfiddle.net/jsfiddlertwo/8rmq3foy/
Here is the expand button function
$('#btn-show-all-children').on('click', function(){
    // Enumerate all rows
    table.rows().every(function(){
        // If row has details collapsed
        if(!this.child.isShown()){
            // Open this row
            this.child(format(this.data())).show();
            childTable(this.data());
            $(this.node()).addClass('shown');
        }
    });
});

My format function creates the html for the sub-dataTable
function format ( d ) {
    var childId = d.extn;
  return '

';
}

The childTable function creates the sub-dataTable
var childTable = $(childId).DataTable({
    colReorder: true,
    searching: false,
    info: false,
    paging: false,
    scrollY: false,
    data: data.children,
    columns: [{
        title: "Name",
        render: function(data, type, row, meta) {
          return row.name;
        }
      },
      {
        title: "Class",
        render: function(data, type, row, meta) {
          return row.class;
        }
      },
    ]
    });
}

The expand button expands and shows the sub-dataTables on the current page. The trouble is that when I go to another page, the sub-dataTables aren't there. Once on another page I can click on the row twice (to collapse and then re-expand) and the sub-dataTables are created.
I've tried using the drawcallback but it is called before the new page is created.
How can I make the sub-dataTables be created on all pages?


Q: How to use GCP Local SSD with KubeDB Is there an example of how to set up a KubeDB PostgreSQL streaming replication cluster, where each pod's data is using Google Cloud's Local SSDs (need 2x375GB SSDs merged for each PG node).
I am aware of local SSDs being temporary - for my usecase, performance and ease of scaling is far more important, and my data can be regenerated within a day.
KubeDB docs in the first link have these two settings, but I am not certain how to configure pod affinity, as well as initialize (merge) two local SSDs into one as part of PostgreSQL initialization.

spec.storageType specifies the type of storage that will be used for
  Postgres database. It can be Durable or Ephemeral. Default value of
  this field is Durable. If Ephemeral is used then KubeDB will create
  Postgres database using EmptyDir volume. In this case, you don’t have
  to specify spec.storage field. This is useful for testing purpose.
spec.storage specifies the size and StorageClass of PVC that will be
  dynamically allocated to store data for this database. This storage
  spec will be passed to the StatefulSet created by KubeDB operator to
  run database pods. You can specify any StorageClass available in your
  cluster with appropriate resource requests. If you don’t specify
  spec.storageType: Ephemeral, then this field is required.


Q: binding vs with-bindings in clojure There are two macros binding and with-bindings to redefine dynamic vars. However both seem to have the utility, what is the difference between them ?
;; binding
(def :^dynamic a 10)
(binding [a 20] a) ;; => 20
a ;; => 10

;; with-bindings
(with-bindings {#'a 20}
  a) ;; => 20
a ;; => 10

both of them are changing the per thread dynamic scope, and resetting it to the root binding after the lexical scope is over.

A: The underlying implementation of both is pretty much identical:

*

*push thread bindings (using the bindings supplied)

*try the body

*finally pop thread bindings

binding was added in Clojure 1.0 and with-bindings in 1.1. I don't see the latter used in any code tho', just the former.


Q: Error with download a file from https using webclient I have create a piece of code that download a file from a given URL using WebClient.
The problem is i am getting the following error when the code is trying to download a file from a HTTPS site.
The remote certificate is invalid according to the validation procedure

This issue happened only on the server not on the local machine, so i also don't know how to debug it.
I have read several answers on the web but didn't find anything that could help me.
The piece of code:
 using (WebClient Client = new WebClient())
        {
            string fileName = System.Configuration.ConfigurationManager.AppSettings["siteUploadedDirectory"]
            + "/temp/" + Context.Timestamp.Ticks.ToString()
            + "_" + FileURL.Substring(FileURL.LastIndexOf('/')+1);
            fileName = Server.MapPath(fileName);
            Client.DownloadFile(FileURL, fileName);
            return fileName + "|" + FileURL.Substring(FileURL.LastIndexOf('/')+1);
        }

The URL i am trying:
http://Otakim.co.il/printreferrer.aspx?ReferrerBaseURL=cloudents.com
&ReferrerUserName=ram
&ReferrerUserToken=1
&FileURL=https://www.cloudents.com/d/lzodJqaBYHu/pD0nrbAtHSq

The file URL:
FileURL=https://www.cloudents.com/d/lzodJqaBYHu/pD0nrbAtHSq
Any help will be appreciated

A: You can bypass the certificate validation process by following code snieppet
    ServicePointManager.ServerCertificateValidationCallback
 += (sender, certificate, chain, sslPolicyErrors) => true;


Q: How to add classes from a selector string? I have several CSS classes in the form of a selector, for example .myclass.myclass2 and I want to apply both classes to an element.
I could .split() the string and apply each class with .addClass(), but before I do, I'd like to know if there's a "native" jQuery function to do this kind of thing or if someone has written a function to handle it.
To better explain: I want a function that I can pass it a CSS selector and it'll add the classes to an element. Like $('#myelem').addClass('.myclass.myclass').
(I would also love it to handle other CSS selectors such as #myid, but I fear that's asking too much and I'd probably need a full parser function.)

A: addClass takes a space separated string, so all you need to do is replace dots with spaces:
var classes = '.myclass.myclass2';
$(element).addClass(classes.replace(/\./g,' ').trim()))

A: create two classes inside style tag like this
        .a {
       backgroud-color:red;
       }
     .b{
       color:blue;
       }
      </style>

now add your jquery codes
then inside javascript code

here is the html

A: You can add this to your script:
$.fn.oldAddClass = $.fn.addClass;
$.fn.addClass = function(x){
    if(typeof x == 'string'){
        this.oldAddClass(x.replace(/\./g, ' '));
    }else{
        this.oldAddClass(x);
    }
}

Then call addClass() with your dot :
$(el).addClass('.class1.class2');

Fiddle : http://jsfiddle.net/8hBDr/

A: You cannot add css selectors (like #elemid.myclass) directly to an element in native jQuery. The example below shows how to add multiple classes using a space delimited string.
$(elem).addClass("myclass mycalss2")

And the documentation:
http://api.jquery.com/addClass/


Q: How to clear pending message from azure service bus? I am using azure service bus for receiving message to processing my background process. In my background process I want to clear already processed messages from azure service bus. Is there any way or method to clear azure service bus messages???

A: Read How to receive messages from a queue and make sure you use _queueClient.Complete() or _queueClient.Abandon() to finish with each message.

A: You can use "Microsoft.ServiceBus.Messaging" and purge messages by en-queue time. Receive the messages, filter by ScheduledEnqueueTime and perform purge when the message has been en-queued at the specific time.
using Microsoft.ServiceBus.Messaging;

MessagingFactory messagingFactory = MessagingFactory.CreateFromConnectionString(connectionString);

var queueClient = messagingFactory.CreateQueueClient(resourceName, ReceiveMode.PeekLock);

var client = messagingFactory.CreateMessageReceiver(resourceName, ReceiveMode.PeekLock);

BrokeredMessage message = client.Receive();

if (message.EnqueuedTimeUtc < MessageEnqueuedDateTime)
{
    message.Complete();
}


Q: How to refer to yourself in the anonymous class? I have next code in kotlin:
handler.postDelayed(object : Runnable {
            override fun run() {
                Timber.i("run post msg")
                handler.postDelayed(this, AppPrefs.SEARCH_DELAY)
            }
        },AppPrefs.SOCKET_INTERVAL)

how you see it's simple standard way to create delayed task (with Runnable class). Value this references to anonimus Object implements Runnable and compile and works fine
But when i make lamdba for this:
handler.postDelayed({
            Timber.i("run post msg")
            handler.postDelayed(this, AppPrefs.SOCKET_INTERVAL)
        },AppPrefs.SOCKET_INTERVAL)

value this referenced to outher class.
How referenced from inner anonimus class to yourself?

A: You cannot do this. A similar question was asked on Kotlin's forum and yole (one of the creators of the language) said this:

this in a lambda refers to the instance of the containing class, if any. A lambda is conceptually a function, not a class, so there is no such thing as a lambda instance to which this could refer.
The fact that a lambda can be converted into an instance of a SAM interface does not change this. Having this in a lambda mean different things depending on whether the lambda gets SAM-converted would be extremely confusing.


Q: EF code first uncertainty principle - referred entities may not get loaded With automatic database recreation, it is uncertain whether referred entities will get loaded or not.
The context is EF CTP 5 and ASP.NET MVC 2. In the global.asax a database initializer is set that forces recreation of the database every time the application starts up.
Successfully retrieving an entity from a context in a controller action may still cause null reference errors when traversing references even if the references are marked as required (not null in the database). Turning off lazy loading does not make any difference.
This behaviour cannot be reproduced reliably but was observed on two different workstations (XP, 7) using Cassini.
Below are the models. Null reference exception is thrown when trying to access the NewsProvider property of the NewsFeed object. It makes no difference taking off the virtual qualifier.
public class NewsProvider
{
    public int Id { get; set; }

    [Required(ErrorMessage = "Please enter a name")]
    [StringLength(50, ErrorMessage = "The name is too long")]
    public string Name { get; set; }
}

public class NewsFeed
{
    public int Id { get; set; }

    [Required(ErrorMessage = "Please enter a name")]
    [StringLength(50, ErrorMessage = "The name is too long")]
    public string Name { get; set; }

    [Required(ErrorMessage = "Please enter a URL")]
    [StringLength(300, ErrorMessage = "The URL is too long")]
    public string Url { get; set; }

    [Required(ErrorMessage = "Please enter a news provider")]
    public virtual NewsProvider NewsProvider { get; set; }
}

A: This is just a guess, but complex types can NEVER be null. So if you have any reference to a complex type (ICollection) you should initialize them from the Entity constructor.
Example:
 public class NewsProvider
{
    public int Id { get; set; }

    [Required(ErrorMessage = "Please enter a name")]
    [StringLength(50, ErrorMessage = "The name is too long")]
    public string Name { get; set; }
}

public class NewsFeed
{
    public NewsFeed() {
        //Never allow NewsProvider to be null
        NewsProvider = new NewsProvider();
    }
    public int Id { get; set; }

    [Required(ErrorMessage = "Please enter a name")]
    [StringLength(50, ErrorMessage = "The name is too long")]
    public string Name { get; set; }

    [Required(ErrorMessage = "Please enter a URL")]
    [StringLength(300, ErrorMessage = "The URL is too long")]
    public string Url { get; set; }

    [Required(ErrorMessage = "Please enter a news provider")]
    public virtual NewsProvider NewsProvider { get; set; }
}

For more info, here is a great blog post:
http://weblogs.asp.net/manavi/archive/2010/12/11/entity-association-mapping-with-code-first-part-1-one-to-one-associations.aspx


Q: MYSQLI new query within a while fetch I'm just making some website for fun at the moment but I'm stuck at a point.
I want to perform a group quest and any member of the group can start it.
All people of the group will get the same ammount of gold,experience
and share the same cooldown.
I have 3 tables in my database(I will only show important information)
Members:
username, level, experience, playergold

Levels:
level, required_experience

Groups:
leader, member_1, member_2, member_3, last_quest_started, quest_cooldown

Quests:
success_message, failed_message, chance, minimum_experience, maximum_experience, minimum_gold, maximum_gold, cooldown

I want to update last_quest_started and quest_cooldown in groups, and I want to update each member his/her level, experience, playergold
So after getting each username of the group members, the quests data, calculating the experience and gold. I use this to update:
if($select_members_info_stmt = $mysqli->prepare("SELECT members.username, members.level, members.experience, members.playergold, levels.required_experience FROM members INNER JOIN levels ON members.level = levels.level WHERE ((members.username = ?) OR (members.username = ?) OR (members.username = ?) OR(members.username = ?))"))
{
    $select_members_info_stmt->bind_param('ssss', $leader, $member_1, $member_2, $member_3);
    $select_members_info_stmt->execute();
    $select_members_info_stmt->bind_result($selected_username, $level, $experience, $playergold, $required_experience);
    while($select_members_info_stmt->fetch())
    {
        $now = time();

        if($update_user_stats_stmt = $mysqli->prepare("UPDATE members SET level = ?, experience = ?, playergold = ? WHERE username = ?"))
        {
            $update_user_stats_stmt->bind_param('iiiiis', $new_level, $new_experience, $new_gold, $now, $cooldown, $selected_username);
            $update_user_stats_stmt->execute();
            if($update_user_stats_stmt->affected_rows == 0)
            {
                    echo '
Because of a system error it is impossible to perform a task, we apologize for this inconvience. Try again later.
';
            }
            $update_user_stats_stmt->close();
        }
        else
        {
            printf("Update user stats error: %s
", $mysqli->error);
        }
    }
    $select_members_info_stmt->close();
    echo '
'.$success_message.'

';
}
else
{
    printf("Select members info error: %s
", $mysqli_error);
}

But I keep getting:
Update user stats error: Commands out of sync; you can't run this command now (4 times, which is the size my groups are when they are full.)
I just can't find the solution to work around the out of sync error, because I can not close the $select_members_info_stmt because then it would stop fetching.
Please help me out, because I really have no clue what to do.

A: You can't nest your execute() like that.
The best solution is to toss that list of members into an array() once, close your connection, and THEN iterate that array and update each record.
It should look like this:
$select_members_info_stmt->bind_param('ssss', $leader, $member_1, $member_2, $member_3);
$select_members_info_stmt->execute();
$select_members_info_stmt->bind_result($selected_username, $level, $experience, $playergold, $required_experience);

$members = array();
while($select_members_info_stmt->fetch())
{
    // tossing into the array
    $members[] = array(
        'selected_username' =>$selected_username,
        'level' => $level,
        'experience' => $experience,
        'playergold' => $playergold,
        'required_experience' => $required_experience
    );
}
$select_members_info_stmt->close();

// Now iterate through the array and update the user stats
foreach ($members as $m) {
    if($update_user_stats_stmt = $mysqli->prepare("UPDATE members SET level = ?, experience = ?, playergold = ? WHERE username = ?"))
    {
        // Note that you need to use $m['selected_username'] here.
        $update_user_stats_stmt->bind_param('iiiiis', $new_level, $new_experience, $new_gold, $now, $cooldown, $m['selected_username']);
        $update_user_stats_stmt->execute();
        if($update_user_stats_stmt->affected_rows == 0)
        {
                echo '
Because of a system error it is impossible to perform a task, we apologize for this inconvience. Try again later.
';
        }
        $update_user_stats_stmt->close();
    }
    else
    {
        printf("Update user stats error: %s
", $mysqli->error);
    }

}

A: You cannot nest actively running prepared statements on the same connection to mysql.  Once you call execute() on any statement you cannot run another one on the same connection until that prepared statement is closed.  Any fetches on the first prepared statement will fail once you start executing on the second one.
Only one 'live' statement can be prepared and running on the mysql server per connection
If you really need to nest your prepared statements, you could establish 2 separate mysqli connections.


Q: Space-like pion electromagnetic form factor The 1986's publication "A measurement of the space-like pion electromagnetic form factor" (http://dx.doi.org/10.1016/0550-3213(86)90437-2) starts with:

The pion form factor has been measured in the space-like $q^2$ region
  $0.014$ to $0.26 (GeV/c)^2$ by scattering $300 GeV$ pions from the
  electrons of a liquid hydrogen target.

The process under consideration is the elastic scattering of a charged pion with an electron. They conventionally refer to $q^2$ for a space-like photon momentum and to $t=-q^2$ for a time-like photon momentum.
Why does this energy range for the photon correspond to being "space-like"?
As far as I know one can only talk about being "space-like/time-like/light-like" for the separation of two space-time points or events (in 4D Minkowski space). What would be the two points here?
What energy would be the time-like regime for $q^2$ in the context of 300 GeV pions used to measure the e.m. form factor?

A: I believe that by saying

in the space-like $q^2$ region $0.014$ to $0.26 GeV^2$

the authors meant that they are talking about scattering here. It's not this particular energy region that makes it spacelike. More generally one knows that in scattering the momentum transfer is negative $q^2<0$. This means $q$ is a spacelike vector.


Q: Angular2 Two way bindings doesn't work on Firefox I am a newee using Angular 2. I developped some forms with Typesript and it is working with Chrome but doesn't with FireFox (version 45).
First of all, I tried the "two way" data bindings with both browsers : Chrome has a correct behavior but FireFox doesn't take in consideration the binding with ngModel (Find my exemple based on 5 min quickstart of angular2).
In addition, the datepicker of bootstrap works well on Chrome and NOT on Firefox.
Thanks in advance,
app.component.ts
import {Component, OnInit, Event} from 'angular2/core';
import {FORM_DIRECTIVES, NgForm, NgIf, NgFor} from 'angular2/common';

import {Types} from './types';

@Component({
    selector: 'my-app',
    templateUrl:'./app/app.component.html',
    directives : [
      FORM_DIRECTIVES,
      NgForm,
      NgIf,
      NgFor
    ]
})
export class AppComponent implements OnInit {

  field:any;

  types:Array<string> = Types;

  ngOnInit() {
      this.field= {};
  }

  onChange(event:Event) {
    console.log(this.field.type);
  }
}

app.component.html

My First Angular 2 App

 Select

<select class="form-control"
        [(ngModel)]="field.type"
        (change)=onChange($event)
        title="Type">
   <option *ngFor="#t of types">{{ t }}</option>
</select>

 Input

  <input type="text"
        class="form-control input-sm"
        [(ngModel)]="field.type"
        placeholder="type">

A: I found a solution which is not very nice :

*

*HTML file : in the select tag I added #typeField

*TS file : I changed the onChange method like below :

app.component.ts
import {Component} from 'angular2/core';

import {Types} from './types';

@Component({
    selector: 'my-app',
    templateUrl:'./app/app.component.html'
})

export class AppComponent {

  field:any = {};

  types:Array<string> = Types;

  onChange(event:Event, newValue:any) {
    this.field.type = newValue;
    console.log(this.field.type);
  }
}

app.component.html

My First Angular 2 App

 Select

<select class="form-control"
        [(ngModel)]="field.type"
        #typeField
        (change)="onChange($event, typeField.value)"
        title="Type">
   <option *ngFor="#t of types">{{ t }}</option>
</select>

 Input

  <input type="text"
        class="form-control input-sm"
        [(ngModel)]="field.type"
        placeholder="type">


Q: Values from Image column are different than expected after insertion I'm developing a windows form application for insert records contained in a table from one database from another table located in a different database.
The involved column is called FPTemplate and its data type is Image.
Using this line of code for get the information of a column which its data type is System.Byte[] (in the DataTable variable):
BitConverter.ToString((byte[])row["FPTemplate"], 0)

I don't get the expected results which I detailed in the following lines.
When I make the insert with this code-behind1:
// Insert records in "UserFinger" destination table.
string sql_cmd = "";
DataTable dt; // Has the info obtained from origin database.

// Loop rows of 'dt' variable.
foreach (DataRow row in dt.Rows)
{
    // Build the T-SQL statement to execute.
    sql_cmd = " INSERT INTO UserFinger (Userid, Fingerid, FPTemplate) " +
              " VALUES ('" + row["Userid"].ToString() + "', " + row["Fingerid"].ToString() + ", '" + BitConverter.ToString((byte[])row["FPTemplate"], 0) + "')";

    // Execute built T-SQL statement.
    ExecuteSQL(GetConnectionStringSQL_Cloud(), "UserFinger", sql_cmd);
}

I get this results in the destination table - see FPTemplate column -:

But, in the origin table, its values - in the FPTemplate column - are:

How can I correctly send the origin values to the destination table?
I think this is due to use BitConverter instead of ByteConverter, but I have no idea how to proceed for get the desired results, honestly.

1 I know this isn't the best way to do the insertions of the records, this is a test I'm working.


Q: Calculation of Fourier coefficients So I have a function $$f(t)\enspace\in\enspace L^{2}([0,1])$$ $$f(t)= \begin{cases}%
  \frac{1}{2} -t       & \text{if  $0 \leq t\leq \frac{1}{2},$}\\
  0 & \text{if  $\frac{1}{2} \lt  t\leq 1$}
 \end{cases}$$
How do I calculate the Fourier coefficients $$\left\langle{f|1} \right\rangle , \left\langle{f|A_{k} } \right\rangle , and \left\langle{f|B_{k}} \right\rangle$$
Any help is appreciated.
Thanks.


Q: How to extract a .tar.gz file on UNIX I have a file (reviews_dataset.tar.gz) that contains many files which contains data. I am required to extract the files in this archive and then perform some basic commands on the file. So far I have created a directory named (CW) and found a command tar zxvf fileNameHere.tgz but when I run this it of course cannot find my file as I have not "downloaded it" into my directory yet? How do I get this file into my directory so that I can then extract it? Sorry if this is poorly worded I am extremely new to this.

A: You must either run the command from the directory your file exists in, or provide a relative or absolute path to the file.  Let's do the latter:
cd /home/jsmith
mkdir cw
cd cw
tar zxvf /home/jsmith/Downloads/fileNameHere.tgz

A: You should use the command with the options preceded by dash like this:
tar -zxvf filename.tar.gz

If you want to specify the directory to save all the files use -C:
tar -zxf filename.tar.gz -C /root/Desktop/folder