text:
Q: android how to know if i have location available i've made a listener that checks is the GPS status is changed..
i want the listener to check if the phone is able get location at all, if now throw gps, then throw cellolar cell..
how can i add it to my listener ?
my listener:
locMgr.addGpsStatusListener(new GpsStatus.Listener()
    {
        public void onGpsStatusChanged(int event)
        {
                switch(event)
                {
                        case GpsStatus.GPS_EVENT_STARTED:
                            locationStatus.setText("Location is On");
                                break ;
                        case GpsStatus.GPS_EVENT_STOPPED:
                             locationStatus.setText("Location is Off");
                                break ;
                }
        }
    }) ;

A: Write a class
public class MyLocationListener implements LocationListener {
        /**
         * This function handles location change event if location is found
         */
        public void onLocationChanged(Location loc) {...

Now, whenever you'll get some GPS location, it'll come inside onLocationChanged() method.
Do not forget to add the following permissions in your manifest-
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Also make sure you are adding both the location listeners GPS as well as Network like-
locationManager.requestLocationUpdates(
                LocationManager.NETWORK_PROVIDER, 0, 0, locListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
                0, locListener);

A: If you mean you would like to know specific provider availability, you could use:
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); //or other provider.

And track its availability using LocationListener callbacks:
    @Override
    public void onProviderEnabled(String provider) {

    }

    @Override
    public void onProviderDisabled(String provider) {

    }

Ofcourse you will need a propriate location permissions in your manifest.


text:
Q: Repositioning an Image on Swift I'm making a flappy bird-esque game on swift and am having trouble resetting the character once it hits an object or the ceiling. Usually it's not an issue because it will just restart where it last left off. However, when it hits a high object or the ceiling, it gets stuck because the character immediately moves up and continues to hit the ceiling infinitely, causing you to have to close and restart the game.
What line of code do I need to reset it's position automatically upon collision? Thanks!

redpajama_set_name: RedPajamaStackExchange


text:
Q: Hide li if broken image I have a list of images where each image is wrapped in a li:

How can I hide this entire li if image 1.jpg is broken as if it never existed in the DOM?
I found some good js on how to hide the image and learned from another SO post that I want to display:none so I don't create an empty row. But I'm having trouble putting these together.

A: You can use an onerror handler for the image:

// this function must be in the global scope
function hideContainer(el) {
    $(el).closest("li").hide();
}

Or, you could even just remove it if you really want it as if it never existing in the DOM:
// this function must be in the global scope
function hideContainer(el) {
    $(el).closest("li").remove();
}

If you don't want to put an onerror handler in the HTML (the only reliable place you can put it) then you can hide the images initially and then check .complete when your jQuery runs and if the image is not yet complete, then install a .load() handler like this:
CSS:
/* use some more specific selector than this */
li {display: none;}

jQuery:
$("li img").each(function() {
    if (this.complete) {
        // img already loaded successfully, show it
        $(this).closest("li").show();
    } else {
        // not loaded yet so install a .load handler to see if it loads
        $(this).load(function() {
            // loaded successfully so show it
            $(this).closest("li").show();
        });
    }
});

A: In jQuery there is .error event handler http://api.jquery.com/error/.
Example:
$('img').error(function(event) {
   $(this).closest('li').hide();

});

A: Using jQuery you can set your
 to load ONLY IF the  loads.  Read along here.
HTML starts as:

Either give it a class if it's part of a group, an ID if it's very specific and you just want that one, or select all the images on the page if you want.  For my example I'll use the class to select it as a group.
jQuery:
$('.imgSet').load(function() {
    $(this).parents('li').show();
});

Basically it's hidden until the image loads.

A: You can use this:

on error handle the image and if not found get its id and remove itself from the DOM


text:
Q: In meteor, is there a onRendered function for all templates? In meteor, is there a onRendered function for all templates? Or is there an easy alternative?
Example:
Template.allTemplates.onRendered(function(){/*doSomething()*/});

Rather than:
Template.template0.onRendered(function(){/*doSomething()*/});
Template.template1.onRendered(function(){/*doSomething()*/});
Template.template2.onRendered(function(){/*doSomething()*/});

A: Seems like the answer is right in front of you:
_.each(_.keys(Template), function(key) {
     if (Template[key] instanceof Blaze.Template) {
        console.log(key, "is the name of a template");
        Template[key].onRendered(myGlobalOnRenderFunction);
     }
});

I wouldn't recommend it though. It seems hard to predict what will happen in this case, because this will trigger for nested template as well, so you may get a lot more calls to that handler than you may wish.


text:
Q: Issue with Connecting to PPTP VPN - Modem hangup I have following issue with connection to PPTP VPN in Ubuntu 14.04.

*

*I installed ppp and ppp-linux

*I set up /etc/ppp/chap-secrets to following
113.41.242.167\\mark    PPTP    NaksOsP    *

*I created /etc/ppp/peers/vpn1 with following
pty "pptp 113.41.242.167 --nolaunchpppd"
name 113.41.242.167\\mark
remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
ipparam vpn1
mru 1412
mtu 1412

*I edited /etc/ppp/options.pptp to following
lock
noauth
refuse-pap
refuse-eap
refuse-chap
refuse-mschap-v2
nobsdcomp
nodeflate

*Then I run sudo pon vpn1 with no response, so I ran sudo pon vpn1 debug dump logfd 2 nodetach with following output
pppd options in effect:
debug       # (from command line)
nodetach        # (from command line)
logfd 2     # (from command line)
dump        # (from command line)
noauth      # (from /etc/ppp/options.pptp)
refuse-pap      # (from /etc/ppp/options.pptp)
refuse-chap     # (from /etc/ppp/options.pptp)
refuse-mschap-v2        # (from /etc/ppp/options.pptp)
refuse-eap      # (from /etc/ppp/options.pptp)
name 113.41.242.167\\mark       # (from /etc/ppp/peers/vpn1)
remotename PPTP     # (from /etc/ppp/peers/vpn1)
        # (from /etc/ppp/options.pptp)
pty pptp 113.41.242.167 --nolaunchpppd      # (from /etc/ppp/peers/vpn1)
crtscts     # (from /etc/ppp/options)
        # (from /etc/ppp/options)
asyncmap 0      # (from /etc/ppp/options)
mru 1412        # (from /etc/ppp/peers/vpn1)
mtu 1412        # (from /etc/ppp/peers/vpn1)
lcp-echo-failure 4      # (from /etc/ppp/options)
lcp-echo-interval 30        # (from /etc/ppp/options)
hide-password       # (from /etc/ppp/options)
ipparam vpn1        # (from /etc/ppp/peers/vpn1)
nobsdcomp       # (from /etc/ppp/options.pptp)
nodeflate       # (from /etc/ppp/options.pptp)
require-mppe-128        # (from /etc/ppp/peers/vpn1)
noipx       # (from /etc/ppp/options)
using channel 28
Using interface ppp0
Connect: ppp0 <--> /dev/pts/22
sent [LCP ConfReq id=0x1 <mru 1412> <asyncmap 0x0> <magic 0xc953e228> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <mru 1412> <asyncmap 0x0> <magic 0xc953e228> <pcomp> <accomp>]
Modem hangup
Connection terminated.
Script pptp 113.41.242.167 --nolaunchpppd finished (pid 8753), status = 0x0

Can anyone please help me with this ? I also tried Network Manager GUI but with no luck


text:
Q: Error while starting the Oracle Weblogic Server 11g When I'm starting the weblogic server, I'm getting the below error.
<Error> <Deployer> <BEA-149205> <Failed to initialize the application 'myapp_weblogic
_10' due to error weblogic.application.ModuleException: .
weblogic.application.ModuleException:
        at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:393)
        at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
        at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
        at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: com.ibm.websphere.servlet.session.IBMSessionListener
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
        Truncated. see log file for complete stacktrace
>

As the error shows that ClassNotFoundException occurs for "com.ibm.websphere.servlet.session.IBMSessionListener".
But I'm not finding how to resolve this error.
Also in Weblogic Server Console, it's showing that application state is "FAILED" in deployement section.
Can someone help me with this?

A: Your application myapp_weblogic contains a web application, in which the web.xml defines a session listener using class com.ibm.websphere.servlet.session.IBMSessionListener. Judging by the name, this session listener class is provided by IBM Websphere. Thus it is not available in Weblogic. Remove this session listener from the web.xml should fix the server startup issue. But if this session listener is important to your application, you need to see how to migrate it onto WLS server.


text:
Q: How many ohms do I need for LEDs controlled by an shift register? So I've got 6 LEDs, 3 red, 3 green. I'm going to control them using a shift register and either an arduino uno, or an arduino due. Now, I know I'm supposed to use resistors for the LEDs, but I'm really confused as to how many ohms. Everywhere I've looked has told me different things. Could someone explain this to me and show me how to actually calculate this?

A: It depends on following three inputs:

*

*the signal or supply voltage \$V_{s}\$ (i.e. the voltage of your shift register output, e.g. 5V or 3.3V)

*the forward voltage \$V_{LED}\$ of your LED (depends on the semiconductor material of the LED and that depends on the color; e.g. 1.3V, 1.8V, 2V, etc.). You get this info from the datasheet of the LED.

*the current \$I_{LED}\$ you want to operate the LED with (the max. current is given in the datasheet; of course the signal source must be able to supply that current); e.g. 10mA

Then the resistance must be
\$R = \frac{V_s - V_{LED}}{I_{LED}}\$
Example: you want to operate a red 1.8V LED with 10mA at a 5V source:
\$R = \frac{5V - 1.8V}{10mA} = \frac{3.2V}{10mA} = 320 \Omega\$

A: Adding to what Curd said, your typical 74HC595 shift register only sink or source 70 mA in total. You may need to reduce the LED current to the maximum current to 70 mA / (max simultaneous LEDs), or if this is not bright enough, then use the shift register to drive transistors which drive the LEDs. In a lot of cases ~6 mA is good enough for indicator LEDs. You could also select a shift register designed for LED driver that can handle higher current, such as this part.
It's because of design choices like these that one does not tend to find general values of current limiting resistance for LEDs. The resistance you select depends on the application.


text:
Q: This key is not authorized for this service We have been using the same key for over a month now and we just notice a few days ago that it is no longer working. We are having trouble searching for answers on the web, we hope someone here can enlighten us about this problem. Thanks!
Here is the full error:

This key is not authorized for this service. If you do not have a key,
  you can obtain a free key by registering at
  http://developer.mapquest.com.

A: There were changes in the licensing structure that were announced late last year. Are you using your key with the correct service?  The Free & Open keys work with the Free & Open APIs and SDKs hosted on the open.mapquestapi.com subdomain.  For instance, if you are calling the Free & Open Geocoding API, you would want to be calling this URL: http://open.mapquestapi.com/geocoding/v1/address?key=YOUR-KEY-HERE


text:
Q: RubyMotion - error build vendor project - how to get details I am trying to build simple project cloned from github (cocosmotion), and I am continuosly getting the exactly same error - "ERROR! Building vendor project 'vendor\cocos2d-iphone' failed to create at least one '.a' library."
I think that is not much of a problem if there is a way to get some details, logs or something similar information, which can help to solve this kind of problem. But all my tries and searches in google are not helpful at the moment.
So my question is - How can I get more detailed information about what is failing to build in that vendor project?
Are there a way to turn on more verbose output?

A: Well actually it turned out that all I need is to do "rake clean" and try to build again after that. This will force total rebuild and I was able to see problems in vendor project compilation process (which was deprecated calls in cocos2d source code which was not latest version).


text:
Q: Sitecore ECM 2.1, slow UI We have just upgraded Sitecore from 6.6 to 7.2, and ECM from 1.3 to 2.1. We are having issues with the Speak UI for ECM being extremely slow. Every operation that seems to fetch data takes several minutes. For example: retrieving the list of recipient lists, where an ajax post request takes minutes to the url http://[domain]/speak/EmailCampaign/TaskPages/AdHockTaskPage?type=Adhoc&id={FD1B449B-C3EA-4820-A10E-E7976A897B8F}&sc_speakcontentlang=nb-NO&ff=1
This is in all our environments (test/production), and we can't get anything from the logs even if we set debug=true on all config settings we can find.
A side note is that we previously used a module to segment the emails (https://marketplace.sitecore.net/en/Modules/Sitecore_EmailCampaign_Segment.aspx) that is deprecated for our version, so we've tried to clean up items and files for this, without anything getting better.
Has anyone had this issue?

A: I've had some issues in the past with performance. The general advice is to go through the performance tuning document first:
https://sdn.sitecore.net/upload/sdn5/products/ecm/200/ecm_tuning_guide_20-usletter.pdf
There are settings described in the document that can fix issues if you have high CPU usage so you should probably check if your CPU is maxing out. The document also describes some of the tools that you can use to measure performance. I found this tool quite useful to give you an idea of what's going on -
/sitecore/admin/dispatchsummary.aspx.
Failing that, you're best off contacting support.

A: For anyone with this problem in the future:
This was a bug with the upgrade from 1.3 -> 2.1. Sitecore support filed it as a bug and sent me a dll which partly replaced some rendering logic for a ECM Speak component. So get in touch with Sitecore support and they should be able to help you!


text:
Q: HTML5 Audio Streaming There has been some talk of this around stackoverflow before, but nothing really answered this question from what I have seen.
I am trying to implement a streaming audio web application. Almost identical to what WFMU has done with their player (http://wfmu.org/html5/player.php).
All I have been able to figure out from their stream is they are piping the stream into PHP, don't know in what format, and then feeding this to jPlayer for HTML5 presentation to the client.
They have this working awesome, but I am just unsure how they are feeding the audio into PHP and what they are doing within their PHP to present it in an acceptable format for HTML5.
Any ideas would be greatly appreciated.
It looks like the PHP script just echos out an audio file (http://blogfiles.wfmu.org/DG/stream3.php).

A: There is no requirement to use PHP.  For the client, all that matters is you send the appropriate content type, and actual content.  In this case, audio/mpeg (MP3), or OGG for Firefox (which, isn't working for them right now, but it definitely can).
I suspect the reason that they are using PHP to relay the stream, is that they are using SHOUTcast as the streaming server.  Doing some poking around, I found this:  http://mp3stream.wfmu.org:8000/
Note that when you hit that URL in your browser, you get the basic information page.  However, if you hit this with an audio player, you get the stream.  The SHOUTcast server decides this based on the User-Agent string.  If it contains "Mozilla" anywhere in the User-Agent, then it returns this page.  If it doesn't, then it returns the stream.  So, for an HTML5 audio player, it would use the browser's User-Agent (which contains Mozilla) and would be unable to access the stream.  I suspect their PHP script is what gets around the problem.
The PHP script would use cURL, connect to the streaming server with its own User-Agent (can be anything, as long as it isn't "Mozilla"), and relay chunk by chunk to the browser that hit the PHP script.  Piece of key-lime-pie.


text:
Q: Android, crossfading between 2 views that are different images using a button I am having an issue crossfading between 2 images using a button. The button isn't implemented but the problem is that I can't even load the image view. Eclipse doesn't give an error in the java code, but when I try to run the application, it crashes. I've included the MainActivity.java, the LogCat, and the XML file below.
public class MainActivity extends ActionBarActivity {

    private View imageView1;
    private View imageView2;
    private int mShortAnimationDuration;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }

        imageView1 = findViewById(R.id.imageView1);
        imageView2 = findViewById(R.id.imageView2);

        // Initially hide the content view.
        imageView2.setVisibility(View.GONE);

        // Retrieve and cache the system's default "short" animation time.
        mShortAnimationDuration = getResources().getInteger(
        android.R.integer.config_shortAnimTime);
    }

    private void crossfade() {

        // Set the content view to 0% opacity but visible, so that it is visible
        // (but fully transparent) during the animation.
        imageView1.setAlpha(0f);
        imageView1.setVisibility(View.VISIBLE);

        // Animate the content view to 100% opacity, and clear any animation
        // listener set on the view.
        imageView1.animate()
                .alpha(1f)
                .setDuration(mShortAnimationDuration)
                .setListener(null);

        // Animate the loading view to 0% opacity. After the animation ends,
        // set its visibility to GONE as an optimization step (it won't
        // participate in layout passes, etc.)
        imageView2.animate()
                .alpha(0f)
                .setDuration(mShortAnimationDuration)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        imageView2.setVisibility(View.GONE);
                    }
                });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container,
                    false);
            return rootView;
        }
    }

}

My xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="ca.mohawk.you.lab6a.MainActivity$PlaceholderFragment" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/desert" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/desert" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="42dp"
        android:text="@string/button_click" />

</RelativeLayout>

Logcat:
04-07 21:51:13.463: D/AndroidRuntime(1099): Shutting down VM
04-07 21:51:13.473: W/dalvikvm(1099): threadid=1: thread exiting with uncaught exception (group=0xb3ab2ba8)
04-07 21:51:13.483: E/AndroidRuntime(1099): FATAL EXCEPTION: main
04-07 21:51:13.483: E/AndroidRuntime(1099): Process: ca.mohawk.you.lab6a, PID: 1099
04-07 21:51:13.483: E/AndroidRuntime(1099): java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.mohawk.you.lab6a/ca.mohawk.you.lab6a.MainActivity}: java.lang.NullPointerException
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.os.Looper.loop(Looper.java:136)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at java.lang.reflect.Method.invoke(Method.java:515)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at dalvik.system.NativeStart.main(Native Method)
04-07 21:51:13.483: E/AndroidRuntime(1099): Caused by: java.lang.NullPointerException
04-07 21:51:13.483: E/AndroidRuntime(1099):     at ca.mohawk.you.lab6a.MainActivity.onCreate(MainActivity.java:36)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.app.Activity.performCreate(Activity.java:5231)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-07 21:51:13.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-07 21:51:13.483: E/AndroidRuntime(1099):     ... 11 more
04-07 21:54:14.453: D/AndroidRuntime(1164): Shutting down VM
04-07 21:54:14.453: W/dalvikvm(1164): threadid=1: thread exiting with uncaught exception (group=0xb3ab2ba8)
04-07 21:54:14.463: E/AndroidRuntime(1164): FATAL EXCEPTION: main
04-07 21:54:14.463: E/AndroidRuntime(1164): Process: ca.mohawk.you.lab6a, PID: 1164
04-07 21:54:14.463: E/AndroidRuntime(1164): java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.mohawk.you.lab6a/ca.mohawk.you.lab6a.MainActivity}: java.lang.NullPointerException
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.os.Looper.loop(Looper.java:136)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at java.lang.reflect.Method.invoke(Method.java:515)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at dalvik.system.NativeStart.main(Native Method)
04-07 21:54:14.463: E/AndroidRuntime(1164): Caused by: java.lang.NullPointerException
04-07 21:54:14.463: E/AndroidRuntime(1164):     at ca.mohawk.you.lab6a.MainActivity.onCreate(MainActivity.java:36)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.app.Activity.performCreate(Activity.java:5231)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-07 21:54:14.463: E/AndroidRuntime(1164):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-07 21:54:14.463: E/AndroidRuntime(1164):     ... 11 more
04-07 21:54:17.973: I/Process(1164): Sending signal. PID: 1164 SIG: 9
04-07 22:01:16.333: D/AndroidRuntime(1184): Shutting down VM
04-07 22:01:16.333: W/dalvikvm(1184): threadid=1: thread exiting with uncaught exception (group=0xb3ab2ba8)
04-07 22:01:16.353: E/AndroidRuntime(1184): FATAL EXCEPTION: main
04-07 22:01:16.353: E/AndroidRuntime(1184): Process: ca.mohawk.you.lab6a, PID: 1184
04-07 22:01:16.353: E/AndroidRuntime(1184): java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.mohawk.you.lab6a/ca.mohawk.you.lab6a.MainActivity}: java.lang.NullPointerException
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.os.Looper.loop(Looper.java:136)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at java.lang.reflect.Method.invoke(Method.java:515)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at dalvik.system.NativeStart.main(Native Method)
04-07 22:01:16.353: E/AndroidRuntime(1184): Caused by: java.lang.NullPointerException
04-07 22:01:16.353: E/AndroidRuntime(1184):     at ca.mohawk.you.lab6a.MainActivity.onCreate(MainActivity.java:36)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.app.Activity.performCreate(Activity.java:5231)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-07 22:01:16.353: E/AndroidRuntime(1184):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-07 22:01:16.353: E/AndroidRuntime(1184):     ... 11 more
04-07 22:01:59.343: I/Process(1184): Sending signal. PID: 1184 SIG: 9
04-07 22:02:01.843: D/AndroidRuntime(1205): Shutting down VM
04-07 22:02:01.843: W/dalvikvm(1205): threadid=1: thread exiting with uncaught exception (group=0xb3ab2ba8)
04-07 22:02:01.853: E/AndroidRuntime(1205): FATAL EXCEPTION: main
04-07 22:02:01.853: E/AndroidRuntime(1205): Process: ca.mohawk.you.lab6a, PID: 1205
04-07 22:02:01.853: E/AndroidRuntime(1205): java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.mohawk.you.lab6a/ca.mohawk.you.lab6a.MainActivity}: java.lang.NullPointerException
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.os.Looper.loop(Looper.java:136)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at java.lang.reflect.Method.invoke(Method.java:515)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at dalvik.system.NativeStart.main(Native Method)
04-07 22:02:01.853: E/AndroidRuntime(1205): Caused by: java.lang.NullPointerException
04-07 22:02:01.853: E/AndroidRuntime(1205):     at ca.mohawk.you.lab6a.MainActivity.onCreate(MainActivity.java:36)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.app.Activity.performCreate(Activity.java:5231)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-07 22:02:01.853: E/AndroidRuntime(1205):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-07 22:02:01.853: E/AndroidRuntime(1205):     ... 11 more
04-07 22:02:51.663: D/AndroidRuntime(1251): Shutting down VM
04-07 22:02:51.663: W/dalvikvm(1251): threadid=1: thread exiting with uncaught exception (group=0xb3ab2ba8)
04-07 22:02:51.673: E/AndroidRuntime(1251): FATAL EXCEPTION: main
04-07 22:02:51.673: E/AndroidRuntime(1251): Process: ca.mohawk.you.lab6a, PID: 1251
04-07 22:02:51.673: E/AndroidRuntime(1251): java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.mohawk.you.lab6a/ca.mohawk.you.lab6a.MainActivity}: java.lang.NullPointerException
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.os.Looper.loop(Looper.java:136)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at java.lang.reflect.Method.invoke(Method.java:515)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at dalvik.system.NativeStart.main(Native Method)
04-07 22:02:51.673: E/AndroidRuntime(1251): Caused by: java.lang.NullPointerException
04-07 22:02:51.673: E/AndroidRuntime(1251):     at ca.mohawk.you.lab6a.MainActivity.onCreate(MainActivity.java:36)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.app.Activity.performCreate(Activity.java:5231)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-07 22:02:51.673: E/AndroidRuntime(1251):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-07 22:02:51.673: E/AndroidRuntime(1251):     ... 11 more

A: It appears that the xml you've posted is from the file fragment_main.xml file. If this is the case, then the problem you're having is that findViewById() is searching for your Views in the Activity's View hierarchy before the Fragment's ViewGroup has been attached to the Activity. If you don't want/need to use Fragments, then simply move the posted xml to activity_main.xml, and remove the relevant Fragment blocks of code. If you want to use Fragments, then move your View initializations and functionalities to PlaceholderFragment.


text:
Q: Creating a Dictionary from a .txt File in Python I am trying to create a dictionary from a txt file "PortList.txt" with information in similar format to below, but keep getting the error "TypeError: unhashable type: 'list'"

TCP  0  Reserved
TCP  1  Port Service Multiplexer
TCP  2  Management Utility

The Key will be the "TCP" and "0" while the value is "Reserved"
My opening code is:
portDictionary = {}
with open('PortList.txt', 'r') as infile:
    for nextLine in infile:
        lineList = nextLine.split()
        keys = [lineList[0], lineList[1]]
        values = [lineList[2]]
        #this won't cover all of the words for the value, but for the test it's just for the first word
        portDictionary[keys] = values


text:
Q: Country code gets appended in the field after jquery validation error in intl-tel Input I'm using the following code to validate country code and contact number :
var e = window.intlTelInput(document.querySelector("#phone"), { separateDialCode: !0, preferredCountries: [currentCountry], hiddenInput: "full", utilsScript: "//cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/js/utils.js" });

but the issue is when i validate
jQuery.validator.addMethod(
                "phoneNumValidation",
                function (el, t) {
                   return e.isValidNumber();
                },
                return  "Please Enter Valid Phone Number"
            ),

on error country code is appended existing number.

there are some other fields which are being validated so as soon jquery validator is fired extra country code is being appended.


text:
Q: Can't build solution in release mode for SDL library on VS 2019
I tried to download the SDL library from this particular link https://www.youtube.com/watch?v=PTQkCRxr6lk&t=194s .However I stumbled upon  a "fatal error" and I have no clue what to do in order to solve it.
Here's what error I got:
1>------ Build started: Project: SDL2, Configuration: Release x64 ------
2>------ Skipped Build: Project: uninstall, Configuration: Release x64 ------
2>Project not selected to build for this solution configuration
1>   Creating library D:/Media/Downloads/SDL2-2.0.10/Build/Release/SDL2.lib and object D:/Media/Downloads/SDL2-2.0.10/Build/Release/SDL2.exp
1>SDL_string.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_vsnprintf_REAL
1>D:\Media\Downloads\SDL2-2.0.10\Build\Release\SDL2.dll : fatal error LNK1120: 1 unresolved externals
1>Done building project "SDL2.vcxproj" -- FAILED.
3>------ Skipped Build: Project: INSTALL, Configuration: Release x64 ------
3>Project not selected to build for this solution configuration
========== Build: 0 succeeded, 1 failed, 4 up-to-date, 2 skipped ==========

A: @Neri-kun I ran into exactly the same problem when building SDL2 on VS2019. It seems that memset is in vcruntime.dll, which is not included in CMakeLists.txt. So find the following part in CMakeLists.txt and add vcruntime to the EXTRA_LIBS. Problem solved:
   # Libraries for Win32 native and MinGW
-  list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 shell32)
+  list(APPEND EXTRA_LIBS vcruntime user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 shell32)

A: This is actually a compiler optimization issue. Something is inlining a call to memset inappropriately. If you inspect the SDL_string.c file, you will find that HAVE_MEMSET is not defined and therefore is not calling memset. The solution file provided in the VisualC folder does build Release configurations correctly. If you inspect the differences between the cmake generated solution and the one in the VisualC folder you should find that the cmake generated version inlines any suitable function while the one from the VisualC folder inlines only __inline marked up functions (/Ob1).


text:
Q: How to get the full image URL on iOS with UIImagePickerController using new PHAsset stuff How the heck do you get the full image URL on iOS with UIImagePickerController using new PHAsset stuff, since the ALAssetLibrary stuff was deprecated?

A: I was having an awful time finding the answer to this, so to help people in the future, here is my code that works to get the actual file URL to a photo selected with the built-in iOS UIImagePickerController. Still a little nervous about using the ALAsset URL to get the PHAsset, if you know of another way to do that then by all means please share.
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL* sourceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
if (sourceURL != nil) {
    PHAsset* asset = [[PHAsset fetchAssetsWithALAssetURLs:@[sourceURL] options:nil] lastObject];

    PHContentEditingInputRequestOptions* assetOptions = [[PHContentEditingInputRequestOptions alloc] init];
    [assetOptions setNetworkAccessAllowed:false];
    [asset requestContentEditingInputWithOptions:assetOptions
        completionHandler:^(PHContentEditingInput* contentEditingInput, NSDictionary* info) {
        NSURL* fullImageURL = contentEditingInput.fullSizeImageURL;
        printf("Hey, got the actual image URL: %s\n", [[fullImageURL absoluteString] UTF8String]);
        }];
    }

// ...finish and dismiss the UIImagePickerController
}


text:
Q: How to merge list of dataframes all with same index and same column names? I have a list of dataframe like this of 90 heat devices
data_list = [df0,df2, ... ,df89]

All of these dataframes in data_list have the same features (= column names):
("timestamp", "outside_temperature", "heating_generation", "power_consumption", "hot_water_storage", etc..)

All dataframes have the index : timestamp for the same period of time
I want to create now new dataframes which are having one feature but for all 90 heat devices
e.g for outside_temperature:
  timestamp        device_0, device_2, device_3 ,..., device_89
01.05.2022 00:10      15.03    14.39     15.69   ...   15.30
01.05.2022 00:15      14.94    14.20     15.30   ...   15.29
01.05.2022 00:20      14.94    14.05     15.29   ...   15.20
.
.
.
etc.

and that for all my features.
Any idea whats the best way to do so ? I was thinking about merging but couldn't find good advice, or do it by a for loops.

A: If I followed your question correctly you could concat the selected columns by first using a comprehension then setting the columns names in two steps.  This does assume that the timestamps are the same in all data frames stored in data_list.
For example the following would concatenate all outside_temperature columns, leaving the columns name the same:
feature_df = pd.concat([x['outside_temperture'] for x in data_list], axis=1)

and then you could rename the columns with something like the following:
feature_df.columns = [f'device_{i}' for i in range(len(data_list))]

A: You can concat your dataframes and then transpose them using pd.pivot  function like in this small example
import pandas as pd
df1 = pd.DataFrame({
    'timestamp': [pd.Timestamp(2022, 1,1), pd.Timestamp(2022, 1,2)],
    'value':[1,2],

})
df2 = pd.DataFrame({
    'timestamp': [pd.Timestamp(2022, 1,1), pd.Timestamp(2022, 1,4)],
    'value':[3,4]
})

dfs = [df1, df2]
# add df tag
for (idx, df) in enumerate(dfs):
    df['device'] = f'device_{idx}'

final_df = pd.concat([df1, df2])
pd.pivot(index = 'timestamp' , columns = 'device', values= 'value', data= final_df )


text:
Q: Filtering Asana tasks by multiple tags Once more the task bestowed on me is to work with the Asana API. What I am trying to do is to generate certain filtered lists with tasks.
What I am trying to get out of the API:
- A list of all tasks for all users and in all projects and workspaces
- A list of tasks with all tasks having certain tags (filtered by more than one tag)

With filtering on tags I mean: Get all tasks that have tag A, tag B and tag E.
Is this possible with the API?

A: Currently neither is possible - fetching a list of tasks requires either a project, tag, or assignee, and you can only fetch the tasks for a specific tag. We've thought about how to support more advanced queries, but we don't yet have that on our roadmap.


text:
Q: How to write a typescript library, that requires another library? I have written a typescript library (mathquill-typescript) that requires Jquery. I use jquery as a node_module. So my mathquill-typescript library starts like this:
import * as $ from 'jquery'

export namespace MathQuillLoader {
  ...

Now when I (or someone else) want to use this library, for example with SystemJS, I still need to specify details about jquery:
System.config({
baseURL: './'
,
map: {
  'jquery': 'node_modules/jquery/dist/jquery.js',
  'mathquill-typescript': 'node_modules/mathquill-typescript/dist/index.js'
}
});

Is there a way, that jquery is just an implementation detail and the user of mathquill-typescript doesn't need to know about it? At the same time I wouldn't want to inline jquery, since I want jquery to be only loaded once by the browser.


text:
Q: When print ASCII 0x07 character on console in .NET this causes system beep I write such code in VB.NET:
Console.WriteLine(ChrW(7))

And this is causes the system beep. What is this? And how to off this behavior?

A:
What is this?

The BEL character/code: https://en.wikipedia.org/wiki/Bell_character

And how to off this behavior?

Don't send character 7 to the console when you don't want it to beep.

A: If you never want beeps from the console, stop or disable the beep service.
For example,
net stop beep

in an Administrative command prompt.


text:
Q: How to solve SMTP connection problem in CodeIgniter? I have a mail function. And when I start the service it send e-mail from my array. My array include 60 mail. When start the service it send 10-15 mail and after got error like this.
from: The following SMTP error was encountered:

Unable to send data: QUIT
quit:

The following SMTP error was encountered:

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter

function sendMail($to,$cc="",$subject,$message,$title="",$attach="",$from="")
{
    $CI = & get_instance();
    $CI->load->library("email");

    $CI->email->clear(TRUE);
    $CI->email->set_newline("\r\n");
    if($title==""){
        $title="q Group";
    }

    if($from=="") {
        $from="q@q.com.tr";
    }
    $CI->email->from($from, $title);
    if($cc<>"")
        $CI->email->cc($cc);
    $CI->email->subject($subject);

    $CI->email->message($message);
    if($attach<>"")
    {
        $CI->email->attach($attach);
    }
    $mailList = explode(",",$to);
    $sendMailList = "";
    foreach ($mailList as $key=>$item) {
        if (filter_var($item, FILTER_VALIDATE_EMAIL)) {
            $sendMailList .=$item.",";
        }
        else{
            MailLogModel::setLog($item,$subject,0,"Mail Adresi Hatalı");
            if(count($mailList)==1)
                return ["status"=>false,"message"=>"Mail Adresi Hatalı"];
        }
    }
    $sendMail = substr($sendMailList,0,-1);
    $CI->email->to($sendMail);
    if (!  $CI->email->send()){
        MailLogModel::setLog($sendMail,$subject,0,html_entity_decode(imap_utf8($CI->email->print_debugger('headers','subject'))));
        return ["status"=>false,"message"=>$CI->email->print_debugger(array('headers'))];
    }
    else{
        MailLogModel::setLog($sendMail,$subject,1);
        return ["status"=>true];
    }
}

My config file is here:
$config['protocol']  = "smtp";
$config['SMTPAuth']    = true;
$config['smtp_host'] = "mail.MYSERVICE.com.tr";
$config['smtp_user'] = "";
$config['smtp_pass'] = "";
$config['smtp_port'] = "25";
$config['charset'] = "utf-8";
$config['mailtype']    = "html";
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
$config['smtp_timeout']    = 5;

How can I solve this problem?


text:
Q: Is it true that $\int\frac{1}{x}\,dx=\ln x\implies\ln x = \frac{x^0}{0}$? I have recently learned that $\int\frac{1}{x}\,dx=\ln x$.
However, by the power law of integration, the integral of $1/x$ is equal to $x^0 / 0$ which is undefined. Therefore, is $x^0 / 0 = \ln x$?
Am I correct in this assumption?

A: Your observation can be properly understood using a limit. Specifically, $f(x,p)=\int_1^x y^{p} dy$ is a continuous function of $p$, even at $p=-1$. This means that
$$\lim_{p \to -1} \frac{x^{p+1}-1}{p+1} = \ln(x).$$
You could prove this directly with L'Hospital's rule, provided you already knew that $\frac{d}{dx} a^x = a^x \ln(a)$.

A: The power rule cannot be used when integrating $\int \frac 1x\,dx = \int x^{-1}\,dx$.
I assume you are referring to the fact that for $n\neq -1$, $$\int x^{n} \,dx = \dfrac{x^{n+1}}{n+1}+ C$$  Note that this holds for all integers $n \neq -1$.
So $\dfrac {x^0}0 \neq \ln |x|$, and as you know, $\dfrac {x^0}0$ is not defined.

A: We can define $\log{x}$ explicitly as
$$ \int_1^x \frac{dt}{t}; $$
but why this definition?
Note that, for general powers $x^{n-1}$, we have
$$ \int_1^x t^{n-1} \, dt = \frac{x^n-1}{n}, $$
so we can't just set $n=0$ here to have a sensible answer without getting $0/0$. However, this suggests that
$$ \lim_{n \to 0} \frac{x^n-1}{n} = \log{x}. \tag{1} $$
This is in fact true, even if we define the logarithm as the inverse to the exponential: recall the definition of $e^x$ as a limit,
$$ y = e^x = \lim_{m \to \infty} \left( 1+\frac{x}{m}\right)^m $$
say, then we can do some algebra to find
$$ x= \lim_{m \to \infty} m(y^{1/m}-1), $$
(or just substitute this in and see what happens) and if you set $m=1/n$ you recover the limit (1).

A: A slight, but important correction to make:
$\int\frac{1}{x}\,dx=\ln |x|$ + c
We use the absolute value of x in order to have the same domain for both the right and left hand side.
If we only take the natural log of x, our x values are restricted to being > 0.
Whereas in  $x^-1$, Our x values are only restricted to x !=0

A: all the answers so far use integral representation of $\ln x.$ i will use the fact that $$ \text{ the derivative of } a^x \text{ at } x = 0 \text{ is }\ln a.$$  written in the form $$\lim_{x \to 0} \frac{a^x - 1}{x} = \ln a. $$  switching  the roles of $x$ and $a$ we have $$\lim_{a \to 0} \frac{x^a - 1} a = \ln x. $$ in a less than rigorous way, we have  $$\frac{x^0 - 1} 0 = \ln x  $$


text:
Q: EnableClientValidation on Master Page I'm trying out ASP.NET MVC 2 Preview and when I use client side validation it all works if the following:
Is used on a content page. If it is on a Master Page - client side validation fails.
Is it just me or is this by design? If so - why?

A: The answer is "it's just a preview." :)  There will be bugs or other design nits - this being one of them - and they will hopefully be resolved in the future.


text:
Q: activesheet in excel VBA Appologies for wery simple question i have, i'm just new in programming. Is the Activesheet in excel VBA means that if you have a code
Sheets("Point Assignments").Select
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Range("B2:B" & lastrow).Select
Application.CutCopyMode = False
Selection.Copy

The ActiveSheet will be the "Point Assignments"
Also, in the lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row what is meant by .END(xlup). Row
Thanks very much for the help
Regards,
Kenneth

A: Yes, but using ActiveSheet and not explicitly referring to a specific sheet does not make for good code.
It's difficult in a larger project to track which sheet is supposed to be active at any given time, particularly if you're calling out to other procedures which also interact with the workbook, and might leave the workbook in a different state from where it began.
So - a better approach would be something like:
With Sheets("Point Assignments")
    lastrow = .Cells(.Rows.Count, 1).End(xlUp).Row
    .Range("B2:B" & lastrow).Copy
End With

or simpler:
With Sheets("Point Assignments")
    .Range(.Range("B2", .Cells(.Rows.Count, 1).End(xlUp)).Copy
End With


text:
Q: Is my proof that the operations $+$ and $^{-1}$ are well defined for the rational numbers correct? Any feedback is appreciated, thanks!
-Let the equivalence relation $\sim$ be defined on the set $\mathbb{Z} \times \mathbb{Z}^{*}$, where $\mathbb{Z}^{*}$ = $\mathbb{Z}-\{0\}$, such that for $a,b,c,d \in \mathbb{Z}, (a,b) \sim(c,d) $ iff $ad=bc$.
-Let $\mathbb{Q}$ be the set of equivalence classes of $\mathbb{Z} \times \mathbb{Z}^{*}$ with respect to $\sim$. The elements $\bar{0}, \bar{1} \in \mathbb{Q}$ are defined as $\bar 0 = [(0,1)]$ and $\bar{1} = [(1,1)]$.
-Let the operation + on $\mathbb{Q}$ be defined as $[(x,y)]+[(z,w)]=[(xw+yz,yw)]$ for $[(x,y)],[(z,w)] \in \mathbb{Q}$.
-Let the operation $^{-1}$ on $\mathbb{Q}^{*}$ ,where $\mathbb{Q}^{*}=\mathbb{Q}-\{\bar{0}\}$, be defined as $[(x,y)]^{-1}=[(y,x)]$ for $[(x,y)] \in \mathbb{Q}^{*}$.
We seek to prove that + and $^{-1}$ are well defined. We begin with proving that + is well defined.
Let $[(x,y)]=[(a,b)]$ and $[(z,w)]=[(c,d)]$, where $[(x,y)],[(z,w)],[(a,b)],[(c,d)] \in \mathbb{Q}$.
From hypothesis, $zd=wc$. Thus, $(aw)d+(bz)d=(ad)w+b(zd)=(ad)w+b(wc)=(ad)w+(bc)w$. Multiplying both sides of the equation by $b$, we obtain $(aw)bd+(bz)bd=(ad)bw+(bc)bw$. Rearranging and simplifying, the equation becomes $(aw+bz)bd=bw(ad+bc)$. This implies that $[(a,b)]+[(z,w)]=[((aw+bz),bw)]=[((ad+bc),bd)]=[(a,b)]+[(c,d)]$.
From hypothesis, $xb=ya$. Thus, $(xw)b+(yz)b=(xb)w+y(bz)=y(aw)+y(bz)$. Multiplying $w$ on both sides of the equation yields $(xw)bw+(yz)bw=yw(aw)+yw(bz)$. Rearranging and simplifying gives $(xw+yz)bw=yw(aw+bz)$. This implies that $[(x,y)]+[(z,w)]=[((xw+yz),yw)]=[((aw+bz),bw)]=[(a,b)]+[(z,d)]$.
Putting this two results together, $[(x,y)]+[(z,w)]=[(a,b)]+[(z,w)]=[(a,b)]+[(c,d)]$. Thus + is well defined.
Next we prove that the operation $^{-1}$ is well defined. Let $[(x,y)]=[(a,b)]$, where $[(x,y)],[(a,b)] \in \mathbb{Q}^{*}$.
By hypothesis, we know that $xb=ya$. $[(x,y)]^{-1}=[(y,x)]$ and $[(a,b)]^{-1}=[(b,a)]$.Hence,$[(x,y)]^{-1}=[(a,b)]^{-1}$ if $ya=xb$, which is exactly what hypothesis implies. Hence, the operation $^{-1}$ is well defined.


text:
Q: Accessing a context object in a Django class-based generic view I'm using a DetailView to view a Project object, and I would like to be able to access the Project object being viewed in order to pass it to a decorator, something like this:
class ProjectDetailView(DetailView):
    context_object_name = "project"
    model = Project

    @method_decorator(membership_required(project))
    def dispatch(self, *args, **kwargs):
        return super(ProjectDetailView, self).dispatch(*args, **kwargs)

However, passing in "project" or "object" to the decorator gives me an "object", not a Project instance. How can I get that Project instance so my decorator function can work with it?

A: Object is retrieved inside a dispatch() method, so your decorator can not use it.
You may check membership inside of an overriden get() method:
class ProjectDetailView(DetailView):
    context_object_name = "project"
    model = Project

    def get(self, request, **kwargs):
        self.object = self.get_object()
        if not self.object.is_member(self.request.user):
            return HttpResponseRedirect('/') # or something else
        context = self.get_context_data(object=self.object)
        return self.render_to_response(context)

If you want to stick to decorator, you'll have to retrive object from database within your decorator, based on args (id or slug) to view. But you will be retrieving object from database twice, first in your decorator, and then within a view.


text:
Q: Matching Strings and Count Frequency I have a list of companies with their subsidiaries, the data looks as below:
CompanyName            Employees
Microsoft China          1
Microsoft India          1
Microsoft Europe         1
Apple Inc                1
Apple Data Inc           1
Apple Customer Service Inc   1
Data Corp                1
Data SHCH                1
Data India               1
City Corp                1
Data City                 1

If two companies have same words (e.g. Apple Inc and Apple Data Inc), they are considered one company. I will group those companies together, and calculate their total number of employees.
The expected return should be:
Company     Employees
Microsft     3
Apple        3
Data         3
City         2

*

*The company will return the common word

*The Employees return the sum of company and its subsidiaries

Most of the pandas function doesn't really work in this case. Any suggestions on For Loop?

A: *

*As you requested in the comments

*

*If the company is always the first word in CompanyName
# extract company as word at index 0
df.CompanyName = df.CompanyName.str.split(expand=True)[0]

# groupby company name and count
dfg = df.groupby('CompanyName').agg({'CompanyName': 'count'})

# display(dfg)
             CompanyName
CompanyName
Apple                  3
City                   1
Data                   4
Microsoft              3

A: I don't think there's a 'very' simple way to do what you want. But it's not too complex too.
First, you need to define clearly the ~criterion to decide wich names are the same 'company'.
We can try with "get the first world and see if it matches", obviously it's not a perfect approach, but it'll do for now.
Then, you can create an object to store your new data. I would recommend a dictionary, with entries like company: (total employees).
You'll now iterate over the rows of the dataframe, with apply and a function to do what you want. It'll look like this:
dict = {}

def aggregator(row):
    word1 = row.company.split(" ")[0]

    if word1 in dict.keys:
       dict[word1] += row.employees

    else:
        dict[word1] = row.employees

dataframe.apply(aggregator, axis = 1)


text:
Q: Can we prove that $\displaystyle 12 \int_{0}^{1}f^{2}(x)dx\le\int_{0}^{1}(1-x^4)(f''(x)) ^2dx$ if $f''$ is only Riemann integrable? Let $f:[0, 1]\to \mathbb{R}$ be a two times differentiable function such that $f''$ is Riemann integrable, $f(0)=0$ and $f'(0)=0$. Is it true under these assumptions that $$12 \int_{0}^{1}f^{2}(x)dx\le\int_{0}^{1}(1-x^4)(f''(x)) ^2dx?$$
The source of my problem is this, where I also proved this inequality if $f$ is a $C^2$ class function, i.e. if we know that $f''$ is not only Riemann integrable, but actually continuous. For the sake of completeness, I will add my short proof here.
By Taylor's Theorem with Integral Remainder we know that $$f(x)=\int_0^x (x-t)f''(t)dt$$
for any $x\in [0,1]$.
Thus, $$\int_0^1 f^2(x)dx=\int_0^1 \left(\int_0^x (x-t)f''(t) dt\right)^2 dx \stackrel{\text{C-S}}{\le}\int_0^1 \frac{x^3}{3}\left(\int_0^x (f''(t))^2 dt\right)dx=\frac{1}{12}\int_0^1(1-x^4)(f''(x))^2dx$$ and we are done.
The OP from AoPS required $f''$ to be only Riemann integrable and I wonder if this inequality still holds in that case or if he actually intended $f''$ to be continuous.
So far I've only come up with the idea that maybe I can somehow approximate a two times differentiable function with a Riemann integrable second derivative by a sequence of $C^2$ class functions. I don't know if this is possible (I haven't taken an advanced course in real analysis yet, so please bear with me if there is some well known density argument that I am not aware of), but this is all I could come up with.

A: The Riemann integrability of $f''$ is sufficient to ensure that Taylor's theorem with the integral remainder holds. Using integration by parts, you have
$$
\int_0^x (x-t)f''(t) \, dt = \left[ (x-t)f'(t) \right]_{t=0}^{t=x} + \int_0^x f'(t) \, dt =- x f'(0) + f(x) - f(0)
$$
or
$$
 f(x) = f(0)  + xf(0) + \int_0^x (x-t)f''(t) \, dt \, .
$$
More generally, the integral form of the remainder
$$
 R_{k}(x)=\int _{a}^{x}{\frac {f^{(k+1)}(t)}{k!}}(x-t)^{k}\,dt.
$$
is valid if $f^{(k)}$ is absolutely continuous on a closed interval $[a, b]$.
In order to show that
$$ \tag{*}
\int_0^1 \frac{x^3}{3}\left(\int_0^x (f''(t))^2 dt\right)dx=\frac{1}{12}\int_0^1(1-x^4)(f''(x))^2dx
$$
we can take a short detour via the Lebesgue integral. A Riemann integrable function on a compact interval is continuous almost everywhere, it is also Lebesgue integrable, and the Riemann integral coincides with the Lebesgue integral (see for example General condition that Riemann and Lebesgue integrals are the same).
Therefore,
$$
 g(x) = \frac{x^4-1}{12} \int_0^x f''(t)^2 \,dt
$$
is differentiable almost everywhere on $[0, 1]$, with
$$
g'(x) = \frac{x^3}3 \int_0^x f''(t)^2 \,dt - \frac{1-x^4}{12} f''(x)^2 \, .
$$
The right-hand side is Riemann- (and therefore Lebesgue-)integrable, so that the fundamental theorem of Lebesgue integral calculus can be applied, and it follows that
$$
0 = g(1) - g(0) = \int_0^1 g'(x) \, dx \\
= \int_0^1 \frac{x^3}{3}\left(\int_0^x (f''(t))^2 dt\right)dx -\frac{1}{12}\int_0^1(1-x^4)(f''(x))^2dx \, .
$$
Finally, all integrals on the right exist as Riemann integrals, so that $(*)$ holds for the Riemann integral as well.

A: You can also see that
$$
\int_0^1 {x^3\over 3}\left(\int_0^x (f''(t))^2 dt\right) dx={1\over 12}\int_0^1 (1-t^4)(f''(t))^2 dt
$$
by Fubini's theorem (interchange of the order of integration):
$$
\eqalign{
\int_0^1 {x^3\over 3}\left(\int_0^x (f''(t))^2 dt\right) dx
&= \int_0^1 \left(\int_t^1 {x^3\over 3} dx\right)(f''(t))^2 dt\cr
&=\int_0^1 {1-t^4\over 12}(f''(t))^2 dt.\cr
}
$$
For justification of the application of Fubini you can use the observation of Martin R that $f''$ is Lebesgue measurable and bounded, being Riemann integrable by hypothesis.


text:
Q: angular 1.5: factory to component its possible to change the binding of a component from a factory in angular 1.5.8?
(I want prepare a factory to display msgs when my http-interceptor caught an error 500)
For example.
Thats factory:
 angular.module('app')
    .factory('msgFct', ['$log', '$timeout', tuiMsgFct]);

    function tuiMsgFct($log, $timeout) {
      var module  = {};
      var self    = module;

      module.foo = function() {
        var node = document.getElementById('js-foo');

        node.setAttribute('bar', 'Awesome');
      };
      return module;
    }

To set thats bindings
/// COMPONENT IN DOM
<foo-component id="js-foo" bar=""></foo-component>

 //// COMPONENT TEMPLATE
<span>{{fooComponent.bar}}</span>

 //// COMPONENT CONTROLLER

  angular.module('app').component('fooComponent', {
    templateUrl: '...',
    controller: fooComponent,
    controllerAs: 'fooComponent',
    bindings: {
      bar: '<'
    }
  });

  function fooComponent() {
    var self = this;

  }


text:
Q: Surface Integral Problem and Formula For this question:
Calculate $\int \!\!\! \int E\cdot \vec n d\sigma$ where S is the parametric surface $X(s,t)=[st,s^2,t^2]^T$, $0\le s\le t\le 1$, and the E is the vector field $E(x,y,z)=[3yz,zx,2xy]^T$
Do I just use the formula:
$\int\!\!\!\int E(x(s,t))\cdot (\frac{\partial x}{\partial t}\times \frac{\partial x}{\partial s})dsdt$
Leading me to: $\int_0^1\int_0^1 (3s^2t^2,st^3,2s^3t)\cdot (0,0,-s)=\int_0^1\int_0^1 -2s^4t=-\frac{1}{5}$
Is that correct?

A: Either your $\frac{\partial X}{\partial t}$ and $\frac{\partial X}{\partial s}$ are wrong, or you computed your cross product wrong.  Here's what I get:
$$
X_t=[s,0,2t]^\intercal\\
X_s=[t,2s,0]^\intercal\\
X_t\times X_s=[-4st,2t^2,2s^2]^\intercal
$$ Also, I think you misinterpreted what $0\leq s\leq t\leq 1$ means.  That means that the integral bound for $t$ should go from $s$ to 1, not from 0 to 1.  This also means we integrate with respect to $s$ last.
$$
\begin{align*}
\int E\cdot\vec{n}d\sigma &= \int_0^1\int_s^1 (3s^2t^2,st^3,2s^2t)\cdot(-4st,2t^2,2s^2)dtds\\ & = \int_0^1\int_s^1 (-12s^3t^3+2st^5+4s^4t)dtds=-\frac{19}{140}
\end{align*}
$$
You might need to verify that the sign is correct, depending on which way $\vec{n}$ is oriented (in or out).


text:
Q: Desktop Folder Redirection Consistency I have changed our Desktop folder redirection policy to point to a new share on the server. Some computers are accepting the new policy and displaying the new shortcuts. Others display no icons and others display the old share.
How can I force a policy update on all workstations so they all show the new shortcuts? Running gpupdate does not have an effect, and neither does deleting the profile from System Properties - Advanced.
Thanks

A: Check the resultant set of policy mmc snapin on the misbehaving systems. It is possible an other policy is overriding your new settings. Verify that the group policy is actually bound to the OUs that the troubled workstations reside in.


text:
Q: How to set CSS property in adjacent elements? I am trying to set the css style from a sibling element.
For example:

Title

                --> This element class is dynamic..

Test1
 --> This element class is dynamic..

                --> This element class is dynamic..

Test2
 --> This element class is dynamic..

                --> This element class is dynamic..

Test3
 --> This element class is dynamic..

                --> This element class is dynamic..

Test4
 --> This element class is dynamic..

CSS
.title {
    color:red;
}

.title + .desc1 {    --> only set the first element as blue. I need to set all desc
    color:blue
}

I am using Angular ng-repeat and show those h4 dynamically. Is there anyway I can use title class relation to set h4 property in my case? Thanks!

A: Try ~

.title {
  color: red;
}
.title ~ div[class^=desc] {/* class name starting with `desc` */
  color: blue
}

Title

Test1

Test2

Test3

Test4

A: You can use a CSS atribute selector.  Try [class^="desc"].  This will select all elements whose class starts with "desc".

[class^="desc"] {
  /* all elements that have classes that begin with "desc" */
  color: blue
}

Title

Test1

Test2

Test3

Test4

A: HTML:

                --> This element class is dynamic..

Test1
 --> This element class is dynamic..

                --> This element class is dynamic..

Test2
 --> This element class is dynamic..

                --> This element class is dynamic..

Test2
 --> This element class is dynamic..

                --> This element class is dynamic..

Test2
 --> This element class is dynamic..

CSS:
.desc .lesson{
   color: blue;
}

There is no need to give each 'desc' its own unique name. You can simply have them all named the same and apply the CSS above to make all of them blue.

A: From how understand, your problem is to add a css color rule for the H4 to the immediate child of the 'title' class. Right.
Then Why not just try.
.title + div {
    color:blue
}

This will just let you style the immediate sibling to
.
Which is

And if, you need to add different css rules to each of these Four desc Divs. then, you can write, something like:
/*First class desc1 */
.title + div {
    color:#00a1ff;
}
/*First class desc2' */
.title + div + div {
    color:#00a1ff;
}
/*First class ' desc3' */
.title + div + div + div {
    color:#32d2db;
}
/*First class ' desc4' */
.title + div + div + div + div {
    color:#32d2db;
}

A: If I understand your problem correctly, you want child h4 s to have one color and the title to have another color. If so, define color for all h4 s first, then set color for the particular
h4.title as:
h4{
color: blue;
}
h4.title{
color: red;
}

Or is it that you need to do the sibling thing and this is just a sample case?


text:
Q: Deleted Github Repo made me lose Xcode files I'm new to GitHub Desktop and I was working on a project that I was trying to push to the remote server but it wasn't working.
Now Xcode has this source control that I have committed to my local repository I guess?? But now I've deleted my Repository from Github Desktop because it wasn't pushing all the files into the remote server.
This made me lose my project, and now I do not know where to find it. I was hoping that there is a way I can get the files back from the local git from my Mac

A:
but I did commit the files before deleting it though.

Then, in command line, check the output of git log or git reflog: you should see your commit.
A git checkout <old-commit> -- . (or, with Git 2.23+, git restore -s=<oldCommit> -SW :\) would restore what you have committed.
Restore locally at least: you would still need to push it to GitHub.
Then you can reopen XCode.


text:
Q: real analysis problem about $C^1$ functions Let $f: I \to \mathbb{R}$ be a $C^1$ function, where $I$ is an open interval in $\mathbb{R}$. Suppose that $f(0)\not = 0$. Prove that there are neighborhoods $U$ and $V$ of $0$ in $\mathbb{R}$ such that for all $x\in U$ there exists a unique $y\in V$ such that $$xf(y) = \int_0^y f(xt) dt,$$ and prove that the function $g:x\in U \mapsto y \in V$ defined by this is a $C^1$ function and satisfies $g'(0) = 1$.
How do I prove this? In reading through it, it seems that it may involve the Mean Value Theorem, but I just cant seem to piece it together and don't really know where to start.
thanks to all who take time to help

A: It is an application of the Implicit function theorem. Define
$$
F(x,y)=x\,f(y)-\int_0^yf(x\,t)\,dt\implies F(0,0)=0.
$$
We have to show that it is possible to solve for $x$ as a function of $y$ in a neighborhood of $(0,0)$. For this, check that the conditions of the Implicit function theorem are satisfied.


text: Q: Как остановить выполнение JS кода в браузере что бы посмотреть стили блока который появился? Есть динамический лоадер который не прописан в разметке первоначально, через 10 секунд после появления исчезает и разметка скрывается. Может можно остановить работу скрипта через панель разработчика либо как то еще добраться к разметке и стилям этого блока?


text:
Q: how can I know whether an android app widget is in background I do not want to update UI of my app widget when it go to background(you can not see it), how can I know an app widget is in background?

A: You cannot detect whether or not your homescreen widget it currently visible. There is an open bug report requesting this here.
At best, you could check to see if the homescreen (or any launcher in general) is visible:
public boolean isHomeShowing(){
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    ArrayList<string> homeList = new ArrayList<string>();
    for(ResolveInfo info : this.getPackageManager().queryIntentActivities(intent, 0)){
        homeList.add(info.activityInfo.packageName);
    }

    ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
        for (RunningTaskInfo t : am.getRunningTasks(1)) {
            if (t != null && t.numRunning > 0) {
                ComponentName cn = t.baseActivity;
                if (cn == null)
                   continue;
                else
                   if (homeList.contains(cn.getPackageName())) return true;
            }
        }
    return false;
}


text:
Q: Create slideshow for images using nstimer? How to create a slide show for the images using NSTimer in iphone

A: *

*Schedule a method to run every second (or as quick as you want the images to switch)

*Create an array of your images file names

*In the scheduled method change the UIImageView.image to be one from the images array by index.

There's a post here http://i-tutor.weebly.com/blog.html on how to schedule a method.


text:
Q: Angular Service not getting hit, function is undefined TypeScript I have created an extension method. Inside that extension method I tried to call the web API using the httpClient, however the method which is calling the HTTP is giving me an undefined error.
When using a debugger, I can see that my debugger is not going inside the class and I can't figure out why.
Note: This is an Extension method, not a service class
Extension.model.ts
declare global {
  interface Object {
    JsonServiceReceiver(): any[];
  }
}

class serviceChecker {

  constructor(private http: HttpClient) {}
  asd() {
    this.http.get('http://jsonplaceholder.typicode.com/posts').subscribe(data => {
      console.log(data);
    });
  }
}

Object.defineProperty(Object.prototype, 'JsonServiceReceiver', {

  value: function() {

    // according to my knowledge I am getting an error here, while object creation.

    let objservice: serviceChecker;
    objservice.asd();
  },
  enumerable: false
});

export {}

Error: ERROR TypeError: Cannot read property 'asd' of undefined

Here is the file from which I am attempting to call the extension method:
app.component.ts
import { Component, OnInit } from '@angular/core';
import { Employee } from './Employee.model';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {

  EmployeArray: Employee[] = [];

  submit() {
    this.EmployeArray = Object.JsonServiceReceiver();
    console.log("data", this.EmployeArray);
  }

}

I'm having trouble figuring out what I'm doing wrong. Again, I'm not using services, I'm using an extension method in TypeScript.

A: Well this construction: let objservice : serviceChecker; is not really creating the object, but rather assigning the type to the variable. So your variable objservice just has the type of your service. To actually create it, you need to use the let objservice = new serviceChecker()


text:
Q: Nesting a table, column of type string in BigQuery I have a query that I am running against my dataset in BigQuery. The data is partly the google analytics data for a particular website.
I want to be able to nest the string values for my key_web, to simplify the output and get the option to go deeper in detail if I want to.
The prd.key_web is of type string.
I have no idea how to do it !
It is a one to many relationship between the user who can have multiple rows in the table.
All fields are of type string except for prd.dat_log.
A simpler query would be:
 select
        prd.key_web
        , dat_log AS date
        , prd.nrb_fp AS nrb_fp
        , prd.tps_fp AS tps_fp
        , prd.univ
        , prd.suniv
        , prd.fam
        , prd.sfam
    from product as prd

A: Simple ARRAY_AGG function can create nested array in aggregation
select
  prd.key_web,
  ARRAY_AGG(STRUCT(
    dat_log,
    prd.nrb_fp,
    prd.tps_fp,
    prd.univ,
    prd.suniv,
    prd.fam,
    prd.sfam)) AS details
from
  product as prd
group by
  key_web


text:
Q: How do I calculate center of mass of a grid-type object? I am making a game with 2D objects that are grid based. These objects are made out of tiles that are actually the cells of the grid.
Each tile has a "mass" that is more than 0 and no upper limit. I want to calculate the tile which is the center of mass of the object.
Consider that the objects are made out of hundreds of blocks and some estimations are acceptable.
I am expecting that, once I find out the center of mass, and apply a force to the object that is tangential with that center of mass, the object will spin around its own axis, without moving in 2D space, just spinning.

A: Assuming that each tile has uniform surface density (mass per unit of area) then the centre of mass of any one tile is located at its geometrical centre. Then, it's easy to prove that the CM of an object made of multiple tiles is simply the weighted average of the centres of the constituent tiles, where the weights are the masses of the tiles.
In equations, if an object is made of $n$ tiles and the centre of tile $k$ (of mass $m_k$) is at the point $p_k$, then the CM of the object is located at the point $P_{cm}$ such that
$P_{cm} = \displaystyle\frac{\sum_{k=1}^{k=n} m_k\,p_k}{\sum_{k=1}^{k=n} m_k}$
Again, to make it crystal clear, $p_k$ is the geometrical centre of tile $k$, assuming that each tile has uniform density.
I am expecting that, once I find out the center of mass, and apply a force to the object that is tangential with that center of mass, the object will spin around its own axis, without moving in 2D space, just spinning.
First, notice that the CM of the object may not necessarily be part of the object (for example, the CM of a ring is not part of the ring) so you may not necessarily be able to apply forces at that point.
Secondly, if you apply a single force to the object along any line (passing or not by the CM of the object), the object will accelerate, according to Newton's second law, $\vec{F} = m\vec{a}$.
If you want the object to rotate but not accelerate, then you'll need to apply at least two forces of equal magnitude and opposite directions but with a non-zero total torque. In other words, you'll need to apply torques made of forces that cancel each other (the forces cancel each other, not the torques).
As an example, consider the object below, with 8 identical tiles. Because the tiles are identical, the object's CM is as indicated by the red dot.
In the top figure, a single force is applied to the object. The object will simply accelerate. In both of the bottom figures, two forces of the same magnitude but opposite directions are applied to the object. In both cases, the object will not accelerate but will rotate.


text:
Q: MSVC equivalent to GCC's -fno-finite-math-only? On GCC, we enable -ffast-math to speed up floating point calculations. But as we rely on proper behavior of NaN and Inf floating point values, we also turn on -fno-finite-math-only, so that optimization which assume values aren't NaN/Inf
For MSVC, the "equivalent" to -ffast-math is apparently /fp:fast. However, like GCC's -ffast-math, it also includes the optimizations which assume that Nan/Inf aren't present. (Critically, is appears tests like std::isnan() aren't guaranteed to give "accurate" results.)
Is there an option for MSVC C++ compilation which allows you to take advantage of most of the /fp:fast optimizations, but still treats NaN and Inf values "properly"? (Or at the very least, guarantees that tests like std::isnan()/std::isinf() will detect NaN/Inf if they do happen to be generated.)

A: guarantees that tests like std::isnan()/std::isinf()

Unlike GCC, MSVC (CL RC 19) doesn't actually optimize out std::isnan on the /fp:fast setting:
Another alternative that will never be optimized out is to call the C99 isnan or the MSVC intrinsic _isnanf. Or roll your own nan test against a known bit-mask, which can be generated with std::numeric_limits::quiet_NaN.
See:
https://godbolt.org/g/YdZJq5


text:
Q: How to use CSS namespace selectors with an HTML document? I have an HTML document that uses namespaces:
<!DOCTYPE html>
<html lang="en"
      xmlns:test="http://example/test">
<head>
    <title>Selectors</title>
    <link href="selectors.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <test:p>Hello</test:p>
</body>

</html>

As you can see in this document I defined xmlns:test="http://example/test" namespace and then used it here: <test:p>Hello</test:p>.
According to css @namespace selector documentation, in my css file I selected test:p element like so:
@namespace test url("http://example/test");

test|p {
    color:red;
}

For some reason test:p element is not selected. Can anyone please tell me what I did wrong and how to select elements with the appropriate namespace?

A: You can use back slash to escape the colon sign:
test\:p {
   color:blue;
}

and if you use jQuery, you must use double slash
$('.test\\:p')


text:
Q: Strange error with mod rewrite i have a strange error with my mod_rewrite.
This is my htaccess:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?a=$1
RewriteRule ^(.*)/(.*)$ index.php?a=$1&b=$2
RewriteRule ^(.*)/(.*)/(.*)$ index.php?a=$1&b=$2&c=$3

When i type into my adress bar:
localhost/test/1/2

And in my index.php file i have:
echo '<pre>';
print_r($_GET);
echo '</pre>';

What i should expect to see is:
Array
(
    [a] => test
    [b] => 1
    [c] => 2
)

But the result i get is:
Array
(
    [a] => index.php
    [b] => 1
    [c] => 2
)

What im doing wrong?

A: If-Then-Else Logic, Mutually Exclusive (and Final) Rules
There are several problems.

*

*In mod-rewrite, one set of conditions applies to one rule only. But here you are trying to apply them to multiple rules.

*Your rules are not mutually exclusive. The .* matches all characters, so it can match all three patterns. We need more specific rules.

*Your rules are not final (L flag needed).

Try this:
RewriteEngine On

# IF: Does the file or folder exist?
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d

# THEN leave unchanged, skip 3 rules
RewriteRule ^ - [L,S=3]

# ELSE (the file or folder does not exist)
RewriteRule ^([^/]+)/?$ index.php?a=$1 [L]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?a=$1&b=$2 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?a=$1&b=$2&c=$3 [L]

# FINALLY: leave unchanged
RewriteRule ^ - [L]


text:
Q: Then I need to show that the topology induced in $A$ by $X$ coincides with the topology induced in $A$ by $Y$ $X$ a topological space
$Y$ a subspace of $X$
$A$ a subspace of $Y$
That is $A \subset Y \subset X$
Then I need to show that the topology induced in $A$ by $X$ coincides with the topology induced in $A$ by $Y$
Be:

*

*$\tau_1$ the topology induced in $A$ by $Y$

*$\tau_2$ the topology induced in $A$ by $X$.

*$\tau_Y$ the $Y$ topology

*$\tau_X$ the $X$ topology
We need to show that one is contained in the other.

Let $U \subset A$ tq $U \in \tau_1$. So there is an open $V \in \tau_Y$ tq $U = V \cap A$. But we know that if $V \in \tau_Y$ it means that there is $W$ in $\tau_X$ tq $V = W \cap Y$
So I have two equations:
$U = V \cap A$ (equation 1)
$V = W \cap Y$ (equation 2)
I need to show that $U$ is in $\tau_2$, meaning that $U = W \cap Y$.
If I substitute equation 2 for 1, I have:
$U = (W \cap Y) \cap A$.
Could someone help me finish?

A: Since $A\subseteq Y,W\cap Y\cap A=W\cap A$. Thus $U=W\cap A\in\tau_2$.

For showing that $\tau_2\subseteq\tau_1$, proceed similarly.

Let $U'\in\tau_2$. Then $U'=A\cap V'$ for some $V'\in\tau_X$. But $A\cap V'=A\cap\underbrace{Y\cap V'}_{M\in\tau_Y}\in\tau_1$.


text:
Q: Pinescript cant' set variable text at alert? Can't set the text to a variable?
If do not, need to set the alarm for each text separately.
+
can set variable text function?

A: To create alerts with variable text use the alert() function.


text:
Q: Can't get data from other html using $.get function(response) I have a single page concept, where there is always one navigation-menu, and below is a div with exchangable contents. The contents come from other html files.
In the function "navigateToPage", I'm trying to grab data from inside a div in another html-file, the div has an ID (#content-main) and class (.fragment), so I would like to filter/find for all the content from in there and put it in the current site's div with the same ID.
function getPageName() {
    var
        pathName = window.location.pathname,
        pageName = "";

    if (pathName.indexOf("/") != -1) {
        pageName = pathName.split("/").pop();
    } else {
        pageName = pathName;
    }

    return pageName;
}

function navigateToPage() {

    var pageName = getPageName();

        $.get(pageName, function (response) {

        var
        // Wrap the resulting HTML string with a parent node
        // so jQuery can properly select against it.
            markup = $("<div>" + response + "</div>"),

        // Extract the fragment out of the markup.
            fragment = markup.find(".fragment").html();

        $("#content-main").html(fragment);
        });
}

Problem is, there seems to be no content grabbed into navigateToPage().
The description for the procedure is from Craig Shoemaker.
I thought maybe the get & response is deprecated, and I would have to use sth like this ?
I should add the 3rd part, maybe the error is there..?
    $("a[data-role='ajaxLink']").on('click', function (e) {

        if (window.history && window.history.pushState) {
          e.preventDefault();
          var pageName = $(this).attr("href");
          window.history.pushState(null, "", pageName);
          navigateToPage();
        }
    });

A: It seems this solved the issue:
$('#content-main').load(pageName + " .fragment");

Thou', don't know why the other method did not work...
I have to add, since the DIV with class ".fragment" will be loaded into DIV #content-main, one has to beware to not create nested DIVs. I solved the problem because I have a DIV below #content-main on each html, where I will put the class .fragment.


text:
Q: Choice of authentication approach for financial app on PostgreSQL First some background.
The LedgerSMB project is an open source financial accounting software project that runs on PostgreSQL.  We implement a very large amount of business logic in user defined functions, which act as the main mapping tool between program object methods and database behavior.  Currently we use database users as authentication users, partly by choice (this allows centralized security logic, so that other tools can be written and re-use permissions given to users), and partly by necessity (after we forked from SQL-Ledger, there weren't many options for retrofitting security onto that codebase).
This buys us access to a reasonable number of single signon options that PostgreSQL has access to, from LDAP to Kerberos 5.  We can even use PAM where passwords are concerned.  It also allows us to re-use permissions when integrating with other applications, or allowing other client interfaces.  For a financial accounting application this seems like a net win.
There are obvious costs involved.  For the web application, we are very limited to the types of http auth that can be supported.  DIGEST for example is entirely out.  BASIC works, and we could implement KRB5 easily enough (I plan on having this supported and working out of the box for 1.4).  Very strong authentication measures cannot be properly managed on this directly although we could probably shim them in if necessary (for example BASIC + client-side SSL cert with a cn matching the user name and a specific root ca).
At the same time we've run into a fair amount of criticism mostly from the development crowd and more occasionally from dba's who tell me that the application should be the security barrier, not the database.  My view is still that a smaller security perimeter is generally better, that the re-use of business logic and security logic go together, and that it strikes me as dangerous to re-use business logic without re-using security logic on the same level of the program.
Am I missing any major tradeoffs here?  Are there gotchas that I am not considering?

A: I think you're conflating authentication and authorization.
I completely agree that keeping the security model in the DB is wise, especially as LedgerSMB is designed with access from multiple clients in mind. Unless you plan on going 3-tier with a middleware layer it makes perfect sense to have users as database roles, especially for something like an accounting app.
This does not mean you have to authenticate users against the database using a PostgreSQL-supported authentication method. Your database users, roles and grants can be used for authorization only if you like.
Here's how it works for a web ui for example:

*

*jane connects to web ui server and authenticates using whatever method is desired, say HTTPS X.509 client certificate handshake and DIGEST auth. The server now has a connection from a user it accepts is really jane.

*The server connects to PostgreSQL using a fixed username/password (or Kerberos or whatever you like), authenticating its self to the db server as the user webui. The db server trusts webui to authenticate its users so webui has been given appropriate GRANTs (see below).

*On that connection the server uses SET ROLE jane; to assume the authorization level of the user jane. Until RESET ROLE; or another SET ROLE is run, the connection is operating with the same access rights as jane and SELECT current_user() etc will report jane.

*The server maintains the association between the database connection on which it has SET ROLE to jane and the web session for user jane, not allowing that PostgreSQL connection to be used by other connections with other users without a new SET ROLE inbetween.
You are now authenticating outside the server, but maintaining authorisation in the server. Pg needs to know what users exist, but doesn't need passwords or authentication methods for them.
See:

*

*SET SESSION AUTHORIZATION

*SET ROLE

*GRANT
Details
The webui server controls the queries run, and it's not going to let jane run raw SQL (I hope!) so jane can't RESET ROLE; SET ROLE special_admin_user; via the web ui. For added safety I'd add a statement filter to the server that rejected SET ROLE and RESET ROLE unless the connection was in or entering a pool of unassigned connections.
You're still free to use direct authentication to Pg in other clients; you can mix and match freely. You just have to GRANT the webui user the rights to SET ROLE to users who can log in via the web and then give those users any normal CONNECT rights, passwords, etc you want. If you want to make them web-only, REVOKE their CONNECT rights on the database (and from public).
To make such an authentication/authorisation split easy I have a special role assume_any_user that I GRANT every newly created user to. I then GRANT assume_any_user to the real username used by things like a trusted web front-end, giving them the rights to become any user they like.
It's important to make assume_any_user a NOINHERIT role, so the webui user or whatever has no privilges by its self and can only act on the database once it's SET ROLE to a real user. Under no circumstances should webui be a superuser or DB owner.
If you're connection pooling, you can use SET LOCAL ROLE to set role only within a transaction, so you can return connections to the pool after COMMIT or ROLLBACK. Beware that RESET ROLE still works, so it still isn't safe to let the client run whatever SQL they want.
SET SESSION AUTHORIZATION is the related but stronger version of this command. It doesn't require role membership, but it's a superuser only command. You don't want your web ui connecting as a superuser. It can be reversed with RESET SESSION AUTHORIZATION, SET SESSION AUTHORIZATION DEFAULT or SET SESSION AUTHORIZATION theusername to regain superuser rights so it isn't a privilege-dropping security barrier either.
A command that worked like SET SESSION AUTHORIZATION but was irreversible and would work if you were a role member but not superuser would be great. At this point there isn't one, but you can still separate authentication and authorisation pretty well if you're careful.
Example and explanation
CREATE ROLE dbowner NOLOGIN;
CREATE TABLE test_table(x text);
INSERT INTO test_table(x) VALUES ('bork');
ALTER TABLE test_table OWNER TO dbowner;

CREATE ROLE assume_any_user NOINHERIT NOLOGIN;
CREATE ROLE webui LOGIN PASSWORD 'somepw' IN ROLE assume_any_user;

CREATE ROLE jane LOGIN PASSWORD 'somepw';
GRANT jane TO assume_any_user;
GRANT ALL ON TABLE test_table TO jane;

CREATE ROLE jim LOGIN PASSWORD 'somepw';
GRANT jim TO assume_any_user;

Now connect as webui. Note that you can't do anything to test_table but you can SET ROLE to jane and then you can access test_table:
$ psql -h 127.0.0.1 -U webui regress
Password for user webui:

regress=> SELECT session_user, current_user;
 session_user | current_user
--------------+--------------
 webui        | webui
(1 row)

regress=> SELECT * FROM test_table;
ERROR:  permission denied for relation test_table

regress=> SET ROLE jane;
SET

regress=> SELECT session_user, current_user;
 session_user | current_user
--------------+--------------
 webui        | jane
(1 row)

regress=> SELECT * FROM test_table;
  x
------
 bork
(1 row)

Note that webui can SET ROLE to jim, even when already SET ROLEd to jane and even though jane hasn't been GRANTed the right to assume the role jim. SET ROLE sets your effective user ID, but it doesn't remove your ability to SET ROLE to other roles, that's a property of the role you connected as, not your current effective role. Consequently you must carefully control access to the SET ROLE and RESET ROLE commands. There is, AFAIK, no way to permanently SET ROLE for a connection, truly becoming the target user, though it'd certainly be nice to have.
Compare:
$ psql -h 127.0.0.1 -U webui regress
Password for user webui:

regress=> SET ROLE jane;
SET

regress=> SET ROLE jim;
SET
regress=> SELECT session_user, current_user;
 session_user | current_user
--------------+--------------
 webui        | jim
(1 row)

to:
$ psql -h 127.0.0.1 -U jane regress
Password for user jane:

regress=> SET ROLE webui;
ERROR:  permission denied to set role "webui"
regress=> SET ROLE jim;
ERROR:  permission denied to set role "jim"

This means that SET ROLE isn't exactly the same as logging in as a given role, something you must keep in mind.
webui can't SET ROLE to dbowner since it hasn't been GRANTed that right:
regress=> SET ROLE dbowner;
ERROR:  permission denied to set role "dbowner"

so by its self it's pretty powerless, it can only assume the rights of other users and only when those users have web access enabled.


text:
Q: Full height resizing wrong I made a full height sidebar on my bootstrap website, but when I resize the browser, it just goes wrong, as you can see it in the screenshots below.
How can I make it be full height while resizing, and keep everything within the blue side ? Thanks a lot !
The Codepen : Here

HTML Code :
<!DOCTYPE html>

        <meta charset="utf-8" />

        <link rel="stylesheet" href="dist/css/bootstrap.min.css" />
        <link rel="stylesheet" href="hover-min.css" />
        <link rel="stylesheet" href="main.css" />
        <link href='https://fonts.googleapis.com/css?family=Roboto:400,900' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="animate.css">

                        First name

                        NAME

                        JOB

                        Company

WHY

HOW

WHO

Portfolio

Resume

View PDF

Contact

+336 31 94 74 90

CSS Code
 /* GENERAL SETTINGS*/
html,body{height:100%;}
.container-fluid, .row {
    height:100%;
}
a:hover {
    color : yellow;
    text-decoration : none;
}
a {
    text-decoration : none;
    color : white;
}

/* HOMEPAGE BLUE FILTER EFFECT - not for this page */
img.nyc {
    /*position:fixed;*/
    left:0;
    z-index:-1;
}
#opacity {
    position : fixed;
    background-color: #428BCA;
    display:inline-block;
}
#opacity img {
    opacity: 0.5;
    -webkit-animation: animation 1s linear;
    -moz-animation: animation 1s linear;
    -ms-animation: animation 1s linear;
    -o-animation: animation 1s linear;
    animation: animation 1s linear;
}
@-webkit-keyframes animation{
    from{
        opacity: 1;
    }
    to{
        opacity: 0.5;
    }
}
@-moz-keyframes animation{
    from{
        opacity: 1;
    }
    to{
        opacity: 0.5;
    }
}
@-ms-keyframes animation{
    from{
        opacity: 1;
    }
    to{
        opacity: 0.5;
    }
}
@-o-keyframes animation{
    from{
        opacity: 1;
    }
    to{
        opacity: 0.5;
    }
}
@keyframes animation{
    from{
        opacity: 1;
    }
    to{
        opacity: 0.5;
    }
}
#landingpage {
    padding : 20px;
    display: table;
    position: absolute;
    height: 100%;
    width: 100%;
}
#logodiv {
    position : absolute;
    z-index : 0;
}
#rowlandingpage {
    display: table-cell;
    vertical-align: middle;
}
.brandlogo{
    color : white;
    font-family : Roboto, sans serif;
    font-weight : 900;
    font-size : 2em;
    line-height : 22px;
    margin-top : 0;
    margin-bottom : 0;
}
.brandlogo h2{
    color : white;
    font-family : Roboto, sans serif;
    font-weight : 900;
    font-size : 1em;
    line-height : 30px;
    margin-top : 20px;
    margin-bottom : 0;
}
.yellow {
    color : yellow;
}

#claim{
    color : white;
    font-family : Roboto, sans serif;
    font-weight : 900;
    font-size : 4.5em;
    margin-top : -100px;;
}

#singlebutton {
    background-color : yellow;
    color : #61A4D3;
    font-family : Roboto, sans serif;
    font-weight : 900;
    font-size : 1.5em;
    border-radius: 1px;
    border-style : none;
    width : 190px;
    height : 50px;
}

#blueside{
    width : 150px;
    height:100%;
    min-height:100%;
    background-color: #64A5D4;
    padding:10px;
    color:#efefef;
    box-shadow: 6px 0px 10px grey;
}

#menu {
    margin-top : 50px;
}

#hireme {
    margin-top : 80px;
}

.puce{
    -moz-border-radius: 10px/10px;
    -webkit-border-radius: 10px 10px;
    border-radius: 10px/10px;
    border:solid 8px yellow;
    width:8px;
    height:8px;
    margin-left : auto;
    margin-right : auto;
    margin-top : 20px;
    margin-bottom : 20px;
}

#viewPDF{
    background-color : red;
    color : #61A4D3;
    font-family : Roboto, sans serif;
    font-weight : 900;
    font-size : 1em;
    width : 110px;
    height : 30px;
    line-height : 30px;
    margin-left : auto;
    margin-right : auto;
    margin-top : 5px;
}

.resumeBox {
    background-color : red;
    width : 34px;
    height : 30px;
    line-height : 30px;
    margin-top : 5px;
}

.resumeBoxIcon {
    color : #64A5D4;
}

#contactNumber {
    font-size : 0.88em;
}

.contactBox {
    background-color : red;
    width : 53px;
    height : 30px;
    line-height : 30px;
    margin-top : 5px;
}

#contactIcon {
    color : #64A5D4;
    font-size : 1.5em;
    line-height : 30px;
    height:30px;
}

A: Try this:
#blueside{
    width : 150px;
    height: auto;
    background-color: #64A5D4;
    padding:10px;
    color:#efefef;
    box-shadow: 6px 0px 10px grey;
}

A: If you want the sidebar to always take 100% of the height, and always remain on the side,
body {
    height:100%;
    /* Make room for the sidebar */
    margin-left:150px;
}

#blueside {
    position:fixed;
    left:0;
    top:0;
    height:100%;
    width:150px;
    background-color: #64A5D4;
    padding:10px;
    color:#efefef;
    box-shadow: 6px 0px 10px grey;
}

The fixed positioning insures the sidebar will remain on the side, taking up the same width, and always 100% of the height.
You could also add a wrapper inside the #blueside div, like .sidebar-wrapper, and add height:100%;width:100%;overflow-y:scroll; so your sidebar content is scrollable, and always in the right place.

A: Try this fiddle http://jsfiddle.net/owLnxcz5/
use col-md-3 instead of col-lg-1

A: First of all, you need a fixed positioned aside with 100% height or two columns with equal height; All methods are required body { height: 100%; overflow: hidden; } and .child { height: 100%; overflow: auto; }
Solution with fixed position:

html {
  box-sizing: border-box;
}
html, body {
  height: 100%;
  padding: 0;
  margin: 0;
}
body {
  color: rgba(0,0,0,.2);
  overflow: hidden;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}

.Aside {
  width: 150px;
  height: 100%;
  position: fixed;
  overflow: auto;
  background-color: #70c1b3;
}
.Main {
  height: 100%;
  padding-left: 150px;
  overflow: auto;
  background-color: #f3ffbd;
}

  #Aside

  #Main

If you need two equal columns with 100% height of body, you can search by "Css equal columns".
Where is one of the realizations with flexbox.

html {
  box-sizing: border-box;
}
html, body {
  height: 100%;
  padding: 0;
  margin: 0;
}
body {
  display: flex;
  color: rgba(0,0,0,.2);
  overflow: hidden;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}

.Aside {
  width: 150px;
  background-color: #70c1b3;
  overflow: auto;
}
.Main {
  flex: 1;
  background-color: #f3ffbd;
  overflow: auto;
}

  #Aside

  #Main