text:
Q: Rails ActionMailer ignores settings in environment.rb I put my ActionMailer config in my config/environment.rb file like so:
MyApp::Application.initialize!
MyApp::Application.configure do

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      address: "smtp.elasticemail.com",
      port: 2525,
      domain: "myapp.com",
      authentication: "plain",
      user_name: "my_username",
      password: "my_password",
      enable_starttls_auto: true
  }

end

My understanding is that this is the correct way to configure settings that will apply to all your environments.
This worked fine in development, but when I deployed to my staging server (which uses a custom config/environments/staging.rb config file) I got a "connection refused" error when it tried to deliver mail. staging.rb has no mailer-related settings in it at all.
So I fired up the console on the staging server with RAILS_ENV=staging rails c, and "puts Rails.application.config.action_mailer" shows that the settings I put in environment.rb are indeed in effect, but for some reason ActionMailer is not using them.
Through experimentation I found that copying the config directly into staging.rb solves the problem. Why is this necessary? If the rails console shows the settings are in effect, why isn't ActionMailer using them?
Digging deeper, I see that my mailer class's delivery_method is not set as expected:
MyMailer.foo(Person.find(1)).delivery_method

 => #<Mail::SMTP:0x0000000370d4d0 @settings={:address=>"localhost", :port=>25, :domain=>"localhost.localdomain", :user_name=>nil, :password=>nil, :authentication=>nil, :enable_starttls_auto=>true, :openssl_verify_mode=>nil, :ssl=>nil, :tls=>nil}>

A: put
MyApp::Application.configure do

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      address: "smtp.elasticemail.com",
      port: 2525,
      domain: "myapp.com",
      authentication: "plain",
      user_name: "my_username",
      password: "my_password",
      enable_starttls_auto: true
  }

end

before MyApp::Application.initialize!


text:
Q: How to extract particular part of a string? I have a Link which never changes. The only thing which changes is the file name (in bold). so how do I get the file name from this link? I want to display this in a textview or toast-
http://apkins.aptoide.com/aptoide-8.1.0.1.apk?=x

A: String given = "http://apkins.aptoide.com/aptoide-8.1.0.1.apk?=x";
String extractedAppName = given.substring(given.lastIndexOf("/") + 1, given.lastIndexOf("?"));

This should work. It takes the position of the / before the name and then the position of the ?. It takes the string (substring) between those two characters. Just give it a try and you'll see.

A: This should do the trick
String fileName = url.substring(url.lastIndexOf('/') + 1);

You can also try URLUtil.guessFileName(url, null, null)
Edit 1
String url = "any url"

A: Here is a regex-less solution:
public static String getFileName(String link) {
     int endIndex = link.lastIndexOf('?');
     return link.substring(26, endIndex);
 }

It's pretty simple. It first gets where the file name ends i.e. the position of the last "?". Then it "cuts out" a new string from the link starting from the 27th character to the end of the file name.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Compile failed in java NetBeans
hi i have done all my coding in java but i got into a error with this line and i have trying many some ways to fix it wont work can someone help me please!

on line 284
C:\Users-----\Magazine\src\magazine\Client.java:284: error: incompatible types: int cannot be converted to Supplement
                                                        payCustomer.get(index).setSupp((payCustomer.get(index).aListSize()-1)).setSup(supList.get(i));
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
C:\Users-----\Magazine\nbproject\build-impl.xml:930: The following error occurred while executing this line:
C:\Users-----\Magazine\nbproject\build-impl.xml:270: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 5 seconds)

// CLIENT CLASS
package magazine;

import java.util.*;

public class Client {

    public static void main(String[] args) {
        // SCAN THE TEXT INPUT FORM THE SOURCE
        Scanner sc = new Scanner(System.in);
        String customerList = "";
        String menuList = "";
        String supplementList = "";
        double cost;
        // CREATE A LIST OF USING FRIST NAME, LASIT NAME, EMAIL, PAYMENT METHOD
        String firstn = "";
        String lastn = "";
        String email = "";
        String pMethod = "";
        String pFN = "";
        String pLN = "";
        // BOOLWAN TO ALTER CUSTOMER CLASS
        boolean checkCustomer;
        boolean checkDeleteCustomer;
        //REMOVE THE ELEMENT BY 1
        int index = -1;

        Magazine newMag = new Magazine("", 19.00);
        // ADDITION ELEMENTS IN ARRAYLIST
        ArrayList<Supplement> supList = new ArrayList<>();
        //CONSTRUCT MAGAZINE
        supList.add(new Supplement("categorie", 5.99));
        supList.add(new Supplement("categorie", 8.99));
        supList.add(new Supplement("categorie", 3.55));
        supList.add(new Supplement("categorie", 9.50));

        ArrayList<payment> payCustomer = new ArrayList<>();

        //A NEW PAYMENT FOR CUSTOMER
        payCustomer.add(new payment(""));
        //GET SUPPLEMENT
        payCustomer.get(0).setSupp(supList.get(1));
        payCustomer.get(0).setSupp(supList.get(2));
        //ADDING A NEW SUPPLEMENT
        payCustomer.add(new payment(""));
        payCustomer.get(1).setSupp(supList.get(0));
        payCustomer.get(1).setSupp(supList.get(3));
        //ADD ANEW PAYMENT
        payCustomer.add(new payment(""));
        //ADD A NEW ASSOCIATED FOR THE CUSTOMER
        payCustomer.get(0).addAssC(new AssociateCustomer(""));
        //ADD A SUPPLEMENT FOR ASSOCIATED CUSTOMER
        payCustomer.get(0).getAssC(0).setSupp(supList.get(2));
        payCustomer.get(1).addAssC(new AssociateCustomer(""));
        payCustomer.get(1).getAssC(0).setSupp(supList.get(2));
        payCustomer.get(2).addAssC(new AssociateCustomer("));

        //WHILE LOOP TO EXIT THE MENU BY E
        while (!menuList.equals("E")) {
            //DISPLAY MENU BY OPTIONS
         i rook this part off for my own reson do not want any one copy my work!!

            menuList = sc.nextLine().toUpperCase();

            if (!menuList.equals("E")) {
                switch (menuList) {
                    case "1":
                        System.out.println("Printing out the text of all the emails for all customemr");

                        for (int i = 0; i < payCustomer.size(); i++) {
                            for (int w = 0; w < 4; w++) {
                                System.out.println("Week " + (w + 1));
                                System.out.println(payCustomer.get(i).getFirstName());
                                System.out.println(newMag.getName() + " for Week" + (w + 1));

                                //LOOK FOR A SUPPLEMNT WITH LOOP
                                if (payCustomer.get(i).suppSize() > 0) {
                                    System.out.println("A list for your supplement:");
                                    for (int s = 0; s < payCustomer.get(i).suppSize(); s++) {
                                        System.out.println((s + 1) + "| " + payCustomer.get(i).getSupp(s).getSuppName());
                                    }
                                    System.out.println();
                                }
                                if (payCustomer.get(i).aListSize() > 0) {
                                    for (int c = 0; c < payCustomer.get(i).aListSize(); c++) {
                                        System.out.println("Week " + (w + 1));
                                        System.out.println(payCustomer.get(i).getFirstName());
                                        System.out.println(newMag.getName() + " for Week" + (+1));
                                        if (payCustomer.get(i).suppSize() > 0) {
                                            System.out.println("A list for your supplement:");
                                            for (int s = 0; s < payCustomer.get(i).suppSize(); s++) {
                                                System.out.println((s + 1) + "| " + payCustomer.get(i).getSupp(s).getSuppName());
                                            }
                                            System.out.println();
                                        }

                                    }
                                }
                            }
                        }

                           break;

                    case "2":
                        System.out.println("Printing out payment for emails");
                        for (int i = 0; i < payCustomer.size(); i++) {
                            cost = 0;
                            cost += newMag.getCost();

                            for (int a = 0; a < payCustomer.get(i).suppSize(); a++) {
                                cost += payCustomer.get(i).getSupp(a).getCost();
                            }
                            for (int b = 0; b < payCustomer.get(i).aListSize(); b++) {
                                cost += newMag.getCost();
                                for (int a = 0; a < payCustomer.get(i).getAssC(b).suppSize() ;a++) {
                                    cost += payCustomer.get(i).getAssC(b).getSupp(a).getCost();
                                }
                            }
                            cost *= 4; //multiple by 4 weeks

                            System.out.println(payCustomer.get(i).getFirstName());
                            System.out.println("Amount Due:" + cost);

                        }
                        break;

                    case "3":
                        System.out.println("Creating a new (Customer) or (Associated Customer)");
                        System.out.println("Please select one of the options below");
                        System.out.println();
                        System.out.println("[1]--> Customer");
                        System.out.println("[2]--> Associate Customer");
                        customerList = sc.nextLine();

                        switch (customerList) {
                            case "1":
                                System.out.println("Input new customer");

                                firstn = "";
                                lastn = "";
                                email = "";
                                pMethod = "";
                                checkCustomer = true;

                                System.out.println("Please Enter First Name:");
                                firstn = sc.nextLine();
                                System.out.println("Please Enter Last Namer:");
                                lastn = sc.nextLine();

                                for (int i = 0; i < payCustomer.size(); i++) {
                                    if ((payCustomer.get(i).getFirstName().equals(firstn)) && (payCustomer.get(i).getLastName().equals(lastn))) {
                                        System.out.println("Customer exists, Please try again.");
                                        checkCustomer = false;
                                    }
                                    for (int j = 0; j < payCustomer.get(i).aListSize(); j++) {
                                        if ((payCustomer.get(i).getAssC(j).getFirstName().equals(firstn) && (payCustomer.get(i).getAssC(j).getLastName().equals(lastn)))) {
                                            System.out.println("Customer exists, Please try again.");
                                            checkCustomer = false;
                                        }
                                    }
                                }
                                if (checkCustomer == true) {
                                    System.out.println("Please Enter Email");
                                    email = sc.nextLine();
                                    System.out.println("Please Select Payment Method");
                                    System.out.println("[1]--> Credit Card");
                                    System.out.println("[2]--> Direct Debit");

                                    while ((!pMethod.equals("Credit Card")) && (!pMethod.equals("Direct Debit"))) {
                                        pMethod = sc.nextLine();
                                        //SWITCH METHOD FOR PAUMENT AS CREDIT AND DIRECT DEBIT
                                        switch (pMethod) {
                                            case "1":
                                                pMethod = "Credit Card";
                                                break;
                                            case "2":
                                                pMethod = "Direct Debit";
                                                break;
                                            default:
                                                System.out.println("Invalid input");
                                                break;
                                        }
                                    }
                                    payCustomer.add(new payment(firstn, lastn, email, pMethod));

                                    System.out.println("Adding Supplement to Customer");
                                    System.out.println("Please Enter 'Y/YES' to accept or 'N/NO' to reject: ");
                                    for (int i = 0; i < supList.size(); i++) {
                                        supplementList = "";
                                        System.out.println("Title: " + supList.get(i).getSuppName() + "Cost: $" + supList.get(i).getCost() + "(Y/N)");
                                        while ((!supplementList.equals(("Y")) && (!supplementList.equals("N")))) {
                                            supplementList = sc.nextLine().toUpperCase();
                                            switch (supplementList) {
                                                case "Y":
                                                    payCustomer.get(payCustomer.size() - 1).setSupp(supList.get(i));
                                                    break;
                                                case "N":
                                                    break;
                                                default:
                                                    System.out.println("Invalid Input");
                                                    break;

                                            }

                                        }
                                    }
                                }
                                break;

                            //CREATING A NEW ASSOCIATION FOR THE CUSTUOMER BY FRIST AND KAST NAME AND EMAIL
                            case "2":
                                System.out.println("++ Creating new Associate Customer ++");
                                System.out.println();
                                pFN = "";
                                pLN = "";
                                firstn = "";
                                lastn = "";
                                email = "";
                                checkCustomer = false;
                                index = -1;
                                //DISPLAY THE INFROMATION FOR THE CUSTOMER
                                System.out.println("Information about the Customer");
                                System.out.println("Please Enter the First Name:");
                                pFN = sc.nextLine();
                                System.out.println("Please Enter the Last Name:");
                                pLN = sc.nextLine();

                                for (int i = 0; i < payCustomer.size(); i++) {
                                    if ((payCustomer.get(i).getFirstName().equals(pFN)) && (payCustomer.get(i).getLastName().equals(pLN))) {
                                        System.out.println("Customer exists");
                                        //A STEMENT "TRUE" IF THE CUSTOMER BEEN CREATED
                                        checkCustomer = true;
                                        index = i;
                                    }
                                }
                                if (checkCustomer == true) {
                                    System.out.println("Please Enter First Name:");
                                    firstn = sc.nextLine();
                                    System.out.println("Please Enter Last Name:");
                                    lastn = sc.nextLine();

                                    for (int i = 0; i < payCustomer.size(); i++) {
                                        if ((payCustomer.get(i).getFirstName().equals(firstn)) && (payCustomer.get(i).equals(lastn))) {
                                            System.out.println("Customer Exists");
                                            checkCustomer = false;
                                        }
                                        for (int c = 0; c < payCustomer.get(i).aListSize(); c++) {
                                            if ((payCustomer.get(i).getAssC(c).getFirstName().equals(firstn)) && (payCustomer.get(i).getAssC(c).getLastName().equals(lastn))) {
                                                System.out.println("Customer Exists");
                                                checkCustomer = false;
                                            }
                                        }
                                    }
                                    if (checkCustomer == true) {
                                        System.out.println("Enter Email");
                                        email = sc.nextLine();
                                        payCustomer.get(index).addAssC(new AssociateCustomer(firstn, lastn, email));
                                        for (int i = 0; i < supList.size(); i++) {
                                            supplementList = "";
                                            System.out.println("Title: " + supList.get(i).getSuppName() + "Cost: $" + supList.get(i).getCost() + "(Y/N)");
                                            while ((!supplementList.equals(("Y")) && (!supplementList.equals("N")))) {
                                                supplementList = sc.nextLine().toUpperCase();
                                                switch (supplementList) {
                                                    case "Y":
   The problem is here   --->                 payCustomer.get(index).setSupp((payCustomer.get(index).aListSize()-1)).setSup(supList.get(i));
                                                        break;
                                                    case "N":
                                                        break;
                                                    default:
                                                        System.out.println("Invalid Input");
                                                        break;

                                                }
                                            }

                                        }

                                    }
                                }
                                else {
                                    // LOOK UP FOR CUSTOMER NAME
                                    System.out.println("Customer doesn't exist");
                                }
                                break;
                                 default:
                                System.out.println(" Invalid Input");
                                break;
                        }
                        break;
                            // TO DELATE A CUSTOMER
                            case "4":
                                System.out.println("Delete Customer");
                                firstn = "";
                                lastn = "";
                                checkDeleteCustomer = false;
                                //ENTER THE INFO AS FRIST AND LAIST NAME TO DELETE
                                System.out.println("Please Enter First Name");
                                firstn = sc.nextLine();
                                System.out.println("Please Enter Last Name");
                                lastn = sc.nextLine();

                                for (int i = 0; i < payCustomer.size(); i++) {
                                    if ((payCustomer.get(i).getFirstName().equals(firstn)) && (payCustomer.get(i).getLastName().equals(lastn))) {
                                        checkDeleteCustomer = true;
                                        // DISPLAY MESSAGE IF THE CUSTOMER BEEN DELETED
                                        System.out.println(payCustomer.get(i).getFirstName() + "," + payCustomer.get(i).getLastName() + "been deleted");
                                        payCustomer.remove(i);
                                    }

                                    for (int c = 0; c < payCustomer.get(i).aListSize(); c++) {
                                        if ((payCustomer.get(i).getAssC(c).getFirstName().equals(firstn)) && (payCustomer.get(i).getAssC(c).getLastName().equals(lastn))) {
                                            checkDeleteCustomer = true;
                                            System.out.println(payCustomer.get(i).getAssC(c).getFirstName() + payCustomer.get(i).getAssC(c).getLastName() + "been deleted");
                                            payCustomer.get(i).removeAC(c);
                                        }
                                    }
                                }

                                if (checkDeleteCustomer == false) {
                                    System.out.println("Customer doesn't exist");

                                }
                                break;
                            // LOOK UP FOR A CUSTOMER BY NAME
                            case "5":
                                System.out.println("Display customer's name: ");
                                for (int i = 0;i<payCustomer.size();i++){
                                    System.out.println("Customer #" + (i+1)+ " = " +payCustomer.get(i).getFirstName()+ " " + payCustomer.get(i).getLastName());
                                    if(payCustomer.get(i).aListSize()>0){
                                        System.out.println("Associate Customers are: ");
                                        for(int c = 0;c< payCustomer.get(i).aListSize();c++){

                                            System.out.println(payCustomer.get(i).getAssC(c).getFirstName()+payCustomer.get(i).getAssC(c).getLastName());
                                        }
                                    }
                                }
                                break;

                            default:
                                //DISPLAY MESSAGES IF THE INPUT INVALID
                                System.out.println("Invalid Input");
                                break;
                        }

                }
            }
        }

    }


text:
Q: sql query to get a scheduled report to run for that curent month only I have an SSRS 2005 report that has a dataset for to an Oracle database.  The report that i have essentially just pulls all data back from an audit log.  This report works perfectly fine and i have scheduled thi to run and send an email using the new subscription method within SSRS.
The only issue i have is i want the report to run on the last day of the month (its set up to do this alreday) and run the report based on that month only.  Getting the report to run specifically for a month is what im unsure on?  I though i would be able to set parameters within the report but these only enable my user to select a calendar date?
Is there a DATEADD or DATEPART type of function i can use to complete this task?
Regards
B

A: Best bet would be to set up a dynamic date default for the date patameter at the report level, and set up the subscription to use this default value, so whenever the subscription runs it would automatically have the appropriate date.
Probably the easiest thing to do is set the parameter as the current date, if that would work, e.g. something like =Today(). So that will be calculated whenever the subscription runs.
You can set the default value for whatever you need; first day of the current month, etc. You should able to set whatever value you need without too much trouble.
So for the first day of the month something like:
=DateSerial(Year(Today()), Month(Today()), 1).
Users running the report ad-hoc could just reset the parameter as required.
I'm assuming the report handles the amount of data to return correctly assuming the right data parameter is sent.

A: 2 Parameters @DateFrom and @DateTo
Default Value for @DateFrom that outputs the first day of the current month:
=DateAdd("d",-Day(Today())+1,Today())
Default Value for @DateTo that outputs the last day of the current month:
=DateAdd("d",-Day(Today())+1,DateAdd("m",1,Today()))


text:
Q: How and where should I use the keyword "use" in php I used use the keyword "use" generally above the class definition. Like this:
<?php
namespace suites\plugins\content\agpaypal;
use \Codeception\Util\Fixtures;
use \Codeception\Verify;
use \Codeception\Specify;

class agpaypalTest extends \Codeception\Test\Unit
{
    protected $tester;
    ...

But now I realised, that I have to put the line for the trait Specify into the class definition. Like this:
 <?php
namespace suites\plugins\content\agpaypal;
use \Codeception\Util\Fixtures;
use \Codeception\Verify;

class agpaypalTest extends \Codeception\Test\Unit
{
    use \Codeception\Specify;

    protected $tester;
    ...

I think it is because the package \Codeception\Specify; is a trait. But I do not understand why I couldn't reuse this trait when I set the line
use \Codeception\Specify;
before the class definition?
I would be happy if someone could point me to a hint or an explanaiton that explains to me where I should use the keyword "use" the best.

A: You can not import class with use keyword. You have to use include/require statement. Even if you use some php auto loader, still autoloader will have to use either include or require internally.
The Purpose of use keyword:
Consider a case where you have two classes with same name; you'll find it strange, but when you are working with big MVC structure, this happens. So if you have two classes with same name, put them in different name spaces. Now consider when your auto loader is loading both classes (does by require), and you are about to use object of class. In this case, the compiler will get confused which class object to load among two. To help the compiler make a decision, you can use the use statement so that it can make a decision which one is going to be used on.
Here refer this
How does the keyword 'use' work

A: use is basically including a class in the file to use it.
There are two ways to include a class file in another file.
The most general is require or include method. Another method is using composer. Assume this Directory Structure
Project
  |
  |--- Folder A
  |      |
  |      |---UserRegistration.php
  |
  |---Example
         |
         |--TestUserRegistration.php

In Folder A there is UserRegistartion.php and you want to use the code in TestUserRegistration.php  In UserRegistration.php It can be  class, trait or Interface
Method 1.
In TestUserRegisteration.php you can include or require file UserRegistartion.php
and use it
Method 2
Using Composer. In UserRegistration.php you define namespace FolderA; as the first line of code. Then write your code as you do. So Now you want to use this file in TestUserRegistration.php you do
include vendor/autoload.php;
use FolderA\UserRegistration;

Which one is better and why?
Method 2 using composer is the best method. In method 1 wherever you want to include UserRegistration you have to find the relative path to UserRegistration file. So lets assume some day you need to change the directory structure your application will break as the relative path you had provided now it does'nt exist.
But in Method 2 you always use the namespace you provided \ The filename instead of where you want to use. So even you change the directory structure you don't have to got all codes and modify the path. It will work as it was.
To know more study about how to use namespace and composer.

A: In PHP, the keyword use is used in 3 cases:

*

*As class name alias - simply declares short name for a class (must be declared outside of the class definition)
(manual: Using namespaces: Aliasing/Importing )

*To add a trait to a class (must be declared inside (at the top) of the class definition)
(manual: Traits)

*In anonymous function definition to pass variables inside the function
(manual: Anonymous functions)


text:
Q: Redraw only a part of the pane I'm using ZedGraph to display curves (with 10k+ points) on my application.
I've added vertical bars to allow the user to see the value of a point (kind of cross-hair). Every time the user moves the mouse, the whole control is redrawn:
bool stackedGraphControl1_MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
{
    DrawCursors(e.Location);
    Refresh();
    return false;
}

With more than 2 curves, the computer becomes laggy. One solution is to draw only the vertical bars (remove the Refresh() call and draw only the vertical bars). This is way faster but the graphical result is funny:

But not very useful. I understand that all the vertical bars are drawn again and again without being removed.
Is there a way to redraw (ie: delete and draw) only the bars (which are in the GraphObjList of my panes) ?

A: In the past I have accomplished this functionality by overriding the OnPaint of the ZedGraphControl to create a layered drawing effect.
Paint ZedGraph to an intermediate Bitmap or BufferedGraphics. Saving this Bitmap for future painting, and invalidating the bitmap when other things change (axis values, curves added)
Future OnPaint calls blit this Bitmap to the graphics object and manually drawing any GraphObjs on top of this.
MouseMove events just update the properties of the indicator and force a redraw with the cached zedgraph image.


text:
Q: AngularJs 1: How to inject a service to a controller from the directive declaration I've created a directive for managing (creating/updating/deleting) comments on customers in my application.
Now I'd like the exact same comment functionality (look and feel) on users, so the only thing I need to do is replace my CustomersService with my UsersService.
Both services have the same methods for "crud-ing" comments (I would make both implement an ICommentsService interface if possible in javascript).
My question is how can I in the best possible way reuse my already created View and Controller so I don't have to duplicate code?
My initial approach is to create two separate directives (CustomerComments and UserComments) that reference the same view and controller, but injecting a CustomersService or a UsersService respectively. The problem I'm facing with this, is how to keep the "DI-definition" in the directive declaration whilst having the controller in a separate file...?
This is my directive declaration:
angular.module('myApp').directive('myComments', [
    function() {
        'use strict';
        return {
            restrict: 'E',
            scope: {
                commentId: '='
            },
            templateUrl:'mycomments.html',
            controller: 'CommentsCtrl',  //<-- How to define injected objects here?
        };
    }
]);

...and this is my controller:
angular.module('myApp').controller('CommentsCtrl', [
    '$scope',
    '$q',
    'CustomersService',   //<-- These "DI-objects" should be defined in the directive declaration
    function ($scope, $q, commentsService) {

        $scope.addComment = function(comment){
            commentsService.addComment(comment);
        };

        $scope.getComment = function(commentId){
            retur commentsService.getComment(commentId);
        };

        //...etc...
    }
]);

Or are there better ways to solve this?

A: Usually you do not explicitly register a directive's controller. That is somewhere you would have:
function CommentsCtrl($scope, $q, commentsService) {

And in your directive(s):
controller: ['$scope','$q','CustomersService', CommentsCtrl]


text:
Q: WPF User Control property not getting value I am trying to create a very simple WPF User Control to represent a digital clock.
I have a couple of things I want client code to be able to change, e.g. foreground text colour, font etc., so I've made some public properties for them.  Some of the code is shown below:
    public partial class DigitalClock : System.Windows.Controls.UserControl
    {
        public string Color { get; set; }

        private Timer timer;
        private string DisplayString { get { return DateTime.Now.ToString("dd-MM-yy HH:mm:ss"); } }

        public DigitalClock()
        {
            InitializeComponent();
            this.timer = new Timer();
            this.timer.Tick += new EventHandler(UpdateClock);
            this.timer.Interval = 1000;
            this.timer.Enabled = true;
            this.timer.Start();
            UpdateClock(null, null);

            try
            {
                //exception thrown here as this.Color is null
                Color color = (Color)ColorConverter.ConvertFromString(this.Color);
                tbClock.Foreground = new SolidColorBrush(color);
            }
            catch (Exception ex)
            {
                Console.WriteLine(">>>" + ex.Message);
            }
        }

        private void UpdateClock(object sender, EventArgs e)
        {
            tbClock.Text = DisplayString;
        }
    }
}

I'm using it on another page like this:
<CustomControls:DigitalClock color="#ff000000" />

There are no syntax errors and the clock appears on the screen, but whenever the code hits the line where it's trying to set the colour, I just get an Object reference is not set to an instance of an object.
I assume this is something to do with the point in time at which the Color property is set, since after the first 'tick' of the timer, the value is no longer null.  How do I get around this?

A: When you insert your control inside another XAML document, the properties that are set from this document will be set after your control is intantiated, which means at the time your constructor is invoked the Colorproperty that you may have set in your other XAML document still has its default value.
To do what you want you can either:

*

*Listen for the Loaded event of your control (see https://msdn.microsoft.com/en-us/library/ms742302%28v=vs.110%29.aspx), this will be invoked after all the properties of the control instance are set (you may want to start your timer here, and stop it in the Unloaded event to make sure it doesn't tick when the control isn't instantiated on screen),

*You can write a body for the setter of your Color property to propagate the change:
public string Color
{
  set { tbClock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(value)); }
}

*

*If you want to set the color from another XAML document, you can also provide a property of type Brush instead of color:

public Brush ClockForeground
{
    get { return tnClock.Foreground; }
    set { tnClock.Foreground = value; }
}

So that in your other XAML document, you can set the color directly by letting the XAML parser translate the color name into a brush automatically:
<local:DigitalClock ClockForeground="Yellow" />

*

*Or better, you can declare a dependency property on your control and use data binding (assuming here tbClock is a TextBlock):

public Brush ClockForeground
{
    get { return (Brush)GetValue(ClockForegroundProperty); }
    set { SetValue(ClockForegroundProperty, value); }
}
public static readonly DependencyProperty ClockForegroundProperty = DependencyProperty.Register("ClockForeground", typeof(Brush), typeof(DigitalClock));

public DigitalClock()
{
    InitializeComponents();
    ...
    BindingOperations.SetBinding(tbClock, TextBlock.ForegroundProperty, new Binding
    {
        Source = this,
        Path = new PropertyPath(ClockForegroundProperty)
    });
}

A: You should not declare properties as CLR properties. You should create instead Dependency Properties which in default allows you binding, validation and many, many more. Check this out: http://www.codeproject.com/Articles/32825/How-to-Creating-a-WPF-User-Control-using-it-in-a-W. In your example handle event Loaded like this:
  this.Loaded += DigitalClock_Loaded;
 void DigitalClock_Loaded(object sender, RoutedEventArgs e)
        {
                //your actions
                Color color = (Color)ColorConverter.ConvertFromString(this.Color);
        }

Properties is not yet bound in constructor.

A: Instead of asigning the color in the constructor, since it will be always null because the property will not be set until object is instantiated, it seems better to use the setter of the Color property, using a backing field.
Also, note that you should use Dependency Properties in this case, and take advantage of binding.


text:
Q: Unsure how to model many-to-many relationship in MongoDB I'm new to MongoDB and I'm trying to model a Many to Many relationship into at least 2 collections (I need two collections for the project). What I'm having is a collection of universities, faculties and specializations, and another collection for students and their gradebook (this was the middle entity between specializations and students in SQL, not sure if it's needed in Mongo anymore). I tried to use This as an inspiration but it limits me as I can only search students by university id (I want for example to search students from a certain specialization or a certain faculty). I could put every row from university, faculty and specialization in the student collection and vice versa but I really don't think it's ideal. Here's what I have so far:
db.students.insertOne({_id:1, firstname: 'John', lastname: 'Silas', ethnicity:'english', civilstatus:'single', residence:'London', email:'johnSilas@gmail.com', gradebook:[{ year:2018, registrationyear:2017, formofeducation:'traditional'}], universities:[1]})

db.universities.insertOne({_id:1, name:'University of London', city:'London', adress:'whatever', phone: 'whatever', email: 'whatever@gmail.com', faculty:[{name: 'Law', adress:'whatever', phone: 'whatever', email: 'whatever@gmail.com'}], specialization:[{name:'criminal rights', yearlytax:5000, duration: 3, level:'bachelordegree', language:'english'}], students: [1,2]})

I'm sorry if I don't understand basic noSQL concepts, I am new to it. Thanks in advance.

A: Basic patterns for many to many association between A and B:
Inline references

*

*On A, store the list of B ids in a field like b_ids

*On B, store the list of A ids in a field like a_ids
This requires two writes whenever an association is created or destroyed, but requires either zero or one joins at query time to traverse the association (if you just want the id of Bs for a given A and you have the A already no further queries are needed).
Join model
Create a model C which has two fields: a_id and b_id. Each association is represented by a single instance of C.
This requires one write whenever an association is created or destroyed, but requires joins on all queries involving association (potentially two joins per query).


text:
Q: efficient matlab implementation for Lukas-Kanade step I got an assignment in a video processing course - to implement the Lucas-Kanade algorithm. Since we have to do it in the pyramidal model, I first build a pyramid for each of the 2 input images, and then for each level I perform a number of LK iterations. in each step (iteration), the following code runs (note: the images are zero-padded so I can handle the image edges easily):
function [du,dv]= LucasKanadeStep(I1,I2,WindowSize)
It = I2-I1;
[Ix, Iy] = imgradientxy(I2);
Ixx = imfilter(Ix.*Ix, ones(5));
Iyy = imfilter(Iy.*Iy, ones(5));
Ixy = imfilter(Ix.*Iy, ones(5));
Ixt = imfilter(Ix.*It, ones(5));
Iyt = imfilter(Iy.*It, ones(5));
half_win = floor(WindowSize/2);
du = zeros(size(It));
dv = zeros(size(It));
A = zeros(2);
b = zeros(2,1);
%iterate only on the relevant parts of the images
for i = 1+half_win : size(It,1)-half_win
    for j = 1+half_win : size(It,2)-half_win
          A(1,1) = Ixx(i,j);
          A(2,2) = Iyy(i,j);
          A(1,2) = Ixy(i,j);
          A(2,1) = Ixy(i,j);
          b(1,1) = -Ixt(i,j);
          b(2,1) = -Iyt(i,j);
          U = pinv(A)*b;
          du(i,j) = U(1);
          dv(i,j) = U(2);
      end
  end
end

mathematically what I'm doing is calculating for every pixel (i,j) the following optical flow:

as you can see, in the code I am calculating this for each pixel, which takes quite a long time (the whole processing for 2 images - including building 3 levels pyramids and 3 LK steps like the one above on each level - takes about 25 seconds (!) on a remote connection to my university servers).
My question: Is there a way to calculate this single LK step without the nested for loops? it must be more efficient because the next step of the assignment is to stabilize a short video using this algorithm.. thanks.

A: I ran your code on my system and did profiling. Here is what I got.

As you can see inverting the matrix(pinv) is taking most of the time. You can try and vectorise your code I guess, but I am not sure how to do it. But I do know a trick to improve the compute time. You have to exploit the minimum variance of the matrix A. That is, compute the inverse only if the minimum variance of A is greater than some threshold. This will improve the speed as you won't be inverting the matrix for all the pixel.
You do this by modifying your code to the one shown below.
function [du,dv]= LucasKanadeStep(I1,I2,WindowSize)
It = double(I2-I1);
[Ix, Iy] = imgradientxy(I2);
Ixx = imfilter(Ix.*Ix, ones(5));
Iyy = imfilter(Iy.*Iy, ones(5));
Ixy = imfilter(Ix.*Iy, ones(5));
Ixt = imfilter(Ix.*It, ones(5));
Iyt = imfilter(Iy.*It, ones(5));
half_win = floor(WindowSize/2);
du = zeros(size(It));
dv = zeros(size(It));
A = zeros(2);
B = zeros(2,1);
%iterate only on the relevant parts of the images
for i = 1+half_win : size(It,1)-half_win
    for j = 1+half_win : size(It,2)-half_win
          A(1,1) = Ixx(i,j);
          A(2,2) = Iyy(i,j);
          A(1,2) = Ixy(i,j);
          A(2,1) = Ixy(i,j);
          B(1,1) = -Ixt(i,j);
          B(2,1) = -Iyt(i,j);
        % +++++++++++++++++++++++++++++++++++++++++++++++++++
        % Code I added , threshold better be outside the loop.
        lambda = eig(A);
        threshold = 0.2
        if (min(lambda)> threshold)
            U = A\B;
            du(i,j) = U(1);
            dv(i,j) = U(2);
        end
        % end of addendum
        % +++++++++++++++++++++++++++++++++++++++++++++++++++

%           U = pinv(A)*B;
%           du(i,j) = U(1);
%           dv(i,j) = U(2);
      end
  end
end

I have set the threshold to 0.2. You can experiment with it. By using eigen value trick I was able to get the compute time from 37 seconds to 10 seconds(shown below). Using eigen, pinv hardly takes up the time like before.

Hope this helped. Good luck :)

A: Eventually I was able to find a much more efficient solution to this problem.
It is based on the formula shown in the question. The last 3 lines are what makes the difference - we get a loop-free code that works way faster. There were negligible differences from the looped version (~10^-18 or less in terms of absolute difference between the result matrices, ignoring the padding zone).
Here is the code:
function [du,dv]= LucasKanadeStep(I1,I2,WindowSize)

    half_win = floor(WindowSize/2);
    % pad frames with mirror reflections of itself
    I1 = padarray(I1, [half_win half_win], 'symmetric');
    I2 = padarray(I2, [half_win half_win], 'symmetric');

    % create derivatives (time and space)
    It = I2-I1;
    [Ix, Iy] = imgradientxy(I2, 'prewitt');

    % calculate dP = (du, dv) according to the formula
    Ixx = imfilter(Ix.*Ix, ones(WindowSize));
    Iyy = imfilter(Iy.*Iy, ones(WindowSize));
    Ixy = imfilter(Ix.*Iy, ones(WindowSize));
    Ixt = imfilter(Ix.*It, ones(WindowSize));
    Iyt = imfilter(Iy.*It, ones(WindowSize));

    % calculate the whole du,dv matrices AT ONCE!
    invdet = (Ixx.*Iyy - Ixy.*Ixy).^-1;
    du = invdet.*(-Iyy.*Ixt + Ixy.*Iyt);
    dv = invdet.*(Ixy.*Ixt - Ixx.*Iyt);

end


text:
Q: Best way to iterate over S3 and download each file separately into python I have a large amount of files in S3 (~150gb of text files) in a fairly simple folder structure. There are a number of folders and within each of these there are several Gb of files. I would like to use boto3 to iterate over the contents of s3 and download each file, operate on that file in python (does not need to reupload/alter the original in s3) and then move on to the next file. The hard part is there are also other objects in the bucket that I would like to ignore, such as some of the folders and zip files that are present.
I've had some luck with the following to list the contents of s3, but I don't know how to access the names of the files within python
for object in s3.Bucket('name_of_bucket').objects.all():
    print(object)

printing the object gives the name of the files, but I don't know how to access the contents of the object within python. The object is a boto3.resources.factory.s3.ObjectSummary object.
I'm either looking for help with how to use this method or a completely different method.
Thank you in advance

A: Just like print(object), you can check the name of the object via object.key and, if desired, download it with object.download_file.
You can then access the contents of the file on the local disk.
While you could use object.get() and then access the contents via the streaming body Body response, it is better to read/manipulate the file from the local disk.
All functions are documented in: Boto3 Docs: S3 Object

A: use download_file method
for obj in first_bucket.objects.all():
     subsrc = obj.Object()
     print(obj.key)  # gives file name
     obj.download_file(f'/tmp/{obj.key}')   # download file


text:
Q: invalid path "/ipfs/about.html": invalid CID: selected encoding not supported After going through the tutorial for a multipage ipfs site, i am getting the following error:
https://docs.ipfs.io/how-to/websites-on-ipfs/multipage-website/#add-files-to-ipfs

It seems it is trying to find the page in the general IPFS directly and not take into account my folder structure (which is the same as in the example on the tutorial site).
I tried also to hardcode each link and CID loading the files separately, still inside the folder but it doesn't work how it's shown in the example.
I also see the url structure of the example is different than the one the desktop ipfs is sharing.
Perhaps there is something i am missing, or that is missing, from the tutorial?


text:
Q: Поделиться в Facebook [iOS 7] Доброе время суток, ситуация такая: есть textField, как мне информацию с textField рассказать в Facebook? И что для этого нужно?
A: Доброе время суток уважаемый!

*

*Вам нужно - это добавить фреймворк: "Social.framework";

*Импортировать "Social/Social.h";

*В файле .h объявить SLComposeViewController *slComposeViewController //название может быть произвольное;

*Сама реализация:

//Допустим наш textView/Field называется "textViewDetailNotes".
// .m
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
     slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
     [slComposeViewController setInitialText:[[self textViewDetailNotes] text]];

     [self presentViewController:slComposeViewController animated:YES completion:nil];
     [[self textViewDetailNotes] resignFirstResponder];
}
else
{
     //Если пользователь не авторизован в Настройки/Facebook
}


text:
Q: How can I define a function that guarantees not to change its argument, even if the argument is non-const? This is sort of a follow up to this question
Consider the following snippet
void f(int const &); // f "guarantees" not to change its parameter

int main()
{
  int const a = 42;  // a is not modifiable
  f(a); // so f definitely can't modify a
        // (at least not without invoking UB), that's great

  int b = 42; // b is modifiable
  f(b); // but f could modify b legally? huh? not so great
}

My understanding: f can only modify b, and it must use const_cast to do so. Also, this is generally a bad idea, and should not be done. Also, there are reasons for why there is a mechanism in the language to ignore const.
If my understanding is correct, then my question is, is there a way to write a function that is guaranteed to not modify its argument. i.e. is there a way to do the following
void f(int const_really &); // f *guarantees* not to change its parameter

int main()
{
  int b = 42; // even if b is modifiable
  f(b); // f is not allowed to modify b legally
        // (or is UB if it does)
}

Edit: One reason for doing this would be to allow the compiler to do optimizations. Currently, a function that accepts an argument by const-reference is not allowed to assume that the bits of the argument will not be modified by the function. This is because the function could do a legal const_cast, or the argument type could have mutable members.
If the function could rely on the argument not being modified, then I would assume that certain kinds of optimizations could be done (similar to whole-program optimizations that prove the argument never changes).
Is that something that could be added to the language?
If not, is there some reason why this can never be done?

A: The keyword for that is const. It already offers as strong a guarantee as C++ will ever give - that is none, if the implementer of the function chooses so.
If you decide to cast away const, all bets are off, and you better know what you are doing.
C++ is a language that will always allow you to cast away anything, in one way or another. So whatever new const_really keyword you introduce, it will be left right where const is now - powerless if the programmer decides to ignore it and do a bunch of casts. Disallowing that will go against the core tenet of C++ - absolute control, if the programmer needs it. There is no need for a new keyword, because there is nothing to be gained from adding one.

A: const is the best you can have.
If you are worried that some external program can still magically modify the parameter b, that can possibly happen, even if you use other language like C#, Java, etc. Once you have a grasp of the address of b accidentally/intentionally and you specify an access like in kernel-mode or const_cast you can modify it. Anything can be modified internally.
You just now have to focus inside your function. Adding const is enough. If YOU didn't modify b inside YOUR function that's enough proof that b won't be modified even if can still be modified in a hack way. You know the full logic inside of the function. You can see that b won't be modified.
In addition, const_cast have a useful purpose. In my case, I have getters of big object that I have to return as const so most of member variables and methods won't be modified or accessed. But I have to set a special methods to add things on that big object. It's just like categorize access. I hope they'll add it to c++ someday.


text:
Q: Hide admin menu items and restrict access based on Role i know about the way to show/hide menu items in admin based on user roles, but anyone can just type the address and access the specific menu. I was wondering if there is a way to restrict that as well.
For the moment i'm using this code:
add_action( 'admin_init', 'my_remove_menu_pages' );

function my_remove_menu_pages() {
    // If the user does not have access to publish posts
    if(!current_user_can('add_users')) {
        // Remove the "Tools" menu
        remove_menu_page('tools.php');
    }
}

A: How about going the other way:
http://codex.wordpress.org/Function_Reference/add_role


text:
Q: Admob Interstitial error androidstudio i am getting this error when i want to run apk.
Error:
Information:Gradle tasks [:app:assembleDebug]
Error:Öffnendes Anführungszeichen wird für Attribut "android:name" erwartet, das mit Elementtyp "uses-permission" verknüpft ist.
Error:Exception while parsing the supplied manifest file /home/murat/Downloads/BestSoccerTips/app/src/main/AndroidManifest.xml

Öffnendes Anführungszeichen wird für Attribut "android:name" erwartet, das mit Elementtyp "uses-permission" verknüpft ist.

my manifest.xml is like here:
<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

    <activity android:name="com.google.android.gms.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
    android:theme="@android:style/Theme.Translucent" />
    <activity android:name=".FullscreenActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

where is the error please help thanks


text:
Q: How can change text view visibility when i click it even it was hidden? What i have is two text view, and what i am trying to do is when i start to write in one of them the other will be invisible which worked fine , and here is the code :
@Override
                    public void onFocusChange(View v, boolean hasFocus) {

                                textView2.setVisibility(View.INVISIBLE);

                    }
                });
              textView2.setOnFocusChangeListener(new OnFocusChangeListener() {
                    @Override
                    public void onFocusChange(View v, boolean hasFocus) {
                        // TODO Auto-generated method stub

                                textView.setVisibility(View.INVISIBLE);

                    }
                });

But the thing is , i want to reverse it too .. so if (textview) is hidden and i click on it's area while it's hidden , to return visible and the other one is invisible , how can i do this? any help please?

A: You can showing/hiding your 1st textView by checking if the 2nd textview is focused:
textView2.setOnFocusChangeListener(new OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        if (hasFocus) {
            textView.setVisibility(View.INVISIBLE);
        } else {
            textView.setVisibility(View.VISIBLE);
        }
    }
});

textView.setOnFocusChangeListener(new OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        if (hasFocus) {
            textView2.setVisibility(View.INVISIBLE);
        } else {
            textView2.setVisibility(View.VISIBLE);
        }
    }
});

EDIT:
View.OnClickListener clickListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        v.setVisibility(View.VISIBLE);
    }
});
textView.setOnClickListener(clickListener);
textView2.setOnClickListener(clickListener);

A: you can do something like this:
<LinearLayout
        android:id="@+id/txt1"
        android:layout_width="match_parent"
        android:layout_height="30dp">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

</LinearLayout>
<LinearLayout
        android:id="@+id/txt2"
        android:layout_width="match_parent"
        android:layout_height="30dp" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView"
            android:visibility="invisible" />

 </LinearLayout>

second linear layout has it's area.but inner textView does not show.so you can set onClick for it.
LinearLayout l1 = (LinearLayout) findViewById(R.id.txt1);
final TextView textView2 = (TextView) findViewById(R.id.textView2);
l1.setOnClickListener(new OnClickListener(){
    @override
    public void onClick(View view){
       textView2.setVisibility(View.VISIBLE);
    }
});

A: Use setVisibility() method for doing this
//To make textView not visible
textView.setVisibility(View.GONE);

//To make textView visible
textView.setVisibility(View.VISIBLE);


text:
Q: why there are two ssl_certs folders in Centos /usr/local/lib/ruby/2.1.0/rubygems/ssl_certs

/usr/local/lib/ruby/site_ruby/2.1.0/rubygems/ssl_certs

The contents are different as well.
The first one has the following .pem:
Class3PublicPrimaryCertificationAuthority.pem
DigiCertHighAssuranceEVRootCA.pem
EntrustnetSecureServerCertificationAuthority.pem
GeoTrustGlobalCA.pem

The second one has the following .pem:
AddTrustExternalCARoot-2048.pem
AddTrustExternalCARoot.pem
Class3PublicPrimaryCertificationAuthority.pem
DigiCertHighAssuranceEVRootCA.pem
EntrustnetSecureServerCertificationAuthority.pem
GeoTrustGlobalCA.pem


text:
Q: How to start e2e tests after creating a new aurelia project So  I created a new project with aurelia-cli and selected protractor for e2e testing, I expected to have a command similar to au karma for running e2e tests but there is none.
How do I run the e2e test?

A: At the moment, I guess there is no command to run the e2e tests (as you can check here: https://github.com/aurelia/cli/tree/81b029191f4752fecdaf0192bb03c7cd0bc87d8f/lib/resources/tasks)
However, the CLI generated projects provide a lot of different nps scripts. One of it contains starting the e2e tests. However, nps itself is not a dev dependency in the CLI projects. A fast way to run e2e tests is the following:
On the CLI, change to your project and run:
npm install -D nps

This adds nps as a dev dependency and makes all scripts from package-scripts.js available (if you have installed nps globally, skip this step).
Then, you can run the e2e tests via:
npm start -- e2e

Or, if you have installed nps globally (or at least, it is available in your PATH), you can also run
nps e2e

A: Did not quite work as expected, the nps trick does not work for a aurelia-cli project, probably works for webpacker.
Endedup using a combination of this post http://mobilemancer.com/2017/01/05/aurelia-spa-unit-testing-and-e2e-testing/ and the skeleton app here https://github.com/aurelia/skeleton-navigation/tree/master/skeleton-typescript-aspnetcore/src/skeleton
My config and task file are here https://gist.github.com/alexandru-calinoiu/8bf0a5e97f05311e388fe333f6b83b75


text:
Q: Node next to other tikz I want to write a code to get a network package structure.
        1          var         4
-------------------------------------
|   Control   |    Casa   |   Mia   |

Currently I have the code below, but I have noticed that I get two lines in stead of 1 between the cell Control and Casa. Any help?
\documentclass{article}

\usepackage[latin9]{inputenc}
%\usepackage[utf8x]{inputenc}
%\usepackage[spanish]{babel}
%\usepackage[spanish]{translator}
\usepackage[OT1]{fontenc}

%TikZ stuff
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgf}
\usetikzlibrary{shapes,arrows,automata,plotmarks,positioning}

\begin{document}

\begin{tikzpicture}%[scale=1.5]
    \tikzstyle{every path}=[draw, font=\small]

    \node[right,draw, minimum width=2cm,minimum height=0.8cm,fill=white](b0) {Control};
    \node[right=0cm of b0, draw, minimum width=2cm,minimum height=0.8cm,fill=white](b0) {Casa};
\end{tikzpicture}

\end{document}

Edit 1:
Now I have this, but figure is not center, and don't now how to make a line from the corners of control to get to the total of the other row
\begin{figure}
\newcommand{\size}{\linewidth}

\begin{tikzpicture}%[scale=1]
    \tikzstyle{every path}=[draw, font=\small]

    \node[right,draw, minimum width=0.15*\size,minimum height=0.8cm,fill=white](b0) {Control};
    \node[above=-0.2 of b0, minimum width=0.15*\size,minimum height=0.8cm] {1};
    \node[above left=-0.2 and -0.5 of b0, minimum width=0.2*\size,minimum height=0.8cm] {byte};

    \node[right=0cm of b0, draw, minimum width=0.2*\size,minimum height=0.8cm,fill=white](b1) {Longitud};
    \node[above=-0.2 of b1, minimum width=0.2*\size,minimum height=0.8cm] {1};

    \node[right=0cm of b1, draw, minimum width=0.6*\size,minimum height=0.8cm,fill=white](b2) {Valor};
    \node[above=-0.2 of b2, minimum width=0.6*\size,minimum height=0.8cm] {8};

    \node[below left=1 and -2 of b0 ,draw, minimum width=0.2*\size,minimum height=0.8cm,fill=white](h0) {Bloqueo};
    \node[below=-0.2 of h0, minimum width=0.15*\size,minimum height=0.8cm] {1};
    \node[below left=-0.2 and -0.5 of h0, minimum width=0.15*\size,minimum height=0.8cm] {bit};

    \node[right=0cm of h0, draw, minimum width=0.3*\size,minimum height=0.8cm,fill=white](h1) {M\'{a}ximo n$^o$ intentos};
    \node[below=-0.2 of h1, minimum width=0.2*\size,minimum height=0.8cm] {3};

    \node[right=0cm of h1, draw, minimum width=0.2*\size,minimum height=0.8cm,fill=white](h2) {RSV};
    \node[below=-0.2 of h2, minimum width=0.2*\size,minimum height=0.8cm] {1};

    \node[right=0cm of h2, draw, minimum width=0.4*\size,minimum height=0.8cm,fill=white](h3) {Intentos restantes};
    \node[below=-0.2 of h3, minimum width=0.4*\size,minimum height=0.8cm] {3};

\end{tikzpicture}
\caption{Mi figura}
\end{figure}

A: As was suggested, I think matrix is a good option to draw byte and bit fields.
Next code show how to use two matrices with two rows each one and how to join their corners to represent that the second one is a detailed field.
\documentclass[tikz,border=2mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{lmodern}
\usepackage{textcomp}
\usetikzlibrary{matrix,positioning}

\begin{document}

%\begin{figure}
\newcommand{\size}{\linewidth}

\begin{tikzpicture}[
    every path/.style={draw, font=\small},
     labelfield/.style={outer sep=0pt, minimum height=5mm,font=\small, anchor=center},
    field/.style={outer sep=0pt, draw, minimum height=8mm,
    minimum width=#1\size,font=\small,anchor=center}]

    \matrix (A) [matrix of nodes, column sep=-\pgflinewidth,
    row 1/.style={nodes=labelfield}, row 2/.style={nodes={field=.15}}] {
    byte & 1 & 1 & 8 \\
     &  Control & |[field=.2]|Longitud &  |[field=.6]| Valor\\
    };

    \matrix (B) [matrix of nodes, column sep=-\pgflinewidth,
            below=5mm of A,
            row 2/.style={nodes=labelfield},
            row 1/.style={nodes={field=.15}}] {
     &  |[field=.2]| Bloqueo & |[field=.3]|Màximo n\textdegree{}  intentos &  |[field=.2]| RSV & |[field=.2]| Intentos restantes\\
    bit & 1 & 3 & 1 & 3\\
    };

    \draw (A-2-2.south west) -- (B-1-2.north west);
    \draw (A-2-2.south east) -- (B-1-5.north east);

\end{tikzpicture}
\end{document}


text:
Q: Unable to add LSTM layer on top of embedded layer on GPU - Keras with tensorflow backend Below is the code snippet:
from keras.models import Sequential
from keras.layers import LSTM, Embedding

lang_model = Sequential()
lang_model.add(Embedding(1000, 100, input_length=25))
lang_model.add(LSTM(100,return_sequences=True)) #stuck here

lang_model.summary()

When I run the above code on my local CPU, it runs fine, but when running on a GPU on google cloud, it just doesn't work. It doesn't even show any error, its just gets stuck on the 3rd line.
Please suggest.
Just figured out that it works fine with theano backend, but fails when I use tensorflow backend.
Thanks.


text:
Q: Julia spherical harmonics different from python I would like to calculate the Spherical Harmonics with Julia. I have done this with the following code:
using GSL

function radius(x, y, z)
    return sqrt(x^2 + y^2 + z^2)
end

function theta(x, y, z)
    return acos(z / radius(x, y, z))
end

function phi(x, y, z)
    return atan(y, x)
end

function harmonics(l, m, x, y, z)
   return (-1)^(m) * GSL.sf_legendre_sphPlm(l, m, cos(theta(x,y,z)))*ℯ^(im*m*phi(x,y,z))
end

harmonics(1, 1, 11.66, -35, -35)
harmonics(1, 1, -35, -35, -35)

The output is the following:
0.07921888327321648 - 0.23779253126608726im
-0.1994711402007164 - 0.19947114020071643im

But doing the same with the following python code:
import scipy.special as spe
import numpy as np

def radius(x, y, z):
    return np.sqrt(x**2 + y**2 + z**2)

def theta(x, y, z):
    return np.arccos(z / radius(x, y, z))

def phi(x, y, z):
    return np.arctan(y / x)

def harmonics(l, m, x, y, z):
    return spe.sph_harm(m, l, phi(x, y, z), theta(x, y, z))

harmonics(1, 1, 11.66, -35, -35)
harmonics(1, 1, -35, -35, -35)

Results in the following output:
(-0.07921888327321645+0.23779253126608718j)
(-0.19947114020071638-0.19947114020071635j)

So the sign of the first result is different. But since only one of the results has a different sign, the cause cannot be in the prefactor (-1)^m. I can't see through this anymore and can't explain why the results are different.

A: The comment by @Oscar Smith got me started on the solution. Julia uses a different convention for the angles returned by atan, provided two arguments are passed [Julia, Numpy]. If we use atan(y / x) instead of atan(y, x) in Julia we get the same result.


text:
Q: Is this an efficient or even correct way of parsing serial data? To preface I am new to java (so take it ez on me lol) but here is what I am trying to do:
I have a GPS puck that I am reading via usb. The GPS puck uses some UI but I am trying to capture the data so I can use for my own application. I am reading in the packet from the serial buffer and trying to strip it down to just the payload and dissect the fields into a hashMap (not sure if this is the right application for it or not).
I want to add that the reason I care about efficiency in this case is because data will be getting processed through every fairly rapidly as the GPS puck is constantly getting Sat data (approx. every 200/300ms), so I am trying to avoid any bottlenecking if possible.
Here is the code that I have dished out, I know that in the code the buffer is not reading anything but in an effort to remove redundant code, just assume the data written in the comments is what we would be saying if we sys.out.
/*

Assume this is serial data received from GPS serial packet:
B5 62 01 02 1C AA AA AA AA 01 02 03 04 0A 0B 0C 0D B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4 E1 E2 E3 E4 01 02;
     |  |   /  |                                                                                /  |
     |  \ len   \                                                                                /  CRC
    /    |       \                                                                                /
   /     |        \                                 PAYLOAD                                        /
Header   |         \                                                                              /
    class & id      \                                                                            /

*/
HashMap<String, String> payloadDict = new HashMap<String, String> (); // HashMap to write to

Bytes[] buffer; // serial buffer
String byteToHex = DataTypeConverter.parseHexBinary(buffer); // converts byte data to string in Hex

// Since the first few fields in the packet are static (header, class & id, and len),
// I strip the HEX string to only contain the payload
int payloadStartIndex = byteToHex.indexOf("C") + 1;
String payload = byteToHex.substring(payloadStartIndex, payloadStartIndex + 29);

/*

Assume this is the payload string after we parse:

AA AA AA AA 01 02 03 04 0A 0B 0C 0D B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4 E1 E2 E3 E4
**added seperation every 2 hex values for readability,
  but assume it's just one giant string

*/

// write to HashMap
payloadDict = NAV_POSLLH(payload);

/*

so to visualize what I would imagine being saved to the HashMap:

iTOW:   AA AA AA AA
lon:    01 02 03 04
lat:    0A 0B 0C 0D
height: B1 B2 B3 B4
hMSL:   C1 C2 C3 C4
hAcc:   D1 D2 D3 D4
vAcc:   E1 E2 E3 E4

*/

public Map<String, String> NAV_POSLLH(String dataArr) {
    // Temp HashMap
    HashMap<String, String> dict = new HashMap<String, String> ();

    /*
        this is the payload format.
        payloadStructure are the names of the all the fields I want to parse
        and hexOffset are the beginning of each field.
    */

    String[] payloadStructure = new String[6] {"iTOW", "lon", "lat", "height", "hMSL", "hAcc", "vAcc"};
    int[] hexOffset = new int[6] {0, 7, 11, 15, 20, 24};

    // loop through each field
    for(int i = 0; i < byteOffset.length; i++) {
        String parse = "";

        // I am not sure if this is the best way to handle out of index errors
        // in java, but this is what I thought would work
        if(byteOffset[i] == 24) {
            parse = dataArr.substring(hexOffset[i]);
            map.put(payloadStructure[i], parse);
            return dict;
        }

        // parse the substring from the beginning of each hex offset
        // to the next index -1
        parse = dataArr.substring(byteOffset[i], hexOffset[i+1] -1);
        map.put(payloadStructure[i], parse);

        // finally return HashMap
        return dict;
    }
}

I am not sure if the comments explain the packet structure well enough or if it is confusing (because the format is janky), so I attached a screenshot of the packet layout I made.

So what I am trying to ask from all of this:
Based on what I am trying to accomplish, is this an efficient or even a correct way of implementing it? I am not sure if there is anything I am just obviously missing.
I am unable to compile or test any code right now so I am just trying to visualize what the output would be haha. Thanks so much for anyone's input!

A: I would make a Packet class and fill it using ByteBuffer. That class has great methods for parsing, including bulk get methods for various primitive sizes. You might consider using a ByteBuffer for the payload member of that class


text:
Q: Opencv 'undefined reference to `cv::namedWindow....' (linking error) I'm using the following CMake file to build an opencv project using the command cmake followed by make.
cmake_minimum_required(VERSION 2.8)
project(t)
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /home/keiths/opencv/opencv-2.4.11_build/build)
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(${OpenCV_INCLUDE_DIRS})

find_package(OpenCV REQUIRED)
find_package(MPI REQUIRED)

add_executable(t t.cpp)
target_link_libraries(t ${OpenCV_LIBS} ${OpenCV_LIBRARIES} opencv_core opencv_highgui opencv_calib3d opencv_contrib opencv_core opencv_features2d opencv_flann opencv_gpu opencv_highgui opencv_imgproc opencv_legacy opencv_ml opencv_nonfree opencv_objdetect opencv_ocl opencv_photo opencv_stitching opencv_superres opencv_ts opencv_video opencv_videostab rt pthread m dl)

MESSAGE(${OpenCV_LIBS})
MESSAGE(${OpenCV_INCLUDE_DIRS})

cmake completes fine, but make gives me the following error:

CMakeFiles/t.dir/t.cpp.o: In function main': t.cpp:(.text+0x56):
  undefined reference to
  cv::namedWindow(std::__cxx11::basic_string, std::allocator > const&, int)' collect2:
  error: ld returned 1 exit status make[2]: * [t] Error 1 make[1]: *
  [CMakeFiles/t.dir/all] Error 2 make: *** [all] Error 2

I've tried running the following command
g++ t.cpp $(pkg-config --libs opencv --cflags)
but get the following error

/home/keiths/tmp/ccWFcaXH.o: In function main': t.cpp:(.text+0x56):
  undefined reference to
  cv::namedWindow(std::__cxx11::basic_string, std::allocator > const&, int)' collect2:
  error: ld returned 1 exit status

I'm running the following simple code
#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
//#include <mpi.h>

 using namespace cv;

 int main(int argc, char **argv) {
      Mat image;
      namedWindow( "Display window", WINDOW_AUTOSIZE );
      return 0;
  }

I've tried as many recommendations as I can without success. Platform is CentOS and I'm a limited user (non-root) with my locally installed (more recent) versions of g++/gcc. I get the correct list of libraries for the pkg-config command and have configured library paths as well as the PATH to my local opencv folder
Just to add a very important point, I tried compiling the same code while explicitly specifying the stock g++ compiler (/usr/bin/g++) and all went well. So it seems that the problem would be with my local g++ compiler at '/home/keiths/lbin'. I need this latest version however for the c++11 capability (the old is 4.4.7 and it would take ages for the Sysadmin to upgrade it)

A: I had built my OpenCV library using the old g++ compiler (in the system bin folder), prior to building the latest g++. Rebuilding the OpenCV library using the new g++ compiler did it for me. Out of curiosity, I tried building the OpenCV example using the old compiler and it returned many 'undefined reference' lines, but I'm happy to swap problems since I don't need it anyway!


text:
Q: Access to related data (e.g. renderings) in Autodesk Forge using Data Management API Is there any possibility to access referenced data (e.g. renderings) in Autodesk forge?
Maybe, using something like
GET projects/:project_id/items/:item_id/relationships/refs

myhub of Autodesk360

A: It does not seem to be exposed at the moment. Sorry.
I made a note of this in our tracking system, that this functionality is sought after.
Unfortunately, I cannot tell at the moment when it will become available.
If you set up the references yourself - at the moment that could be an attachment - then you would be able to retrieve that relationship:
Create an Attachment


text:
Q: resignFirstResponder not hiding keyboard on textFieldShouldReturn I have a view with a UITextField which should hide the keyboard when return is pressed.
My function is this:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
 if ( textField == userPassword ) {
  [textField resignFirstResponder];
 }
 return YES;
}

Normally the keyboard should be hidden but it stays on the screen. resignFirstResponder is correctly called. What am I missing?

A: This solution worked for me after none of the above did. after calling resignFirstResponder i added a modal view & removed it.

    [myTextField resignFirstResponder];
    UIViewController *dummyController = [[UIViewController alloc] init];
    UIView *dummy = [[UIView alloc] initWithFrame:CGRectMake(-1, -1,1,1)];
    [dummyController setView:dummy];
    [self presentModalViewController:dummyController animated:NO];
    [dummyController dismissModalViewControllerAnimated:NO];

A: I see you have the iPad tag on this. Do you happen to be presenting a modal view using UIModalPresentationFormSheet? If so, it looks like this is a limitation of the FormSheet modal presentation (either Apple is doing it intentionally for some reason, or it is a bug). See these other questions for more details:
Modal Dialog Does Not Dismiss Keyboard
Modal View Controller with keyboard on landscape iPad changes location when dismissed

A: To deal with the bug mentioned by Brandon, you can try closing and re-opening your modal view controller as long as you still have a reference to it.
[textField resignFirstResponder];
[self dismissModalViewControllerAnimated:NO];
[self presentModalViewController:yourModalViewControllerReference animated:NO];

(where "self" should be the controller you used to originally open the modal view controller)

A: There is this helpful method which allows you to dismiss the keyboard when presenting the Modal Dialog:
 - (BOOL)disablesAutomaticKeyboardDismissal { return NO; }

This will override the default behavior of the modal dialog set by Apple and allow you dismiss the keyboard. It is in the UIViewController Class.
I hope this helps someone!

A: I was having the same problem. I realized that after connecting the delegate to the File's Owner in Interface Builder, I neglected to save in Interface Builder. Once I saved, I recompiled and the keyboard disappears correctly when hitting return.

A: xcode 4.5.1
Simply click control then on the textfield drag and release on the .h file
(control key+ drag)
then in the pop up menu select
connection=acton;
name= any name;
type=id;
event=did end on exit;
arguments=sender;

then click connect button

A: Did you remember to implement the UITextFieldDelegate protocol?

A: If you are using the Interface Builder, look if your UITextField has the delegated linked with your class.
-Select your UITextField and in your Connections look if exits one connection in Outlets->delegate. If not, conect with you File's Owner Class.
This need to be linked with your File's Owner Class. This delegate tell where to search for a method. If your are overriding a method, you need to tell where the object will search for that.

A: I have read so many articles about this issue, where the onscreen keyboard refuses to hide when you call resignFirstResponder, but none of the suggestions worked for me.
I'm using XCode 5 (iOS 7) and have a iPhone screen containing a couple of controls which require the onscreen keyboard, but if the user clicks on the UIButton, then I want the keyboard to disappear.

I probably wasted one full day experimenting with resignFirstResponder and adding disablesAutomaticKeyboardDismissal functions to return NO, but nothing worked.  Once the onscreen keyboard appeared, I could never get it to disappear again.
But then I had a small brainwave  (as I only have a small brain).
Now, when the user clicks on my UIButton, I simply disable the UITextField and UITextView controls.
- (IBAction)btnDate_Tapped:(id)sender {
    //  The user has clicked on the "Date" button.
    self.tbClientName.enabled = NO;
    self.tbComments.editable = NO;

And suddenly, the app finds it has no editable text fields needing an onscreen keyboard, and it neatly slides the keyboard out of sight.
(Relieved sigh.)
My UIButton actually makes a popup dialog appear.  When the user dismisses the popup, I re-enable these two controls, so if the user taps in one of them, the keyboard will appear again.
-(void)popoverControllerDidDismissPopover:(UIPopoverController *) popoverController {
    //  The user has closed our popup dialog.
    //  We need to make our UITextField and UITextView editable again.
    self.tbClientName.enabled = YES;
    self.tbComments.editable = YES;
    ... etc...
}

Simple, isn't it !
And surprisingly, this workaround even works on UIViewControllers which appear in Modal style.
I hope this helps other XCode victims out there.

A: Based on your comment that it looks like focus has shifted, then I think what may be happening is that the keyboard is staying open for the next text input field.  If your return key is a "Next" key, then returning YES for textFieldShouldReturn: will make the next textField the first responder, and keep the keyboard visible.

A: The easiest way is:

*

*Go to your user interface builder,

*select UITextField and "Control-Drag" to "Detail View Controller-Detail" and release.

*The window will pop-up. Then under "Outlets" select "Delegate".
That's it. It worked for me.

A: if you are in UIModalPresentationFormSheet just call
- (BOOL)disablesAutomaticKeyboardDismissal
{
    return NO;
}

A: Swift 3.0:
override var disablesAutomaticKeyboardDismissal: Bool {
    get{
        return false
    }
    set {
        self.disablesAutomaticKeyboardDismissal = false
    }
}

A: Swift 3.0
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {

    if textField == addressTextField {
        textField.resignFirstResponder()

        return false
    }

    return true
}


text:
Q: JSON payload validates against schema even though field is missing I assume I've missed something in defining the schema. Note that the id property is required under the form property, but it is not provided in the JSON, yet the JSON validates correctly according to multiple JSON validators online.
Schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://example.biz",
  "type": "object",
  "properties": {
    "form": {
      "type": "object",
      "nullable": false,
      "properties": {
        "id": {
          "type": "number",
          "description": "The unique identifier of the form.",
          "nullable": false
        },
        "name": {
          "type": "string",
          "description": "The name of the form.",
          "nullable": false
        }
      }
    }
  }
}

JSON Payload
{
  "form": {
    "name": "Test 2"
  }
}

A: Your schema doesn't specify which properties are required.  You need to set required to the fields you want to be there.  You may also wish to set additionalProperties to false.
Docs: https://json-schema.org/understanding-json-schema/reference/object.html#required-properties
I don't see nullable as a key anywhere in the json schema docs.
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://example.biz",
  "type": "object",
  "properties": {
    "form": {
      "type": "object",
      "properties": {
        "id": {
          "type": "number",
          "description": "The unique identifier of the form."
        },
        "name": {
          "type": "string",
          "description": "The name of the form."
        }
      },
      "required": ["id", "name"],
      "additionalProperties": false
    }
  }
}


text:
Q: youtube video id, pass it to url I was trying to create a youtube video image for my blog, so that if a user writes a post including his text and a youtube link, my blog will generate a text and an image preview of youtube video (like in facebook when you post a youtube link). This is what I have done:
<?php

    $find_youtube = "http://www.youtube.com";

    if(preg_match("[$find_youtube]", $row['comment'])) {

        parse_str( parse_url( $row['comment'], PHP_URL_QUERY ), $my_array_of_vars );

        $row['comment'] = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", "

", $row['comment']);

    }
?>

my problem is that I cannot $my_array_of_vars to the link. Any idea how to fix this problem...or any other suggestions?


text:
Q: Spivak's Calculus, Ch 11, problem 24: describe the graph of a rational function Spivak, Chapter 11 "Significance of the Derivative", problem 24

*Describe the graph of a rational function (in very general terms, similar to the text's description of the graph of a polynomial
function).

Let $f(x)=\frac{r(x)}{s(x)}$ for polynomial functions $r$ and $s$.
If $r$ and $s$ have a common root $a$ with multiplicity 1, then these polynomials have a common factor $x-a$. For $x \neq a$ we can cancel these factors and we are left with another rational function $g(x)=\frac{p(x)}{q(x)}=\frac{a_nx^n+a_{n-1}x^{n-1}+...+a_0}{b_mx^m+b_{m-1}x^{m-1}+...+b_0}$, where $p(x)$ and $q(x)$ have no common roots.
$g(x)$ is not defined at roots of $q(x)$, and roots of $p(x)$ are roots of $g(x)$. At roots of $q(x)$ the graph of $g(x)$ has a vertical asymptote.
What happens to the graph of $g$ at common roots of $r$ and $s$?
If the common root has multiplicity 1 as described above, it seems that what happens is that $f$ is undefined at these points but the graph isn't a vertical asymptote.
Here is an example
$$f(x)=\frac{(x-1) \cdot x}{(x-1)\cdot x^2} \implies \lim\limits_{x \to 1} f(x)=\lim\limits_{x \to 1} \frac{1}{x} = 1$$
Since the common root isn't a root of $p$ or $q$ (because it has multiplicity 1 in $r$ and $s$), we know that $\lim\limits_{x \to a} f(x) = \lim\limits_{x \to a} g(x)=\frac{p(a)}{q(a)}$
In the following example, 1 is a root of $r(x)$ with multiplicity 2.
$$g(x)=\frac{(x-1)^2 \cdot x}{(x-1) \cdot x^2} =\frac{x-1}{x-1} \cdot \frac{(x-1)\cdot x}{x^2} \implies \lim\limits_{x \to 1} g(x)= \lim\limits_{x \to 1} \frac{x-1}{x}=0
$$
Therefore 1 is also a root of $p$. Hence $\lim\limits_{x \to a} f(x) = 0$
In the example below, now 1 is a root of $s$ with multiplicity 2. It is also a root of $q$ (but not $p$). Hence we get the vertical asymptote.
$$g(x)=\frac{(x-1) \cdot x}{(x-1)^2 \cdot x^2} \implies \lim\limits_{x \to 1} g(x)= \lim\limits_{x \to 1} \frac{1}{(x-1) \cdot x}=\infty
$$
In summary, for a root $a$ common to $r$ and $s$ (including common multiplicity), $f$ is not defined at $a$, but the limit $\lim\limits_{x \to a} f(x)=\frac{p(a)}{q(a)}$ .
If the multiplicity of the common root is larger in the numerator, then $\lim\limits_{x \to a} f(x)=0$, if it is larger in the denominator then we have a vertical asymptote.
Are there any more cases?


text:
Q: JQuery :: Capture hover event and change CSS on child div I know I'm missing a small piece of this ... but for markup like this:

Link Text & Link Description

I have the following jquery
$('a.menusegment').hover(function () {
    // insert code here
});

What I want to do is change the top border color of the div contained in 'a.menusegment'
Any help would be greatly appreciated.
Thanks!

A: $(function(){
    $('a.menusegment').hover(function () {
        var thisNode = $(this);
        thisNode.children('div').css('border-top', '1px solid #f60');
    });
});

A: $('a.menusegment div').hover(function (e) {
    e.stopPropagation();

    // change color here
},
function(){
//code to execute on mouseleave
}
);

http://jsfiddle.net/3Bh5J/

A: If i understand your question... You dont need any kind of js
In CSS:
a.menusegment:hover div{
border-top:solid red 1px;
}


text:
Q: Form post data to ASHX hidden fields I have next form and some ashx
 <form action="FileUpload.ashx" method="POST" enctype="multipart/form-data" id="frmUpload">
        <input id="fileupload" type="file" name="files[]" />
        <input id="viewId" type="hidden" />
        <input id="moduleId" type="hidden" />
        <button id="btnUpload" type="submit">Upload</button>
    </form>

I can get file inside of   ProcessRequest(HttpContext context)
   context.Request.Files - file containe file information, but context.Request.Form["viewId"] is empty.
That should I do to get hidden fields values ?
Thanks.

A: You need to add the name="viewid" also. The name attribute is used when you make post, not the id
read also: HTML input - name vs. id  in the line "Used on form elements to submit information"


text:
Q: Method chaining within a javascript closure module Here's a question for js gurus. I'd like to enable method chaining in a js module coded as follows. I'd also like for each method to be able to return an object literal of various values. In the context of how this is coded, how would I enable the function chaining such as method2().method3()
Thanks!
var module1Constructor = (function() {

    // methods:

    var init = function() {

        var someValue = 'value';

        method2().method3(); // chained method calls

        return {module1:'iDontKnow',returnedValue1:someValue}; // how to pass value back to enable function chaining?

    }; // init

    var method2 = function() {

        var someValue = 'value';

        return {module1:'iDontKnow',returnedValue1:someValue}; // how to pass value back to enable function chaining?

    }; // method2

    var method3 = function() {

        var someValue = 'value';

        return {module1:'iDontKnow',returnedValue1:someValue}; // how to pass value back to enable function chaining?

    }; // method3

    return function module1Constructor() {

        this.init = init;

    } // return function module1Constructor() {

})(); // module1Constructor

var module1 = new module1Constructor;

module1.init();

A: How is method chaining necessary if it isnt accessible by the user?
So you may want to write onto the prototype of a function, making it a regular constructor:
function module1Constructor(){
    //...
    }
module1Constructor.prototype={
         test:1,
         a:function(){
           alert(this.test++);
           return this;
          },
         //extended
         b:function(){
            return Object.assign(new module1Constructor(),this,{c:alert});
         }
 };

Use like this:
test=new module1Constructor().a().a().a().a();
test.a().c();//doesnt work
test.a().b().c();//does work
test.a().b().a();

A: The term method chaining is more related to prototypes, in this case, what I see in your comments is you want to access values within functions, that is called closure, which is a way to access a value when a function is invoked outside it's lexical scope. so in your object literal that you are returning, you can do.
 var method2 = function() {

    var someValue = 'value';

    return {module1:'iDontKnow',returnedValue1:someValue, method3:method3};

 }