text:
Q: Best way to open/close browser window? I have request from the customer to adjust some old functionality in the system. The current file has href links that look like this:
#Name#

If you look the code above you see that target="_blank" page will be opened in the new browser window. However, user wants to be able to close that window if they click OK/Cancel button in page.detail.cfm. I tried using this code for closing the browser window:
var closeBtn = document.getElementById('btn_cancel');
closeBtn.addEventListener('click', cancel);
function cancel(){
    window.close();
}

After I tested the code and clicked Cancel message in the dev tools looks like this:
Scripts may not close windows that were not opened by script.

I guess that window can't be closed if not previously opened with JavaScript. I'm not sure what would be the best approach to solve this issue? Thanks for your help.

A: Technically a script is not allowed to close a page that a user has opened as opposed to it being opened by a script itself. It's a browser security issue. I know there were some hacks for it but thing like this get patched pretty quick from what I can tell. You could technically open the window with a script instead with some sort of click event or such, but again this is a bit of a work around. Check this out https://developer.mozilla.org/en-US/docs/Web/API/Window/close


text:
Q: Logstash: How to match the timezone ID 'CET' in a date filter pattern? In Logstash, I want to convert a string into a timestamp using the date filter. The string looks follows:
Fri Nov 05 06:24:28.651 CET 2021

I've tried the following pattern to no avail:
  date {
      match => [ "syslog_timestamp", "EEE MMM dd HH:mm:ss.SSS ZZZ yyyy"]
      locale => "en_US"
      timezone => "Europe/Berlin"
      target => "syslog_timestamp"
  }

This is confusing since Logstash is said to use the Joda library and Joda in turn says 'CET' is a legal timezone ID. I confirmed the results by testing the Jody library v2.10.13 directly in a Java application.
How to parse CET/CEST in the date filter?

A: Since time zone names (z) cannot be parsed and ZZZ still wouldn't match the daylight-saving variant 'CEST' according to Joda's documentation, I worked around this issue in Logstash by handling the timezone code as text and passing multiple patterns with the standard time zone and daylight-saving time zone to the filter:
match => [ "syslog_timestamp", "EEE MMM dd HH:mm:ss.SSS 'CET' yyyy", "EEE MMM dd HH:mm:ss.SSS 'CEST' yyyy"]

redpajama_set_name: RedPajamaStackExchange


text:
Q: Camera shutting down VM - java.lang.RuntimeException: setParameters failed This is my error:
12-03 20:25:30.767  19809-19809/com.app.test E/AndroidRuntime? FATAL EXCEPTION: main
    Process: com.app.test, PID: 19809
    java.lang.RuntimeException: setParameters failed
            at android.hardware.Camera.native_setParameters(Native Method)
            at android.hardware.Camera.setParameters(Camera.java:1878)
            at com.app.test.CameraManager.TakePicture(CameraManager.java:107)
            at com.app.test.DesignerFragment.CameraAction(DesignerFragment.java:808)
            at com.app.test.MainActivity.CameraAction(MainActivity.java:1031)
            at com.app.test.MainActivity$3.onClick(MainActivity.java:297)
            at android.view.View.performClick(View.java:5198)
            at android.view.View$PerformClick.run(View.java:21147)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

This is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.app.test"
    android:versionCode="43"
    android:versionName="3.0" >

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="21" />

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

    <!--  <uses-permission android:name="android.permission.CAMERA" />
      <uses-feature android:name="android.hardware.camera" android:required="false" />
      -->

    <uses-feature android:name="android.hardware.camera" android:required="false"/>

    <!--<uses-feature android:name="android.hardware.camera.front" android:required="false" />-->

    <uses-feature android:name="android.hardware.camera.front" android:required="false"/>

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-feature android:name="android.hardware.location" />
    <uses-feature android:name="android.hardware.camera.setParameters" />

    <!--
      IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
      to match your app's package name + ".permission.C2D_MESSAGE".
    -->

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <uses-permission android:name="android.permission.FLASHLIGHT"
        android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
        android:protectionLevel="normal"/>
    <uses-feature android:name="android.hardware.camera.flash"/>

    <!--
      IMPORTANT: Change "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the lines below
      to match your app's package name + ".permission.C2D_MESSAGE".
    -->
    <permission
        android:name="com.app.test.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.app.test.permission.C2D_MESSAGE" />

    <application
        android:name="com.app.application.GlobalApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.parse.ui.ParseLoginActivity.PARSE_LOGIN_ENABLED"
            android:value="true" />

        <!-- Google Analytics Version v4 needs this value for easy tracking -->
        <!--
            <meta-data android:name="com.google.android.gms.analytics.globalConfigResource"
            android:resource="@xml/global_tracker" />
        -->

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

        <activity
            android:name="com.parse.ui.ParseLoginActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop" >
            <meta-data
                android:name="com.parse.ui.ParseLoginActivity.PARSE_LOGIN_ENABLED"
                android:value="true" />
            <!-- <meta-data -->
            <!-- android:name="com.parse.ui.ParseLoginActivity.PARSE_LOGIN_EMAIL_AS_USERNAME" -->
            <!-- android:value="true"/> -->
            <meta-data
                android:name="com.parse.ui.ParseLoginActivity.FACEBOOK_LOGIN_ENABLED"
                android:value="true" />
            <meta-data
                android:name="com.parse.ui.ParseLoginActivity.TWITTER_LOGIN_ENABLED"
                android:value="true" />
        </activity>

        <!-- <activity -->
        <!-- android:name="com.app.test.MainActivity" -->
        <!-- android:configChanges="keyboardHidden|orientation|screenSize" -->
        <!-- android:label="@string/app_name" -->
        <!-- android:screenOrientation="portrait" > -->
        <!-- </activity> -->

        <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

        <meta-data
            android:name="com.parse.APPLICATION_ID"
            android:value="@string/parse_app_id" />
        <meta-data
            android:name="com.parse.CLIENT_KEY"
            android:value="@string/parse_client_key" />
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
        <meta-data
            android:name="com.app.test.notification_icon"
            android:resource="@drawable/ic_launcher" />

        <activity
            android:name=".DispatchActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".IntroActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name=".UserSettingsActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:theme="@style/PreferenceScreen" >
        </activity>
        <activity
            android:name=".EditProfileActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:parentActivityName=".EditProfileActivity"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name=".ChangePasswordActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:parentActivityName=".ChangePasswordActivity"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name=".PaymentDetailsActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:parentActivityName=".PaymentDetailsActivity"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name=".MainActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />
            </intent-filter>
        </activity>
        <activity
            android:name=".PurchaseActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.app.gallery.GalleryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.app.feed.FeedActivityV2"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.app.feed.SearchActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:parentActivityName="com.app.feed.FeedActivityV2"
            android:screenOrientation="portrait">
        </activity>
        <activity
            android:name="com.app.feed.SuggestedUserActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:parentActivityName="com.app.feed.FeedActivityV2"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name="com.app.comments.CommentsActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:parentActivityName="com.app.feed.FeedActivityV2"
            android:screenOrientation="portrait" >
        </activity>

        <activity
            android:name="com.app.notifications.NotificationsActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:parentActivityName="com.app.feed.FeedActivityV2"
            android:screenOrientation="portrait" >
        </activity>

        <service
            android:name="com.paypal.android.sdk.payments.PayPalService"
            android:exported="false" />

        <activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
        <activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
        <activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
        <activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
        <activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" />
        <activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" />
        <activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" />
        <activity android:name="com.paypal.android.sdk.payments.PayPalProfileSharingActivity" />
        <activity android:name="com.paypal.android.sdk.payments.ProfileSharingConsentActivity" />
        <activity
            android:name="io.card.payment.CardIOActivity"
            android:configChanges="keyboardHidden|orientation" />
        <activity android:name="io.card.payment.DataEntryActivity" />

        <provider
            android:name="com.app.utility.ContentProvider"
            android:authorities="com.app"
            android:enabled="true"
            android:exported="true" >
        </provider>

        <activity
            android:name=".PaymentProcessingActivity"
            android:label="@string/title_activity_payment_processing" >
        </activity>
        <activity
            android:name="com.app.utility.WrapperWeb"
            android:label="@string/title_activity_wrapper_web" >
        </activity>

        <service android:name="com.parse.PushService" />

        <!-- Custom Receiver -->
        <receiver
            android:name=".Receiver"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.parse.push.intent.RECEIVE" />
                <action android:name="com.parse.push.intent.DELETE" />
                <action android:name="com.parse.push.intent.OPEN" />
            </intent-filter>
        </receiver>
        <!-- End Custom Receiver -->

        <receiver android:name="com.parse.ParseBroadcastReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.parse.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <!-- IMPORTANT: Change "com.parse.tutorials.pushnotifications" to match your app's package name. -->
                <category android:name="com.app.test" />
            </intent-filter>
        </receiver>

        <!-- replace @drawable/push_icon with your push icon identifier -->
        <meta-data
            android:name="com.parse.push.notification_icon"
            android:resource="@drawable/ic_stat_ic_notification" />

        <activity
            android:name="com.app.feed.FeedActivitySingle"
            android:label="@string/title_activity_feed_activity_single"
            android:parentActivityName="com.app.gallery.GalleryActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.app.gallery.GalleryActivity" />
        </activity>
    </application>

</manifest>

I've been wracking my head as to why this doesn't work. The front camera shuts down the app every time I launch it. What could be going wrong? What is wrong with my manifest?

A: Can you post the code that launches the Camera?
What I can see right now is that you declare a permission that does not exist:
<uses-permission android:name="android.hardware.camera.autofocus" />

There are some features declaration that have typos:
<used-feature android:name="android.hardware.location" />
<used-feature android:name="android.hardware.camera.setParameters" />

You can try fixing these for a start, see if it helps. You can see the list of all features available for declaration here

A: I made sure all my  permissions were set to false under required:
<uses-permission android:name="android.permission.CAMERA" />

<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<uses-feature android:name="android.hardware.camera.setParameters" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />

<uses-permission android:name="android.permission.FLASHLIGHT"
    android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
    android:protectionLevel="normal"/>

<uses-feature android:name="android.hardware.camera.flash" android:required="false" />

I also fixed some typos as suggested above by k3v1n3ud3.


text:
Q: Ignore linkable modals in browser history I am using UI Router 0.2.15 with Angular 1.4.3. Some of my pages can open a Twitter Bootstrap modal. By default, there is no way to link directly to an open modal, so I wrote a custom directive that will listen to a query parameter in the URL to open and close the modal. If the query parameter is present, it opens the modal, if not, it closes it. This comes in handy when users want to link to different modals on the same page, or simply want to deeplink to a modal. So buttons that used to trigger some JavaScript to open a modal now just link to a slightly different route instead that will open the modal through the directive.
This is handled by the following code from my directive:
scope.$watch(function () {
  return $state.params[param];
}, function (param) {
  $timeout(function () {
    if (param) {
      element.modal('show');
    } else {
      element.modal('hide');
    }
  }, 0, false);
}, true);

// When the modal is closed, remove the param from the URL
element.on('hidden.bs.modal', function () {
  $state.params[param] = undefined;

  scope.$apply(function () {
    $state.go($state.current, $state.params);
  });
});

This works fine, but here's my problem. Imagine the following flow:

*

*You open page a

*You open page b

*You click on a link to a modal at ?_id=1

*The query param _id=1 is appended, the modal is opened

*You close the modal, the query param is removed

*You go back in history

*It reopens the modal, since the last entry in history contains the query parameter

The modal is reopened, even though the user expects to end up on page a. After all, that was the last page the user visited.
In other words, how do I make the modal not have any effect on the browser's history, even though it's linkable?
My first idea was to replace the last entry in history whenever the query param changes. However, once the modal is opened, it's too late to do that, since I would need to access the second to last history entry and replace it with the current one, which, as far as I know, is impossible.
Ideally, there would be something like { location: 'replace' } on query parameter changes, that can be defined as another option in the routes.
I also checked Can you use hash navigation without affecting history? and AngularJS redirect without pushing a history state, to no avail.


text:
Q: MySql Module shutdown unexpectedly in XAMPP i try to use MySql in XAMPP but the error below appears each time. i don't know if the problem is caused by the used port or there is another problem.
This is the message that appears:
Error: MySQL shutdown unexpectedly.
20:44:59  [mysql]   This may be due to a blocked port, missing dependencies,
20:44:59  [mysql]   improper privileges, a crash, or a shutdown by another method.

A: click config and choose my.ini
and change the port to 8111


text:
Q: How to randomize the percentage values? I have a problem with VBA excel.
In column F, I have a number 57.07%. This column has 102 Rows. The idea is to generate random values in percentage, but the total average of these random numbers has to be 57.07%
I managed to generate random full numbers. But when it comes to adding and removing decimals for some reason I get no results.
Sub RandomiseSum()
    Dim countries As Range, country As Range, pageviews As Range, clicks As Range, impressions As Range, col_f As Range, col_g As Range, col_h As Range, earnings As Range

Dim arr() As Double, i, z, y As Integer

'~~>Count the result of the range of countries
Set countries = Range("B4:B102")
Set pageviews = Range("C4:C102")
Set impressions = Range("D4:D102")
Set clicks = Range("E4:E102")
Set col_f = Range("F4:F102")
Set col_g = Range("G4:G102")
Set col_h = Range("H4:H102")
Set earnings = Range("I4:I102")
ReDim arr(countries.count - 1)
For i = 0 To countries.count - 1
    arr(i) = Rnd
Next i
i = i - 1                                           '~~> Remove 1 from the total cell number in order to put the decimals/diferences in it at the end

'~~> Totals
TotalC = Range("C2").Value
TotalD = Range("D2").Value
TotalE = Range("E2").Value
avg_f = Range("F2").Value
avg_g = Range("G2").Value
avg_h = Range("H2").Value
TotalI = Range("I2").Value

col_h = avg_h
half1 = i / 2
half2 = (i / 2) + 1
z = half2
y = 4
x = 0

Do Until x = half1
    this_nr = "H" & y
    xnum = WorksheetFunction.RandBetween(0, 42) / 100
    Range(this_nr).Value = Range(this_nr).Value - xnum

    y = y + 1
    z_nr = "H" & z
    Range(z_nr).Value = Range(z_nr).Value + xnum

    z = z + 1
    x = x + 1
Loop
rnr = 0
Do Until rnr = half1
    x12 = WorksheetFunction.RandBetween(4, 102)
    x22 = WorksheetFunction.RandBetween(4, 102)
    x12 = "H" & x12
    x22 = "H" & x22
    x3 = x12

    Range(x12).Value = Range(x22).Value
    Range(x22).Value = Range(x3).Value

    rnr = rnr + 1
    Loop
        y = 4
        z = half2
        For x = 0 To x = half1
            this_nr = "H" & y
            z_nr = "H" & z

           Range(this_nr).Value = Range(this_nr).Value - 0.3
           Range(z_nr).Value = Range(z_nr).Value + 0.03

            z = z + 1
            x = x + 1
         Next x
End Sub

As you can see from the picture, I get that .07 in all cells but I'm not being able to remove that value from some cells and add it to other ones.

Any ideas?
Is my loop wrong?

A: I managed to solve it. If anyone else will encounter the same problem, here's the code.
What I did here is that I added another variable named "xnum2" where I would generate a random decimal number and then for each loop I would remove that value from the CELLx.value and add it to another CELLy.value, so that the average would still be the same.
    col_h = avg_h
    half1 = i / 2
    half2 = (i / 2) + 1
    z = half2
    y = 4
    x = 0

    Do Until x = half1
        this_nr = "H" & y
        xnum = WorksheetFunction.RandBetween(0, 42) / 100
        Range(this_nr).Value = Range(this_nr).Value - xnum

      xnum2 = WorksheetFunction.RandBetween(0, 9) / 10000
   Range(this_nr).Value = Range(this_nr).Value - xnum2

        y = y + 1
        z_nr = "H" & z
        Range(z_nr).Value = Range(z_nr).Value + xnum
      Range(z_nr).Value = Range(z_nr).Value + xnum2

        z = z + 1
        x = x + 1
    Loop
    rnr = 0
    Do Until rnr = half1
        x12 = WorksheetFunction.RandBetween(4, 102)
        x22 = WorksheetFunction.RandBetween(4, 102)
        x12 = "H" & x12
        x22 = "H" & x22
        x3 = x12

        Range(x12).Value = Range(x22).Value
        Range(x22).Value = Range(x3).Value

        rnr = rnr + 1
        Loop


text:
Q: Mage::getStoreConfig not working I have set the multiple select option in system configuration.
I need to get the selected values.
I used the following,
Mage::getStoreConfig('customer/group_location/data')
But I didn't get anything. Somebody help me
below is the system.xml code
<?xml version="1.0"?>
<config>
    <sections>
        <customer translate="label" module="customer">
            <groups>
                <group_location translate="label">
                    Group Location
                    <sort_order>200</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <data>
                            Group Location
                            <frontend_type>multiselect</frontend_type>
                            <source_model>customerattribute/attribute</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <can_be_empty>1</can_be_empty>
                        </data>
                    </fields>
                </group_location>
            </groups>
        </customer>
    </sections>
</config>

A: Just an idea...
Change data for any other identifier, as personal as you can, as it's a very common alias in Magento for getting data


text:
Q: CSS animation transform bug on edge I'm having a weird bug/lag with some animations on edge, it looks like the lag came after I've added position: fixed to the div that is being animated, it works fine on every browser but edge (not sure about safari tho).

document.addEventListener('DOMContentLoaded', _ => {
  const animBoxOne = document.querySelector('.animation-box-1')
  const animBoxTwo = document.querySelector('.animation-box-2')

  animBoxOne.classList.add('animation-1')
  setTimeout(() => {
    animBoxOne.classList.add('hidden')

  }, 6000);

})
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
}

.logo-box {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.logo {
  width: 50%;
}

.animation-box-1 {
  max-height: 100vw;
  width: 900%;
  position: fixed;
}

.animation-1 {
  animation-name: introAnimation;
  animation-duration: 6s;
  animation-fill-mode: forwards;
  transition: opacity 2s;
}

.animation-box-2 {
  max-height: 100vw;
  width: 900%;

}

.square {
  width: 100vw;
  height: 100vh;
  display: block;
  float: left;
}

.square-1 {
  background: black;
}

.square-2 {
  background: #9F7324;
}

.square-3 {
  background: white;
}

.square-4 {
  background: black;
}

.hidden {
  opacity: 0;
}

@keyframes introAnimation {
  40% {
    transform: translateX(0)
  }

  55% {
    transform: translateX(-100vw)
  }

  70% {
    transform: translateX(-200vw)
  }

  85% {
    transform: translateX(-300vw);
  }

  100% {
    transform: translateX(-300vw);
  }
}

.clearfix ::after {
  content: '';
  clear: both;
}

Here's a codepen link: https://codepen.io/matheusferraresi/pen/BVWvWg
.animation-box-1 {
max-height: 100vw;
width: 900%;
position: fixed;
}

That's the block I'm talking about, does anyone have any idea of how can I fix it? I need the position fixed because I'm using this animation like a preloader or is there any other way of doing it?
Thanks in advance.

A: Add position:fixed; z-index:-1; to .animation-box-2


text:
Q: Getting error from sprinng boot : Whitelabel Error Page When I am  running this app from IDE, it is working fine, but when app running from the command line, it gives me the following error:

http://localhost:8080/welcome
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing
this as a fallback. Thu Dec 30 21:46:01 BDT 2021 There was an
unexpected error (type=Not Found, status=404)

My controller is :
package com.example.demo;

@Controller
public class HelloController {

    @RequestMapping("/welcome")
    public String home() {
        System.out.println("this is home page");

        return "home";
    }

}

application.properties
spring.mvc.view.prefix=/views/
spring.mvc.view.suffix=.jsp

Jsp file loction is :
webapp\views\home.jsp


text:
Q: exponential Radioactive decay A doctor injects you with 500 milligrams of a radioactive compound for medical imaging. It has a half-life of 6 hours. How long will it take for 99.9% of it to decay? Round to the nearest hour.
Answer
99.9*500 = 500e^kt
99.9 = e^kt
99.9 = e^6k
ln99.9 = lne^6k
4.6041 = 6k
k = 0.76736
I actually made some progress. Now I'm stuck here. How do i proceed?

A: Always divide percentages by $100$ to get proportions in contexts like this. If $99.9\%$ (a proportion of $0.999$) has decayed, you're left with $0.001$ times the original total. Let's work in hours. Since $e^{-6k}=\frac12$, $e^{-kt}=0.001\implies t=6\frac{\ln 1000}{\ln 2}\approx60$.


text:
Q: taglibs and variable declarations generate empty lines at the top of source page I have declared some taglibs and variables in my jsp page as below:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:set var="site" scope="session" value="${site}"/>
<c:set var="thumb" scope="session" value="${thumbnail}"/>
<c:set var="geoCode" scope="session" value="${geoCode}"/>
...
<fmt:setLocale value="${local}" />
<fmt:setBundle basename="MessagesBundle" />
<!DOCTYPE html>
<head>
    <meta charset="utf-8">
...

when I run the app and then view the source I see blank new lines on top of the source page:
.

<!DOCTYPE html>
<head>
    <meta charset="utf-8">

I just placed a dot to demonstrate the empty lines.
Any idea on how I can remove these empty lines?

A: You need to tell the JSP servlet to trim directive whitespaces. You can achieve that by adding the following entry to webapp's web.xml:
<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <trim-directive-whitespaces>true</trim-directive-whitespaces>
     </jsp-property-group>
</jsp-config>

Or, if you'd like to configure it server-wide instead of on a per-webapp basis, then consult the servletcontainer documentation on the matter. You didn't tell which one you're using, but in case of Tomcat, it'd be a matter of editing its /conf/web.xml to add the following entry to the <servlet> declaration of the JSP servlet:
<init-param>
    <param-name>trimSpaces</param-name>
    <param-value>true</param-value>
</init-param>

Unrelated to the concrete problem, your @page contains a lot of default and repeated mess. It can be simplified as follows:
<%@page pageEncoding="UTF-8"%>


text:
Q: Querying BigQuery tables in a given date range In Google BigQuery i have tables in the following format: daily_records_yyyy_mm_dd . I need to run a query over multiple tables in a given date range. The TABLE_DATE_RANGE function expects table names to be in the format [prefix][day], where [day] is in the format YYYYMMDD.
Can i still use TABLE_DATE_RANGE in my case or is there some other way ?
Thanks

A: No, you cannot use TABLE_DATE_RANGE here as it requires specific format
In your case (for BigQuery Legacy SQL) - you should use TABLE_QUERY where you can use any expressions to choose tables
Also - for BigQuery Standard SQL - you can use _TABLE_SUFFIX pseudo column to also work with any table name format
Examples:
Legacy SQL
SELECT *
FROM (
  TABLE_QUERY(YourDataset, 'LEFT(table_id, 14) = "daily_records_"
                            AND LENGTH(table_id) = length("daily_records_") + 10
                            AND DATE(REPLACE(RIGHT(table_id, 10), "_", "-"))
                            BETWEEN DATE("2015-11-01") AND DATE("2016-01-30")')
)

Standard SQL
SELECT *
FROM `YourDataset.daily_records_*`
WHERE REPLACE(_TABLE_SUFFIX, "_", "-")
      BETWEEN "2015-11-03" AND "2016-01-05"


text:
Q: APEX 5 error - numeric or value error: character string buffer too small I work on APEX 5 application and have IR displaying numeric values for 31 days of month (there are 31 columns). I need every column to be link to another modal page. I set every column as Link but when page loads, get error

numeric or value error: character string buffer too small.

If I leave only 25 columns to be Link and rest of them to be Plain Text, it works fine. But if I change 26. column to be link, get an error.
What is the problem?


text:
Q: How to run mypy in Spyder? I wish to use mypy with Spyder but when I issue the command %mypy the following error got detected:
error: Name "runcell" is not defined

I assume that mypy is correctly installed because when I run %load_ext mypy_ipython I get no error messages.
To reproduce the problem you can define an arbitrary working code-cell that uses typing functions in the Spyder editor and then run %load_ext mypy_ipython to load the module and then %mypy to execute it.


text:
Q: jQuery: how to refresh DOM after fading in new elements? I want to make a small survey. I want that the user has to answer some questions. A new question is fading in after clicking an answer. But this only works one time, because the new question which was on display:hidden before is not in the DOM I think. So I need to refresh the DOM I think?
Here is an example: http://jsfiddle.net/x2yu6tvw/
qstnNo = $('.question').data('id');

$('.answer').on( 'click', function(){
    $('.question[data-id="' + qstnNo + '"]').fadeOut(800, function(){
        nextQstn = qstnNo+1;
        $('.question[data-id="' + nextQstn + '"]').delay(300).fadeIn(300);

    });
});

What can I do that jQuery listen also to the new added element?

A: Here is the working demo.
JS
$('.answer').on( 'click', function(){
    qstnNo = $(this).parent('div').data('id');
    $('.question[data-id="' + qstnNo + '"]').fadeOut(800, function(){
        nextQstn = qstnNo+1;
        $('.question[data-id="' + nextQstn + '"]').delay(300).fadeIn(300);

    });
});

ISSUE: qstnNo value was not correct in your case. That should be dynamic not fixed.


text:
Q: Implementing AdMob Rewarded video ads in IOS module( libGDX) I've added interstitial admob ads in my ios version of my libgdx game.
but i can't find something like GADRewardedVideo
// Build.Gradle
implementation "org.robovm:robopods-google-mobile-ads-ios:1.6.0"

// IOSLauncher
import org.robovm.pods.google.mobileads.GADInterstitial;
import org.robovm.pods.google.mobileads.GADRequest;

I imported this from robopods, is there something missing ?

A: Version 1.6.0 of robopods-google-mobile-ads-ios artifact under org.robovm group is too old(~Aug, 2015).
RoboVM is no more, try MobiVM (fork based on the last open-source version of RoboVM)
Inject artifact under mobivm hood :
implementation "com.mobidevelop.robovm:robopods-google-mobile-ads-ios:2.2.2"

If you like to work with snapshot version, use 2.2.3-SNAPSHOT

Hopefully you've added GoogleMobileAds.framework in your ios module before Gradle injection.


text:
Q: Specify a different output css file name with gulp postcss-uncss Is it possible to specify a different css file name as the output using the gulp plugin postcss-uncss?

A: Check out the gulp-rename plugin: https://www.npmjs.com/package/gulp-rename


text:
Q: Git cannot checkout files with readonly permissions I'm having some troubles with a git repository that have some files in readonly mode (chmod 0440).
Sometime, one of those files get modified on another branch ; and when you try to checkout that branch, git fails to update that file with a
warning: unable to unlink path/to/the/file: Permission denied
The problem is that those files need to be in readonly mode, because the framework used beyond those files throws heavy warning messages when those files are writable, and even more problematic, each time we are (re)installing the framework in our continuous integration process, the framework updates those files to be in readonly mode.
I tried to use git hooks to automatically chmod those files to 0664 before checking out any file/branch, then chmod them back to 0440, but I'm not sure such hooks exist.
An unwanted solution would be to chmod myself those files to 0664 each time I know they could change with git, then chmod them back to 0440 to avoid pushing writable files in a prod environment, but it would lead to fails for sure.
Another solution would be to commit them in 0664 mode and update our continuous integration process to re-chmod those file to 0664 after the framework is being (re)installed and totally ignore the warnings ; while keeping the chmod to 0440 for the prod environment.
What you guys do you think of this problem, and what is the best solution I could have to fix it ?

A: Sounds like you are trying to use Git as a deployment tool.
Git is not meant as deployment tool. One of the most important reasons is, that it doesn't track permissions except for the user-executable one. If a file is read-only, Git of course cannot modify it, because it is read-only.
Maybe you should read http://gitolite.com/deploy.html to get some hints on how to maybe be able to build a deployment tool around Git.


text:
Q: Boolean expression for a modified Queens problem I saw the boolean expressions for the N Queens problem from here.
My modified N queens rules are simpler:
For a p $\times$ p chessboard I want to place N queens in such a way so that

*

*Queens will be placed adjacently, rows will be filled first.

*p $\times$ p chessboard size will be adjusted until it can hold N queens

For example, say N = $17$, then we need a $5\times5$ chessboard and the placement will be:
\begin{array}{|c|c|}\hline
Q &Q &Q &Q &Q \\ \hline
Q &Q &Q &Q &Q \\ \hline
Q &Q &Q &Q &Q \\ \hline
Q &Q & & & \\ \hline
& & & & \\ \hline
\end{array}
How would you build a boolean expression for this problem?


text:
Q: How to Zip mutiple files using Zend(2) Compress? Files are getting zipped..but once i extracting the zip file, the result is single file..not a multiple file.How to zip multiple file using zend filter(Zip)..?
Here is my code..
//zip part
        $filter = new Compress(array(
            'adapter' => 'Zip',
            'options' => array(
                'archive' => TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR. "download" . DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id.'.zip'
            )
        ));
        $file_list = scandir(TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR. "download". DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id);
        if(count($file_list) >2){
            foreach ($file_list as $file) {
              if (in_array($file, array(".",".."))) continue;
              $filter->filter(TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR. "download". DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id . DIRECTORY_SEPARATOR . $file);
            }
        }
        //zip end

A: Every $filter->filter(…) invocation creates a new archive that contains only one file and the existing archive with the previous file gets overwritten. Solution:
$filter = new Compress([
  'adapter' => 'Zip',
  'options' => [
    'archive' => TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR . 'download'
      . DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id . '.zip'
  ]
]);

// assuming you _can_ create archive from the whole directory
$filter->filter(TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR . 'download'
  . DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id);


text:
Q: Run Powershell commands on Azure Function with az template I would like to write a script which pulls Azure SQL database into Azure SQL Elastic Pool. But that should be running from Azure Function
But got this error:
ERROR: The specified module 'AzureRM.Compute' was not loaded because no valid module file was found in any module directory.
When I included Azure RM, I'm getting a new error as I cannot use AzureRM and Az commands.
Can I use only AZ commands to connect to my desired subscription?
Following is the code I'm trying:
$resourceGroupName = "<VALUE>"
$location = "<VALUE>"
$PoolName = "<VALUE>"
$adminSqlLogin = "<VALUE>"
$password = "<VALUE>"
$serverName = "<VALUE>.database.windows.net,1433"
$DatabaseName = "<VALUE>"

Set-ExecutionPolicy Unrestricted -Scope CurrentUser

Import-Module Az.Sql

$azureAccountName ="<VALUE>"
$azurePassword = "<VALUE>" | ConvertTo-SecureString -AsPlainText -Force

$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)

Login-AzureRmAccount -Credential $psCred -SubscriptionId $subscriptionId

Set-AzSqlDatabase -ResourceGroupName $resourceGroupName `
    -ServerName $serverName `
    -DatabaseName $DatabaseName `
    -ElasticPoolName $PoolName

But getting following error in Azure Function:
Login-AzureRmAccount : Method 'get_SerializationSettings' in type 'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly
'Microsoft.Azure.Commands.ResourceManager.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

A: You shouldn't mix AZ and ARM cmdlets. I would recommend you to use the new AZ cmdlets only. If you use Managed Identity within your Azure Function, you don't even have to manually connect to your Azure Account since this is already done for you in the profile.ps1:
if ($env:MSI_SECRET -and (Get-Module -ListAvailable Az.Accounts)) {
    Connect-AzAccount -Identity
}

Just ensure you add Az to the requirements.psd1:
@{
    Az = '1.*'
}


text:
Q: QGlWidget does not properly update if Windows compositor switched off Noticed that the update of my scene which is embedded into a QGlWidget does not work properly if I switch of the transparency in Windows 7. The scene is not updated completely or just after a while. The events are properly called. The OpenGL context uses 3.3. Looks like a frame buffer problem. Someone ever noticed similar behavior?

A: Looks like a known problem with the compositor, I have to call InvalidateRect.
InvalidateRect((HWND)winId(), NULL, TRUE);


text:
Q: I cant click on a link in selenium using firefox browser I want to click on the Search link mentioned in the below HTML, have highlighted it as well; but selenium is not recognising it, The last line of the code
below(Search).

DesktopActivity
Search

A: I have sorted this out by myself, problem was with the Firefox driver (GekoDriver) i have downgraded it and executed the script it went well. Tried several times no issue still. Hence closing this question and thanks for the help


text:
Q: codeigniter page not found on live server codeigniter page not found showing but working fine in local server.
I had uploaded codeigniter file of one basic simple page on live server but there it is showing no page found and same file it is working on local server.
In that I had
mine.php ---- controller
index.php --- view

I loaded in routes default controller - mine in config base url- domain.com removed index.php also
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

can I know please why it is showing page not found, might be some routing issue but I had loaded default controller also.  Please help out on this

A: First of all start error logging properly so you can see the actuall error.
Change your file name's first letter capital. This is mendetory as explained here ci3 manual - controllers. It says class name as well as file name must start with capital. ( If your Dev machine is windows  then it will not show errors if you don't follow this rule. Because window's file system is case insensitive. But on your server it is linux.so it will show error)
If you still  don't get it working then try access the url  with index.php in it. Temporaryly disable .htaccess .If you get it working then may be  you have problem in . htaccess. Try the following link to properly remove index.php from your url. Expression engine forum  .This htaccess worked for me on all different server I have used.

A: add this in .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|images|asset|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>


text:
Q: Android long to time Я хочу вывести изменение текста timer
countDownTimer = object : CountDownTimer(premiumInfo.overTime.time - System.currentTimeMillis(), 1000) {

    override fun onTick(p0: Long) {
        Log.d("Timer", p0.toString())
        val format = SimpleDateFormat("HH:mm:ss")
        val timeString = format.format(Date(p0).time)
        Log.d("Timer String", timeString)
        switch_premium.text = "Премиум [$timeString]"
    }

    override fun onFinish() {
        Log.d("Finish", "true")
        switch_premium.text = "Премиум"
        context?.let {
            Toast.makeText(context, "Обновление данных", Toast.LENGTH_SHORT).show()
        }
        getProfile()
    }
}.start()

Но полученное время на 3 часа больше (думаю это часовой пояс). Мне же нужно без timeZone. Как поправить?
Log
2020-05-13 19:06:19.651 18783-18783/com.app.peshkariki D/Timer: 53349
2020-05-13 19:06:19.656 18783-18783/com.app.peshkariki D/Timer String: 03:00:53
2020-05-13 19:06:20.654 18783-18783/com.app.peshkariki D/Timer: 52346
2020-05-13 19:06:20.659 18783-18783/com.app.peshkariki D/Timer String: 03:00:52
2020-05-13 19:06:21.059 19322-19336/? I/cebook.service: ProcessProfilingInfo new_methods=0 is saved saved_to_disk=0 resolve_classes_delay=8000
2020-05-13 19:06:21.656 18783-18783/com.app.peshkariki D/Timer: 51344
2020-05-13 19:06:21.663 18783-18783/com.app.peshkariki D/Timer String: 03:00:51
2020-05-13 19:06:22.658 18783-18783/com.app.peshkariki D/Timer: 50342
2020-05-13 19:06:22.662 18783-18783/com.app.peshkariki D/Timer String: 03:00:50

Ладно, давайте начнем сначала, может я не туда пошел и все осложнил.
С сервера приходит дата в формате
yyyy-MM-dd HH:mm:ss

Так как Gson не знает как разбираться (а в будущем Room как хранить), приходится писать TypeConverter
class GsonUTCDateAdapter : JsonSerializer<Date?>, JsonDeserializer<Date?> {
    private val dateFormat: DateFormat

    @Synchronized
    override fun serialize(date: Date?, type: Type?, context: JsonSerializationContext?): JsonElement {
        return JsonPrimitive(dateFormat.format(date))
    }

    @Synchronized
    override fun deserialize(jsonElement: JsonElement, type: Type?, jsonDeserializationContext: JsonDeserializationContext?): Date {
        return try {
            dateFormat.parse(jsonElement.asString)
        } catch (e: ParseException) {
            throw JsonParseException(e)
        }
    }

    init {
        dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()) //This is the key line which converts the date to UTC which cannot be accessed with the default serializer
    }
}

Таким образом мы приводим к типу Date
data class PremiumInfo(
        @SerializedName("is_active") var isActive: Int,
        @SerializedName("premium_description") var description: String,
        @SerializedName("premium_over_time") var overTime: Date,
        @SerializedName("premium_over_timeleft_text") var overTimeLeftText: String
)

Так как CountDownTimer принимает на вход 2 параметра Long (от какого времени, и с какой периодичностью)
Что такое длительность времени? Это разница 2 дат, поэтому я использую пришедшую Date и текущее системное время (так как непонятно в какой timeZone пришло с сервера), произвожу разницу и это время начала (длительность премиум аккаунта) собственно в формате Long.
Каждый Tick время уменьшается на 2 параметр. Теперь осталось Long превратить в Date и получить Time, но при переводе из Long в Date откуда - то взялась разница в 3 часа. Откуда он взялся, ну наверно в SimpleDateFormat. Я посмотрел, там есть есть метод setZone, но зачем мне для продолжительности зона, так ведь?
а setZone установить в null нельзя.
Поэтому я и спросил решение. Возможно можно где - то проще сделать, например Joda - Time (там и Period и Duration) использовать, но эта библиотека избытачна , а вес приложения увеличит, поэтому я и спросил, можно как-то по другому сделать стандартными пакетами Java и Kotlin такую простейшую операцию

A: Это не ответ, а скорее разъяснение где в подобных задачах с датами кроются подводные камни.
Компьютерам по сути плевать на часовые пояса, их придумали люди, чтобы с одной стороны себе жизнь облегчить, с другой стороны усложнить, занимаясь расчетами.
С точки зрения ОС Линукс, абсолютное время это System.currentTimeMillis()

the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

Т.е. у компьютеров свои боги и это просто сколько миллисекунд прошло с полуночи 1-го января 1970 по Гринвичу.
Вот тут и кроется подводный камень, в последнем слове по Гринвичу. В полночь по Гринвичу в Берлине уже 2:00, а в Москве и того 3:00.
Поэтому когда получаете откуда-то дату и время в "человеческом" формате (текстовом), необходимо всегда при переводе в "компьютерный" формат (бинарный) учитывать "человеческий" часовой пояс.
Иначе всегда (кроме, конечно случаев что вы в зоне UTC+0) будут возникать расхождения, пытаясь их "как-то" решить, будете по факту просто костылить свой код. Костыли как правило перестают работать, когда к простому "сдвигу" во времени еще добавится переход в другую дату.
Поверьте, все это уже решили до вас. Просто пользуйтесь, выставляйте часовой пояс у даты корректно и все будет работать как надо.
Уточнение. Понятие по Гринвичу устарело :) Правильно

UTC – Всемирное координированное время


text:
Q: Finding the eigenvalues and eigenvectors of tridiagonal matrix Let $A$ be a tridiagonal matrix as below:
$${A_{n \times n}} = \left[ {\begin{array}{*{20}{c}}
{a}&{b_1}&{}&{}&{}\\
{c_1}&{a}&{b_2}&{}&{}\\
{}&{c_2}&{\ddots}&{\ddots}&{}\\
{}&{}&{\ddots}&{\ddots}&{b_{n-1}}\\
{}&{}&{}&{c_{n-1}}&{a}
\end{array}} \right]$$
I want to show that for any eigenvalue $\lambda$ of $A$:
$$|\lambda-a|\leq 2\sqrt{\max\limits_{j}|b_j|\max\limits_{j}|c_j|}$$
I think, this link can help us!

A: The best you can do is invoke Gershgorin's theorem. This gives you that
$$|\lambda_i-a|\leq |c_{i-1}|+|b_i|\leq \max_j |c_j|+\max_j
|b_j|,$$
where $c_{i-1},b_i$ are zero outside their specification in $i$.

A: Post updated. So as Alex said, we can use Gershgorin's theorem. we have
$$|\lambda_i-a|\leq |c_{i-1}|+|b_i|\leq \max_j |c_j|+\max_j
|b_j|.$$
I think there is a relation with Inequality of arithmetic and geometric mean because:
$$\max_j |c_j|+\max_j|b_j|\geq 2\sqrt{\max_j|b_j|\max_j|c_j|}$$


text:
Q: Java: How might one go about generating custom compiler warnings for method usages? I've been doing some work with annotation processing, and it would be really helpful to be able to warn the user about using certain annotated methods. This is basically creating a custom version of the @Deprecated annotation. I thought a good place to start might be the actual annotation processor for @Deprecated, but I can't seem to locate it.  :_
(Note that this is similar, but not the same as How to intentionally cause a custom java compiler warning message?)
Thanks!

A:
Think of some of the code inspection warnings like passing null into a varargs method.

For this use case, look at the Checker Framework for existing checkers (like the nullness checker) and how to create custom checkers (or other type annotation processors).
https://checkerframework.org/
I use this tool and its bundled checkers and like it very much.
Without knowing exactly what you have in mind, I wouldn't be surprised if some of the checkers already address some of your ideas. You may be able to create some pluggable types to address your other ideas. At the very least, it might give you some ideas on how to or how not to approach what you want to do.

A: Thanks to everyone for their feedback. Looking into the compiler API, it's definitely doable (but not so simple). This article provided a good start for the compiler API. I think in the future I will look into writing an extensible rule checker. Attempting to hijack the @Deprecated annotation, by the way, will not work, as inside of the compiler it is removed along with the other "platform annotations".
For now, I'm going with the rather coarse solution of bludgeoning the programmer with a verbose checked exception. While it does clutter the code, it also avoids the complexity of actually analyzing their intent. Something like:
try {
    doWork(workUnit, 15, Style.STRICT);
} catch (MakeSureYouOverrodeEverythingYouWantedToFirst warning) {
    ; // will never actually reach here, but you have been warned!
}

If the programmer fails to do as instructed, the output of their program can be pseudorandomly buggy, and hence rather tedious to debug. And while this solution is certainly a frowned upon hack of exception handling (including by me), it rather simply fullfils my needs.
Besides, the extra effort just might encourage the programmer to actually do what they're supposed to!
I'm still interested in hearing other ideas, if you have one.

A: The annotation processor is in the javac, you can find the source in OpenJDK. However, itsn't not designed to be extensible.
What you are better off doing is to use code analysis like FindBugs or PMD as these are designed to be extended and have your build fail if certain conditions fail.


text:
Q: Chkconfig on Linux Mint 12 giving tons of errors I'm trying to disable some services from starting at boot time on my Linux Mint 12 laptop.
So I installed chkconfig, which has worked great for me before on Fedora.
However, on Linux Mint 12, it gives me tons of errors. Here is an example, trying to disable the rsync service:
$ sudo chkconfig rsync off
insserv: warning: script 'K01acpi-support' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'cryptdisks-udev' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `cryptdisks-udev'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `cryptdisks-udev'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'acpid' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `acpid'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `acpid'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'plymouth-upstart-bridge' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-upstart-bridge'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `plymouth-upstart-bridge'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'rsyslog' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `rsyslog'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `rsyslog'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'friendly-recovery' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `friendly-recovery'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `friendly-recovery'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'udevtrigger' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udevtrigger'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `udevtrigger'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'udev-finish' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udev-finish'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `udev-finish'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'plymouth-stop' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-stop'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `plymouth-stop'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'apport' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `apport'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `apport'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'dbus' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `dbus'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `dbus'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'cryptdisks-enable' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `cryptdisks-enable'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `cryptdisks-enable'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'hwclock' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `hwclock'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `hwclock'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'lightdm' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `lightdm'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `lightdm'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'udevmonitor' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udevmonitor'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `udevmonitor'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'ufw' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `ufw'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `ufw'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'binfmt-support' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `binfmt-support'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `binfmt-support'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'udev' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udev'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `udev'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'irqbalance' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `irqbalance'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `irqbalance'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'cron' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `cron'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `cron'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'nmbd' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `nmbd'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `nmbd'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'plymouth-splash' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-splash'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `plymouth-splash'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'procps' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `procps'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `procps'
insserv: warning: script 'acpi-support' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'network-manager' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `network-manager'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `network-manager'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'smbd' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `smbd'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `smbd'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'dmesg' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `dmesg'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `dmesg'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'module-init-tools' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `module-init-tools'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `module-init-tools'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'network-interface' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `network-interface'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `network-interface'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'console-setup' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `console-setup'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `console-setup'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'anacron' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `anacron'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `anacron'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'modemmanager' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `modemmanager'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `modemmanager'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'udev-fallback-graphics' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udev-fallback-graphics'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `udev-fallback-graphics'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'plymouth' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `plymouth'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'network-interface-security' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `network-interface-security'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `network-interface-security'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'alsa-store' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `alsa-store'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `alsa-store'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'alsa-restore' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `alsa-restore'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `alsa-restore'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'avahi-daemon' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `avahi-daemon'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `avahi-daemon'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'plymouth-log' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-log'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `plymouth-log'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'mysql' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `mysql'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `mysql'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'atd' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `atd'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `atd'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'hostname' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `hostname'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `hostname'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'cups' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `cups'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `cups'
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'hwclock-save' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `hwclock-save'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `hwclock-save'
insserv: script virtualbox: service vboxdrv already provided!
insserv: script virtualbox: service virtualbox already provided!
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'setvtrgb' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `setvtrgb'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `setvtrgb'

It seems to have worked when I run:
# chkconfig rsync
  rsync  off

Is it bad to continue to use chkconfig? Can anyone suggest an alternate service-managing program, or a way to fix the errors when running chkconfig?

A: According to this Linux Mint Community document, chkconfig works but does kick out errors.
You should review the documentation on using upstart as I believe Linux Mint is moving to this method for controlling system services.

A: Since it is an ubuntu based distro you can also use update-rc.d.
update-rc.d rsync remove

or install rcconf wich is a really nice text-based user interface


text:
Q: dataOnChange crashes fragment that has been replaced java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
        at com.darkjp.todo.MyListsFragment.sendSomeToThatRecyclerViewBiatch(MyListsFragment.java:93)
        at com.darkjp.todo.MyListsFragment.access$000(MyListsFragment.java:24)
        at com.darkjp.todo.MyListsFragment$1.onDataChange(MyListsFragment.java:61)

and the checkbox causing the crash:
isDoneCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
        final DatabaseReference mDone = database.getReference("tasksList/" + taskListIndex).child("task/" + taskIndex);
        mDone.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {
                Task updateTask = new Task();
                if (snapshot.child("creator").getValue() != null) {
                    if (snapshot.child("creator").getValue().toString().equals(""))
                        updateTask.setCreator("no creator found");
                    updateTask.setCreator(snapshot.child("creator").getValue().toString());
                }
                if (snapshot.child("title").getValue() != null && !snapshot.child("title").getValue().toString().equals(""))
                    updateTask.setTitle(snapshot.child("title").getValue().toString());
                if (snapshot.child("description").getValue() != null && !snapshot.child("description").getValue().toString().equals(""))
                    updateTask.setDescription(snapshot.child("description").getValue().toString());
                if (snapshot.child("done").getValue() != null)
                    updateTask.setDone(isDoneCheckBox.isChecked());
                mDone.setValue(updateTask);
            }

            @Override
            public void onCancelled(@NonNull DatabaseError error) {

            }
        });
    }
});

The recyclerView received a changed, which is nornam, but the recyclerView is in a fragment I suppose "onPause". Fragment has been replaced (dynamic frameLayout), and should be on its way to destruction or get back from the backstack, I guess.
The onChange seems to get it crashes the app.
I'm studying the onPause/onResume fragments behavior to see how I could manage a dataOnChange when its "sleeping" but I can't see no clue.
If I got the problem well: i try to find a recyclerView that does not exist in the actual fragment (and can't be reached while onPause(), OnResume()...).
I can't figure out why that fragment is called (when another one would have been more pertinent. The one i'm thinking of is called/instantiated by myListFragment... i guess a parent/children flow is behind that mystery.

A: Ok...
Was not a lifecycle one.
i was doing a getView() to get the "R.id.xxxxxx" recyclerView. And it was wrong so it launched once but could not be resume. I just, now, get the recyclerView from a "classic"
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        view = inflater.inflate(R.layout.fragment_my_lists, container, false);
        myRecycler = view.findViewById(R.id.myRecycler);
}

i was doing a
myRecycler = this.getView.findViewById(R.id.myRecycler);


text:
Q: ¿Cuál es la versión más antigua de .net (asp.net) que puedo publicar en el IIS de un WS2012R2? Tengo varios sitios web desarrollados en diferentes versiones de Visual Studio (y por ende en diferentes versiones de .net desde la 1.0), VS2002, Vs2003, VS2005, Vs2008, bueno hasta la 2015, todos los sitios web que fueron desarrollados desde VS2002 hasta VS2008 se encuentran publicados en un Windows Server 2003.
Ahora bien la pregunta es, ¿cuáles de estos sitios los puedo publicar en Windows Server 2012 R2? Bueno me imagino que a partir de .net 2.0 (VS2005) puedo hacerlo, pero mi duda es sobre .net 1.0 y .net 1.1 (VS2002 y VS2003), alguien podría colaborarme al respecto.

A: La verdad es que recomendaria que si tienes algun codigo en .net 1.0 veas de planear una migracion de version de forma urgente, no deberia ser complejo, con solo abrir el codigo en una version mas nueva del VS y cambiando la version del framework deberia compilar correctamente ya que con esa version primigenia de .net la funcionlidad deberia ser muy basica.
Respecto a implementar .net 1.1 en Win 2012 no vas a poder realizarlo, no esta soportado
Ejecutar aplicaciones de .NET Framework 1.1 en Windows 8, Windows 8.1 o Windows 10
quizas si instalas .net 3.5 en el servidor este pueda ejecutar versiones compiladas con .net anteriores


text:
Q: How to find out the number of days between two dates i am trying to get number of days between two given dates, but while trying this way its not giving the number of days.
$pur_dt = date_create('2015-08-03');

$todate = date_create(date('Y-m-d'));

$diff = date_diff($todate,$pur_dt);
print_r($diff);
echo $diff->format('%R%a days');
if($diff>15) //checking condition if $pur_dt - $todate > 15
{
    echo 'Hello you are not eligible';
}
else
{
    echo 'eligible';
}

its not working, not giving the number of days between given two dates.

A: Try this. It is very simple.
   <?php

     $date1 = strtotime("2015-11-16 10:01:13");
     $date2 = strtotime("2015-05-06 09:47:16");
     $datediff = $date1 - $date2;
     echo floor($datediff/(60*60*24))." days"; //output 194 days

    ?>

A: It's better using DateTime class, you can see comment(9) at PHP manual as it answer your question

A: Try this,
    $pur_dt = date_create('2015-08-03');
    $todate = date_create(date('Y-m-d'));
    $datediff = $pur_dt - $todate;
    $diff = $datediff/(60*60*24);
    if($diff>15) //checking condition if $pur_dt - $todate > 15
     {
       echo 'Hello you are not eligible';
     }
    else
     {
       echo 'eligible';
     }

A: Try This :
$pur_dt = Date('2015-08-03');

$todate = Date(date('Y-m-d'));

$pur_dt = strtotime($pur_dt);
$todate = strtotime($todate);

$seconds_diff = $todate - $pur_dt;

$$diff = floor($seconds_diff/(60*60*24));

if($diff>15) //checking condition if $pur_dt - $todate > 15
{
    echo 'Hello you are not eligible';
}
else
{
    echo 'eligible';
}

A: Try this
$pur_dt = date_create('2015-08-03');

$todate = date_create(date('Y-m-d'));

$diff = date_diff($todate,$pur_dt);
print_r($diff);
echo $diff->format('%R%a days');
if($diff->days>15) //checking condition if $pur_dt - $todate > 15
{
    echo 'Hello you are not eligible';
}
else
{
    echo 'eligible';
}


text:
Q: Controller.Request.QueryString has no key in Authorization Filter I'm trying to write a custom Authorization Filter to check the rights of a user. I have created my Filter Class and decorated my action with my custom attribute. My problem is that when the following statement is executed :
var controller = (Mvc.Controllers.MyController) filterContext.Controller;
var id = Int32.Parse(controller.Request.QueryString["id"]);

in the method
IAuthorizationFilter.OnAuthorization(AuthorizationContext filterContext)

I get a null reference error. When I debug, I can see that the QueryString property has absolutely no key (it's a GET action, taking a "id" parameter). Do you think that when the authorization filter is executed, the query string is not yet binded to te controller ? (That the authorization filters are executed too early). But if it's the case what is the intended usage of an authorization filter ? Do you think that the proper way to do it is to use an Action Filter and to override OnActionExecuting() ?

A: The answer suggested in a comment and accepted by the OP is: the id is a part of the route rather than the query string.


text:
Q: How do I use the audio embeddings from Google Audioset for audio classification? I have extracted audio embeddings from Google Audioset corpus (https://research.google.com/audioset/dataset/index.html). The audio embeddings contain a list of "bytes_lists" which is similar to the following
  feature {
    bytes_list {
      value: "#\226]\006(N\223K\377\207\r\363\333\377\000Y\322v9\351\303\000\377\311\375\215E\342\377J\000\000_\000\370\222:\270\377\357\000\245\000\377\213jd\267\353\377J\033$\273\267\307\035\377\000\207\244Q\000\000\206\000\000\312\356<R\325g\303\356\016N\224\377\270\377\237\240\377\377\321\252j\357O\217\377\377,\330\000\377|\246\000\013\034\000\377\357\212\267\300b\000\000\000\251\236\000\233\035\000\326\377\327\327\377\377\223\0009{"
    }
  }

Now, I want to use these audio embeddings for training my own model (CNN). I have some confusion about these audio embeddings.

*

*Should I extract STFT and MFCC from the audio embeddings? If so, how can I do that (any way to use librosa?)? Or, are the audio embeddings already transformed to MFCC?

*What should be the best way to split the audio set corpus into train, test and validate datasets? They are if Tfrecord format and each tfrecord file contain various segment of audio clips having different class labels.

*If I want to work on selective class labels (such as rowing, or car sound), what should be the best way to extract the selective audio segments?

Please share some helpful resources about working with Google audioset corpus if possible.


text:
Q: .yarnrc for Mac and Windows I have a .yarnrc file with a Windows path in it.
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

yarn-offline-mirror "C:\\yarn-offline-mirror"
yarn-offline-mirror-pruning true

This project is shared between Windows and Mac users though.
Can I craft a file path that will work for both?


text:
Q: How to Save the Checkmark Accessory in A Cell Trying to develop a checklist app and have been stuck for a while trying to save the state of a checkmark. When I go off the tableView and back on all of the saved checkmarks are erased. I have imported UKIT then defined the class.
Here is my code:
var PreDefinedTasks = ["1", "2", "3", "4"]

// MARK: - Table view data source

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: true)

    if let cell = tableView.cellForRow(at: indexPath as IndexPath) {
        if cell.accessoryType == .checkmark{
            cell.accessoryType = .none
        }
        else{
            cell.accessoryType = .checkmark
        }
    }
}

override func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return PreDefinedTasks.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "List1", for: indexPath)

    cell.textLabel?.text = PreDefinedTasks[indexPath.row]

    return cell
}

I have looked into NSCoder as a solution but cant seem to get it to work properly. Any help is appreciated!

A: Here is how I would go about it, if you follow the whole solution, it will save even when the app closes.
Make an array off type Bool like this: var checkmarks = [Int : Bool]()
Then, in cellForRow function, add this:
if checkmarks[indexPath.row] != nil {
    cell.accessoryType = checkmarks[indexPath.row] ? .checkmark : .none
} else {
    checkmarks[indexPath.row] = false
    cell.accessoryType = .none
}

And in the didSelectRow function, add this:
if let cell = tableView.cellForRow(at: indexPath as IndexPath) {
    if cell.accessoryType == .checkmark{
        cell.accessoryType = .none
        checkmarks[indexPath.row] = false
    }
    else{
        cell.accessoryType = .checkmark
        checkmarks[indexPath.row] = true
    }
}

If you want it to save when the app closes, you have to save the checkmarks array in UserDefaults by doing this:
In didSelectRow function, at the bottom after everything add this:
UserDefaults.standard.set(NSKeyedArchiver.archivedData(withRootObject: checkmarks), forKey: "checkmarks")
UserDefaults.standard.synchronize()

Then also, in viewDidLoad, add this:
if let checks = UserDefaults.standard.value(forKey: "checkmarks") as? NSData {
    checkmarks = NSKeyedUnarchiver.unarchiveObject(with: checks as Data) as! [Int : Bool]
}

Let me know if this answer helped and if you have any questions.
EDIT:
So what I completely forgot about is that [Int : Bool] is not an NSDictionary, it is just a Dictionary. UserDefaults can't store Dictionary objects, only NSDictionary which is why you have to change it to NSData so it is able to save the [Int : Bool]. Hope it works this time :)

A: You can save the indexpath in your array based on checkmark selected on your tableView rows.

A: As per you implementation, the UITableViewCell is getting reused with identifier as "List1". So if you want to re-use the cell then you have to keep updating the correct accessoryType by storing the state against the predefines tasks.

A: Since cells get unloaded and later reused, you'll need to store the state of the checkmark elsewhere. In this example in an array called preDefinedTaskCheckmarkState. When loading the cells you'll also need to set the checkmark state.
var PreDefinedTasks = ["1", "2", "3", "4"]
var preDefinedTaskCheckmarkState = [Bool](repeating: false, count: 4)

// MARK: - Table view data source

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: true)

    if let cell = tableView.cellForRow(at: indexPath as IndexPath) {

        preDefinedTaskCheckmarkState[indexPath.row] = !(cell.accessoryType == .checkmark)

        cell.accessoryType = preDefinedTaskCheckmarkState[indexPath.row] ? .checkmark : .none
    }
}

override func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return PreDefinedTasks.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "List1", for: indexPath)

    cell.textLabel?.text = PreDefinedTasks[indexPath.row]
    cell.accessoryType = preDefinedTaskCheckmarkState[indexPath.row] ? .checkmark : .none

    return cell
}


text:
Q: FloatingRateBond cashflow retrieval and printing I am using the FloatingRateBond class to create a floating rate bond object, which I have already priced correctly. However, now I need to retrieve the cashflows and the dirty price to decompose the yield. I have been trying the following without any success:
Leg cf=floatingRateBond.cashflows();
     Leg::iterator it;
     for(it=cf.begin();it!=cf.end();++it)
        cout<<"Type: "<<typeid(*it).name()<< "    value:" << *it<<endl;

Output:
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14362a50
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14362c40
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14362e70
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x143630a0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x143632d0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14363500
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14363730
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14363960
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14363b90
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14363dc0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14363ff0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14364220
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14364450
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14364680
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x143648b0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14364ae0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14364d10
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14364f40
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14365170
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x143653a0
Type: N5boost10shared_ptrIN8QuantLib8CashFlowEEE    value:0x14362660

thanks

A: Your question is not really clear. You're trying to iterate Leg, which should be defined as
typedef std::vector< boost::shared_ptr<CashFlow> > Leg;source
So if it = cf.begin(), than *it is of type boost::shared_ptr<CashFlow>, which would explain the type N5boost10shared_ptrIN8QuantLib8CashFlowEEE and the address 0x14365170.
Have you tried to de-referece one more time, to get CashFlow? Was that your problem?

A: I have. however I get the same thing. My collegue solved it by not using an iterator but just a simple for loop and then pointing to the ->amount()
I don't understand however how is this different given that quantlib is built upon STL and boost.
like so:
Leg cf=floatingRateBond.cashflows();
     for (Size j=0; j<cf.size()-1; j++) {
            if (!cf[j]->hasOccurred(settlementDate, false)) {
                Date myDate =  cf[j]->date();
                Real Amount = cf[j]->amount();
                cout << "Date is " << myDate << "  |  Amount is " << Amount << endl;

            }
        }

If it did (*it)->amount(); it would yield an error.


text:
Q: C - printf error I'm trying to compile an example from Sam's Learn C in 24 Hours.
When I try compiling the following code I get an error:
/* 03L02.c: Calculate an addition and print out the result */
#include <stdio.h>
/* This function adds two integers and returns the result */
int integer_add( int x, int y )
{
    int result;
    result = x + y;
    return result;
}
int main()
{
    int sum;
    sum = integer_add(5, 12);
    printf("The addition of 5 and 12 is %d.\n", sum);
    return 0;
}

This is the errors my compiler gives:
In function main
stray "\147\' in program
The undeclared identifier is declared only once
for each function it appears in
syntax error before addition
stray "\' in program
stray "\148' in program

Thanks in advance.

A: You are using the wrong kind of quotes for the string in your program. You have " while it should be ".

A: You just mistaken the quote character, change it to this:
printf("The addition of 5 and 12 is %d.\n", sum);

I don't know what keyboard you use, but usually the " character is above the '2' character (I am using an italian keyboard so maybe that's different for your country).
Surely you'll find that character somewhere.
If I'm not mistaken it's 34 in ASCII table, so on windows you can get it by pressing alt+34.

A: because of wrong double qoute
printf("The addition of 5 and 12 is %d.\n", sum);

to
printf("The addition of 5 and 12 is %d.\n", sum);

A: Don't use "smart quotes" in code!!!!! For string delimiters use plain old quotes. Here ("""""""""""""") are a few (here single quotes: '''''''''''''') you can probably copy/paste :)

A: I see your error because same character. See your code
printf("The addition of 5 and 12 is %d.\n", sum);

try change to:
printf("The addition of 5 and 12 is %d.\n", sum);

can you see the differences? the Qoute " it's must be "


text:
Q: take a list of numbers from the command line and print the largest number I have to write a program that, when given numbers from the command line, manages to read and print the highest number.
import sys
numbers = sys.argv[1]
def map(f,items):
   result = []
   for i in range(0,len(items),1):
   result = result + [f(items[i])
   return result

im trying to find the easiest way to go about doing this! Thank you!

A: import sys
print(max(float(x) for x in sys.argv[1:]))

Alternatively, you can use print(max(sys.argv[1:], key=float)) (thanks to the nice addition by frostnational).
Demo:
>> python a.py 12 6 3.14 11
12.0

Explanation: If we add print(sys.argv) to the script, the output for the above example will be
['a.py', '12', '6', '3.14', '11']
12.0

The solution is slicing off the first element of sys.argv, converting the other strings to floats in a generator expression, and then finding the maximum.

A: @timgeb answer is very good but i would also check argparse if you are using the command line interface it can give you some very good option for your current and future code, by using argparse you can save a lot of programming time and get a full help and usage messages.
I'll take the example form the docs since it's relevant for your question, this code will print either max or sum.
import argparse

parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
                   help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
                   const=sum, default=max,
                   help='sum the integers (default: find the max)')

args = parser.parse_args()
print(args.accumulate(args.integers))

For max: just call the code with a list of numbers.
For sum: or any other option you would like to add you can use an argument, in this case --sum


text:
Q: Div size is not size according to its content with display: inline-block; HTML:

0.89$ per kg

        <input type="button" class="addToCart" value="Add to cart" id="addToCart" />

CSS:
body{
    background: #272727;
}

.itemOne{
    display: inline-block;
    padding: 5px;
    text-align: center;
    border: 2px solid black;
    background-color: white;
}

.itemOne img{
    width: 30%;
    height: 50%;
}

h1{
    font-size: 1.05em;
    color: black;
    font-family: 'IBM Plex Sans', sans-serif;
}

How it looks
It doesn't want to make div size fit content on div
I tried everything maybe its because of the picture because without it worked but I don't know how to fix it.

A: The problem is that you have width: 30% and height: 50% for your  but you didn't specify how wide and tall the .itemOne is, so the browser takes 30% as 30% of the size of your original image.
Here are some solutions to your problem:
SOLUTION 1 - set width for .itemOne and set width: 100% for .itemOne img:

body{
    background: #272727;
}

.itemOne{
    display: inline-block;
    padding: 5px;
    text-align: center;
    border: 2px solid black;
    background-color: white;
    width: 30%;
}

.itemOne img{
    width: 100%;
}

h1{
    font-size: 1.05em;
    color: black;
    font-family: 'IBM Plex Sans', sans-serif;
}

0.89$ per kg

        <input type="button" class="addToCart" value="Add to cart" id="addToCart" />

SOLUTION 2 - set fixed width for your .itemOne img:

body{
    background: #272727;
}

.itemOne{
    display: inline-block;
    padding: 5px;
    text-align: center;
    border: 2px solid black;
    background-color: white;
}

.itemOne img{
    width: 300px;
}

h1{
    font-size: 1.05em;
    color: black;
    font-family: 'IBM Plex Sans', sans-serif;
}

0.89$ per kg

        <input type="button" class="addToCart" value="Add to cart" id="addToCart" />

A: By using a percentage for width and height, the pixel size of the image in the DOM stays unchanged. Only its appearance is reduced, and the
 scales so it can fit the original image.
The fix is to specify an exact width and/or height for the image, as in this example, with a 400x300 image scaled back to a width of 150px:

body {
  background: green;
}

.itemOne {
  display: inline-block;
  padding: 5px;
  text-align: center;
  border: 2px solid black;
  background-color: white;
}

.itemOne img {
  width: 150px;
  border: solid 1px red;
}

h1 {
  font-size: 1.05em;
  color: black;
  font-family: 'IBM Plex Sans', sans-serif;
}

0.89$ per kg

  <input type="button" class="addToCart" value="Add to cart" id="addToCart" />