text:
Q: How to add fog to texture in shader (THREE.JS R76) So firstly, I am aware of this post: ShaderMaterial fog parameter does not work
My question is a bit different...
I am trying to apply the fog in my three.js scene to a shader thats using a TEXTURE and I can't figure it out. My best guess as to what is supposed to go into the frag was:
resultingColor = mix(texture2D(glowTexture, vUv), fogColor, fogFactor);
This works when the texture2D part is just a normal color but as a texture it doesn't render.
THREE.glowShader = {

vertexShader: [

    `
    varying vec2 vUv;

    void main() {
        vUv = uv;
        gl_Position =  projectionMatrix * modelViewMatrix * vec4(position,1.0);
    }

    `

].join("\n"),

fragmentShader: [

    "uniform sampler2D glowTexture;",
    "varying vec2 vUv;",
    "uniform vec3 fogColor;",
    "uniform float fogNear;",
    "uniform float fogFar;",

    "void main() {",
         `
        vec4 resultingColor = texture2D(glowTexture, vUv);
        `,
        `#ifdef USE_FOG

            #ifdef USE_LOGDEPTHBUF_EXT

                float depth = gl_FragDepthEXT / gl_FragCoord.w;

            #else

                float depth = gl_FragCoord.z / gl_FragCoord.w;

            #endif

            #ifdef FOG_EXP2

                float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );

            #else

                float fogFactor = smoothstep( fogNear, fogFar, depth );

            #endif`,

            // resultingColor = mix(texture2D(glowTexture, vUv), fogColor, fogFactor);

        `#endif`,
        "gl_FragColor = resultingColor;",
    "}"

].join("\n")

}

A: Here is a fiddle that shows a ShaderMaterial with a texture and red fog
<script id="vertexShader" type="x-shader/x-vertex">
    varying vec2 vUv;
    varying vec3 vPosition;
    void main( void ) {
      vUv = uv;
      vPosition = position;
      gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
    }
  </script>

  <script id="fragmentShader" type="x-shader/x-fragment">
    varying vec2 vUv;
    uniform sampler2D texture;
    uniform vec3 fogColor;
    uniform float fogNear;
    uniform float fogFar;
    void main() {
      gl_FragColor = texture2D(texture, vUv);
      #ifdef USE_FOG
          #ifdef USE_LOGDEPTHBUF_EXT
              float depth = gl_FragDepthEXT / gl_FragCoord.w;
          #else
              float depth = gl_FragCoord.z / gl_FragCoord.w;
          #endif
          float fogFactor = smoothstep( fogNear, fogFar, depth );
          gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
      #endif
    }
  </script>

Here is a bit of how to create the material
var uniforms = {
    texture:     { type: "t", value: texture},
    fogColor:    { type: "c", value: scene.fog.color },
    fogNear:     { type: "f", value: scene.fog.near },
    fogFar:      { type: "f", value: scene.fog.far }
};
var vertexShader = document.getElementById('vertexShader').text;
var fragmentShader = document.getElementById('fragmentShader').text;
material = new THREE.ShaderMaterial(
  {
    uniforms : uniforms,
    vertexShader : vertexShader,
    fragmentShader : fragmentShader,
    fog: true
  }
);


text:
Q: libgdx - how to move a 3d model instance forward I'm wrestling with a simple cube which doesn't want to move properly forward with libgdx.
Here's the code:
public void move(float delta) {
    transform.translate(direction.x * speed * delta, direction.y * speed * delta, direction.z * speed * delta);
    transform.getTranslation(position);
}

public void rotateLeft(float delta) {
    float degrees = 1 * rotateSpeed * delta;
    transform.rotate(Vector3.Z, degrees);
    direction.rotate(Vector3.Z, degrees);
}

public void update(float delta) {
    rotateLeft(delta);
    move(delta);
}

and here's the result :
cube test video download link
where the blue arrow is the direction + the cube position vector and the red one is the direction.
I must have mistaken the translate() method...
Any idea?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Display information related to the currently selected record on a list page You need to display information related to the currently selected record on a Microsoft Dynamics AX 2012 list page. What should I use?

*

*A. Action Pane

*B. Cues Fact Box

*C. Fast Tab

*D. Preview Pane

Correct Answer: B
My Response: C (Incorrect)
I don't anderstand why is it a cue fact box ?

A: "Fast tab" is not correct because you do not use fast tabs in list pages.
I would consider both B and D correct.
Cues fact box because it updates the information when you select another record in the list page.
So does a preview pane, but usually it is information from the same record rather than related records, fx. Customer list page. In the Sales order list page you see order line information in the preview pane, I consider this related information, but it should probably be restricted to child records only.


text:
Q: Support for compiling ASN1 file to C with CONTAINING keyword I'm using ESNACC for compiling multiple ASN source files to C code. For ease of understanding, I will explain the scenario here as succintly as possible:-
FileA.asn1 contains the following:-
FileA DEFINITIONS ::=
BEGIN
  A ::= SEQUENCE
  {
        AContent   [0] OCTET STRING (CONTAINING FileB.B)
  }
END

FileB.asn1 contains the following:-
FileB DEFINITIONS ::=
BEGIN
  B ::= SEQUENCE
  {
        BElem1   [0]  INTEGER,
        BElem2   [1]  INTEGER
  }
END

I used ESNACC to compile both files in one command. Upon analysing the C source files generated, I observed that the AContent field will be decoded as a constructed OCTET STRING (the data being received in the application guarantees that the field will be specified as constructed) with its contents being filled into a simple string. This means that FileB does not come into the picture at all. I was hoping that AContent would be further decoded with a structure of FileB being filled, so that I can easily access the elements within. This does not seem to be the case.
I'm fairly new with ASN1, so please let me know if my understanding is wrong in any way.

*

*Is ESNACC not capable of generating code for supporting CONTAINING keyword properly?

*Are there other compilers that are able to do this?

*Can this be done by using ESNACC in any way?

*If this cannot be done using ESNACC, and I don't want to use any other compiler, how would I access the contents within AContent at runtime easily?

A: I am not sure of the capabilities of ESNACC, but there are many other compilers that support the CONTAINING keyword.  An excellent list of compilers can be found at https://www.itu.int/en/ITU-T/asn1/Pages/Tools.aspx which is part of the ITU-T ASN.1 Project.

A: Heimdal's ASN.1 compiler (lib/asn1/) has support for the funky Information Object System syntax extensions that allow you to declare things like what all goes into Certificate Extensions (for example), and the generated code will decode everything recursively in one go.


text:
Q: applying function to a series of items in a list of lists I have a function that needs to be applied to the same item in a list which is in a list pool. it is as follows:
myFUN<-function(x) {

myRESULT<-sqrt(sd(x)/50)

return(myRESULT)
}

i need to apply myFUN to a list such as:
big.list[[i]][["smaller.list"]][["smallest.list"]]
here, the thing is that there are 1500 different i in big.list and each of them have smaller.list and smallest.list in them. in other words, smallest.list is a list in smaller.list while smaller.list is a list in i and i is a list in big.list. also is are numbers from 1 to 1500.
I need to apply myFUN to each of the is and get the mean of them.

A: An option is to loop through the list, extract the smaller.list and smallest.list, apply the function. and then get the mean
mean(sapply(big.list, function(x) myFUN(x[["smaller.list"]][["smallest.list"]])))


text:
Q: I couldn't figure out something about mass and weight measurement Today when I was studying physic for my University enterance exam I have stucked in one topic.
I understood the difference between mass and weight. Mass is the amount of material an object contains and weight is the force applied to that mass due to gravity or other source of potential force(like magnetic feild maybe, not sure)
But when it comes to measurement of mass and weight I just couldnt understand the fact we need at least a little bit gravity to measure mass but then whats the difference between weight and mass now? Without gravity or other force to an object I can't measure weight as well. I am just trying to imagine in very very very low gravity just enough to keep our feets on ground in a scenario like this if I measure the mass will it be same really? Or does that the mass we measure in earth isnt actually mass? just something close to it I just can not quite figure out this with an actual example.
I would be glad if someone explains this to me with an basic example.

A: We do not need gravity to measure mass, there are lots of scientific experiments where mass can me determined.  A particle accelerator is an example where we see motion due to fundamental forces, the motion is affected by mass. Weight always refers to the gravity force, gravity on earth or gravity on the moon, etc.
There are 4 fundamental forces that science studies, and the attraction of masses is due to the gravity force, this is why we see weight on earth.  But we can also charge a mass or create a charged particle and use the EM force to study its mass as well.


text:
Q: Trying to get Code::Blocks working on Mac, running Lion. Can't get the compiler set up properly First off, sorry if this is a stupid question. I installed code::blocks to try and get to know the program and start working on teaching myself c++. I have a MacBook Pro with OS 10.7.3. I ave code::blocks 10.05. When I try to build a "Hello world" nothing happens. Based on some googling I've figured out that it's because code::blocks doesn't know where to find the debugger/compiler. Further googling yielded me this page which tells me to install Xcode and to fix some things in the code::blocks settings. However, this wiki obviously has not been updated since Apple went to the App store, because the file paths it gives for the compiler do not exist (there is no /Developer/* even after installing Xcode). Xcode 4.3.2 was already installed when I installed code::blocks and code::blocks "auto-detected" several compilers. They did not work. If anyone knows where Xcode hides its compilers now that Apple has moved to the app store, I would be much obliged.

A: Besides Xcode the app, you need to install the "command line tools", which allow you to call the compilers from the command line.
Go to this page: https://developer.apple.com/xcode/index.php
And look under "Looking for additional developer tools".  It'll require you to log in with your Apple developer ID (which is free to get if you haven't already paid the $99 for the program membership). Once you are in, the package you want to install next is "Command Line Tools for Xcode - Late March 2012" (or whatever the latest one listed there is).


text:
Q: Selected item in a listview doesn't unselect I can select multiple items in a listview. But if i click on one, it turns blue. That's normal, so that shows it is selected. But if i click again on the same item, it doesnt uncheck. So i can't change my selection. Somebody who knows how to fix this stupid little problem?
Edit: This is my listview:
 <ListView Height="155" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible"  SelectedItem="{Binding Path=SelectedQuestionDropList, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" dd:DragDrop.IsDragSource="True"
  dd:DragDrop.IsDropTarget="True" SelectionMode="Multiple" Margin="0,0,542,436" Background="#CDC5CBC5"
                 dd:DragDrop.DropHandler="{Binding}" Name="DropListView"  ItemsSource="{Binding Path=SelectedExaminationQuestions,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" SelectionChanged="ListView_SelectionChanged_1" VerticalAlignment="Bottom">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Header="Verkorte naam" Width="Auto" DisplayMemberBinding="{Binding Path=ShortName}" />
                        <GridViewColumn Header="Omschrijving" Width="Auto" DisplayMemberBinding="{Binding Path=Description}" />
                        <GridViewColumn Header="Type" Width="Auto" DisplayMemberBinding="{Binding Path=Type}" />

                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>

A: I was facing a similar problem and found that, while left-click always select the item pointed to, you can use Ctrl + left-click to toggle selection in a list view. This is the default behavior.

A: You can write a wpf behaviour. Something like:
public class ListViewBehaviour
{
    /// <summary>
    /// Enfoca automaticament el item sel·leccionat
    /// </summary>
    public static readonly DependencyProperty AutoUnselectItemProperty =
        DependencyProperty.RegisterAttached(
            "AutoUnselect",
            typeof(bool),
            typeof(ListViewBehaviour),
            new UIPropertyMetadata(false, OnAutoUnselectItemChanged));

    public static bool GetAutoUnselectItem(ListView listBox)
    {
        return (bool)listBox.GetValue(AutoUnselectItemProperty);
    }

    public static void SetAutoUnselectItem(ListView listBox, bool value)
    {
        listBox.SetValue(AutoUnselectItemProperty, value);
    }

    private static void OnAutoUnselectItemChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
    {
        var listView = source as ListView;
        if (listView == null)
            return;

        if (e.NewValue is bool == false)
            listView.SelectionChanged -= OnSelectionChanged;
        else
            listView.SelectionChanged += OnSelectionChanged;
    }

    private static void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // TODO write custom selection behaviour
    }
}

And to apply it to a listview:
<ListView bb:ListViewBehaviour.AutoUnselect="True">
    ...
</ListView>


text:
Q: Use a string from an outside class to the main class I have a main class file that calls methods as objects from other outside class files.
I'm having a hard time using a string in the main class file that was defined in an outside class file.
This is the main class:
import java.util.Scanner;

public class TW5K
{
    public static void main(String[] args)
    {
        CiteNum citenumber = new CiteNum();
        PlateNum platenumber = new PlateNum();
        DateNum datenumber = new DateNum();

        citenumber.CiteEnt();
        platenumber.PlateEnt();
        datenumber.DateEnt();

        System.out.println(); // I want to print the string "dateld" here, from the outside class.
    }
}

This is the outside class:
import java.util.Scanner;

public class DateNum
{
    public void DateEnt()
    {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter date of violation: ");
        String dateld = input.nextLine();
        System.out.println();
    }
}

A: Return the value:
public String DateEnt()
{
    Scanner input = new Scanner(System.in);

    System.out.print("Enter date of violation: ");
    String dateld = input.nextLine();
    System.out.println();
    return dateld;
}

Then:
String dateld = datenumber.DateEnt();

System.out.println(dateld);


text:
Q: How to count the numer of pdf pages in python that has blank pdf page also I have tried to print the count of pdf document which includes some blank white pdf page using pypdf module. But it avoids the blanks page and print the count of rest of pages. Below is the code.
import sys

import pyPdf

from pyPdf import PdfFileReader, PdfFileWriter

pdf_document = PdfFileReader(file(normalpdfpath,"r"))

normal = pdf_document.getNumPages()
print normal

A: step 1:-

pip install pyPDF2

step 2:-
import requests, PyPDF2, io
url = 'sample.pdf'
response = requests.get(url)
with io.BytesIO(response.content) as open_pdf_file:
  read_pdf = PyPDF2.PdfFileReader(open_pdf_file)
  num_pages = read_pdf.getNumPages()
  print(num_pages)

A: You may try this, which worked for me:
import re
import os

rxcountpages = re.compile(r"/Type\s*/Page([^s]|$)", re.MULTILINE|re.DOTALL)

def count_pages(filename):
    data = file(filename,"rb").read()
    return len(rxcountpages.findall(data))

if __name__=="__main__":
    parent = "/Users/username/"
    os.chdir(parent)
    filename = 'LaTeX20120726.pdf'
    print count_pages(filename)

For Python 3.6+
import re

rxcountpages = re.compile(rb"/Type\s*/Page([^s]|$)", re.MULTILINE|re.DOTALL)

def count_pages(filename: str) -> int:
    with open(filename, "rb") as infile:
        data = infile.read()
    return len(rxcountpages.findall(data))

if __name__=="__main__":
    filename = '/Users/username/LaTeX20120726.pdf'
    print(count_pages(filename))

Regards

A: Just for all your googlers, here is an updated version of this answer and comment that works using built-in packages:
import re

# compile your regex to make it faster
PAGE_COUNT_REGEX = re.compile(
    rb"/Type\s*/Page([^s]|$)",
    re.MULTILINE|re.DOTALL
)

def get_page_count(floc, regex=PAGE_COUNT_REGEX):
    """Count number of pages in a pdf"""
    with open(floc, "rb") as f:
        return len(regex.findall(f.read()))

get_page_count("path/to/your/file.pdf")


text:
Q: "Error occurred during initialization of VM" in linux server I am trying to run java command in linux server it was running well but today when I tried to run java I got some error-

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

my memory space is -
root@vps [~]# free -m
         total       used       free     shared    buffers     cached
Mem:     8192        226       7965          0          0          0
    -/+ buffers/cache:        226       7965
Swap:            0          0          0

How can I solve this problem.

A: This error can occur when ulimits are set. What's the output of ulimit -a?

A: Restart(reboot) system or server it will work well.


text:
Q: iTunes Unable To Backup iPhone Whenever I try to backup my 128 GB iPhone 6s, I get an error

iTunes could not back up the iPhone 'Talon's iPhone 6s' because not enough free space is available on this computer.

While my internal SSD doesn't have enough space, I have my iTunes Library on an external HD which has 1.32 TB free. I have made sure that the library is in fact on the external drive by selecting it by holding the Option key when launching iTunes.
Any ideas on how to fix this?
PS: iTunes 12.4.1.6, OS X 10.11.5, iOS 9.3.2

A: The default location for iPhone Backups is:
$HOME/Library/Application Support/MobileSync/Backup

If the Macintosh HD doesn't have adequate free space and or adequate free space cannot easily be made available at the default location, then the following can be used as a workaround.
First, if the iPhone is showing in iTunes eject it, then close iTunes.
If you have existing backups at the default location you can first copy the existing Backup folder to a new location on a different drive/partition/volume that has adequate free space.
Once you've copied the Backup folder to a new location you can either delete the original or rename it, e.g.: Backup.old. This needs to be done to allow for the creation of a symbolic link to the new location of the MobileSync Backup folder and the symlinks name also needs to be "Backup".
To create the symbolic link, it Terminal, use the following command line example while changing the path to what's appropriate for your use.
ln -s /Volumes/<Your External HDD>/MobileSync/Backup ~/Library/Application\ Support/MobileSync/Backup

With the symbolic link created you can now open iTunes, connect the iPhone and perform a backup.


text:
Q: Cannot resolve symbol 'animSlide' I really don't understand why I have this error.
package com.example.paul_2.a18martie;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    LinearLayout ll;
    TextView tv;
    ImageView imag1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        RelativeLayout rl = (RelativeLayout) findViewById(R.id.ioi);

        ImageView iv = new ImageView(this);
        iv.setBackgroundResource(R.drawable.aatrox);
        RelativeLayout.LayoutParams params = new       RelativeLayout.LayoutParams(100,120);
        params.leftMargin = 50;
        params.topMargin = 60;
        rl.addView(iv, params);

        animSlide = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide);
        iv.startAnimation(animSlide);

Can someone tell me why animSlide give's me the error Cannot resolve symbol 'animSlide'.
I can let you the slide.xml file but I think isn't the problem...
<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

    <translate
        android:fromXDelta="0%p"
        android:toXDelta="75%p"
        android:duration="800" />
</set>

I am sorry if I am terribly wrong with something, but I am very new on all of this.

A: In Java, you must declare all variables. The compiler is complaining because you use a variable named animSlide without declaring it.


text:
Q: Could you help me finding some less colloquial equivalent to highlighted phrases of this speech
Today I want to be able to give you some good tips on parallel parking. It's part of your road test. It's something you need to learn. For most new drivers it's real difficult, because they're not able to judge angles. And parallel parking is all about angles. I'll take you through a typical parking, I'll take you through how I teach it , and maybe that'll help you in passing your road test. The first thing you want to do is you want to pull over over and you want to stop alongside a parked car. Typically, an inspector will give you a command to pull over, stop next to the red or blue car. You're just going to pull over, put your blinker on to the right, and pull over even with that car.

*

*taken from a series of videos teaching driving

*

*Why did the man use  be able in his speech? What is the difference between be able and I would like to or I want ? I mean what the listener should make of  I want to be able to give you ...  . Why did not he say I want to give you... ?

*When he says I'll take you through a typical parking , I get the meaning of take one through ,It means I am going to teach you , isn't it? But my real concern is what the second I'll take you through means, while saying I'll take you through how I teach it . Perhaps it doesn't mean I will teach you that how I teach it ! , does it?

*The man always says the first thing you want to do . Why does not he say the first thing you should do , the first thing you need to do ? What are the diffrences in meaning? Isn't it unnatural saying you want to do ?

*In the last sentence he says You're just going to pull over, is the use of going to just weakening would and will? I think here it means something else. I think it means you just want to or you just start

A: For the most part, I think your instincts are accurate.

*

*Precisely, I want to give you... is exactly what he means.

*Slightly confusing, but I think he means "I am going to give you an example of a typical parking scenario, as I teach it." Both sentences really mean the same thing.

*As with the rest of your examples, he's speaking very informally. Yes, the first thing you should do is a good understanding.

*Not sure if I follow your meaning here. I think he's using "just" to imply that the steps you will follow are simple. So yes, I guess he's using it to weaken the sentence. (Where do "would" and "will" come from?) The suggestion that these steps are simple or basic is to offset the difficulty he mentions in the fourth sentence. edit: fixated on the wrong word. He's laying out a set of steps - "You will: [step 1], [step 2], [step 3]." but phrased in a very informal manner.


text:
Q: Javascript tests do not continue when reaching the ajax code In the onClick attribute of a button of my form there is a call to a javascript function. In this function there are tests of whether fields are not filled in. There is also a call to an Ajax function when a textfield is filled with a value , to test if the value already exists in the Mysql database. My problem is that when arriving at the ajax function then the remaining of the javascript tests are not preformed , although there are still fields that are not filled in. So how to make the remaining tests executed ?
Here is my code :
<input type="button" name="btn_Valider" id="btn_Valider" value="Valider" class="bouton2" onClick="testerDonneesForm();"/>

function testerDonneesForm(){
        if (document.frm_Produit.prod_code.value == "") {
            alert( "Le champ ''Code produit'' ne doit pas être vide!");
            document.frm_Produit.prod_code.focus;
            return false;
        }
        else if (document.frm_Produit.prod_code.value != "") {
            ajaxRechercherCodeProduit();
        }
        else if (document.frm_Produit.type_prod_code.value == "") {
            alert( "Le champ ''Type code produit'' ne doit pas être vide!");
            document.frm_Produit.prosp_cin.focus;
            return false;
        }
        else {
            document.getElementById("frm_Produit").submit() ;
        }
    }

function trim (myString)
{
    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

function ajaxRechercherCodeProduit() {

    var g_XhrObject = get_Xhr() ;
    var prod_code = document.getElementById('prod_code').value;
    var url = '<?php echo HTTP_AJAX ?>Produit/ajaxVerifieCodeProduit.php?prod_code='+prod_code;

    if (g_XhrObject) {
        g_XhrObject.onreadystatechange = function()
        {
            if (g_XhrObject.readyState == 4 && g_XhrObject.status == 200) {

                if (trim(g_XhrObject.responseText) != "0")
                {
                    alert(g_XhrObject.responseText);
                    return false;
                }
            }
        }

        g_XhrObject.open("POST", url, true) ;
        g_XhrObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') ;
        g_XhrObject.send(null);
    }
}

A: You want the tests to be individual if statements, not else if parts of a single if statement. With an if-else if-else statement, the execution moves past the end of the if structure as soon as one of the conditions is found to be true, or it has executed the else condition (none of the preceding conditions were true).


text:
Q: How to properly decouple classes from frameworks (source level decoupling) I am working on a game project using Microsoft XNA framework, although this question is a generic one that involves decoupling of classes/systems.
Let's say i have a class (simplified to suit this example) as shown here:
public class GameCell
{
        public Color Color { get; set; }
}

I would like to reuse as much code as i can between multiple platforms that use C#.
The problem of directly referncing the Color struct is that this type is defined in the XNA assemblies, creating a strong coupling (or dependency) between my code and XNA.
The other framework i will be using may (or may not) have its own Color object, with its own set of properties and API.
I would like to have the same source file "know" to use either the XNA or other framework's implementation automagically.
I know other types of decoupling methods such as IoC, but that would mean i would be plugging in different versions of a system/class, instead of reusing the same class in different contexts.
Is this even possible to do? how would u suggest to keep such a system portable?
I've seen some cases (in native C++ development) where you would define a set of classes that mirror the classes the framework you're using has (for example here - define Color again), and so it is possible to "re-map" this later on to use different classes, upon need.
Another option is to mess around using #IFDEF to play with the using statements in the header of the class (switching from XNA to other platforms).
What is the best alternative in this case?

A: Typically what you do is create your own Color structure and have it do the translation using conditional compilation switches. For example:
#define USE_DOTNET
//#define USE_SOMETHINGELSE

#if USE_DOTNET
using System.Drawing;
#endif

#if USE_SOMETHINGELSE
using SomethingElse.Drawing;
#endif

public struct MyColor
{
    #if USE_DOTNET
    Color TheColor;
    #endif
    #if USE_SOMETHINGELSE
    SomethingsColor TheColor;
    #endif

    public int R
    {
        get
        {
            #if USE_DOTNET
                // code to return .NET Color.R value
            #endif
            #if USE_SOMETHINGELSE
                // code to return SomethingColor.R value
            #endif
         }
    }
}

Another way is to have separate regions for the .NET and SomethingElse code. For example:
#if USE_DOTNET
public int R
{
    get { return TheColor.R; }
}
// other properties and methods here
#endif

#if USE_SOMETHINGELSE
// properties and methods for using SomethingElse
#endif

This can work well, but you have to be very careful when writing your code so that you don't  use the .NET Color structure anywhere but in these portability layers.
We used this technique in C/C++ when developing games that had to run on Windows, the Mac, and several different game consoles. It's a pain to set up the portability layers, but once they're set up, it's pretty easy to use.
I would caution you, though, not to give your portability classes and structures the same names as classes or structures from the .NET libraries or the other libraries you're using. If you do that, you're going to confuse yourself, and you're likely to write some non-portable code that you won't discover until you start trying to port it. (Not that I'm speaking from experience or anything . . .)


text:
Q: Passing connection string properties when using DTEXEC I am wondering what the correct format is for passing connection string properties on the command line when using dtexec:
dtexec.exe /Ser IpAddress\Instance /IS "\SSISDB\Data Warehouse\MyProject\MyPackage.dtsx" /DumpOnError /Set \Package.Variables[DW_ConnectionString].Properties[Value];\""Data Source=IpAddress;Initial Catalog=DWDB;Provider=SQLNCLI10.1;IntegratedSecurity=SSPI;"\"

I have defined the above command line configuration where I am attempting to pass override properties for the default connection string properties. The packages I'm targeting are not using package connections, but instead project level parameters/properties have been defined to store the DB connections.
For some reason I can't get this to work . I am getting an error message on the server saying
Failed to configure an overridden property that has the
following path: \Package.Variables
[DW_ConnectionString].Properties
[Value]. An error occurred while setting the value of
property "Value". The error returned is 0x80020009
Is my format correct for overriding properties?
The packages are hosted on a remote server

A: Try using DTEXECUI next time to generate your command string.  It has places for all of the variables, connection managers etc.  All you have to do is bring up your package and it fills everything in.  You then enter any changes you want in the GUI then go to the Command line tab and it will give you the string to put after DTEXEC.EXEC.  You can of course also run the package from DTEXECUI also.

A: It turns out that my format was wrong:
It's incorrect to use /Set Package Variable in this context:
The correct format is:
/Par "$Project::DW_ConnectionString";\""Data Source=Server\Instance;Initial Catalog=myDb;Provider=SQLNCLI11.1;Integrated Security=SSPI;AutoTranslate=False;"\"


text:
Q: jQuery image PULSE animation on mouseover, fades to another image I'm trying to make an effect where on mouseover the image pulses between two different files in jQuery. I have the beginning written, but I'm struggling with the actual animation part.
Here is what I have so far. I know that I need to write something that tells the image to fade into the next image and then fades back. Thanks in advance for your time.
(function($) {
    $(document).ready(function() {
        window.pulse_image = null;
        window.pulse_continue_loop = false;

        $('.pulse').mouseover(function() {
            // User is hovering over the image.
            window.pulse_continue_loop = true;
            window.pulse_image = $(this);

            PulseAnimation(); // start the loop
        }).mouseout(function() {
            window.pulse_continue_loop = false;
            window.pulse_image.stop();
        });
    });
})(jQuery);

I'm hoping to do something similar to this where it would be easy to apply to multiple images - having two images, one example_off.jpg and example_on.jpg.
jQuery(function(){
            $(".img-swap").hover(
                function(){this.src = this.src.replace("_off","_on");},
                function(){this.src = this.src.replace("_on","_off");
            });
        });

A: Well, you don't necessarily need a plugin to do this.  Lets say you have an image tag like
<img id = "image" src = "/path/to/front_image" data-alternate = "/path/to/back_image" width = "50" height = "50" />

You can set the data attribute to hold the path to the alternate image, and implement a swap like
//bind mouse events to image element with a given function
$("img#image").on("mouseover", function(e){
                imageSwap($(e.currentTarget));
               })
               .on("mouseout", function(e){
                 imageSwap($(e.currentTarget));
               });

function imageSwap(image){
   //get the alternate source image as a placeholder
   var newSource = image.data("alternate");

   //save the image's current source in the data attribute
   image.data("alternate", image.attr("src"));

   //execute fadeOut operation of the image
   image.fadeOut("fast", function(e){

     //replace the image source attribute with the new image source
     image.attr("src") = newSource;

     //execute the fadeIn operation to show the new image
     image.fadeIn("fast");
   });
}

What this allows you to do is bind the mouseover and mouseout events to a single function that swaps the image source attributes with a data variable and executes a fadeOut and fadeIn operation in sequence.


text:
Q: Laravel Require if is null in database laravel 5.8
I want a rule of laravel validation for update that be like this:
only push error when the value of this field is null and this field in the database is null too
if the field is null but in the database this field has value that validation is ok
I tried this
            'logo' => 'required_without:logo',

A: You may have to write a custom Rule or do some checks on the field to wrap around your validation definitions.
$rules= [...];

if($model->field === null){
    $rules['logo' => 'required'];
}


text:
Q: using decltype w/ parameter pack for C++11 I'm trying to get the multi_index_t code from the second answer here answered by davidhigh to work with C++11. C++11 does not support auto& type returns.
I converted the return types for the class, but I don't understand how/if it's possible to support the helper function multi_index() without using C++14.
The code:
#include<array>

template<int dim>
struct multi_index_t
{
  std::array<int, dim> size_array;
  template<typename ... Args>
  multi_index_t(Args&& ... args) : size_array(std::forward<Args>(args) ...) {}

  struct iterator
  {
    struct sentinel_t {};
    std::array<int, dim> index_array = {};
    std::array<int, dim> const& size_array;
    bool _end = false;

    iterator(std::array<int, dim> const& size_array) : size_array(size_array) {}

    iterator& operator++()
    {
      for (int i = 0;i < dim;++i)
      {
        if (index_array[i] < size_array[i] - 1)
        {
          ++index_array[i];
          for (int j = 0;j < i;++j) { index_array[j] = 0; }
          return *this;
        }
      }
      _end = true;
      return *this;
    }
    std::array<int, dim>& operator*()  { return index_array; }
    bool operator!=(sentinel_t) const { return !_end; }
  };

  iterator begin() const { return iterator{ size_array }; }
  iterator end() const { return typename iterator::sentinel_t{}; }
};

template<typename ... index_t>
auto multi_index(index_t&& ... index) // <-- this doesn't compile
{
  static constexpr int size = sizeof ... (index_t);
  auto ar = std::array<int, size>{std::forward<index_t>(index) ...};
  return multi_index_t<size>(ar);
}

According to this answer, you can't recursively expand the variadic function template via decltype(). Any ideas?

A:
C++11 does not support auto& type returns.

So you can simply explicit the types.
For multi_index() you have that return a multi_index_t<size>, where size is sizeof...(index_t), so you can write
template<typename ... index_t>
multi_index_t<sizeof...(index_t)> multi_index(index_t&& ... index)

According to this answer, you can't recursively expand the variadic function template via decltype.

Correct, but I don't see recursion in your multi_index() function, so I don't see how apply recursion over decltype().
If you really want (but why?), you can explicit the returning type through decltype() as follows
template<typename ... index_t>
auto multi_index(index_t&& ... index)
   -> decltype( multi_index_t<sizeof...(index_t)>
                   { std::array<int, sizeof...(index_t)>
                        {{ std::forward<index_t>(index) ... }} } )

but I don't see a reason to do this instead of simply explicit multi_index_t<sizeof...(index_t)>


text:
Q: How to set the center of Modalview controller.Is there any solution I can find? How to set center of the modalview controller to its center of self.view or Appdelegate window.I have sample code.The following code is presenting modalview at the right corner of the screen not at the center of the screen.
   MaterialDetailsViewController *materialDetails =[[MaterialDetailsViewController alloc]initWithNibName:NSLocalizedString(@"MaterialDetailsViewController",nil) bundle:nil];
      materialDetails.view.frame = CGRectMake(0, 0, 750, 650);
      materialDetails.modalPresentationStyle = UIModalPresentationFormSheet;
      materialDetails.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;  //transition shouldn't matter
      [self presentViewController:materialDetails animated:YES completion:nil];
     materialDetails.view.superview.frame = CGRectMake(self.view.superview.center.x - (750/2),
                                                       self.view.superview.center.y - (650/2),
                                                        750,650);
I tried to set the modalview frame center to self.view.center in MaterialDetailsViewController class like below
AppDelegate *delegate = [AppDelegate sharedInstance];
self.view.center = delegate.window.center;

But it doesn't fit to the center of the screen.I can try out this with Popovercontroller I can best do with that but i couldn't manage with modalview controller.I think this post will be helpful for those who are trying hard to set the frame for modalview.

A: Add to your MaterialDetailsViewController
- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
    self.view.superview.bounds = CGRectMake(0, 0, 750, 650);
}

iOS 5+


text:
Q: Incomplete term slugs output from a foreach loop with get_the_terms I'm using this PHP to get all the product category slugs on a single product page:
global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
if(is_array($terms)){
foreach ($terms as $term) {
    $product_cat_slug = $term->slug;
    $product_cat_slugs = ' product_cat-' . $product_cat_slug;
    echo $product_cat_slugs;
}
}

The line echo $product_cat_slugs; outputs product_cat-category1 product_cat-category2, which I will use for div classes.
The problem is that when I delete the echo $product_cat_slugs; from the function above and use <?php echo $product_cat_slugs; ?> elsewhere on the page, all I get for output is the last category slug product_cat-category2, and not both categories product_cat-category1 product_cat-category2.
What's wrong? It appears that $product_cat_slugs is overwritten when outside the foreach; how can I prevent that?

A: You are overwriting $product_cat_slugs on every iteration of your loop - so when it's finished, that variable will be set to the last value.
Why not do all of your outputs inside that loop?
Or if for some reason you don't want to do that, make $product_cat_slugs an array instead of a variable:
$product_cat_slugs = [];
foreach ($terms as $term) {
    $product_cat_slug = $term->slug;
    $product_cat_slugs[] = ' product_cat-' . $product_cat_slug;
}


text:
Q: Can not convert tf.map_fn during TFLite Conversion (With Minimum Example) When trying to convert tf.map_fn, tflite converter throws the next error:
2020-06-05 22:27:19.003670: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-06-05 22:27:19.003971: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-06-05 22:27:19.004272: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-06-05 22:27:19.004567: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-06-05 22:27:19.004842: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-06-05 22:27:19.005144: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-06-05 22:27:19.005465: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-06-05 22:27:19.006000: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2020-06-05 22:27:19.006294: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-06-05 22:27:19.006536: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0
2020-06-05 22:27:19.006735: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N
2020-06-05 22:27:19.007280: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4831 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060, pci bus id: 0000:01:00.0, compute capability: 6.1)
2020-06-05 22:27:19.301593: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: graph_to_optimize
2020-06-05 22:27:19.301969: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: Graph size after: 1282 nodes (966), 1999 edges (1683), time = 33.269ms.
2020-06-05 22:27:19.302215: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: Graph size after: 1282 nodes (0), 1999 edges (0), time = 15.255ms.
2020-06-05 22:27:19.302403: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: map_while_body_33337
2020-06-05 22:27:19.302750: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: Graph size after: 39 nodes (0), 42 edges (0), time = 1.062ms.
2020-06-05 22:27:19.303076: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: Graph size after: 39 nodes (0), 42 edges (0), time = 0.9ms.
2020-06-05 22:27:19.303388: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: cond_png_false_33387
2020-06-05 22:27:19.303619: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: Graph size after: 8 nodes (0), 8 edges (0), time = 0.331ms.
2020-06-05 22:27:19.303812: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: Graph size after: 8 nodes (0), 8 edges (0), time = 0.34ms.
2020-06-05 22:27:19.304065: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: cond_png_true_33386
2020-06-05 22:27:19.304353: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.304665: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.304962: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: map_1_while_cond_34702
2020-06-05 22:27:19.305318: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.305696: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.306091: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: decode_image_cond_jpeg_false_33368
2020-06-05 22:27:19.306474: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: Graph size after: 11 nodes (0), 12 edges (0), time = 0.448ms.
2020-06-05 22:27:19.306808: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: Graph size after: 11 nodes (0), 12 edges (0), time = 0.489ms.
2020-06-05 22:27:19.307104: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: cond_gif_false_33398
2020-06-05 22:27:19.307397: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.307741: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.308084: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: decode_image_cond_jpeg_true_33367
2020-06-05 22:27:19.308466: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.308762: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.309035: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: map_1_while_body_34703
2020-06-05 22:27:19.309325: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.309541: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.309842: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: map_while_cond_33336
2020-06-05 22:27:19.310108: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0.001ms.
2020-06-05 22:27:19.310376: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0.001ms.
2020-06-05 22:27:19.310642: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: cond_gif_true_33397
2020-06-05 22:27:19.310783: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:19.310998: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-06-05 22:27:21.532247: I tensorflow/core/grappler/devices.cc:55] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 1
2020-06-05 22:27:21.532847: I tensorflow/core/grappler/clusters/single_machine.cc:356] Starting new session
2020-06-05 22:27:21.535655: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1060 computeCapability: 6.1
coreClock: 1.733GHz coreCount: 10 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 178.99GiB/s
2020-06-05 22:27:21.536315: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-06-05 22:27:21.536688: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-06-05 22:27:21.537057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-06-05 22:27:21.537401: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-06-05 22:27:21.537814: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-06-05 22:27:21.538133: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-06-05 22:27:21.538423: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-06-05 22:27:21.538987: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2020-06-05 22:27:21.539329: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-06-05 22:27:21.539617: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0
2020-06-05 22:27:21.540042: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N
2020-06-05 22:27:21.540561: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4831 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060, pci bus id: 0000:01:00.0, compute capability: 6.1)
2020-06-05 22:27:21.867862: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: graph_to_optimize
2020-06-05 22:27:21.868148: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 931 nodes (-351), 1333 edges (-666), time = 84.162ms.
2020-06-05 22:27:21.868426: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 931 nodes (0), 1333 edges (0), time = 20.041ms.
2020-06-05 22:27:21.868694: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: map_1_while_body_34703_frozen
2020-06-05 22:27:21.868934: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 30 nodes (0), 27 edges (0), time = 0.558ms.
2020-06-05 22:27:21.869323: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 30 nodes (0), 27 edges (0), time = 0.322ms.
2020-06-05 22:27:21.869599: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: map_while_cond_33336_frozen
2020-06-05 22:27:21.869891: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 11 nodes (0), 8 edges (0), time = 0.256ms.
2020-06-05 22:27:21.870168: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 11 nodes (0), 8 edges (0), time = 0.111ms.
2020-06-05 22:27:21.870434: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: decode_image_cond_jpeg_false_33368_frozen
2020-06-05 22:27:21.870756: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 11 nodes (0), 12 edges (0), time = 0.415ms.
2020-06-05 22:27:21.871043: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 11 nodes (0), 12 edges (0), time = 0.195ms.
2020-06-05 22:27:21.871326: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: cond_png_true_33386_frozen
2020-06-05 22:27:21.871605: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 6 nodes (0), 4 edges (0), time = 0.199ms.
2020-06-05 22:27:21.871895: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 6 nodes (0), 4 edges (0), time = 0.067ms.
2020-06-05 22:27:21.872182: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: cond_gif_true_33397_frozen
2020-06-05 22:27:21.872445: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 8 nodes (-7), 8 edges (-6), time = 0.434ms.
2020-06-05 22:27:21.872715: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 8 nodes (0), 8 edges (0), time = 0.093ms.
2020-06-05 22:27:21.872937: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: cond_gif_false_33398_frozen
2020-06-05 22:27:21.873215: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 15 nodes (-4), 18 edges (-2), time = 0.527ms.
2020-06-05 22:27:21.873520: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 15 nodes (0), 18 edges (0), time = 0.164ms.
2020-06-05 22:27:21.873774: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: cond_png_false_33387_frozen
2020-06-05 22:27:21.874025: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 8 nodes (0), 8 edges (0), time = 0.264ms.
2020-06-05 22:27:21.874282: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 8 nodes (0), 8 edges (0), time = 0.129ms.
2020-06-05 22:27:21.874542: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: decode_image_cond_jpeg_true_33367_frozen
2020-06-05 22:27:21.874782: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 9 nodes (-3), 8 edges (-2), time = 0.378ms.
2020-06-05 22:27:21.875115: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 9 nodes (0), 8 edges (0), time = 0.109ms.
2020-06-05 22:27:21.875358: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: map_1_while_cond_34702_frozen
2020-06-05 22:27:21.875596: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 11 nodes (0), 8 edges (0), time = 0.255ms.
2020-06-05 22:27:21.875888: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 11 nodes (0), 8 edges (0), time = 0.107ms.
2020-06-05 22:27:21.876138: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:797] Optimization results for grappler item: map_while_body_33337_frozen
2020-06-05 22:27:21.876413: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 39 nodes (0), 42 edges (0), time = 1.324ms.
2020-06-05 22:27:21.876736: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:799]   constant_folding: Graph size after: 39 nodes (0), 42 edges (0), time = 0.491ms.
Traceback (most recent call last):
  File "deploy.py", line 122, in <module>
    generator = run(model.generator, tflite_path)
  File "deploy.py", line 88, in run
    tflite = convert(wrapped)
  File "deploy.py", line 63, in convert
    tflite_model = converter.convert()
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\lite\python\lite.py", line 514, in convert
    result = _toco_convert_impl(
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\lite\python\convert.py", line 491, in toco_convert_impl
    data = toco_convert_protos(
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\lite\python\convert.py", line 227, in toco_convert_protos
    raise ConverterError("See console for info.\n%s\n%s\n" % (stdout, stderr))
tensorflow.lite.python.convert.ConverterError: See console for info.
2020-06-05 22:27:28.323077: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-06-05 22:27:31.116166: W tensorflow/compiler/mlir/lite/python/graphdef_to_tfl_flatbuffer.cc:144] Ignored output_format.
2020-06-05 22:27:31.116208: W tensorflow/compiler/mlir/lite/python/graphdef_to_tfl_flatbuffer.cc:147] Ignored drop_control_dependency.
loc(fused[callsite("map/TensorArrayV2_1@__inference_call_34750"("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\ops\map_fn.py":417:0) at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\util\deprecation.py":574:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\deblurrer-1.0.0-py3.8.egg\deblurrer\model\wrapper.py":42:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\framework\func_graph.py":957:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py":3299:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\def_function.py":441:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\framework\func_graph.py":981:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py":2657:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py":2777:0 at "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py":2446:0))))))))), "image_byte_wrapper/StatefulPartitionedCall/map/TensorArrayV2_1"]): error: requires element_shape to be 1D tensor during TF Lite transformation pass
loc(fused[callsite("map/TensorArrayV2_1@__inference_call_34750"("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\ops\map_fn.py":417:0) at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\util\deprecation.py":574:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\deblurrer-1.0.0-py3.8.egg\deblurrer\model\wrapper.py":42:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\framework\func_graph.py":957:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py":3299:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\def_function.py":441:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\framework\func_graph.py":981:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py":2657:0 at callsite("C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py":2777:0 at "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py":2446:0))))))))), "image_byte_wrapper/StatefulPartitionedCall/map/TensorArrayV2_1"]): error: failed to legalize operation 'tf.TensorListReserve'
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\Scripts\toco_from_protos-script.py", line 11, in <module>
    load_entry_point('tensorflow==2.2.0', 'console_scripts', 'toco_from_protos')()
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\lite\toco\python\toco_from_protos.py", line 93, in main
    app.run(main=execute, argv=[sys.argv[0]] + unparsed)
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\absl\app.py", line 299, in run
    _run_main(main, args)
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\absl\app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\lite\toco\python\toco_from_protos.py", line 50, in execute
    output_str = _pywrap_toco_api.TocoConvert(
Exception: C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\ops\map_fn.py:417:3: error: requires element_shape to be 1D tensor during TF Lite transformation pass
  return map_fn(
  ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\util\deprecation.py:574:7: note: called from
      return func(*args, **kwargs)
      ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\deblurrer-1.0.0-py3.8.egg\deblurrer\model\wrapper.py:42:9: note: called from
        images = tf.map_fn(pre_input, inputs, dtype=tf.float32)
        ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\framework\func_graph.py:957:13: note: called from
            return autograph.converted_call(
            ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py:3299:5: note: called from
    return wrapped_fn(*args, **kwargs)
    ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\def_function.py:441:9: note: called from
        return weak_wrapped_fn().__wrapped__(*args, **kwds)
        ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\framework\func_graph.py:981:7: note: called from
      func_outputs = python_func(*func_args, **func_kwargs)
      ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py:2657:9: note: called from
        func_graph_module.func_graph_from_py_func(
        ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py:2777:7: note: called from
      graph_function = self._create_graph_function(args, kwargs)
      ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py:2446:7: note: called from
      graph_function, _, _ = self._maybe_define_function(args, kwargs)
      ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\ops\map_fn.py:417:3: error: failed to legalize operation 'tf.TensorListReserve'
  return map_fn(
  ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\util\deprecation.py:574:7: note: called from
      return func(*args, **kwargs)
      ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\deblurrer-1.0.0-py3.8.egg\deblurrer\model\wrapper.py:42:9: note: called from
        images = tf.map_fn(pre_input, inputs, dtype=tf.float32)
        ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\framework\func_graph.py:957:13: note: called from
            return autograph.converted_call(
            ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py:3299:5: note: called from
    return wrapped_fn(*args, **kwargs)
    ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\def_function.py:441:9: note: called from
        return weak_wrapped_fn().__wrapped__(*args, **kwds)
        ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\framework\func_graph.py:981:7: note: called from
      func_outputs = python_func(*func_args, **func_kwargs)
      ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py:2657:9: note: called from
        func_graph_module.func_graph_from_py_func(
        ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py:2777:7: note: called from
      graph_function = self._create_graph_function(args, kwargs)
      ^
C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\eager\function.py:2446:7: note: called from
      graph_function, _, _ = self._maybe_define_function(args, kwargs)

Special care to the line Exception: C:\ProgramData\Anaconda3\envs\deblurring-model\lib\site-packages\tensorflow\python\ops\map_fn.py:417:3: error: requires element_shape to be 1D tensor during TF Lite transformation pass. The code:
import tensorflow as tf

class ImageByteWrapper(tf.keras.Model):
    @tf.function(input_signature=[tf.TensorSpec(shape=[None, 1], dtype=tf.string)])
    def call(self, inputs):
        def pre_input(image):
            image = tf.io.decode_image(image)
            image = tf.cast(image, dtype=tf.float32)
            image = (image - 127.0) / 128.0
            return image

        images = tf.map_fn(pre_input, tf.squeeze(inputs, axis=1), dtype=tf.float32)

        return images

def convert(model):
    converter = tf.lite.TFLiteConverter.from_keras_model(model)
    #converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
    #converter.target_spec.supported_ops = [
        #tf.lite.OpsSet.TFLITE_BUILTINS,
        #tf.lite.OpsSet.SELECT_TF_OPS,
    #]
    tflite_model = converter.convert()

    return tflite_model

model = ImageByteWrapper()

test_input = tf.random.uniform(shape=[64, 64, 3], minval=0, maxval=255, dtype=tf.int32)
test_input = tf.cast(test_input, dtype=tf.uint8)
test_input = tf.io.encode_jpeg(test_input)
test_input = tf.stack([test_input, test_input])
test_input = tf.reshape(test_input, [-1, 1])

with tf.device('/cpu:0'):
    test_output = model(test_input)

tflite = convert(model)

I tried different shapes for inputs, like [batch, 1, 1] or [batch], this changes the fn input elements accordingly, but no luck, seems to be a problem with the shape of the inner TensorArray elements, but i dont know how i can have control over that.
Thanks in advance!
PD: I opened a issue on github, but seems collaborator are busy: https://github.com/tensorflow/tensorflow/issues/40221 if you wish to add some details there, you are invited!


text:
Q: Where is MvcRouteHandler registered I'm trying to understand ASP.Net MVC at a lower level.  Specifically, I'm trying to understand how the MVC runtime gets started.  For my initial dig into the call stack / decompilation it appears that it gets started by the MvcRouteHandler which then constructs the MvcHandler.  However, I can't seem to find where the MvcRouteHandler is registered.  How does this RouteHandler get added to the ASP.Net pipeline?
Update
Upon further inspection, I have traced the MvcRouteHandler construction into the RouteCollectionExtensions class which looks to contain extensions for the RouteCollection class.  The specific method that contains the constructor has the following definition:
public static Route MapRoute(this RouteCollection routes,
                             string name,
                             string url,
                             object defaults,
                             object constraints,
                             string[] namespaces)

I believe the key is found in this line of code:
Route route = new Route(url, new MvcRouteHandler());

So, to me this is where the MvcRouteHandler gets assigned.  The overall chain of events looks like this:
Everything starts in Global.asax.cs
Application_Start()
RouteConfig.RegisterRoutes
RouteCollectionExtensions.MapRoute(this RouteCollection routes, string name, string url, object defaults)
RouteCollectionExtensions.MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints)
RouteCollectionExtensions.MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces)

From here, it's just a matter of the route matching, which then causes the MvcRouteHandler to be used which calls into the MvcHandler and starts the entire chains of events.  So my initial assumption that the MvcRouteHandler was registered in a config somewhere was wrong.  Instead, it is configured via the code starting in the Application_Start event in the global.asax.cs file.
Is this correct?

A: The request goes through the ASP.net pipeline and then get caught by the UrlRoutingModule HTTP module.
More info: How does ASP.NET MVC work?
Edit: The routing module is installed in your machine web.config, which your site web.config inherits. You can find it at %systemroot%\Microsoft.NET\Framework\$versionNumber$\CONFIG\Web.config


text:
Q: Capture region of website/etc. to clipboard as image? I often need to capture a fixed portion of my screen (typically in Chrome) to the clipboard, for posting as a background in a PowerPoint slide.
Question
Where can I find an extension for Chrome or an app for Windows 7 that can accomplish the desired (below)?
Desired

*

*Select a region for storage in the clipboard.

Undesired
But because I cannot do that, I need to:

*

*Capture my screen via 3rd party software.

*Save the captured region as a file.

*Paste in the image.

*Crop the image.

*Clipboard the resulting image.

A: You can use extension from Chrome Web Store, like this one:
Awesome Screenshot: Capture & Annotate
Using this tool, you can capture

*

*visible part of page

*selected area

*entire page

*local image

*desktop (premium feature)

If you need to take screenshot of other applications, you can use Snipping Tool.

A: Thanks, Brian (see comments on OP).
Built-in tool
Windows Snipping Tool comes with Windows 7 (and I believe everything from Vista on did).
Usage
(A) Beginners:

*

*Press "Start".

*Type "Snipping Tool".

*Press "Snipping Tool".

*Highlight the region you wish to take into your clipboard.
{Finished}

(B) Experts:

*

*Press "Start".

*Type "Snipping Tool".

*Right-click its icon and press "Properties".

*Under the "Shortcut Properties" tab.

*Press into the "Shortcut Key" field.

*Assign a CTRL + ALT keyboard combination (recommended: left-hand only, like CTRL + ALT + A).

*Press "Okay".

*Use the CTRL + ALT keyboard combination, anytime.

*Highlight the region you wish to take into your clipboard.
{Finished}


text:
Q: Ruby: no such file to load -- EC2 I am using the script from this website: http://dysinger.net/2008/10/13/using-amazon-ec2-metadata-as-a-simple-dns/
I have to say i am a PHPPerson and i know pretty much nothing about ruby. Anyway i am using this scipt on an ec2 instance with Amazon Linux, so I installed ruby and rubygems with yum, and I did
gem install amazon-ec2

$ gem list:
*** LOCAL GEMS ***

amazon-ec2 (0.9.17)
rubygems-update (1.8.25)
xml-simple (1.1.2)

looks good, but when i run the script i get:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require':   no such file to load -- EC2 (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/local/sbin/hosts:2
from /usr/local/sbin/hosts:2:in `each'
from /usr/local/sbin/hosts:2

...why?
I tried to figure this for one hour but still have no idea.

A: The blog post is a little bit outdated. In order to use the amazon-ec2 gem, you need to require 'AWS', not require 'EC2'. This means you have to change the second line to:
%w(optparse rubygems AWS resolv pp).each {|l| require l}

You will also have to change this line:
EC2::Base.new(options).describe_instances # etc...

to
AWS::EC2::Base.new(options).describe_instances # etc...


text:
Q: Is it possible to obtain the shape of an IRL object from the slam algorithm to hide 3D objects? I want to do some test with the AR in Unity, so my idea is to use the ground plane detection of the arcore to instantiate a ring. The ring is made of segments and I want to use an obstacle between the camera and some segment to hide these segments.

I have thought to use the slam to get the shape of the obstacle and use the coordinates to hide (disable or change shader/material) or not the segments behind the obstacle.
I do some researches about Vuforia and I know they use the slam but it does not seem that we can access the shape directly from Vuforia so I thought to use the arcore directly. I think it may be done with spatial mapping.
Because I am not very experienced I prefer to ask about the possibility to do it and if I am in the good way.

A: If I understand correctly, the term you are looking for should be "Occlusion Management". Vuforia. There is a sample package in the asset store, but I don't know how much value it can offer to your cause. Look here
You could as well take a manual approach and integrate your obstacle as Image- or Model-Target, so that you can simply use a virtual replica of your obstacle that hides everything behind it. This however means that your obstacle would have to be always the same object, so I am not sure if this approach is suited for your needs. But this would be the easiest and cleanest way imho.
You can find many tips to get around occlusion problems here


text:
Q: The result of query is different between the client side and the domain service class in a Silverlight application I have a query that brings the whole graph of an object:
IQueryable<Rapport> rap = this.ObjectContext.Rapport.Include("Filtre")
                                  .Include("Filtre.FiltreValeur")
                                  .Include("Tri")
                                  .Include("Section")
                                  .Include("Section.ChampTexte")
                                  .Include("Section.ChampTexte.MiseEnForme")
                                  .Include("Section.Attribut")
                                  .Include("Section.Attribut.MiseEnForme")
                                  .Where(r => r.PK_Rapport == PK_Rapport);

The content of the variable rap is loaded as requested. My problem is that when loading the query, the node "Section" is empty, knowing that it's full at the domain service level.
I load the query as following:
EntityQuery<Rapport> query = _context.GetRapportCompletByIDQuery(_rapport.PK_Rapport);
            _context.Load(query).Completed += (sender1, args1) =>
            {
                this._RapportComplet = ((LoadOperation<Rapport>)sender1).Entities.AsQueryable<Rapport>().First();};

I have no clew how to resolve this. :( HELP!

A: You need to make sure Section has the [Include] directive in your DomainService.Metadata File.


text:
Q: Load images dynamically in gridview onclick I have gridview with image column: Dynamically I am loading id
 <asp:TemplateField HeaderText="Image">
        <ItemTemplate>
            <a href="#" onclick="showImages('<%# Eval("id")%>');">Show Image

         </ItemTemplate>
 </asp:TemplateField>

and on click I am loading the image
    function showImages(id) {
        document.getElementById('img1').src = 'Images/' + id + '.jpg';
    }

the first row loads when I click the "show image" link but when I click on the second row the image does not load. I checked viewsource and I think reason it is not working is because img id is the same for all rows. How do I make the img id also dynamically.
Thanks,

A: you are correct. The reason it is not working is because all your img will have same "id". The simple fix is to generate a dynamic id. You can just append that to your image id.
<asp:TemplateField HeaderText="Image">
        <ItemTemplate>
            <a href="#" onclick="showImages('img<%# Eval("id")%>');">Show Image
            <img id='img<%# Eval("id")%>' />
         </ItemTemplate>
 </asp:TemplateField>


text:
Q: Is there an easy way to reposition views in iOS without manually changing origin/size/center? I find myself often having to reposition subviews of a view after hiding or showing one of them. The way I'm doing this is by programmatically changing a view frame's origin and/or size, or its center. But is there an easier way I'm missing? Is there a way to do it with Autosizing masks?

A: I don't think there's any automatic way of doing this. You could probably get clever about how you do it programmatically (e.g. if you used a set of sequential tag identifiers, you could loop through and calculate the height of the previously visible tag to calculate the origin of the next subview; or if there are a group of subviews that are always going to move together, you could put them in a container UIView and thus move a whole bunch of them by just moving their container view; etc. ... it depends upon how they're laid out and which fields might be hidden).
This won't help you for now, but check out WWDC 2012 session 202 for a discussion of a relevant improvement in iOS 6.


text:
Q: How to make text with a multiple of 16 in length? I have strings with different lengths, for example:
text_1 = 'example'
text_2 = 'a'
text_3 = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi.'

and I must add to them chars (any) because text must be a multiple of 16 in length.
I need it to do this:
c = AES.new('somekey', AES.MODE_ECB)
e_data = cipher.encrypt(text)

How can I do it?

A: This should do:
>>> s = 'fooo'
>>> s += ' ' * (16 - (len(s) % 16))
>>> s
'fooo            '
>>> len(s)
16

Here the number of characters needed is 16 - (len(s) % 16) because len(s) % 16 is the number of characters left over when you divide the length by 16.

A: Add on the difference between 16 and the modulo
text_1 += ((16 - len(text_1) % 16)*'X')


text:
Q: Is appending the html faster than pasting it multiple times? Say that I have a

 that I need placed in 5 different places in a single HTML page. That statistics div has a 6 row long list.
My question is this..
Is it faster to use:

and then use jquery like this:
$( ".statistics" ).append( $(

content

content

content

content

content

content

'));

...rather than copy/paste the code in those 5 different places ?

A: If the content is always going to be the same then, or when it's updated it will need to be updated the same in all five places then appending the div via jQuery would be a quicker option and provide one maintainable place.
Though you would probably want to change your script to
$(".statistics").each(function(){
   $(this).append("
 ...
");
});

In order to append to each div. There's better alternatives to this like using a template engine or even php to include a HTML file which would have the six rows in it.

A: If you want faster and efficient with use of jQuery we can use it with native js
$('.statistics').each(function(i) {
    var newDOM = document.createElement('ul');
    newDOM.innerHTML = '
content

content

content

content

content

content
';

    this[i].appendChild(newDOM);
});


text:
Q: Phone Number display method, sql query Please help me with the below query,please modfiy and let me know,I use ssms
I need to display only Phonenumber. Below is the query I'm using as of now. I divide it using two columns because there might be cell number and home phone.
 CONCAT(RIGHT(LEFT(HR_PN_1.PhoneNumberID, 4), 3), REPLACE(RIGHT(HR_PN_2.PhoneNumberID, 8), '-', '')) as 'PersonPhone',
    CASE
        WHEN HR_PN_2.PhoneNumberID is not null
    THEN CONCAT(RIGHT(LEFT(HR_PN_2.PhoneNumberID, 4), 3), REPLACE(RIGHT(HR_PN_2.PhoneNumberID, 8), '-', ''))
    END as 'PersonWorkPhone',

Example  of data in the PhoneNumnberID column, I have in my table HR_PN_1 and HR_PN_2 is as follows:
(123)456-7890TOMMY
(123)456-7890 DAD
(123)456-7890 ***
(123)456-7890 2300
(123)456-7890CELL#
(123)456-7890

I need these numbers to be displayed as only in phone number format (123)456-7890

A: If those are the values in the column, then you would seem to want:
LEFT(HR_PN_1.PhoneNumberID, 13)

A: If those phonenumbers are always at the start then a simple LEFT will suffice.
And if the position of the phonenumber can change, but it's always in the same format?
Then you could combine SUBSTRING with PATINDEX.
SUBSTRING(PhoneNumberID, PATINDEX('%([0-9][0-9][0-9])[0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]%', PhoneNumberID), 13)

Then wrapping it in a CASE just to avoid returning something that's not a phonenumber.
Example snippet :
declare @HR_PN_1 table (HR_ID int identity (1,1) primary key, PhoneNumberID varchar(100));
declare @HR_PN_2 table (HR_ID int identity (1,1) primary key, PhoneNumberID varchar(100));

insert into @HR_PN_1 (PhoneNumberID) values
('(123)456-7891TOMMY'),
('(123)456-7892 DAD'),
('(123)456-7893 ***'),
('(123)456-7894 2300'),
('(123)456-7895CELL#'),
('(123)456-7896'),
('no phone');

insert into @HR_PN_2 (PhoneNumberID)
select PhoneNumberID
from @HR_PN_1
order by HR_ID desc;

SELECT hr1.HR_ID,
(CASE
 WHEN hr1.PhoneNumberID like '%([0-9][0-9][0-9])[0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]%'
 THEN SUBSTRING(hr1.PhoneNumberID, PATINDEX('%([0-9][0-9][0-9])[0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]%', hr1.PhoneNumberID), 13)
 END) AS "PersonPhone",
(CASE
 WHEN hr2.PhoneNumberID like '%([0-9][0-9][0-9])[0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]%'
 THEN SUBSTRING(hr2.PhoneNumberID, PATINDEX('%([0-9][0-9][0-9])[0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]%', hr2.PhoneNumberID), 13)
 END) AS "PersonWorkPhone"
FROM @HR_PN_1 AS hr1
LEFT JOIN @HR_PN_2 AS hr2 ON (hr2.HR_ID = hr1.HR_ID);

A: How about this?
SELECT SUBSTRING(yourcolumn, PATINDEX('%([0-9][0-9][0-9])[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]%',yourcolumn), 13)
FROM yourtable


text:
Q: Re-looping an array item in a for loop I have a for loop that checks for conditions and I want to know if I can re-run an item through the loop if it doesn't meet the condition after I make some changes to variables.
is it possible to add something to my else statement that will allow me to re-run the same $item under new conditions?
$array_1 = array();
$arraynumber = 0;
foreach($test_array as $item) {
     if($item[2] == $test_array[$y][2]) {
          $array_1[$arraynumber][] = $item;
          $z++;
     } else {
          $arraynumber++;
          $y = $y+$z;
          $z=0;

          echo $item[2];
     }
}

The solution turns out to be this, just for those interested:
foreach($test_array as $item) {
if($item[2] == $test_array[$y][2]) {
  $array_1[$arraynumber][] = $item;
 $z++;
}elseif($item[2] == $test_array[$y+$z][2]){
$array_1[$arraynumber+1][] = $item;

 $y = $y+$z;
  $z=1;

  $arraynumber++;
}else{
$array_1[$arraynumber+2][] = $item;
 $z++;
 $y = $y+$z;
  $z=0;
  $arraynumber++;

echo $item[2];
}
}

A:
re-run an item through the loop

You could use prev() which will set the internal data pointer 1 step back.
prev($test_array); //will re-run the current element in the next iteration

A: You can use
While(true){
//your code
}

before the for loop, but make sure you break the loop, otherwise it will become infinite loop and hanged your server.

A: $array_1 = array();
$arraynumber = 0;
foreach($test_array as $item) {
  if($item[2] == $test_array[$y][2]) {
     $array_1[$arraynumber][] = $item;
     $z++;
  }elseif("Your Second statment"){
   echo 'Your second Task';
  }else{
    $arraynumber++;
    $y = $y+$z;
    $z=0;

    echo $item[2];
  }
}

A: You can also use GOTO .
Example
<?php
for($i=0,$j=50; $i<100; $i++) {
  while($j--) {
    if($j==17) goto end;
  }
}
echo "i = $i";
end:
echo 'j hit 17';
?>

A: Use multilevel break, like this one -
$flag=0;
while(true) {
    while($cond) {
        if($cond2) {
            $flag=1;
            break;
        }
    }
    if($flag) break;
}


text:
Q: How to format the default tooltip to show dates When you hover over the bars you will see the raw epoch times.
How can I convert it to a readable date format, something like this:
tooltip: {
    formatter: function() {
        return  '' + this.series.name +'
' +
            Highcharts.dateFormat('%m-%d-%Y', new Date(this.series.data[0].low)) + ', ' +
            Highcharts.dateFormat('%m-%d-%Y', new Date(this.series.data[0].high));
    }
},

Here is my JSFiddle, http://jsfiddle.net/6qsvjark/157/.


text:
Q: What is the relationship between the lengths of the binary and decimal representations of a number? If a is 1024 bits, then how many digits will its decimal representation have?

A: Bits are binary numerals.  If you have an 8-bit numeral, say 10110001, that is exactly an 8-bit binary numeral.  In fact "bit" is an abbreviation of "binary digit".
When converted to decimal, an $n$-bit binary numeral will have at most $kn$ decimal digits, rounded up, where $k = \log_{10} 2 \approx 0.301$.  So an 8-bit binary numeral, say 10110001, will have around $8\cdot 0.301 = 2.408$ decimal digits—round up to 3.  In this example, $10110001_2 = 177_{10}$, and 177 has three decimal digits.
A 1024-bit binary numeral therefore has about 309 decimal digits.

A: This is just plain wrong.
The number of bits base 2 in 9 is 4
The number of bits base 2 in 10 is 4
Therefore, according to the answer.. regardless of the value of k
The number of digits in both 9 and 10 will be the same...
which is just plain wrong. :)
i think the presumption of that answer is that the number of bits
in n is the same as log2(n)

A: This is actually found using two Log functions. (LOGOT)*(LOGON) where O is your original base, T is your target base, and N is the number you want to translate. This will give you the number of digits you need to represent N number of values in the other base.
This stems from the number of digits your O base is represented by in the target base, a measure that will give you the value of a multiplier which, when multiplied by the number of digits in your number from the O base, gives you the number of digits the target base requires to support the translated number.
Note, any decimal value over zero should be rounded up.
This has been useful in translating desired supported values to hexadecimal array length.


text:
Q: How to change starts image of rating bar in android How can I change the starts image in the android rating bar?
I need it to show it to the user.
Or if not possible - how can show X images of start in a specific possition in the layout?
Yoav

A: I hope I understod your question - you want to use RatingBar and set custom images?
Android's RatingBar already displays stars, but if you want custom image then Define a custom style
<style name="customRatingBar" parent="@android:style/Widget.RatingBar">
    <item name="android:progressDrawable">@drawable/custom_image</item>
    <item name="android:indeterminateDrawable">@drawable/custom_image</item>
</style>

And then use it
<RatingBar style="@style/customRatingBar" ... />

A: First create one drawable
 <?xml version="1.0" encoding="utf-8"?>
  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@android:id/background"
        android:drawable="@drawable/rating_bar_empty" />
    <item
        android:id="@android:id/secondaryProgress"

        android:drawable="@drawable/rating_bar_empty" />
    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/rating_bar_filled" />
</layer-list>

then use drawable in rating bar attribute   `android:progressDrawable="@drawable/drawable_rating_stars"'
 <RatingBar
                    android:id="@+id/ratingBar"
                    style="?android:attr/ratingBarStyleIndicator"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:isIndicator="false"
                    android:numStars="5"
                    android:progressDrawable="@drawable/drawable_rating_stars"
                    android:scaleX="1"
                    android:scaleY="1"
                    android:stepSize="1.0" />


text:
Q: Is there an blockIdx equivalent for thread_groups or thread_block_tiles? I started using cooperative_groups and find myself often to wish for a method that replaces the second line.
thread_block_tile<32> tile = tiled_partition<32>(this_thread_block());
int tileId = this_thread_block().thread_rank()/tile.size();

My assumption here is that:

*

*tileId is the same for every thread in the same tile.

*The tileId goes from 0 to (this_thread_block().size())/tile.size().

I looked into https://devblogs.nvidia.com/cooperative-groups/ and https://docs.nvidia.com/cuda/archive/9.2/cuda-c-programming-guide/index.html#thread-block-tiles-cg. In both sources there is an example similar to:
thread_group tile4 = tiled_partition(this_thread_block(), 4);
if (tile4.thread_rank()==0)
printf("Hello from tile4 rank 0: %d\n",
       this_thread_block().thread_rank());

that produces:
Hello from tile4 rank 0: 0
Hello from tile4 rank 0: 4
Hello from tile4 rank 0: 8
Hello from tile4 rank 0: 12

Which seems to fit with the assumptions.
I am left with two questions:

*

*Does my assumptions hold for the presented way to calculate tileId?

*Is there an simpler way to achieve the desired behavior that I missed?

Example usecase
__device__
int someFkt(thread_block_tile<16> tile, int* data)
{
   // some stuff that works best using 16 threads
}

__global__
void some_kernel(int* data)
{
   thread_block_tile<16> tile = tiled_partition<16>(this_thread_block());
   int tileId = this_thread_block().thread_rank()/tile.size();
   int result = someFkt(tile,data+tileId*tile.size());
}

A: It is correct that the

tileId goes from 0 to (this_thread_block().size())/32

if the tile size was 32.
And the tileId is indeed the same for all the threads in the same tile. These tileIds are also the same for all the blocks, so all the blocks have tileId 0, 1, ...
Only thread_block provide its index:

whereas thread_block provides the following additional block-specific
  functionality:
dim3 group_index(); // 3-dimensional block index within the grid
dim3 thread_index(); // 3-dimensional thread index within the block

Not sure if this was a typo in your example use case:

int tileId = this_thread_block().thread_rank()/32;

The correct from is:
int tileId = this_thread_block().thread_rank()/16;


text:
Q: Make modal windows/dialog boxes open over parent application I am using a 40" 4K TV as a computer monitor. So I frequently have multiple applications open on different parts of the screen. I often move windows around, but it seems that Windows or Windows apps is/are designed to remember the absolute location on a screen where a modal window last was. The result is that dialog boxes and other sub-windows of applications are frequently popping up on the other side of the screen from where the application window actually is.
If things were better designed I would expect modal windows to remember their position relative to their parent window. That would make things less disorienting. I forget how it works on multiple monitors. Do modals at least pop-up on the same monitor as the app that spawns them?
Anyway, I am wondering if there is any possible way to force the behaviour I am looking for. Even a hotkey solution would be better than nothing. I was thinking of making an Autohotkey script to send Alt, Space, M, Any Arrow Key, which would then at least attach the window to the mouse so it could quickly be repositioned. But that only works for certain windows like Open and Save dialogs.

A: Usually position is handled in the app to make sure its on top, same window instead of default one for popup boxes, etc.
There are a few 3rd party apps that will automatically position a new window base off of title, app, etc. I'll let you lookup alternatives but a quick search will bring you WinSize2, TaskLayout
I also see a powershell module called UIAutomation, which you could script into your AHK setup.
UIAutomation Usage


text:
Q: understanding the insert method in Tkinter's Entry widget I've been going through a tutorial on Python's Tkinter, I'm currently working with the Entry widget and just came across the insert method. I understand what the method does (makes a default string to appear in a text entry field), but what I don't get is the method's first parameter, which to the best of my understanding is the index at which the string should start. now here comes the confusion. When playing around with it, giving different values for the index parameter, every time I run it the text appears in the same spot (at the very beginning). So as best I can tell, I'm either doing something wrong or, I'm misunderstanding the documentation. this is a snippet from my code:
 e1 = Entry(master)
 e1.insert(0,"First Name")

When ever I run this, weather the index is 0, 10 or 100 the text "First Name" always appears at the very beginning of the text field

A: First, the statement "makes a default string appear" is not quite true. While it can be used to insert default text, it more correctly is described simply as inserting text, period. It can be default text, replacement text, additional text, whatever you want.
Any index that is before the first character is treated as 0 (zero). Any index that is after the last character is treated as being the end. When you insert something into an entry widget that is empty, every index is treated as 0. Thus, the index is mostly useful for inserting text somewhere into existing text.
For example:
e1 = Entry(master)
e1.insert(0, "hello")
e1.insert("end", "world")
e1.insert(5, ", ")

As an application programmer, you will almost never use the insert method with anything other than an index of 0 (zero) or "end", and perhaps "insert". However, when you try to add advanced functionality (eg: spell checking, auto-complete, etc) you will find the index to be highly useful.

A: In this line:
text.insert('1.0', 'here is my\ntext to insert')

The "1.0" here is the position where to insert the text, and can be read as "line 1, character 0". This refers to the first character of the first line. Historically, especially on Unix, programmers tend to think about line numbers as 1-based and character positions as 0-based.
The text to insert is just a string. Because the widget can hold multi-line text, the string we supply can be multi-line as well. To do this, simply embed \n (newline) characters in the string at the appropriate locations.
From the Tk docs https://tkdocs.com/tutorial/text.html

A: you use it when you use multiple insert() method
for example:
e = Entery(window)
e.pack()
e.insert(0, "Hi")
e.insert(2, " there")
Note : in " there" you should have a space behind it or else it will appear like this (Hithere)


text:
Q: How to Remove  Link Tag for a Specific Value using Jquery I have the following situation within a report that has the following  element. Please note that this can appear multiples times as it is a report.
My question is, when the value is 'N', using jQuery, I would like to remove the whole  tag and just display the value of 'N' alone, without the underline below it, otherwise if the value is 'Y' then leave it as it is.
For example:
Y

N

A: $('a').filter(function(){
    return this.innerHTML === 'N';
}).replaceWith('N');

Live DEMO

A: Add a class name of your choice so that you can have more control over your td elements out of all td elements present: for eg: "report_td"
so html look like this:
...

Then try like this:
$(function(){
  $("td.report_td").each(function(i, e){
    var tdElement = $(e);
    var value = tdElement.find("a").text();
    if(value == "N") {
      tdElement.html("N");
    }
  });
});

A: $('a').each(function() {
if ( $(this).text() == 'N') {
    $(this).replaceWith('N');
}
});


text:
Q: Graying out HTML form elements I want to let the user select one "row" to use to submit the with to request a report type.  How can I put radio buttons in the first column of a table and whichever is selected is the active row that gets sent to the next page via the submit button?

A: I think Andreas is on the right track, but it's not as useful as it could be.  This should be a bit better:
<?php
blah ...

echo <<<HTML
    <form action="handler.php" action="post">

HTML;

foreach ($rows as $row)
{
    $id = $row['id'];
    $text = $row['text'];  // escape this unless you know it's safe

    echo <<<HTML

            <input type="radio" value="$id" name="theRadioButton" />
            <input type="text" name="textfield_$id" value="$text" />

HTML;
}

echo <<<HTML

</form>
HTML;

form handler:
<?php
    $id = isset($_POST['theRadioButton']) ? $_POST['theRadioButton'] : null;

    if ($id)
    {
        $textfield = $_POST["textfield_$id"];
    }
?>

A: If you want to do it in pure PHP, i guess you could do this:
<form action="ascript.php" action="post">

            <input type="radio" value="row1" name="theRadioButton" />
            <input type="text" name="row1textfield" />

            <input type="radio" value="row2" name="theRadioButton" />
            <input type="text" name="row2textfield" />

            <input type="radio" value="row3" name="theRadioButton" />
            <input type="text" name="row3textfield" />

</form>

ascript.php
<?php
    if ($_POST['theRadioButton'] == "row1") {
        echo $_POST['row1textfield'];
        // Handle row 1 ..
    }
    else if ($_POST['theRadioButton'] == "row2") {
        echo $_POST['row2textfield'];
        // Handle row 2 ..
    }
    else if ($_POST['theRadioButton'] == "row3") {
        echo $_POST['row3textfield'];
        // Handle row 3 ..
    }
?>

However, if you're willing to use some jQuery, you could just name the textfields the same thing and disable the fields you're not going to use. Here's a fiddle: http://jsfiddle.net/rrvQu/1/