text:
Q: Classpath problem for my Ant Build file I have been using this exact Build.xml file. I had problems in the beginning using the junit task with it, but I figured out those problems a couple months ago.
Recently I got the all to common error message when I ran my build file with the test task.
test:
[junit] Testsuite: com.mmz.mvc.test.AgentDAOTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit] Null Test:  Caused an ERROR
[junit] com.mmz.mvc.test.AgentDAOTest
[junit] java.lang.ClassNotFoundException: com.mmz.mvc.test.AgentDAOTest
[junit]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[junit]     at java.lang.Class.forName0(Native Method)
[junit]     at java.lang.Class.forName(Class.java:247)
[junit]     at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[junit]     at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[junit]     at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

BUILD FAILED
C:\Users\myName\Documents\Java\mmz\WEB-INF\build.xml:45:
Testcom.mmz.mvc.test.AgentDAOTest failed

I know this problem is related to my classpath, but I am not sure why this would all of a sudden break when it has been working for so long.
My build follow looks like the following.
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="build.dir" value="classes"/>
<property name="web.dir" value="war"/>

 <path id="build.classpath">
  <fileset dir="lib">
      <include name="*.jar"/>
  </fileset>
  <fileset dir="${appserver.lib}">
      <include name="servlet*.jar"/>
  </fileset>
  <pathelement path="${build.dir}"/>
  <pathelement path="${test.dir}"/>
 </path>

 <path id="classpath.base"/>
 <path id="classpath.test">
 <pathelement location="c:/ant/lib/junit.jar" />
 <pathelement location="${build.dir}"/>
 <pathelement location="${src.dir}"/>
 <pathelement location="${test.dir}" />
 <pathelement location="classes"/>
 <path refid="classpath.base" />
 </path>

 <target name="build">
    <mkdir dir="${build.dir}"/>
     <mkdir dir="${test.dir}"/>
     <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"    deprecation="false" optimize="false" failonerror="true">
      <src path="${src.dir}"/>
       <classpath refid="build.classpath"/>
     </javac>
  <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
      <src path="${test.dir}"/>
      <classpath refid="build.classpath"/>
  </javac>
  </target>

    <target name="test">
    <junit haltonfailure="true">
      <classpath refid="classpath.test" />
      <classpath refid="build.classpath"/>
      <formatter type="brief" usefile="false" />
      <test name="com.mmz.mvc.test.AgentDAOTest"/>
      <test name="com.mmz.mvc.test.AgentProfileDAOTest"/>
      <test name="com.mmz.mvc.test.BuyerDAOTest"/>
      <test name="com.mmz.mvc.test.BuyerSellerDAOTest"/>
      <test name="com.mmz.mvc.test.BaseDAOTest"/>
      <test name="com.mmz.mvc.test.MemberDAOTest"/>
      <test name="com.mmz.mvc.test.SellerDAOTest"/>
    </junit>

I am not very good with build files and I am not very good at understanding the how to setup classpaths and everything so If somebody could help I would appreciate it.

A: Looks like a missing jar file, containing the class "com.mmz.mvc.test.AgentDAOTest". Reading your build file suggests the jar used to be located in your "lib" directory.
I'm assuming, of course, that this class is not a missing Java source file located under you "src" or "${test.dir}" directories.....


text:
Q: Speed up classification in field calculator I have a shapefile with a little over one million features (but it could also be 10+ million).
I need to categorize them by an attribute they have. It is a float value, and the categories are:
1: attrib < 0.1
2: attrib >= 0.1 and < 0.3
3: attrib >= 0.3 and < 0.5
4: attrib >= 0.5
I want to add this category value in a new field.
Easy enough using the field calculator, I thought:
CASE
    WHEN attrib < 0.1 THEN 1
    WHEN attrib >= 0.1 AND attrib < 0.3 THEN 2
    WHEN attrib >= 0.3 AND attrib < 0.5 THEN 3
    WHEN attrib < 0.5 THEN 4
END

into a new field ('category', integer, length 1).
This process is very slow (about a minute per 1000 features).
If I just style the features according to the same rules (graduated, 4 classes), that happens in a manner of seconds and I get a fancy visualization, which I take to mean there has to be a faster way to do this.
So the question:
Why is the field calculator so much slower than the graduated style, and what can I do to speed this up?
I am not opposed or unfamiliar with pyqgis, so a python/processing script solution is just as fine. I attempted a small script that basically does the same as the field calculator above, but it has the same low performance:
##input_layer=vector
##General Tools=group
##Test=name

from qgis.core import *

layer = processing.getObject(input_layer)
layer.startEditing()
for i, f in enumerate(layer.getFeatures()):
    level = f['attrib']
    if level < 0.1:
        f['cat'] = 1
    elif level >= 0.1 and level < 0.3:
        f['cat'] = 2
    elif level >= 0.3 and level < 0.5:
        f['cat'] = 3
    elif level >= 0.5:
        f['cat'] = 4
    layer.updateFeature(f)
    if i % 1000 == 0: # Only added this to track how slow the script is
        print i
        progress.setText('Feature ' + str(i))
layer.commitChanges()

Running QGIS 2.18.15.

A: @NyallDawson, one of the core developers of QGIS, posted a blog: "Speeding up your PyQGIS scripts" where he advised on using two methods when iterating through large datasets (described in "Trap #3: Only request values you need"):

*

*Use setFlags(QgsFeatureRequest.NoGeometry) to avoid calling the geometry for each feature;

*Use setSubsetOfAttributes() to only call values from one field.

So you could try using the following where hopefully it should take slightly less time:
##input_layer=vector
##General Tools=group
##Test=name

from qgis.core import QgsFeatureRequest

layer = processing.getObject(input_layer)
request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry).setSubsetOfAttributes(['attrib'], layer.fields())
layer.startEditing()
for i, f in enumerate(layer.getFeatures(request)):
    level = f['attrib']
    if level < 0.1:
        f['cat'] = 1
    elif level >= 0.1 and level < 0.3:
        f['cat'] = 2
    elif level >= 0.3 and level < 0.5:
        f['cat'] = 3
    elif level >= 0.5:
        f['cat'] = 4
    layer.updateFeature(f)
layer.commitChanges()

Note: I have used these methods on layers with thousands of features which worked very well. But not on those with a million features, I would opt to use PostGIS instead.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Azure blueprint deployment, getting Resource ID of publicIPAddresses of ACR Cluster I have an Azure blueprint, which deploys an Azure ACR Cluster. Creating the cluster also triggers creating of the publicIPAddresses of the cluster. I need to get the Resource Id of that IP to be able to automate assigning a DNS/A record to that IP.
I thought about this output record in the artifact, which creates ACR Cluster:
"outputs": {
      "IPAddress": {
          "type": "string",
          "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))).id]"
        },
}

, which as I thought could help me dynamically get that Resource ID, but it doesn't seem to be working. Can somebody point, what am I doing wrong?
Thank you!

A: Try adding 'Full' to your reference() function call, which instructs the call to return all properties, including the id.
see: https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource?tabs=json#reference

A: Actually, if you only want to get the resource Id, you just need to use the function resourceId(), not the reference(). So the value of the outputs should like this:
"value": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"

Note that maybe you want to create an AKS cluster, the ACR is a Container Registry that stores the docker images and it does not need a public IP address.


text:
Q: Travel through NSArray without using loop but cursors? I have an NSArray with objects inside (CLLocation). I can have 50, 100, 300 or more objects inside. In fact, this array is used while the user walking and can follow a direction. But the user can start at the middle of my NSArray, you know what I mean ?
Well, I Have to loop all the time my array to know where my user is compare to the locations in my array.
My question is: Is it possible to use a thing like in Java with a "cursor" in a list, and simply call "Next object" to travel in my array instead of loop ?
Because I need that the user walk on all location of my array.
Example:

*

*Count of my array: 100

*User start at location at index 34 (the nearest location found)

*The user must do 35, 36, 37... 100 AND 0,1,2,3 ... until 33.

Hope it's clear, I really don't know how to do this without using for loop...
Thank you for help and suggestions!
Regards,
Lapinou.

A: Is looks like you are want to use NSEnumerator
NSEnumerator Class Reference
NSArray *anArray = // ... ;
NSEnumerator *enumerator = [anArray objectEnumerator];
id object;

while ((object = [enumerator nextObject])) {
    // do something with object...
}

A: Here's one way:
NSArray * arr = ... yourArray

int index = [arr indexOfObject:currentLocation];
index ++;
if (index == arr.count) index = 0;
id nextLocation = arr[index];

Another might be to create a global counter variable that stores the current position.  If these needs to last after the user closes the app, you could write it to user defaults

A: try this:
@interface ArrayEnumerator : NSEnumerator
{
    NSArray* array;
    NSInteger index;
    NSInteger startIndex;
    BOOL over;
}

- (id)initWithArray:(NSArray*)anArray
            atIndex:(NSInteger)anIndex;
@end
@implementation ArrayEnumerator
- (id)initWithArray:(NSArray*)anArray
            atIndex:(NSInteger)anIndex
{
    if (self=[super init]) {
        array = anArray;
        index = anIndex;
        startIndex = anIndex;
        over = NO;
    }

    return self;
}

- (id)nextObject
{
    if (index == [array count]) {
        index = 0;
        over = YES;
    }

    if (over && index == startIndex)
        return nil;

    return array[index++];
}

- (NSArray*)allObjects
{
    return array;
}
@end

@implementation ViewController

- (void)viewDidLoad
{

    NSArray* array = @[@0,@1,@2,@3,@4,@5,@6,@7,@8,@9];
    id element;

    ArrayEnumerator* enumerator = [[ArrayEnumerator alloc] initWithArray:array atIndex:4];
    while (element = [enumerator nextObject])
        NSLog(@"%@", element);

}

@end

A: You can access array elements by index:
CLLocation * myLocation = myArray[34];

(or)
int i = 34;

CLLocation * myLocation = myArray[i];

A: What is wrong with a for loop?
An iterator is typically used on lists, because you can't access elements in a list by index. However you are working with an array, so you don't need an iterator, but rather some clever way of accessing the array in the desired order.
Maybe this code can provide you with some ideas. This will run from 34 to 100, then start with 0 and go up to 33.
for (int i = 34; i < 134; i++)
{
    int ix = i % 100;
    id whatever = arr[ix];
}


text:
Q: html/CSS Ellipsis I'm trying to get an ellipsis to work like so: http://jsfiddle.net/583mK/1/
Interestingly, it works fine on jsFiddle. Strange thing is given the exact same HTML/CSS it's not working on my app and I can't figure out why. Are there any ellipsis gotchas that could be causing this?
The one big difference is in the Fiddle, it's all static content. In my app, the page loads, and jQuery Template is used to populate the list which I then want to have an ellipsis.
The text is not overflowing, so the overflow is working and the white space is working just not the ... ellipsis.

A: Not sure if this helps:
http://quirksmode.org/css/textoverflow.html
Support is not provided in Firefox. The Mozilla developers think there are too many edge cases involving r-to-l languages etc to implement safely, yet.
Firefox now supports text-overflow: ellipsis starting with version 7 (source). Hurray!
All I know is that you need all these rules:
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;

and it should have width (not an inline element).
Also, use your favourite browser developer tools to check you are not inheriting a property that conflicts.

A: You can achieve height vice text ellipsis through the '-webkit-line-clamp' css property. Use the number based on what line number you want the dots to appear.
.cut-text {
  width: 100px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


text:
Q: Show TODO comments as warnings excluding the Pods folder I have a script to show all my //TODO: comments which looks like this:
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"

find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 |
  xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" |
  perl -p -e "s/($KEYWORDS)/ warning: \$1/"

I want to exclude my Pods folder, therefore I have added -not -path "./Pods/*":
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "./Pods/*" -print0 |
  xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" |
  perl -p -e "s/($KEYWORDS)/ warning: \$1/"

This works as expected when I try it on the Terminal (replacing "${SRCROOT}" with "."), but when it is run by Xcode it uses the Pods folder as well.
How can I exclude the folder in the build phase script?
Final version
This seems to work:
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "." \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "./Pods/*" -print0 |
  xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" |
  perl -p -e "s/($KEYWORDS)/ warning: \$1/"

A: I would use find . and set the working directory of the build script to ${SRCROOT}.  This should allow the . in -not -path "./Pods/*" to make sense to find.

A: I couldn't get it to work correctly without using ${SRCROOT} macro, as you couldn't click on the warning to go to the source line.
I split up the recognized tokens into Warnings and Errors for my own use, thought I would share it here:
KEYWORDS="STUB:|WARNING:|TODO:|FIXME:|DevTeam:|\?\?\?:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: warning: \$1/"

KEYWORDS="ERROR:|XXX:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"
ERROR_OUTPUT=`find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"`

exit ${#ERROR_OUTPUT}


text:
Q: How to show .phtml content in browser I have created the new theme and new phtml file in magento2.1.5
The file path is app/design/frontend/demo/static/Magento_Theme/templates/html/staticpage.phtml
The staticpage.phtml file contains static content, I have used the URL http://localhost/magento2/staticpage.phtml but it shows the 404 page.
I want to show this file content in this URL,
What are steps and changes needed to show phtml file content?

A: Well this is not a proper way, you should not call the file directly.
You will need a controller to handle your page and a layout in which you should call the phtml file.
if the controller already exist :
for ex : home page the controller will be module-cms/Controller/Index/Index.php
and the layout will be cms_index_index.
So if you want to display the block on home page :
create following file in your theme :
app/design/frontend/demo/static/Magento_Theme/layout/cms_index_index.xml
and write following code :
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="<block/container_in_which_you_want_to_show_your_block>">
            <block class="<the_block_class_you_want_to_use)>" name="<block_name>" template="<your_template_reference_path>"/>
        </referenceContainer>
    </body>
</page>

Sample code :

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Framework\View\Element\Template" name="default_no_route" template="Magento_Cms::html/staticpage.phtml"/>
        </referenceContainer>
    </body>
</page>

If the controller does not exist, i.e. you want to show it on a new page.
you need to create a controller and respective layout, router etc,. and use the above code in its layout. Just change referenceContainer tag to container.


text:
Q: Android Adobe PNG Settings for Action Bar Icons I created some icons in illustrator and I am trying to make icons for some buttons, but they are coming out fuzzy, not crisp. I really can't find a good tutorial online.
Look at my sample

These are the steps I take after the icon is complete
1. Create a new image with 32x32
2. Copy and Paste the icon and resize it according to Android Specs

3. File->Save For Web
4. See screenshot for settings

Can someone either let me know if I am using the wrong settings or just my technique? Can someone share how they make icons and make them look good?


text:
Q: How to add suffixes to an amount of money in javascript I have a game where you earn money, and it is very easy to get rich. I want to make it so that if you get money more than a million, instead of showing 1234567, it shows 1.2 million. The process I am trying to go for if the number is more than a million is:
1: get the first two digits
2: remove the first two digits
3: store the remaining digits into a list
4: divide the length of the list by 3
5: get that value in the list of suffixes - 1 (because lists start at 0, not 1)
I can make the list of suffixes, I just need help on how to make this process.

A: This might be a good starting place for you. Let me know if it helps.

const $ = s => [...document.querySelectorAll(s)];

function formatNumber(n) {
  if (n > 10**9 - 1) {
    return (n / 10**9).toFixed(2) + "b"
  } else if (n > 10**6 - 1) {
    return (n / 10**6).toFixed(2) + "m"
  } else {
    return n
  }
}

$("button")[0]
.addEventListener("click", e => {
  const userInput = $("input")[0].value;
  const formattedNumber = formatNumber(userInput);
  $("#display")[0].innerText = formattedNumber;
});
body {
  font-size: 2em;
  }
<input type="number">
<button>Go</button>

output

A: Here's an efficient approach that doesn't require any parsing - just simple string manipulation:

*

*Get the digits greater before the 6 digit mark by subtracting the length of the string by 6

*For the digit immediately after the 6 digit mark, you can use charAt and get the character at the index of the length of the string minus 6
Result:

const num = "13356789";

function wordify(number) {
  if (number.length > 6) {
    const start = num.substring(0, number.length - 6);
    const second = num.charAt(number.length - 6);
    return `${start}.${second} million`;
  }
}

console.log(wordify(num));

Try it yourself with custom numbers:

function wordify(number) {
  if (number.length > 6) {
    const start = number.substring(0, number.length - 6);
    const second = number.charAt(number.length - 6);
    return `${start}.${second} million`;
  }else{
    return `number must have at least 6 digits`;
  }
}

num.addEventListener('input', () => {
  result.innerHTML = wordify(num.value);
});
Enter a number: <input id="num" type="number">

 Result:

A: Handling all cases (thousands, millions and billions):

let money = 1234567;
let strMoney = String(money);

if(strMoney.length >= 7 && strMoney.length <= 9) {
  console.log(Math.round(money/ 1000000 * 100)/100, 'million')
}else if(strMoney.length > 9) {
  console.log(Math.round(money/ 1000000000 * 100)/100, 'billion')
}else if(strMoney.length <= 6 && strMoney.length >= 4){
  console.log(Math.round(money/ 1000 * 100)/100, 'thousand')
}else {
  console.log(money)
}


text:
Q: Intuitive explanation of initial condition for wave equation I've just started a course in Fourier analysis, and have some problem understanding the initial condition of wave equation, and would appreciate if someone would like to explain to me in the easiest possible way, and give an easy example of what it might look like.
So we have the wave equation;
$u_{tt} = c^2 u_{xx}$
with boundary condition $u(0,t)=u(l,t)=0$
And the initial condition $u(x,0) = f(x)$ and $u_t(x,0) = g(x)$
What does the initial condition actually mean? From my understanding $u(x,0)$ is simply the height at point $x$ at time $t=0$, for which we can put in any x?
And what does $u_t(x,0) = g(x)$ mean? Since it's the time derivate I assume we are talking about some kind of speed?
Would really appreciate if someone could explain further, in a non mathematical way so I can get a intuitive feeling about it.
Thanks!

A: $u(x, 0)$ tells you how the wave function looks like at time $t=0$. It could be a sine wave, a triangular function, or anything else.
$u_t(x, 0)$ tells you the "initial speed" of each point.
I find it simple to look at the example of an oscillating string. $u(x, 0)$ is the shape of the string initially. After $t =0$, each point on the string moves up and down. The initial vertical speed of each point $x$ on the string is given by $u_t(x, 0)$. So, these conditions basically tell you the vertical location and vertical speed for each point $x$ on the string.
From a physical perspective, the wave function is simply Newton's second law applies to each point $x$ on the string, which is why it tells you exactly how each point will behave at every time $t$.
I hope this helps.


text:
Q: ChoiceType Not Mapping to Entity Field I have an Announcement Entity that where a EditAnnouncementType form is mapped to. I have two other CheckBoxType forms that automatically update their respective fields, but the ChoiceType form isn't working.
$builder
        ->add('edit', SubmitType::class,
            array
            (
                'label' => 'Save changes',
                'attr' => ['class' => 'btn btn-primary']

            ))

        ->add('type', ChoiceType::class,
            [
                'choices' => [
                    'info_type' => 1,
                    'star_type' => 2,
                    'alert_type' => 3,
                    'lightbulb_type' => 3,
                    'event_type' => 4,
                    'statement_type' => 5,
                    'cat_type' => 6,
                    'hands_type' => 7
                ],

                'mapped' => true,
                'expanded' => true,
                'required' => true,
            ])

The Announcement entity and type field
class Announcement
{
    /**
     * @var int
     */
     private $type;

     /**
     * @return string
     */
     public function getType(): string
     {
        return $this->type;
     }

    /**
    * @param int $type
    *
    * @return $this
    */
    public function setType(int $type)
    {
        $this->type = $type;
        return $this;
    }

A: My suspicion would be that Symfony somehow strict checks the value (using ===).
And since your getter returns a string, the mapping doesn't happen properly.
You should try fixing your getter:
 /**
  * @return int
  */
 public function getType(): int
 {
    return $this->type;
 }

Also mind that you might have a problem in your choice array:
// be careful: those two have the same value
'alert_type' => 3,
'lightbulb_type' => 3,

This would surely cause an issue to Symfony, especially if it uses array_values in order to select the right choice out of the value of your entity.


text:
Q: Time and date in SQL Server create table app
(
     start_date date,
     end_date date,
     start_time time(7),
     end_time time(7)
);

Input: 5/2/2016 08:00:00 to 12:30:00
I need to insert rows in to the above table through a stored procedure like
For every one hour between 08:00 and 12:30
insert into app values ('5/2/2016', '5/2/2016', '08:00:00', '09:00:00')
insert into app values ('5/2/2016', '5/2/2016', '09:00:00', '10:00:00')
insert into app values ('5/2/2016', '5/2/2016', '10:00:00', '11:00:00')
insert into app values ('5/2/2016', '5/2/2016', '11:00:00', '12:00:00')

My code is
@j time(7);
@time time(7);

select @time = time from someTable;

SET @j = @startTime;

while (@j <= @endTime)
begin
    INSERT INTO appointmentt(start_date, end_date, start_time, end_time)
    VALUES (@startDate, @startDate, @j, @j + @time, @tutorId);

    SET @j = @j + @time;
end;

Getting an error like:

Operand data type time is invalid for add operator

A: In this case, to add time to a datetime you can cast it first like this example:
DECLARE @date DATETIME, @time time
SET @date='2010-10-01'
SET @time='15:00:00'
SET @date=@date+CAST(@time AS DATETIME)
SELECT @date AS DATETIME

To add integers to datetimes, you need to use the dateadd() function.
For example:
DATEADD(second,1,@j)

A: Change
SET @j=@j+@time;

To
select  @j = DATEADD(MINUTE, DATEPART(MINUTE, @time),
                     DATEADD(HOUR, DATEPART(HOUR, @time), @j))


text:
Q: Why is my CSS keyframe animation not working? I found a CSS 'bounce' effect here that I would like to implement in my website: http://codepen.io/dodozhang21/pen/siKtp
I tried copying it as is, and for some reason my web browsers (chrome, firefox and IE) didn't read it.
I tried working with -webkits and it didn't work either.
I think there is a specific thing that I am missing that's causing me all of the trouble.
This is my code, Please help me find a solution!
http://jsfiddle.net/ho7gaywb/
    @keyframes(bounce) {
    0%, 20%, 50%, 80%, 100% {
    @include transform(translateY(0));
  }
    40% {
    @include transform(translateY(-30px));
  }
    60% {
    @include transform(translateY(-15px));
  }
}

.bounce{
    -webkit-animation-name: bounce;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-duration: 2s;

    animation-name: bounce;
    animation-iteration-count: infinite;
    animation-duration: 2s;

}

A: *

*You will need to add
 @-webkit-keyframes(bounce) {0%, 20%, 50%,80%, 100% {
        @-webkit-include transform(translateY(0));
}
  40% {
        @-webkit-webkit-include transform(translateY(-30px));
 }
  60% {
        @-webkit-include transform(translateY(-15px));   } }

for Mozilla
    @-moz-keyframes(bounce) {   0%, 20%, 50%, 80%, 100% {
        @-moz-include transform(translateY(0));
 }  40% {
        @-moz-webkit-include transform(translateY(-30px));
 }  60% {
        @-moz-include transform(translateY(-15px));   }
 }


text:
Q: RSpec: Testing that a mailer is called exactly once I have a Mailer that looks something like this:
class EventMailer < BaseMailer
  def event_added(user_id, event_id)
    # do stuff and email user about the event
  end
end

I'm calling this EventMailer like this from inside the Event class:
class Event < Task
  def notify_by_email(user)
    EmailLog.send_once(user.id, id) do
      EventMailer.delay(queue: 'mailer').event_added(user.id, id)
    end
  end
end

where EmailLog is a class that logs sent emails. .delay is added by Sidekiq.
But when I try to test that #notify_by_email is called only once per event and user, my spec fails:
1) Event#notify_by_email only sends once per user
     Failure/Error: expect(EventMailer).to receive(:event_added).once
       (<EventMailer (class)>).event_added(any args)
           expected: 1 time with any arguments
           received: 0 times with any arguments

The spec looks like:
let(:owner) { User.make! }
let(:product) { Product.make! }
let(:event) { Task.make!(user: owner, product: product) }

describe '#notify_by_email' do
  before do
    EventMailer.stub(:delay).and_return(EventMailer)
  end

  it 'only sends once per user' do
    event.notify_by_email(owner)
    event.notify_by_email(owner)

    expect(EventMailer).to receive(:event_added).once
  end
end

Any insights into why this spec is failing and how I can fix it? Strangely, if I put a puts statement inside the block that's passed to EmailLog.send_once, it prints only once, the spec still reports that EventMailer.event_added wasn't called.

A: Your expectation should be declared before the code you're testing. Using expect(...).to receive(...) basically means "this message should be received between now and the end of this spec". Because the expectation is the last line of your spec, it fails.
Try moving it before and you should be good to go:
it 'only sends once per user' do
  expect(EventMailer).to receive(:event_added).once

  event.notify_by_email(owner)
  event.notify_by_email(owner)
end


text:
Q: AWS ECS Task Definition environment variable using private ip parameter I have a simple MVP style fullstack MERN app deployed using 3x services / 3x tasks on a single t2.micro SPOT instance.
Challenge: Every time the SPOT instance is replaced, the private IP changes.
Workaround: The env variable for the backend needs to be updated with DB_HOST such that it can connect to the database task hosted on the same ec2 SPOT instance.
Requirement: Is there a way to pass in the ec2 SPOT container instances private IP as a parameter to the Env variable such that if it changes, the DB_HOST env variable in the backend task definition is automagically updated?

A: You can get the IP address using instance metadata. There is also ECS metadata for containers. If you need this an environment variable you will need to run a script before running your application.
There probably isn't really any good reason for any part of anything to depend on a private ip address. If you want to access this instance in a reliable way, you would use a load balancer, target group, etc. If this is used to host containers on ECS, you would create a Service. Maybe you would use App Mesh.
This is for the exact reason you are experiencing in that the instance can stop and start which will give it a new ip address. This can happen for reasons outside of your control, such as a hardware failure.
In general when you are just getting something up and running you might use this private ip address you have. But once things progress past that and you need this ip address in other places it's best to do things righrt.


text:
Q: Solving $n! = 10^9$ What is the largest $n\in \mathbb{R}$ for which one can solve within one second a problem using an algorithm that requires $f (n)$ bit operations, where each bit operation is carried out in $10^−9$ seconds, with $f (n) = n!$?
The number of bits carried out in $1$ second is $\frac{1}{10^{-9}}=10^9$.
We can estimate that using the fact that,
$$12! \lt 10^9 \lt 13!$$
Question 1: Is there a more systematic approach to solve it? I tried to replace $ n!$ with its upper bound $n^n$, but I am not sure if this is correct as the solution for $n!$ might be less than the solution of $n!$ upper bound $n^n$, or the upper bound solution of $n^n$ is acceptable answer for $n!$ based on question requirement?
$$n^n = 10^9$$

A: So first, if this were a "real-world" problem. Then the answer is 12 because $n$ should be an integer. (E.g. you can have a graph with 12 nodes, but not with 12.5 nodes.)
If we're trying to figure out for which real number $n$ do we have $n! = 10^9$ then we need to understand what that question even means because factorials are only defined for whole numbers. The most common extension of the factorial function to the reals (and complex numbers) is the Gamma function and we can use this (and a computer) to get an answer. The Gamma function is related to the factorial function by $\Gamma(n + 1) = n!$ when $n$ is a whole number.
So the question we want to ask our computer is: solve $\Gamma(n + 1) = 10^9$. But probably we should modify this to: solve $\log \Gamma(n + 1) = 9 \log 10$ since computers have good algorithms for computing $\log \Gamma(x)$ and $10^9$ is quite large so it might be harder to work with numbers at that scale.
If we do this, we get the answer $n \approx 12.2900691486\ldots$.
https://www.wolframalpha.com/input/?i=solve+loggamma%28n+%2B+1%29+%3D+9+log%2810%29

Addendum: so this method also gives a good way to compute the largest integer with $n! \le 10^9$ by rounding down. It's advantage is that if you have a computer algebra system with existing methods, you can program this in 1 line. E.g. in Mathematica, you could write
Floor[n] /. NSolve[{LogGamma[n + 1] == 9 Log[10] && n >= 0}, Reals]

But now let's say we don't have methods already for computing log-gamma or numeric solvers. Then probably the next best thing is to program (or work by hand) some sort of binary search:

*

*compute $10!, 20!, 30!, \ldots$ etc. until you have two values with $a! < 10^9 < b!$. In our case that would be $10! < 10^9 < 20!$. You can use a larger gap than $10$ if the number is really-really-really big.

*then just repeatedly divide the interval in two: $10! < 10^9 < 15!$

*$10! < 10^9 < 13!$

*$11! < 10^9 < 13!$

*$12! < 10^9 < 13!$
Binary search is generally quite fast. Here we have to compute only 6 factorials: 10, 20, 15, 13, 11, 12. If we did a linear search: 1!, 2!, 3!, ... it would take twice as long.


text:
Q: Valgrind not detecting overlapping memcpy? I have this function which I believe has overlapping memory. Since I'm writing ahead of where I'll be reading from, it seems the memcpy is going to go into undefined behavior
void overlappingMemcpy() {
    int* data = new int[20];
    iota(data, data + 20, 1);
    printIntData(data, 20);
    memcpy(data+1, data, 19*sizeof(int));
    printIntData(data, 20);
    delete[] data;
}

But when it is run with Valgrind, I see no errors,
> valgrind --tool=memcheck  ./ValgrindExamples
==81068== Memcheck, a memory error detector
==81068== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==81068== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==81068== Command: ./ValgrindExamples
==81068==
Hello World!
int data for memory at 0x5b210c0of size 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
int data for memory at 0x5b210c0of size 20
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
==81068==
==81068== HEAP SUMMARY:
==81068==     in use at exit: 0 bytes in 0 blocks
==81068==   total heap usage: 3 allocs, 3 frees, 73,808 bytes allocated
==81068==
==81068== All heap blocks were freed -- no leaks are possible
==81068==
==81068== For counts of detected and suppressed errors, rerun with: -v
==81068== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

I'm compiling with -O0 -g -fno-inlines -std=c++14. The assembly shows a call to memcpy, indicating the compiler hasn't inlined it, so I'm completely lost why this isn't getting triggered. Full assembly generated of the above method,
        128 [1] void overlappingMemcpy() {
0x401320                   55                                            push   %rbp
0x401321  <+0x0001>        48 89 e5                                      mov    %rsp,%rbp
0x401324  <+0x0004>        48 83 ec 20                                   sub    $0x20,%rsp
0x401328  <+0x0008>        b8 50 00 00 00                                mov    $0x50,%eax
0x40132d  <+0x000d>        89 c7                                         mov    %eax,%edi
        129 [1]     int* data = new int[20];
0x40132f  <+0x000f>        e8 dc f9 ff ff                                callq  0x400d10 <_Znam@plt>
0x401334  <+0x0014>        ba 01 00 00 00                                mov    $0x1,%edx
0x401339  <+0x0019>        48 89 45 f8                                   mov    %rax,-0x8(%rbp)
        130 [1]     iota(data, data + 20, 1);
0x40133d  <+0x001d>        48 8b 7d f8                                   mov    -0x8(%rbp),%rdi
0x401341  <+0x0021>        48 8b 45 f8                                   mov    -0x8(%rbp),%rax
0x401345  <+0x0025>        48 83 c0 50                                   add    $0x50,%rax
0x401349  <+0x0029>        48 89 c6                                      mov    %rax,%rsi
0x40134c  <+0x002c>        e8 cf 00 00 00                                callq  0x401420 <std::iota<int*, int>(int*, int*, int)>
0x401351  <+0x0031>        ba 14 00 00 00                                mov    $0x14,%edx
0x401356  <+0x0036>        89 d6                                         mov    %edx,%esi
        131 [1]     printIntData(data, 20);
0x401358  <+0x0038>        48 8b 7d f8                                   mov    -0x8(%rbp),%rdi
0x40135c  <+0x003c>        e8 df fb ff ff                                callq  0x400f40 <printIntData(int*, unsigned long)>
0x401361  <+0x0041>        ba 14 00 00 00                                mov    $0x14,%edx
0x401366  <+0x0046>        89 d6                                         mov    %edx,%esi
0x401368  <+0x0048>        ba 4c 00 00 00                                mov    $0x4c,%edx
        132 [1]     memcpy(data+1, data, 19*sizeof(int));
0x40136d  <+0x004d>        48 8b 45 f8                                   mov    -0x8(%rbp),%rax
0x401371  <+0x0051>        48 83 c0 04                                   add    $0x4,%rax
0x401375  <+0x0055>        48 8b 7d f8                                   mov    -0x8(%rbp),%rdi
0x401379  <+0x0059>        48 89 7d f0                                   mov    %rdi,-0x10(%rbp)
0x40137d  <+0x005d>        48 89 c7                                      mov    %rax,%rdi
0x401380  <+0x0060>        48 8b 45 f0                                   mov    -0x10(%rbp),%rax
0x401384  <+0x0064>        48 89 75 e8                                   mov    %rsi,-0x18(%rbp)
0x401388  <+0x0068>        48 89 c6                                      mov    %rax,%rsi
0x40138b  <+0x006b>        e8 d0 f9 ff ff                                callq  0x400d60 <memcpy@plt>
        133 [1]     printIntData(data, 20);
0x401390  <+0x0070>        48 8b 7d f8                                   mov    -0x8(%rbp),%rdi
0x401394  <+0x0074>        48 8b 75 e8                                   mov    -0x18(%rbp),%rsi
0x401398  <+0x0078>        e8 a3 fb ff ff                                callq  0x400f40 <printIntData(int*, unsigned long)>
        134 [1]     delete[] data;
0x40139d  <+0x007d>        48 8b 45 f8                                   mov    -0x8(%rbp),%rax
0x4013a1  <+0x0081>        48 83 f8 00                                   cmp    $0x0,%rax
0x4013a5  <+0x0085>        48 89 45 e0                                   mov    %rax,-0x20(%rbp)
0x4013a9  <+0x0089>        0f 84 0c 00 00 00                             je     0x4013bb <overlappingMemcpy()+155>
0x4013af  <+0x008f>        48 8b 45 e0                                   mov    -0x20(%rbp),%rax
0x4013b3  <+0x0093>        48 89 c7                                      mov    %rax,%rdi
0x4013b6  <+0x0096>        e8 05 fa ff ff                                callq  0x400dc0 <_ZdaPv@plt>
        135 [1] }
0x4013bb  <+0x009b>        48 83 c4 20                                   add    $0x20,%rsp
0x4013bf  <+0x009f>        5d                                            pop    %rbp
0x4013c0  <+0x00a0>        c3                                            retq

Should this not be reported by the tool? It says on the documentation page that it detects "Passes overlapping source and destination memory blocks to memcpy() and related functions."
Edit
Thanks to a commenter, I found that the optimized version of memcpy that appears to be called in the above assembly is redirected by Valgrind to memmove (at least, that's what I surmise). The verbose Valgrind run is below,
> valgrind -v  ./ValgrindExamples
==56912== Memcheck, a memory error detector
==56912== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==56912== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==56912== Command: ./ValgrindExamples
==56912==
--56912-- Valgrind options:
--56912--    -v
--56912-- Contents of /proc/version:
--56912--   Linux version 4.14.7-041407-generic (kernel@gloin) (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3)) #201712171031 SMP Sun Dec 17 15:33:35 UTC 2017
--56912--
--56912-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-avx-avx2-bmi
--56912-- Page sizes: currently 4096, max supported 4096
--56912-- Valgrind library directory: /usr/lib/valgrind
--56912-- Reading syms from /home/charlie/Projects/build-ValgrindExamples-Desktop-Default/ValgrindExamples
--56912-- Reading syms from /lib/x86_64-linux-gnu/ld-2.26.so
--56912--   Considering /lib/x86_64-linux-gnu/ld-2.26.so ..
--56912--   .. CRC mismatch (computed 89c8df08 wanted 47b839f9)
--56912--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.26.so ..
--56912--   .. CRC is valid
--56912-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux
--56912--   Considering /usr/lib/valgrind/memcheck-amd64-linux ..
--56912--   .. CRC mismatch (computed 9fa343a0 wanted dc854ea8)
--56912--    object doesn't have a symbol table
--56912--    object doesn't have a dynamic symbol table
--56912-- Scheduler: using generic scheduler lock implementation.
--56912-- Reading suppressions file: /usr/lib/valgrind/default.supp
==56912== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-56912-by-charlie-on-???
==56912== embedded gdbserver: writing to   /tmp/vgdb-pipe-to-vgdb-from-56912-by-charlie-on-???
==56912== embedded gdbserver: shared mem   /tmp/vgdb-pipe-shared-mem-vgdb-56912-by-charlie-on-???
==56912==
==56912== TO CONTROL THIS PROCESS USING vgdb (which you probably
==56912== don't want to do, unless you know exactly what you're doing,
==56912== or are doing some strange experiment):
==56912==   /usr/lib/valgrind/../../bin/vgdb --pid=56912 ...command...
==56912==
==56912== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==56912==   /path/to/gdb ./ValgrindExamples
==56912== and then give GDB the following command
==56912==   target remote | /usr/lib/valgrind/../../bin/vgdb --pid=56912
==56912== --pid is optional if only one valgrind process is running
==56912==
--56912-- REDIR: 0x401f860 (ld-linux-x86-64.so.2:strlen) redirected to 0x58060901 (???)
--56912-- REDIR: 0x401f640 (ld-linux-x86-64.so.2:index) redirected to 0x5806091b (???)
--56912-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so
--56912--   Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so ..
--56912--   .. CRC mismatch (computed f3fb86a7 wanted 0b99f9ab)
--56912--    object doesn't have a symbol table
--56912-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
--56912--   Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so ..
--56912--   .. CRC mismatch (computed 5ffa922b wanted 4228a583)
--56912--    object doesn't have a symbol table
==56912== WARNING: new redirection conflicts with existing -- ignoring it
--56912--     old: 0x0401f860 (strlen              ) R-> (0000.0) 0x58060901 ???
--56912--     new: 0x0401f860 (strlen              ) R-> (2007.0) 0x04c32db0 strlen
--56912-- REDIR: 0x401d8d0 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c33ee0 (strcmp)
--56912-- REDIR: 0x401fda0 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c374f0 (mempcpy)
--56912-- Reading syms from /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24
--56912--    object doesn't have a symbol table
--56912-- Reading syms from /lib/x86_64-linux-gnu/libm-2.26.so
--56912--   Considering /lib/x86_64-linux-gnu/libm-2.26.so ..
--56912--   .. CRC mismatch (computed b616e9a5 wanted 56d31e5b)
--56912--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/libm-2.26.so ..
--56912--   .. CRC is valid
--56912-- Reading syms from /lib/x86_64-linux-gnu/libgcc_s.so.1
--56912--    object doesn't have a symbol table
--56912-- Reading syms from /lib/x86_64-linux-gnu/libc-2.26.so
--56912--   Considering /lib/x86_64-linux-gnu/libc-2.26.so ..
--56912--   .. CRC mismatch (computed b6c34c34 wanted f79829d1)
--56912--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.26.so ..
--56912--   .. CRC is valid
--56912-- REDIR: 0x57c3f50 (libc.so.6:memmove) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c3010 (libc.so.6:strncpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c4230 (libc.so.6:strcasecmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c2a60 (libc.so.6:strcat) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c3040 (libc.so.6:rindex) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c5bb0 (libc.so.6:rawmemchr) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c40c0 (libc.so.6:mempcpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c3ee0 (libc.so.6:bcmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c2fd0 (libc.so.6:strncmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c2ad0 (libc.so.6:strcmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c4020 (libc.so.6:memset) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57e1f10 (libc.so.6:wcschr) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c2f70 (libc.so.6:strnlen) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c2b40 (libc.so.6:strcspn) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c4280 (libc.so.6:strncasecmp) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c2b10 (libc.so.6:strcpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c43c0 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c3070 (libc.so.6:strpbrk) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c2a90 (libc.so.6:index) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c2f40 (libc.so.6:strlen) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57ce510 (libc.so.6:memrchr) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c42d0 (libc.so.6:strcasecmp_l) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c3eb0 (libc.so.6:memchr) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57e2cc0 (libc.so.6:wcslen) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c3350 (libc.so.6:strspn) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c4200 (libc.so.6:stpncpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c41d0 (libc.so.6:stpcpy) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c5be0 (libc.so.6:strchrnul) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x57c4320 (libc.so.6:strncasecmp_l) redirected to 0x4a2a6e0 (_vgnU_ifunc_wrapper)
--56912-- REDIR: 0x58ad6f0 (libc.so.6:__strrchr_avx2) redirected to 0x4c32730 (rindex)
--56912-- REDIR: 0x57bdeb0 (libc.so.6:malloc) redirected to 0x4c2faa0 (malloc)
--56912-- REDIR: 0x58ad8c0 (libc.so.6:__strlen_avx2) redirected to 0x4c32cf0 (strlen)
--56912-- REDIR: 0x58a9ed0 (libc.so.6:__memcmp_avx2_movbe) redirected to 0x4c35e00 (bcmp)
--56912-- REDIR: 0x58890b0 (libc.so.6:__strcmp_ssse3) redirected to 0x4c33da0 (strcmp)
Hello World!
--56912-- REDIR: 0x4ecc500 (libstdc++.so.6:operator new[](unsigned long)) redirected to 0x4c30830 (operator new[](unsigned long))
--56912-- REDIR: 0x58adde0 (libc.so.6:__mempcpy_avx_unaligned_erms) redirected to 0x4c37130 (mempcpy)
int data for memory at 0x5b210c0of size 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
--56912-- REDIR: 0x58ade00 (libc.so.6:__memcpy_avx_unaligned_erms) redirected to 0x4c366e0 (memmove)
int data for memory at 0x5b210c0of size 20
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
--56912-- REDIR: 0x4eca3b0 (libstdc++.so.6:operator delete[](void*)) redirected to 0x4c316d0 (operator delete[](void*))
--56912-- REDIR: 0x57be3e0 (libc.so.6:free) redirected to 0x4c30cd0 (free)
==56912==
==56912== HEAP SUMMARY:
==56912==     in use at exit: 0 bytes in 0 blocks
==56912==   total heap usage: 3 allocs, 3 frees, 73,808 bytes allocated
==56912==
==56912== All heap blocks were freed -- no leaks are possible
==56912==
==56912== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==56912== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

So the follow-up question: what is choosing to call __memcpy_avx_unaligned_erms, I don't see it in the assembly. Due to the occurrence of the REDIR being aligned to when the memcpy is called, it seems to me as though Valgrind has figured out something I can't see in the assembly :$


text:
Q: Using multiple different editors on the same page "CKEDITOR5" Using multiple different editors on the same page "CKEDITOR5"
Classic e Balloon
I can't put two different types of editors on one page.
Below I leave an example of what it would be like to place 2 different editors.
But as I have a library for each type of editor it appears to say  "CKEditorError: ckeditor-duplicated-modules: Some CKEditor 5 modules are duplicated."
And sorry for the bad English.

// The two libraries repeated but each adapted to a type of editor

// Initialize both types of editors

A: I faced the same question from a customer. More than one BalloonEditor on 1 page.
One solution would be to initialize every instance by his own id, but I thought that it would be easier to add one class to the elements I wanted to become an ballooneditor. So that's what I did:
I introduced a class .editable on selected elements:

  Some text...

  Some other text...

And then (in for instance the document ready function), I handled them as follows:
$(document).ready(function() {

  var id;
  $('.editable').each(function() {
      id = $(this).attr('id');
      if (id != '') {
          BalloonEditor
              .create(document.querySelector( '#' + id ))
              .catch( error => {
                  console.error( 'error' );
              } )
      }
  })

  ....
  ..

});

To track changes to the different elements, I added a handler like this:
$('.editable').on('blur', function(ev) {
    console.log('en blurred');
    var id = $(this).attr('id');
    console.log($(this).html())
    console.log(id);
})

That gave me the opportunity to save the changes with an AJAX handler.
It is just a suggestion, but it works fine for me.

A:

document.addEventListener("DOMContentLoaded", function(event) {
var numb = 1;
  do {
    ClassicEditor
    .create( document.querySelector( '#body'+ numb ), {
      removePlugins: [ 'insertImage', 'insertMedia', 'Link', 'blockQuote' ],
      toolbar: [ 'Heading', 'bold', 'italic', 'bulletedList', 'numberedList',  ]
    } )
    .catch( error => {
      console.error( error );
    } )
    numb++;
  }
  while (numb < 4);
});
.ck-editor__editable_inline {
    min-height: 150px;
  }

<textarea  placeholder="Description"  id="body1" name="body"></textarea>

<textarea  placeholder="Description"  id="body2" name="body"></textarea>

<textarea  placeholder="Description"  id="body3" name="body"></textarea>


text:
Q: Get specific number of rows ordered by date for each key I have a table from which i get data as follows:
val all = sc.cassandraTable("keyspace","table")
 .select("key_name", "column1", "column2", "column3", "date")
 .as((i:String, p:String, e:String, c:Double, d:java.util.Date) => ((i), (c, p, e, d)))

Table is ordered by date. I want to fetch data in a way that for every key_name I will have specified number of records. I don't know if it's achievable in query to cassandra table or it should be done after data is loaded from table. For example I would like to have five latest records for each key_name grouped in some sort of sorted collection.

A: you can use limit on cluster column like below from the link
SELECT * FROM playlists WHERE id = 62c36092-82a1-3a00-93d1-46196ee77204
  ORDER BY song_order DESC LIMIT 50;
https://docs.datastax.com/en/cql/3.1/cql/ddl/ddl_compound_keys_c.html


text:
Q: Send email with attachment using Email Task URL hack '/_ui/core/email/author/EmailAuthor?p3_lkid=' + caseId + '&doc_id=' + docId + '&retURL=' + caseId + '';

I'm using the above URL to send an email with attachment in the doc_id parameter I'm sending the ID of the file to be attached but it is not attaching the file in the task. What am I doing wrong?

A: the solution is very simple - you should clone the email template and associate the attachment to it.
then use the clone emailtemplate in the URL redirect.
and don't forget to add to the URL - +'&new_template=1'
otherwise, it will not be displayed.

A: Thanks, that's why I asked what is the business case for doing this. I have a client wanting to do something very similar at the moment. The approach I have suggested is to use Drawloop as it has a great UI to select the email template, select the contact and select create the document and send it (you can even add other attachments that are already on the record). And you can create a button or even trigger this sending of the email via an outbound message. All this for starting at $12/month/user, is good value. (disclaimer, I am a Drawloop Partner, but I do think this is a great product and a good, non code, solution for this business case, and once you get it in there for one business case, it can be used for so much more).


text:
Q: TypeError: $(...).jqGrid is not a function i want create jqgrid table..
but i have found error and confused to fix this.
i already, search tutorial but do not run :(
This is my screenshot

This is my script :
index.php
<script src="js/jqgrid/js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" media="screen" href="js/jquery-ui/css/custom-theme/jquery-ui-1.8.16.custom.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="js/jqgrid/css/ui.jqgrid.css" />
    <script src="js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
    <script src="js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>

    <style type="text/css">
        div.ui-datepicker
        {   font-size:10px; }

        div.ui-dialog
            {   font-size:11px; }

        div.ui-tabs
            {   font-size:11px; }

        .ui-jqgrid tr.jqgrow td {
            white-space: normal !important;
        }

        .center { width: 640px; margin-left: auto; margin-right: auto; }

    </style>

    <style type="text/css">.ui-jqgrid .ui-jqgrid-bdiv { overflow-y: scroll }</style>

grid_javascript.php
   <?php
        Header("content-type: application/x-javascript");
        include "../connection.php";
        switch ($_GET['type'])
        {

        case "all_user":
                {
                    echo "      $(document).ready(function(){
                                    $('#tbl_all_user').jqGrid({
                                    url:'grid_javascript_data.php?type=all_user',
                                    datatype: 'json',
                                    colNames:['Action','User Group','Username','Real Name','Last Update','Email'],
                                    colModel:[
                                        {name:'action',index:'action', width:150,align:'center', sortable:false},
                                        {name:'user_group',index:'user_group', width:150, align:'center',searchoptions:{sopt:['eq','cn']}},
                                        {name:'username',index:'username', width:150, align:'center',searchoptions:{sopt:['eq','cn']}},
                                        {name:'real_name',index:'real_name', width:150, align:'center',searchoptions:{sopt:['eq','cn']}},
                                        {name:'last_update',index:'last_update', width:150, align:'center',searchoptions:{sopt:['eq','cn']}},
                                        {name:'email',index:'email', width:150, align:'center',searchoptions:{sopt:['eq','cn']}}
                                    ],
                                    pager: jQuery('#div_all_user'),
                                    rowNum:50,
                                    sortname:'username',
                                    sortorder:'desc',
                                    viewrecords: true,
                                    caption: 'Manage All User',
                                    height:$(document).height()*0.7,
                                    width:$(document).width() - 30,
                                    shrinkToFit:true,
                                    // autowidth:true,
                                    toolbar: [false,'top'],
                                    });

                                    jQuery('#tbl_all_user').jqGrid('navGrid','#div_all_user',{edit:false,add:false,del:false},
                                                                                {}, // edit options
                                                                                {}, // add options
                                                                                {}, //del options

                                                                                {multipleSearch:true,width:400});
                                    }); ";

                    break;
            }
    }
    ?>

grid_javascript_data.php
<?php
set_time_limit (9999999999999999);
Header('Content-Type: text/javascript; charset=UTF-8');
include "../connection.php";
switch ($_GET['type'])
{
case "all_user": {

            $page = $_REQUEST['page'];
            $limit =  20;
            $sidx = $_REQUEST['sidx'];
            $sord = $_REQUEST['sord'];
            //$user_id = _REQUEST['user_id'];

            $wh_ews = "";

            $searchOn = Strip($_REQUEST['_search']);
            if($searchOn=='true')
            {
                $searchstr = Strip($_GET['filters']);

                $wh_ews = constructWhere($searchstr);
                $manual_search="1";

            }

            $result = mysql_query("SELECT COUNT(*) AS count FROM tbl_user where user_group in ('user','channel_admin')");
            $row = mysql_fetch_array($result,MYSQL_ASSOC);
            $count = $row['count'];
            if( $count > 0 ) {
                $total_pages = ceil($count/$limit);
            }
            else {
                $total_pages = 0;
            }
            if ($page > $total_pages) $page=$total_pages;
            $start = $limit*$page - $limit; // do not put $limit*($page - 1)
            if($start <0) $start = 0;
            $SQL = "SELECT * FROM tbl_user where user_group in ('user','channel_admin') ".$wh_ews;
            $result = mysql_query( $SQL ) or die("Couldn't execute query.".mysql_error());
            $responce->page = $page;
            $responce->total = $total_pages;
            $responce->records = $count;

            $i=0;
            while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {

            $link_all= "Detail | Edit | Hapus";
            $responce->rows[$i]['id']=$i;
            $responce->rows[$i]['cell']=array($link_all,$row['user_group'],$row['username'],$row['real_name'],$row['last_update'],$row['email']);
            $i++;
            }
            echo json_encode($responce);
    break;

    }
}

Help me thank's.

A: Try including jquery ui before other plugin scripts. Maybe this is the issue:
    <script src="js/jqgrid/js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen" href="js/jquery-ui/css/custom-theme/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="js/jqgrid/css/ui.jqgrid.css" />


text:
Q: Code Own Socket Server or Use Red5/ElectroServer on Amazon EC2? I've been thinking for a long time about working on a multiplayer game in Flash.  I need updates frequently enough that ajax requests won't work so I need to use a socket server.
The system  will eventually have enough objects/players that I would consider it an MMO.  I would like to set up a scalable system on Amazon's EC2. (Which probably effects my choice of server)  This architecture would hopefully allow the game to grow without many changes over time.  (Using a domain decomposition technique or something similar)
Heres my internal debate:
Should I
a. Code my own socket server in C++ or Java?
b. Use the free and open source Red5 socket server for Flash?
or
c. Pay the licensing fees and go for Electroserver?
I consider myself a decent developer, but am at an impasse as to what road to go down.  I'm not sure if I, could develop/would need, the features of one of the prepackaged socket servers.
I'm also not sure if the prepackaged servers would work well in an Amazon EC2 environment and take full advantage of its features.
Any help or guidance would be greatly appreciated.

A: If you do decide to code your own server - rather than C++/Java, you might want to consider using the Twisted network library. It's written in Python, but Python isn't hard to learn (and you don't need much to make Twisted calls). And according to one Success Story, they had no problem implementing a RESTful service using Twisted on Amazon's EC2.

A: I believe, your own socket server or red5 will work well on Amazon EC2 platform.:)


text:
Q: Controllers placed in Sub-Folders have no content I am using a PHP Framework for the first time to get away from writing spaghetti code and so far it is wonderful. I am using Code Igniter and have a base Controller named "Dashboard.php" that loads fine and looks perfect.
When attempting to create some organization, I placed my "Devices.php" into a "Controllers/Devices" sub-folder, then accessed it at "http://domain.com/devices/devices" which loads the text, but the images/css/etc. are missing.
The content of the "Devices" controller is exactly the same as my "Dashboard" so I am not understanding why only the text loads. If I move the "devices.php" file into the root Controllers directory, there are no problems.
class Devices extends CI_Controller
{

    public function index()
    {
        $data['page_title'] = 'Device Portal';

        $this->load->view('meta');
        $this->load->view('sidebar');
        $this->load->view('userbar');
        $this->load->view('header');
        $this->load->view('devices/content');
        $this->load->view('footer');
    }

}

Here is the "Sidebar.php" View...

    <form action="" class="sidebarSearch">
        <input type="text" name="search" placeholder="search..." id="ac" />
        <input type="submit" value="" />
    </form>

            General balance:
            $10,900.36

            +0.6%

A: You need to avoid using relative paths when linking to images/css/etc in your views.
As an example, when you use assets/images/logo.png (relative path) from the page http://domain.com/devices/devices, the browser looks for http://domain.com/devices/assets/images/logo.png
Using the same image path with the page http://domain.com/devices the browser will look for http://domain.com/assets/images/logo.png instead.
When specifying urls to pages, images, etc within your domain, use the URL helper functions to automatically format your urls.
You want to avoid writing urls like this:

And instead generate your urls like this:

<img src="<?php echo base_url('assets/images/logo.png'); ?>" alt="" />

Which will output:

A: In Codeigniter use base_url() function to print assets.
<img src="<?php echo base_url('assets/images/logo.png');?>" alt="" />
This function automatically generate domain before the url.


text:
Q: Need help trying to identify the source of a 404 error for a Java web app I'm not a Java developer but I need to determine why our app suddenly gives a 404 error in only one of our environments even though the code is the same in all.
When I try to navigate to the main home page URL, the code in the following controller is executed.
@Controller
public class ErrorController {

    @RequestMapping(value = "errors", method = RequestMethod.GET)
    public ModelAndView renderErrorPage(HttpServletRequest httpRequest) {

Immediately, it checks an attribute on the incoming HTTP request and it returns a 404 error.
httpRequest.getAttribute("javax.servlet.error.status_code")
I'm trying to use Chrome tools to see what the missing resource is. Besides some 404 errors for some missing jquery png files I only see a couple of messages  "Failed to load resource: the server responded with a status of 404 (Not Found)" messages that both point to the first line of the default page index fil. This file used to have the following lines:
<meta http-equiv="Pragma" content="no-cache"><!-- Solution for Cacheable SSL Page Found Vulnarability -->
<meta http-equiv="Cache-Control" content="no-cache"><!-- Solution for Cacheable SSL Page Found Vulnarability -->

but I blanked these lines out, cleared the cache and the 404 still pointed to the now blank 1st line of the index file.
I also tried to put a break in the ErrorController and looked at the Java stack to see of I can try to determine what threw the error but I was looking at a very deep stack of system code that no noob mortal should have to look at.
I get this error running locally and on a web server. If I run locally and point to another database, I do not get the error, so this suggests that it is data related. I tried to look for any ajax call to the database and check for a failed or suspicious response but so far, I am not finding any.
I've never written a line of Java code, but I have experience with .NET.
Any suggestions on how to determine what is throwing the 404 error?


text:
Q: NoSuchMethod Error on HandlerChainFactory.getGlobalHandlers() using AWS SDK 1.11.97 I have a play 2.4.3 framework app that I'm working on.  I just added uploading images to AWS S3 bucket, which I got working locally.  But when I push to AWS elastic Beanstalk environment, I get the following error when I try create the AmazonS3Client per these instructions:
java.lang.NoSuchMethodError: com.amazonaws.handlers.HandlerChainFactory.getGlobalHandlers()Ljava/util/List;
    at com.amazonaws.services.s3.AmazonS3Client.init(AmazonS3Client.java:668) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:651) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3Builder$1.apply(AmazonS3Builder.java:35) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3Builder$1.apply(AmazonS3Builder.java:32) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3ClientBuilder.build(AmazonS3ClientBuilder.java:64) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3ClientBuilder.build(AmazonS3ClientBuilder.java:28) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:38) ~[com.amazonaws.aws-java-sdk-core-1.11.43.jar:na]
    at utils.image.ImageUtils.getCredentaledS3Client(ImageUtils.java:49) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at utils.image.ImageUtils.save(ImageUtils.java:152) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at utils.image.ImageUtils.createCroppedSquareProxy(ImageUtils.java:93) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at controllers.ControllerUtils.saveImage(ControllerUtils.java:155) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at controllers.user.ModelController.onProfileSubmit(ModelController.java:193) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$18$$anonfun$apply$18.apply(Routes.scala:868) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$18$$anonfun$apply$18.apply(Routes.scala:868) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:136) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:127) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:70) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.GlobalSettings$1.call(GlobalSettings.java:67) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at models.privilege.Authentication$User.call(Authentication.java:51) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:40) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:32) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at scala.concurrent.impl.Future$.apply(Future.scala:31) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.Future$.apply(Future.scala:492) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at play.core.j.JavaAction.apply(JavaAction.scala:94) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:104) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:103) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at scala.Option.map(Option.scala:146) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:103) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:96) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:537) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:537) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) ~[com.typesafe.akka.akka-actor_2.11-2.3.13.jar:na]
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) [com.typesafe.akka.akka-actor_2.11-2.3.13.jar:na]
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [org.scala-lang.scala-library-2.11.6.jar:na]

I couldn't find anything about this via a google search.  Any ideas?
I use Docker to get the app running on EB.  But I am not using Docker to run locally.  I am wondering if that may have something to do with it?

A: I hope you found an answer to this - its almost certainly a dependency versioning issue.
I'm seeing the same issue, but in a Spring Boot application. Works fine locally, but I get the same NoSuchMethodException on the same class and method.
I'm pretty sure that the reason we see it when deployed to AWS is because of IAM roles and how the credentials get determined.

A: Sounds like EB is overriding the base dependencies for the S3 SDK lib (aws-java-sdk-s3), or there is some errant dependency metadata floating around in your build - I'm not familiar with building a Play application, I'm guessing this creates a runnable JAR with bundled dependencies?
I had this same problem is in a Spring Boot project, locally. In the end for me it was due to stale dependencies being provided by Intellij IDEA (re-specifying the base dependencies explicitly and re-building fixed the issue).
<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-core</artifactId>
    <version>${aws.api.version}</version>
</dependency>
<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-kms</artifactId>
    <version>${aws.api.version}</version>
</dependency>

Try specifying the -core (and possibly the -kms) dependency directly in your pom.xml (or build.gradle if you're building with Gradle).
EDIT: I see Play uses SBT! So I guess the syntax is different there.


text:
Q: jqgrid paging in edit form I need to forbid paging to user (nothing should happen on pressing next, prev buttons).
I have found  onPaging: function (b) {...} event with returning 'stop' string. But this works only for the grid. Not for the edit form. When I print param, getting 'user' value all the time.
Can anyone help?

A: Probably you need to use viewPagerButtons: false property of the form editing:
$("#list").jqGrid("navGrid", "#pager", {/*options of navGrid*/},
    {viewPagerButtons: false},    // options of Edit form
    {viewPagerButtons: false});   // options of Add form

A: In editOptions : { viewPagerButtons:false }  This is for Previous and Next button on Edit form


text:
Q: macOS Sierra Server - Problems with permissions in shared folders I have a macOS Sierra with the Server package installed.
There are directories that when a user create/modify files or folders the others users has read only permissions. Only it happen in some directories.
I think that the problem is the umask. I would like to set umask at 011 with this I have read/write in all user/groups.
I have seen how do it but in other mac versions, yosemite, not in Sierra.
I need to apply mask only in a directory don't in all filesystem.
Do anybody help with this issue?
Thank you!

A: There seems to be a general consensus on directories having the permission of 755 while files to have the permission of 644


text:
Q: How to download all files in a directory in ASP.NET using C# I am currently learning uploading / downloading / deleting files in C# asp.net. I figured out how to delete every file in a folder with code like this:
protected void DeleteAllFiles(object sender, EventArgs e)
{
    System.IO.DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/Output"));

    foreach (FileInfo file in di.GetFiles())
    {
        file.Delete();
    }

    foreach (DirectoryInfo dir in di.GetDirectories())
    {
        dir.Delete(true);
    }

    Response.Redirect("~/Outputs.aspx?ReturnPath=" + Server.UrlEncode(Request.Url.ToString()));
}

But I can't find anything on how to download all files in a directory. I figured out how to download individual files but I am having trouble with a button that downloads all files in a directory. Surely there is an easy way to do this? I can't find it anywhere else so this is probably a dumb question to ask but any help is appreciated.

A: It's not possible to send multiple files in a single HTTP request. However, you can create a zip archive of multiple files and send that instead. See this answer for an example.


text:
Q: keyboard browser shortcuts doesn't work in Silverlight if some control is selected In SilverLight application when a textbox or button has the focus if the users press the keyboard shortcuts: Ctrl + y Ctrl + to get the zoom browser this funcionallity doesn't work. Is there any workaround?
Huge thanks
Javier

A: The keyboard support in SL is limited. See the following for more information:

*

*http://msdn.microsoft.com/en-us/library/cc189015(VS.95).aspx

*http://www.liquidjelly.co.uk/supersearch/?q=silverlight%20keyboard%20support&lang=en-GB


text:
Q: Moving more than 1 object with just 1 script in unity /2d I know we can move objects by adding scripts into that objects in unity. But i am curious about something else. How can we create a script that updates all game world (imports all objects and updates their position with every timer tick). How can we import that objects into that script?

A: This is normally done the other way around- the 'move' script is attached to desired objects to move.
However, a couple of ways you can get reference to several objects from the script are:
GameObject.FindObjectsOfType(GameObject);
OR
GameObject.FindGameObjectsWithTag("Untagged");  //returns GameObject[]
Source: http://answers.unity3d.com/questions/329395/how-to-get-all-gameobjects-in-scene.html


text:
Q: enabled text box in the table with rowspan using jquery I am stuck in a problem, i have the following html structure.
Initially, all text box are disabled.
When i tick some checkbox in the first column, i want to enable the text box in this line.
The problem is that i can enable all text boxs except "Tag 02".
I believe that there is a "rowspan=2" in row2, so my code cannot find td in tag02 line.
I post my code below, anybody could help me to figure out this problem?
Thanks a lot.

Setting
Value
Units

<input type="checkbox"/>
Row1
<input type="text"/>
Units
<button>Edit</button>

<input type="checkbox"/>
Row2
Tag 01
<input type="text"/>
Units

Tag 02
<input type="text"/>
Units

<input type="checkbox"/>
Row3
<input type="text"/>
Units

my Code here:
function enableRows(){
     $('#settbl tr').filter(':has(:checkbox:checked)').each(function() {
        $(this).find('input[type=text],select').each(function() {
            this.disabled = false;//only enable "Row1","Row2->Tag01" and "Row3".
        });
    });

}

A: You are doing a search with $('#settbl tr').filter(':has(:checkbox:checked)') which means that , it will return the
  having a check box checked. But in your code as you can see Tag02's parent
 doesn't even have a check box . you should put both <input> that you want to be checked inside same
 with check box .

            <input type="checkbox"/>
            Row2
            Tag 01
            <input type="text"/>
            Units

            Tag 02
            <input type="text"/>
            Units

You can try this codes.

                Setting
                Value
                Units

                <input type="checkbox"/>
                Row1
                <input type="text" disabled />
                Units
                <button>Edit</button>

                <input type="checkbox"/>

                                Row2

                                Row2

                               Tag 01

                                Tag 02

                               <input type="text" disabled />

                                <input type="text" disabled />

                               Units

                                Units

                <input type="checkbox"/>
                Row3
                <input type="text" disabled />
                Units

    <button onclick="enableRows();">Enable Rows</button>


text:
Q: How to open app's specific activity from another app in android I want to open a specific activity of app2 from app1.
How do I do that?
Tried: I am able to open app2 using:
 Intent paypalIntent = getPackageManager().getLaunchIntentForPackage("package.name);

A: You have to try like this
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
                launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                ComponentName cp = new ComponentName("Your App Packge Name that Contains Register Activity", "Register Activity Name");
                launchIntent.setComponent(cp);

                startActivity(launchIntent);

for more info: Android : Call activity of another application


text:
Q: Is it possible for a fragment to extend a fragment? I'm new to mobile development and I'm not sure if this can work. I have a fragment with a Recycled View that displays content. The thing is other fragments also use a Recycler View with the same design. Is it possible to extend that fragment and then reuse everything in it by just changing the Text Views and Images ?
Fragment code:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Json;
using Android.Support.V4.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Support.V7.Widget;
using Android.Graphics;
using Homecheck.Adapters;
using Homecheck.Models;
using Newtonsoft.Json;

namespace Homecheck.Fragments {
    public class SmokeSensor : Fragment {
        private RecyclerView recyclerView;
        private RecyclerView.Adapter adapter;
        private RecyclerView.LayoutManager layoutManager;
        private List<ItemData> itemData;
        private ISharedPreferences pref;
        private SessionManager session;
        private DeviceModel deviceModel;
        private string cookie;
        private const string URL_SMOKE_DATA = "http://10.1.1.20/appapi/getsmokedata";

        public async override void OnStart() {
            base.OnStart();

            session = new SessionManager();
            pref = Activity.GetSharedPreferences("UserSession", FileCreationMode.Private);
            cookie = pref.GetString("PHPSESSID", string.Empty);
            var jsonFetcher = new JsonFetcher();
            JsonValue jsonDashboard = await jsonFetcher.FetchJsonAsync(URL_SMOKE_DATA, null, null, cookie);
            deviceModel = new DeviceModel();
            deviceModel = JsonConvert.DeserializeObject<DeviceModel>(jsonDashboard);

            AddSmokeData();

            adapter = new ViewAdapter(itemData);

            new System.Threading.Thread(new System.Threading.ThreadStart(() => {
                Activity.RunOnUiThread(() => {
                    recyclerView.SetAdapter(adapter);
                });
            })).Start();
        }

        public void AddSmokeData() {
            itemData = new List<ItemData>();

            foreach (SensorData sensorData in deviceModel.SensorData) {
                if (sensorData.Value == "1") {
                    itemData.Add(new ItemData() {
                        title = GetString(Resource.String.smoke_detected_text),
                        date = sensorData.Timestamp,
                        image = Resource.Drawable.smoke_red,
                    });
                }
            }
        }

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View view = inflater.Inflate(Resource.Layout.SmokeSensor, container, false);
            recyclerView = view.FindViewById<RecyclerView>(Resource.Id.smoke_recycler_view);
            recyclerView.HasFixedSize = true;
            layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.Vertical);

            recyclerView.SetLayoutManager(layoutManager);
            recyclerView.SetItemAnimator(new DefaultItemAnimator());
            recyclerView.AddItemDecoration(new SpaceItemDecoration(20));

            return view;
        }

        public class SpaceItemDecoration : RecyclerView.ItemDecoration {
            private int space;

            public SpaceItemDecoration(int space) {
                this.space = space;
            }

            public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                outRect.Left = space;
                outRect.Right = space;
                outRect.Bottom = space;

                if (parent.GetChildAdapterPosition(view) == 0) {
                    outRect.Top = space;
                }
            }
        }

        public class ViewAdapter : RecyclerView.Adapter {
            private List<ItemData> itemData;
            private TextView titleText;
            private TextView dateText;
            private ImageView imageId;

            public ViewAdapter(List<ItemData> itemData) {
                this.itemData = itemData;
            }

            public class ItemView : RecyclerView.ViewHolder {
                public View mainView { get; set; }

                public TextView title { get; set; }

                public TextView date { get; set; }

                public ImageView image { get; set; }

                public ItemView(View view) : base(view) {
                    mainView = view;
                }
            }

            public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
                View itemLayoutView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.SmokeSensorItems, null);

                titleText = itemLayoutView.FindViewById<TextView>(Resource.Id.item_title);
                dateText = itemLayoutView.FindViewById<TextView>(Resource.Id.item_date);
                imageId = itemLayoutView.FindViewById<ImageView>(Resource.Id.item_icon);

                var viewHolder = new ItemView(itemLayoutView) { title = titleText, date = dateText, image = imageId };

                return viewHolder;
            }

            public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
                ItemView itemHolder = viewHolder as ItemView;

                itemHolder.title.Text = itemData[position].title;
                itemHolder.date.Text = itemData[position].date;
                itemHolder.image.SetImageResource(itemData[position].image);
            }

            public override int ItemCount {
                get { return itemData.Count; }
            }
        }

        public class ItemData {
            public string title { get; set; }

            public string date { get; set; }

            public int image { get; set; }
        }
    }
}

A: I've changed this answer, you can extend fragments. I've never seen it done before, but i've just had a play and it works fine. I just think i've never had a case where it makes sense to extend the whole fragment, I tend to just think if something has utility across more than one class, i've put it in another class.
Jame Gosling (head guy who made java) said to not use inheritance as a means to achieve code re-use.
more here: http://www.javaworld.com/article/2073649/core-java/why-extends-is-evil.html

A: That was a bad idea, I'll just use one fragment that will show different info, depending on what it gets.


text:
Q: Remove word 'sip:' from dialing number I use a softphone called eyebeam. When I click on a sip link like:
    0123456789

It will start eyeBeam and directly call the number. Now the problem is that it adds the word "sip:" infront of the number so eyeBeam doesn't recognize it.
My question is how can I only call the number and ignore the word "sip:" ?

A: The problem wasn't the word sip but it was because some telephone number contained
"-", "()" and spaces. So eyeBeam didn't recognize the number.


text:
Q: Weird flex date issue Flex is driving me CRAZY and I think it's some weird gotcha with how it handles leap years and none leap years. So here's my example. I have the below dateDiff method that finds the number of days or milliseconds between two dates. If I run the following three statements I get some weird issues.
        dateDiff("date", new Date(2010, 0,1), new Date(2010, 0, 31));
    dateDiff("date", new Date(2010, 1,1), new Date(2010, 1, 28));
    dateDiff("date", new Date(2010, 2,1), new Date(2010, 2, 31));
    dateDiff("date", new Date(2010, 3,1), new Date(2010, 3, 30));

If you were to look at the date comparisons above you would expect to get 30, 27, 30, 29 as the number of days between the dates. There weird part is that I get 29 when comparing March 1 to March 31. Why is that? Is it something to do with February only having 28 days? If anyone has ANY input on this that would be greatly appreciated.
public static function dateDiff( datePart:String, startDate:Date, endDate:Date ):Number
    {
        var _returnValue:Number = 0;

        switch (datePart) {
            case "milliseconds":
                _returnValue = endDate.time - startDate.time;
                break;
            case "date":
                // TODO: Need to figure out DST problem i.e. 23 hours at DST start, 25 at end.
                // Math.floor causes rounding down error with DST start at dayOfYear
                _returnValue = Math.floor(dateDiff("milliseconds", startDate, endDate)/(1000 * 60 * 60 * 24));
                break;
        }

        return _returnValue;
    }

A: This is not a leap year problem, but rather a daylight savings time problem.
To correct the code to account for DST, you need to look at the timezoneOffset of both dates to determine if the date range is spanning a DST boundary.
var adjustment:Number = ( startDate.timezoneOffset - endDate.timezoneOffset ) * 60 * 1000;
_returnValue = endDate.time - startDate.time + adjustment;

This will get the difference between the two time zones (in minutes), convert that value to milliseconds, and then apply the timezone difference to the millisecond difference to "cancel out" the DST boundary.
Naturally, when both numbers are in the same time zone, the adjustment value becomes 0 and the  time values are not adjusted.

A: You have part of the answer in your comment: 2010-Mar-01 0:00 until 2010-Mar-31 0:00 is thirty (!) days minus one hour (because Mar 14 is DST start in 2010). Since you floor the result of your division, you get 29.
Edit: This answer is of course based on the assumption that the time property of Date takes DST into account. This would explain your problem; I didn't check it, however.


text:
Q: Located closest value in pandas dataframe I'm trying to located the closest value in a dataframe with user input.
Key  col1       col2
10   300        140
12   450        165
15   650        890
20   130        900
25   110        755

let's say i'm trying to input value 16. the value pandas should generate is
Key  col1   col2
15   650    890

I tried the df.loc, but that only works for specific values that are in the dataframe i guess.
Does anybody have an idea how i can fix this?

A: Use Series.idxmin with absolute values after subtract value:
val = 16
df = df.loc[[(df['Key'] - val).abs().idxmin()]]
print (df)
   Key  col1  col2
2   15   650   890

A: IIUC reindex nearest
df=df.set_index(['Key']).reindex([16],method = 'nearest').reset_index()

     col1  col2
Key
16    650   890


text:
Q: iOS - NSTimer causes to stop the app during animation In my app I am using CATransition to slide a banner view. My code is something like this:
ViewDidLoad()
- (void)viewDidLoad
{
    [super viewDidLoad];
    bannerList = [[NSMutableArray alloc] init];
    bannerList = [WebFunctions fetchBannerDataHavingUrl:@"banners/event"];

    NSTimer* timer = [NSTimer timerWithTimeInterval:3.0f target:self selector:@selector(updateLabel) userInfo:nil repeats:YES];
    [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
}

And updateLabel
- (void)updateLabel {

    BannerDC *bannerObj = [[BannerDC alloc] init];
    if (count == bannerList.count){
        count = 0;
    } else {
        bannerObj = [bannerList objectAtIndex:count];

        lblFeaturedEventTitle.text = bannerObj.line1;
        imgFeaturedEventImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:bannerObj.img_url]]];

        // get the view that's currently showing
        [self.viewBannersBackground removeFromSuperview];
        [self.viewBanners addSubview:self.viewBannersBackground];

        // set up an animation for the transition between the views
        CATransition *animation = [CATransition animation];
        [animation setDuration:1.0];
        [animation setType:kCATransitionPush];
        [animation setSubtype:kCATransitionFromRight];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

        [[self.viewBannersBackground layer] addAnimation:animation forKey:@"SwitchToView1"];

        count++;
    }
}

so, due to the timer function my main thread gets stuck (or shows a delay) during animation. I want to use this animation in thread, and I am confused between NSThread and NSTimer, how should I be doing this?

A: You shouldn't be using dataWithContentsOfURL:[ to download your banner image because it is synchronous and you may have already downloaded the image previously and could reuse it.
Look at changing to an asynchronous image management library like SDWebImage which will handle this for you without blocking the main thread (so neither your timer or animation will be affected).

A: You can try: [NSTimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:]
NSThread : run in background thread
NSTimer (should call in main thread) : run in main thread


text:
Q: Override delete model in django I have question model and also have Like and Dislike model, i want that if user have already liked this question and then click like button, delete Like object and question point increase by one.
example: question has 10 like --> i send like, so question has 11 like --> i also send like, so delete object and question's like quantity (10)
class Like(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_("user"))
    question = models.ForeignKey(Question,on_delete=models.CASCADE,verbose_name=_("question"))

    def save(self, *args, **kwargs):
        if not self.pk:
            self.question.point += 1
            self.question.save()
        return super(Like, self).save(*args, **kwargs)

@receiver(post_delete, sender=Like)
def delete_like(sender, instance, using, **kwargs):
    print(instance.question.point) #point is 3
    instance.question.point -= 1
    print(instance.question.point) #point is 2

when i print everything is fine but when i open database, result is not same
edit:
    def get_context_data(self, *args, **kwargs):
        like_exist=bool(Like.objects.filter(user=self.request.user, question=self.get_object()))
        dislike_exist=bool(DisLike.objects.filter(user=self.request.user, question=self.get_object()))
        self.object=self.get_object()
        context = super(QuestionDetail, self).get_context_data(**kwargs)
        try:
            question = Question.objects.get(id=self.kwargs["pk"])
            context['detail'] = question
            context['like_ex']=like_exist
            context['dislike_ex']=dislike_exist
        except Http404:
            return reverse("Profile:error")

        if "like" or "dislike" in self.request.GET:

            if "like" in self.request.GET:

                    if Like.objects.filter(user=self.request.user, question=self.get_object()):
                        Like.objects.filter(user=self.request.user, question=self.get_object()).delete()
                    else:
                        Like.objects.create(user=self.request.user, question=self.get_object())
                        if DisLike.objects.filter(user=self.request.user, question=self.get_object()):
                            DisLike.objects.filter(user=self.request.user, question=self.get_object()).delete()

            if "dislike" in self.request.GET:

                    if DisLike.objects.filter(user=self.request.user, question=self.get_object()).exists():
                        DisLike.objects.filter(user=self.request.user, question=self.get_object()).delete()
                    else:
                        DisLike.objects.create(user=self.request.user, question=self.get_object())
                        if Like.objects.filter(user=self.request.user, question=self.get_object()).exists():
                            Like.objects.filter(user=self.request.user, question=self.get_object()).delete()

        return context