text:
Q: VS Code causes 17.10, 18.04 randomly and completely freeze Please read: See the last bit. I don't believe this is an issue related to Ubuntu, but rather VS Code.
Recently, under 17.10 and 18.04 (I just upgraded today), Ubuntu will randomly and completely freeze. I cannot move the cursor or use the keyboard. Naturally, I have tried switching to a TTY session with no success. Every time, I must resort to SysRq + REISUB, which is (obviously) not preferred.
I have attempted to switch graphics drivers, on the theory that it may be that. I was originally using the open source nVidia driver, and switched to the proprietary to no avail. I'm currently using the open source driver.
All that I typically have open is Firefox (not a ton of tabs loaded) and VS Code, with at most a couple files and a terminal open.
Any ideas?
Update: The system logs show no indication of anything at all happening, let alone something wrong. I don't know if this is related, but sometimes (and especially after booting) programs take a significant amount of time (> 5-10 seconds), even command line programs.
Yet another update! — Even with all GNOME extensions disabled, it still crashed. I tried XFCE, which still crashed.
Summary: Ubuntu completely freezes at seemingly random times, leaving no trace in logs, and is not related to any specific desktop environment or GNOME extensions.
(likely final) update: I'm convinced this is an issue with VS Code. I have been running GNOME for days, with other Electron apps open (Slack, Pulse, etc.), and have not had a single freeze. I have DM'd VS Code on Twitter, and will likely file a bug report as they haven't responded yet.

A: I just ran into this. Upon launch, in a big project, my system would freeze after ~20 seconds and become unresponsive (Ubuntu 18.04).
Running htop while launching VSCode showed that it took all the cores to 100% (i7-8700K), ate all the memory (16gb) and then the swap. The freeze happened moments later.
This was happening because of a bad extension, in my case it was CSS Peek.
So try launching vscode with extensions disabled (code --disable-extensions) and see if it still happens. If it doesn't track down the faulty extension and send it to hell.
I had random full freezes happening and spent quite a few hours trying to find out why. On restart the logs were really not helpful. I initially thought it was the nvidia driver, but no - just a VSCode extension.

A: I got the same issue in my Ubuntu 16.04.
I did switch off git.autorefresh in the Settings, then it works flawlessly and smoothly

A: I've experienced the same problem.
Eventually I realized that in my case the problem is running out of memory (I have 8gb ram and just 1gb swap partition on disk).
I fixed this by allocating additional swap space using file in my root directory:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

this will temporary enable additional 8gb of swap for your system. If it will help, here you can read further instructions for enabling new swap constantly.
Another options are: add RAM physically or add/enlarge swap partition.
I used new swap as a file because I got luks+lvm encrypted system and resizing existing swap partition is too complicated and risky in my case.
P.S. I got Ubuntu 18.04

A: I had the same issue. To fix this for a particular project you will want to update the .vscode/settings.json to look something like this:
{
  "python.pythonPath": "/usr/bin/python3",
  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    "**/node_modules": true,
    "**/.firebase": true
  },
  "files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/**": true
  }
}

A: For me, disabling gpu when calling vscode solved the problem.
Do it by using this alias to open vscode:
alias code='code --disable-gpu'

A: So it turns out that this isn't specific to Ubuntu, but I'll post this here anyways for future reference.
Apparently, even though I'm ignoring certain files using the files.exclude setting (notably the ./node_modules directory), VS Code still watches those files for changes.
To solve that, simply copy the list from files.exclude to files.watcherExclude. This will prevent VS Code from searching the many thousands of files that are in node_modules or other similar directories. That way, it will leave some RAM for Chrome to gobble up.

A: I have also suffered from random system crashes when running VSC. Even tried to start without extensions, which didn't help me at all. A few times my system froze right on startup of VSC.
However, I checked the logs and found that these crashes might correlate to the graphics driver (NVidia GTX 660).
Solution in my case: Switching from Nouveau to proprietary driver (I have chosen the metapackage)
Btw: Using Ubuntu 18.04

A: I had tried above workarounds and no luck.
For me, set the intel_idle.max_cstate=1 parameter in grub worked perfectly.
sudo cp /etc/default/grub /etc/default/grub.backup
sudo nano /etc/default/grub
# find the line begin with GRUB_CMDLINE_LINUX_DEFAULT
# append intel_idle.max_cstate=1 to original parameters.
sudo update-grub

reboot it.

A: For me following workaround worked
Open the Command Palette (Ctrl+Shift+P).
Run the Preferences: Configure Runtime Arguments command. This command will open a argv.json file to configure runtime arguments.
You might see some default arguments there already.
Add
"disable-hardware-acceleration": true
Restart VS Code.

A: Download VSCode and extract it. You'll see a file name "code" in the folder. Open a terminal and navigvate to that folder. Enter the command
./code --disable-gpu

via phero_constructs on reddit
Also, see this issue comments. You can do CTRL+SHIFT+P, then find Preferences Configuration. Insert this into the json (don't forget to add a comma after the preceding entry):
"disable-hardware-acceleration": true

A: After some recent vscode update I came across the same issue, tried almost everything except increasing Swap area but none seemed to work. The reason was vscode plugin eating up 80% of the RAM inside. The interesting part was this extension was not even showing up in vscode.
Next time you open vscode keep a terminal handy and use this command to monitor the RAM usage.
free -m

When you see a very low available RAM then just type this command.
ps -aux

Now just check for the process that is eating most percent of your RAM. For me it was gopls plugin for golang. I just deleted the binary related to this process as its location was also clearly given by above command and restarted vscode. This solved the issue.
P.S I'm using Ubuntu 18.04 LTS

A: For me it was happening because of this extension Laravel Extra Intellisense,
Even though i would start with --disable-extensions it didn't work i had to uninstall it

A: If you use cmake from VS Code, it uses all processors and then GUI frezees. You must decrease number of processor usage like below:

*

*Enter file>preference>settings at VS Code

*Search cmake.parallelJobs at settings panel search

*Set cmake.parallelJobs to a value less than nproc
Note: You can find number of processing units using "nproc" command at terminal.


text:
Q: Reload app after cache.manifest refresh Whenever I update my webapp, the user must load the page twice in order to see the updates.
Because the browser downloads the new updates after the app has already loaded.
Is there any way to attach a trigger to show "updating app" or something, then reload the page upon completion?
CACHE MANIFEST
# Dec 12, 2014 v4

CACHE:
index.html
/assets/css/main.css
http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic
http://fonts.googleapis.com/css?family=Raleway:400,300,700
http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
/assets/js/all.js?v=2

NETWORK:
*
HTTP://*

A: You can use the events provided to detect an updated manifest using javascript:
function onUpdateReady() {
    window.location.reload();
}
window.applicationCache.addEventListener('updateready', onUpdateReady);
if(window.applicationCache.status === window.applicationCache.UPDATEREADY) {
  onUpdateReady();
}

Source
There are more events you can use to detect certain states:

*

*cached

*checking

*downloading

*error

*noupdate

*obsolete

*progress

*updateready

Source

redpajama_set_name: RedPajamaStackExchange


text:
Q: Querying UserType's in NHibernate I have the following scenario:
Let's say that my "Product" table in this legacy database has a "Categories" column of type string. This column stores the category ID's separated by some sort of ascii character. For instance: "|1|" (for category 1), "|1|2|3|" (for categories 1, 2, and 3), etc.
Instead of exposing a string property for that, I want to expose an IEnumerable, so that users of my Product class don't have to worry about parsing those values.
I'm creating a SelectedCatories type that's simply an IEnumerable, and my Product class looks like this:
public class Product
{
    public virtual Guid Id { get; set; }
    public virtual string Name { get; set; }
    public virtual bool Discontinued { get; set; }
    public virtual SelectedCategories Categories { get; set; }
}

I then created a SelectedCategoriesUserType class like so:
public class SeletedCategoriesUserType : IUserType
{
    static readonly SqlType[] _sqlTypes = {NHibernateUtil.String.SqlType};

    public bool Equals(object x, object y)
    {
        // Fix this to check for Categories...
        if (ReferenceEquals(x, y)) return true;
        if (x == null || y == null) return false;
        return x.Equals(y);
    }

    public int GetHashCode(object x)
    {
        return x.GetHashCode();
    }

    public object NullSafeGet(IDataReader rs, string[] names, object owner)
    {
        object obj = NHibernateUtil.String.NullSafeGet(rs, names[0]);
        if (obj == null) return null;

        string[] stringCategories = obj.ToString().Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries);

        var categories = new Categories();

        return
            new SelectedCategories(
                stringCategories.Select(
                    stringCategory => categories.Single(cat => cat.Id == int.Parse(stringCategory)))
                    .ToList());
    }

    public void NullSafeSet(IDbCommand cmd, object value, int index)
    {
        if (value == null)
        {
            ((IDataParameter) cmd.Parameters[index]).Value = DBNull.Value;
        }
        else
        {
            var theCategories = (SelectedCategories) value;

            var builder = new StringBuilder();
            builder.Append("|");
            theCategories.ForEach(i => builder.AppendFormat("{0}|", i.Id.ToString()));

            ((IDataParameter) cmd.Parameters[index]).Value = builder.ToString();
        }
    }

    public object DeepCopy(object value)
    {
        return value;
    }

    public object Replace(object original, object target, object owner)
    {
        throw new NotImplementedException();
    }

    public object Assemble(object cached, object owner)
    {
        throw new NotImplementedException();
    }

    public object Disassemble(object value)
    {
        throw new NotImplementedException();
    }

    public SqlType[] SqlTypes
    {
        get { return _sqlTypes; }
    }

    public Type ReturnedType
    {
        get { return typeof (SelectedCategories); }
    }

    public bool IsMutable
    {
        get { return false; }
    }
}

I then want to build a query that gives me back any product that belongs in a specific category (say, category 2), matching both "|2|", and "|1|2|3|".
Right now, my naive implementation that barely makes my test pass looks like this:
    public IEnumerable<Product> GetByCategory(Category category)
    {
        using (ISession session = NHibernateHelper.OpenSession())
        {
            return session
                .CreateSQLQuery("select * from product where categories LIKE :category")
                .AddEntity(typeof(Product))
                .SetString("category", string.Format("%|{0}|%", category.Id))
                .List()
                .Cast<Product>();
        }
    }

My question is: what's the proper way to right that query?

A: A different way to do that ICriteria query would be this...
return Session
    .CreateCriteria(typeof(Product), "product")
    .Add(Expression.Sql(
        "{alias}.categories LIKE ?",
        string.Format("%|{0}|%", category.Id),
        NHibernateUtil.String))
    .List<Product>();

However, you may want to think about setting up a many-to-many table between Product and Category and setting up a collection of Categories in the Product class. You can still keep your field of concatenated Category Ids (I assume it's needed for legacy purposes), but tie it to the collection with something like this.
public virtual ISet<Category> Categories { get; private set; }

public virtual string CategoriesString
{
    get { return string.Join("|", Categories.Select(c => c.Id.ToString()).ToArray()); }
}

Doing something like this will let you set foreign keys on your tables, and make the queries a bit easier to construct.
return Session
    .CreateCriteria(typeof(Product), "product")
    .CreateCriteria("product.Categories", "category")
    .Add(Restrictions.Eq("category.Id", category.Id))
    .List<Product>();


text:
Q: how to add widget in submenu of wordpress theme I want to add widget in second layer of wordpress menu. and it should be changable from admin panel. as for example if i add calendar widget in second layer than it can be move to another menu or should be able to add another widget.

A: It might be a little too late, but here's the solution I've found to this problem. It might still be helpful to someone out there ;P
First I tried making use of the Max Mega Menu plugin, it was giving too many features I didn't need besides the ability to add widgets to the menu.
But the following plugin takes care of that in a very simple and practical way: Widgets in Menu.
Give it a try, this one did it for me ;)


text:
Q: jQuery clone form increment all attributes of name,class,id,data-id ..etc Our form contain multiple fields and we need to do by jQuery

*

*when cloning fields need increase it's Name, Class, Id,data-id and label for .

How increase IDs like these
block-post-order-1-select
Or names like this
name="xform_demo[block-post-order-1]
You can check this form code
at codepen http://codepen.io/earngate/pen/NxPOZz/
HTML

    Block

    <fieldset id="xform_demo-switch-fold-1" class=" xform-container-switch" data-id="switch-fold-1" data-type="switch">

    On
    Off
    <input class="checkbox checkbox-input" id="switch-fold-1" name="xform_demo[switch-fold-1]" value="1" type="hidden">

    </fieldset>

    Text logo

    <fieldset id="xform_demo-block-cat-title-1" class="xform-container-text " data-id="block-cat-title-1" data-type="text">
    <input id="block-cat-title-1" name="xform_demo[block-cat-title-1]" value class="regular-text " type="text" size="20"></fieldset>

    <fieldset id="xform_demo-block-post-order-1" class=" xform-container-select" data-id="block-post-order-1" data-type="select">

    first-choise

    <input id="s2id_autogen2" aria-labelledby="select2-chosen-2" class="select2-focusser select2-offscreen" aria-haspopup="true" role="button" type="text" size="20">

    <input placeholder id="s2id_autogen2_search" aria-owns="select2-results-2" spellcheck="false" class="select2-input"  type="text" size="20">

    <select title tabindex="-1" id="block-post-order-1-select" name="xform_demo[block-post-order-1]" class="xform-select-item " style="width: 40%; display: none;" rows="6">
    <option></option>
    <option value="Desc" selected="selected">Lates</option>
    <option value="rand">Random Posts</option>
    </select></fieldset>

    Block Style

    <fieldset id="xform_demo-block_type_1" class=" xform-container-image_select" data-id="block_type_1" data-type="image_select">

    <input class=" compiler noUpdate " id="block_type_1_1" name="xform_demo[block_type_1]" value="node" checked="checked" type="radio">

    <input class=" compiler noUpdate  noUpdate " id="block_type_1_2" name="xform_demo[block_type_1]" value="nodey" type="radio">

    </fieldset>

jQuery
    $(document).ready(function () {
    $('table#section-table-section-start1').after('<input class="add_btn" id="add_btn" type="button" value="Add New">');

    $(".add_btn").click(function(e) {
    var avails = $(this).prevAll();
    var cnt = avails.length + 1;

    $('#section-table-section-start1:last').clone().insertAfter("#section-table-section-start1:last").append( $('<input class="del_btn"  type="button" value="Delete this">') );

    $("input.del_btn").css({"float":"right","background-color":"#c00","color":"#fff"});

    e.preventDefault();
    });

    $("body").on('click',".del_btn", function() {
    $(this).parent().remove();
    });

    });

Can you help

A: So the question seems to be "how to increase the number in multiple attributes of multiple nodes."
I will narrow it down to increasing the last integer in multiple attributes, to keep it simple.
You can create a simple function to increase the number of one attribute of one node, then repeat it for the elements and attributes you need:
/* Increase the last number for an attribute of an jQuery element, if possible */
function inc ( node, property ) { // .prop does not work with data-id so must use .attr
   var number = node.attr( property ) ? node.attr( property ).match( /\d+(?=\D*$)/ ) : null;
   if ( number === null ) return; // Abort if has no attribute or no number in it
   node.attr( property, node.attr( property ).replace( /\d+(?=\D*$)/, +number[0]+1 ) );
}

var last = $('[id^=section-table-section-start]:last'), cloned = last.clone();

// For each element with any attribute we need, including the cloned table
cloned.find( '[name],[class],[id],[data-id],[for]' ).add( cloned ).each( function(){
   var me = $( this );
   // Loop and increment each property
   $.each( [ 'name', 'className', 'id', 'data-id', 'for' ], function( i, property ) {
      inc( me, property );
   });
});

There are a few ways to do the loop.

*

*Here we grab all elements and loop each property on each of them.

*If you have less properties you can manually call inc for each property instead of $.each.

*Alternatively you may loop each property first and find the elements, this way you create more jQ objects but check less properties.

You may also notice that I changed your clone code, because with the auto-increasing id you can't pick the last table by id any more.
Here is the full code:

$( function () {
   function inc ( element, property ) {
      var number = element.attr( property ) ? element.attr( property ).match( /\d+(?=\D*$)/ ) : null;
      if ( number === null ) return;
      element.attr( property, element.attr( property ).replace( /\d+(?=\D*$)/, +number[0]+1 ) );
   }

   $('table#section-table-section-start1').after('<input class="add_btn" id="add_btn" type="button" value="Add New">');

   $(".add_btn").click(function(e) {
      var last = $('[id^=section-table-section-start]:last'), cloned = last.clone();
      cloned.find( '[name],[class],[id],[data-id],[for]' ).add( cloned ).each( function(){
         var me = $( this );
         $.each( [ 'name', 'className', 'id', 'data-id', 'for' ], function( i, property ) {
            inc( me, property );
         });
      });
      cloned.insertAfter( last );
      if ( ! cloned.find( '.del_btn' ).length ) {
         cloned.append(
            $( '<input class="del_btn"  type="button" value="Delete this">' )
               .css({"float":"right","background-color":"#c00","color":"#fff"})
         );
      }
      e.preventDefault();
   });

   $("body").on('click',".del_btn", function() { $(this).parent().remove(); });
});

            Block

         <fieldset id="xform_demo-switch-fold-1" class=" xform-container-switch" data-id="switch-fold-1" data-type="switch">

                  On

                  Off

               <input class="checkbox checkbox-input" id="switch-fold-1" name="xform_demo[switch-fold-1]" value="1" type="hidden"/>

         </fieldset>

            Text logo

         <fieldset id="xform_demo-block-cat-title-1" class="xform-container-text " data-id="block-cat-title-1" data-type="text">
            <input id="block-cat-title-1" name="xform_demo[block-cat-title-1]" value class="regular-text " type="text" size="20"/>
         </fieldset>

         <fieldset id="xform_demo-block-post-order-1" class=" xform-container-select" data-id="block-post-order-1" data-type="select">

                  first-choise

               <input id="s2id_autogen2" aria-labelledby="select2-chosen-2" class="select2-focusser select2-offscreen" aria-haspopup="true" role="button" type="text" size="20"/>

                     <input placeholder id="s2id_autogen2_search" aria-owns="select2-results-2" spellcheck="false" class="select2-input"  type="text" size="20"/>

            <select title tabindex="-1" id="block-post-order-1-select" name="xform_demo[block-post-order-1]" class="xform-select-item " style="width: 40%; display: none;" rows="6">
               <option/>
               <option value="Desc" selected="selected">Lates</option>
               <option value="rand">Random Posts</option>
            </select>
         </fieldset>

                        Block Style

         <fieldset id="xform_demo-block_type_1" class=" xform-container-image_select" data-id="block_type_1" data-type="image_select">

                        <input class=" compiler noUpdate " id="block_type_1_1" name="xform_demo[block_type_1]" value="node" checked="checked" type="radio"/>

                        <input class=" compiler noUpdate  noUpdate " id="block_type_1_2" name="xform_demo[block_type_1]" value="nodey" type="radio"/>

         </fieldset>

A: Before talking about a possible solution, I'll try to paraphrase to confirm that my understanding of the problem statement is correct...

*

*You have some HTML that will be cloned to append on a container

*A button will trigger append

*Counter in multiple attributes on the cloned HTML must be incremented

Neither OP nor my suggested solution considers other common possible situations:

*

*What must happen when an element is deleted:

*

*Will the counters be recalculated?

*Are gaps in counters allowed?

*etc...

Anyway, now talking about the solution, I'll not use the code given in OP. Instead, I'll offer a general approach and leave actual implementation as a homework:
HTML:

        <input id="input1id" class="input1class" name="input1name" />

<button type="button" id="trigger">Append Copy</button>

jQuery:
    $(document).ready(function(){
        // HTML to copy. Used an uncommon string (@@) as place holder for actual counter
        var elementCopy = '
'+
'       <input id="input@@id" class="input@@class" name="input@@name" />'+
'
';

        $('#trigger').on('click', function() {
            var count = $('.element').length;   // number of elements with class "element"
            var counter = count + 1;    // Counter to use for new element(s)
            var clone = elementCopy.replace(/\@\@/g, counter);      // Substitute counter for all @@ in elementCopy; note the 'g' switch (global) in regex
            $('.container').append(clone);  // Finally append new HTML
        })
    });

Check this fiddle.


text:
Q: Mongo - How can I aggregate, filter, and include an array of data from the matching documents? I have a mongo-backed contact database going and I'm trying to find duplicate entries in a bunch of different ways.
For example, if 2 contacts have the same phone number they are flagged as a possible duplicate, ditto for email, etc.
I'm using MongoDB 2.4.2 on Debian with pyMongo and MongoEngine.
The closest I have so far is finding and counting records that contain the same phone number:
dbh.person_document.aggregate([
    {'$unwind': '$phones'},
    {'$group': {'_id': '$phones', 'count': {'$sum': 1}}},
    {'$sort': SON([('count', -1), ('_id', -1)])}
])

# Results in
{u'ok': 1.0,
 u'result': [{u'_id': {u'number': u'404-231-4444', u'showroom_id': 5}, u'count': 5},
             {u'_id': {u'number': u'205-265-6666', u'showroom_id': 5}, u'count': 5},
             {u'_id': {u'number': u'213-785-7777', u'showroom_id': 5}, u'count': 4},
             {u'_id': {u'number': u'334-821-9999', u'showroom_id': 5}, u'count': 3}
]}

So I can get the numbers that are duplicates, but I can't for the life of me figure out how to return an array of the Documents that actually contained these items!
I wanna see this kind of return data for each number:
# The ObjectIDs of the documents that contained the duplicate phone numbers
{u'_id': {u'number': u'404-231-4444', u'showroom_id': 5},
  u'ids': [ObjectId('51c67e322b2192121ec4d8f2'), ObjectId('51c67e312b2192121ec4d8f0')],
  u'count': 2},

Any help is greatly appreciated!

A: Ah, blessed be.
Found the solution almost word for word at MongoDB - Use aggregation framework or mapreduce for matching array of strings within documents (profile matching) .
Final result, adding some extra to include the name:
dbh.person_document.aggregate([
    {'$unwind': '$phones'},
    {'$group': {
        '_id': '$phones',
        'matchedDocuments': {
            '$push':{
                'id': '$_id',
                'name': '$full_name'
                }},
        'num': { '$sum': 1}
    }},
    {'$match':{'num': {'$gt': 1}}}
])


text:
Q: Snowflake: Does anyone have any idea that how to create a snowflake organization to organize all the snowflake accounts can anyone explain the complete process to create a snowflake organization account and the way to attach/detach account from it? I looked into the snowflake console as well as in documentation but have not gotten clarity

A: You should submit a ticket to Snowflake Support to enable organization on one of your accounts. This will create the ORGADMIN role in the account. Then you can grant this role to one of your users. The user which has the ORGADMIN role can access the Organization page. From the organization page, you can see your existing accounts, and create new accounts. When you create a new account, it will be in your organization automatically.
If you have an account which you can't see on the organization page, that means the account was created in another organization. In this case, you need to submit a ticket to Snowflake Support and ask them to move your account to your organization.
Normally, it's expected that each customer should have one organization, but if you have multiple organizations, you can also ask Snowflake Support to move your account from one organization to antother (that's how you would detach). If you want to drop an account, you should also contact Snowflake Support, it can't be done through the organization page.


text:
Q: How to filter out data in a PHP array based on date and id? I have an array of users here, the array has more than 2 users and each user array has a registration_date, licence_expiry_date, gender, email, age, and name.
The array looks like this.
$Users = Array(
                    (0) => Array
                        (
                            (id) => '100',
                            (name) => 'Name & Surname',
                            (email) => 'email@email.com',
                            (age) => '25',
                            (gender) => 'male',
                            (registration_date) => '2019-01-03',
                            (licence_expiry_date) => '2019-09-03',
                        ),

                    (1) => Array
                        (
                            (id) => '101',
                            (name) => 'Name & Surname 1',
                            (email) => 'email1@email.com',
                            (age) => '22',
                            (gender) => 'male',
                            (registration_date) => '2019-03-03',
                            (licence_expiry_date) => '2019-02-03',
                        ),

                    (2) => Array
                        (
                            (id) => '102',
                            (name) => 'Name & Surname 1',
                            (email) => 'email1@email.com',
                            (age) => '25',
                            (gender) => 'male',
                            (registration_date) => '2019-01-03',
                            (licence_expiry_date) => '2019-09-03',
                        ),

                    (3) => Array
                        (
                            (id) => '103',
                            (name) => 'Name & Surname 3',
                            (email) => 'email3@email.com',
                            (age) => '25',
                            (gender) => 'male',
                            (registration_date) => '2019-08-03',
                            (licence_expiry_date) => '2019-10-03',
                        ),

                    (4) => Array
                        (
                            (id) => '103',
                            (name) => 'Name & Surname 4',
                            (email) => 'email4@email.com',
                            (age) => '18',
                            (gender) => 'female',
                            (registration_date) => '2018-01-03',
                            (licence_expiry_date) => '2019-12-03',
                        ),
                );

What I want to achieve is to filter the data in this to another array but with some condition. For example, I want to filter this to only the users where the age is 25 and registration_date is after 2019-01-01 and licence_expiry_date before 2019-10-01.
The Expected results would look like this
$UsersFiltered = Array(
                    (0) => Array
                        (
                            (id) => '100',
                            (name) => 'Name & Surname',
                            (email) => 'email@email.com',
                            (age) => '25',
                            (gender) => 'male',
                            (registration_date) => '2019-01-03',
                            (licence_expiry_date) => '2019-09-03',
                        ),

                    (2) => Array
                        (
                            (id) => '102',
                            (name) => 'Name & Surname 1',
                            (email) => 'email1@email.com',
                            (age) => '25',
                            (gender) => 'male',
                            (registration_date) => '2019-01-03',
                            (licence_expiry_date) => '2019-09-03',
                        ),

                );

A: You can use array_filter:
$UsersFiltered = array_filter($Users, function ($v) {
    return $v['age'] == 25 &&
           $v['registration_date'] > '2019-01-01' &&
           $v['licence_expiry_date'] < '2019-10-01';
});

Note that since your dates are in YYYY-MM-DD format they can be compared alphabetically without conversion to a DateTime object, timestamp or similar.
Demo on 3v4l.org

A: You can use array_filter,
$arr = array_filter($arr, function($val){
    return ($val['age'] == 25 && strtotime($val['registration_date']) > strtotime('2019-01-01') && strtotime($val['licence_expiry_date']) < strtotime('2019-10-01'));
});

Demo.
I used > and < as a strict comparison as you didn't mention greater or lesser than equal to.
I use date comparison using strtotime.

A: You can use array_filter like this:
$licence_expiry_date = new DateTime('2019-10-01 00:00:00');
$registration_date   = new DateTime('2019-01-01 00:00:00');

$UsersFiltered = array_filter($Users, function($element) use ($licence_expiry_date, $registration_date) {
    return $element['age'] == 25
        && DateTime::createFromFormat('Y-m-d', $element['registration_date']) > $registration_date
        && DateTime::createFromFormat('Y-m-d', $element['licence_expiry_date']) < $licence_expiry_date;
});


text:
Q: Syntax Error when searching all fields of sql table I am creating a search filter for my sql table and I want to be able to search all the fields of the table and return records that contain the text I have entered. I have multiple tables so hardcoding all the fields into my statement is not an option. I tried this method (see code snippit) but I am getting this error:

class EOIeException with message 'Syntax error (missing operator) in query expression '(fieldContent LIKE '%SearchStr%')
  OR (fieldContent LIKE '%SearchStr%')
  OR ''. Process stopped.

Normally a syntax error is easy to solve but I don't have a clue with this one. Hope you can help. Thanks. Btw the fieldContent and SearchStr is just representations of the actual content.
qryInfo.SQL.Clear;
qryInfo.SQL.Add('SELECT * FROM ' + tableName);
qryInfo.Open;

tblInfo.SQL.Clear;
tblInfo.SQL.Add('SELECT * FROM ' + tableName);
tblInfo.SQL.Add('WHERE (' + qryInfo.Fields[0].AsString + ' LIKE ' + QuotedStr('%' + edtSearch.Text + '%') + ')');

for i:= 1 to qryInfo.FieldCount - 1 do
  begin
    tblInfo.SQL.Add(' OR (' + qryInfo.Fields[i].AsString + ' LIKE ' + QuotedStr('%' + edtSearch.Text + '%') + ')');
  end;
tblInfo.Open;

When putting ShowMessage(tblInfo.Text) before tblInfo.Open I get
 SELECT * FROM tblGymnast
 WHERE (EG000002 LIKE '%S%')
 OR (Erasmus LIKE '%S%')
 OR (Petrus LIKE '%S%')
 OR (Peter LIKE '%S%')
 OR (EF000001 LIKE '%S%')
 OR (2 LIKE '%S%')
 OR (0832133123 LIKE '%S%')
 OR (SFEW33FWX LIKE '%S%')
 OR (- LIKE '%S%')
 OR (2016/03/08 LIKE '%S%')
 OR (1996-08-19 LIKE '%S%')
 OR (M LIKE '%S%')
 OR (Afrikaans LIKE '%S%')
 OR (White LIKE '%S%')
 OR (Trampoline LIKE '%S%')
 OR (1908966000234 LIKE '%S%')
 OR (EL000004 LIKE '%S%')
 OR (ES000002 LIKE '%S%')
 OR (EL000003 LIKE '%S%')
 OR (TR000002 LIKE '%S%')
 OR (ED000001 LIKE '%S%')
 OR (234567890 LIKE '%S%')
 OR (EM000001 LIKE '%S%')

A: After your edit to add the generated SQL, the error in your code became very clear.  (The generated SQL contained invalid column names, and your subsequent comment after I pointed that out confirms that it is in fact data.)
You're trying to retrieve the column names as the left-hand value of the statements using Field[i].AsString, but this is wrong. TField.AsString returns the field's content as a string, not the field's name. To retrieve the name, you need to use TField.FieldName instead.
qryInfo.SQL.Clear;
qryInfo.SQL.Add('SELECT * FROM ' + tableName);
qryInfo.Open;

tblInfo.SQL.Clear;
tblInfo.SQL.Add('SELECT * FROM ' + tableName);
tblInfo.SQL.Add('WHERE (' + qryInfo.Fields[0].FieldName + ' LIKE ' + QuotedStr('%' + edtSearch.Text + '%') + ')');

for i:= 1 to qryInfo.FieldCount - 1 do
begin
  tblInfo.SQL.Add(' OR (' + qryInfo.Fields[i].FieldName + ' LIKE ' + QuotedStr('%' + edtSearch.Text + '%') + ')');
end;
tblInfo.Open;

I'm going to point out that this code is extremely vulnerable to SQL injection, because it blindly uses unsanitized user data to concatenate the SQL statement. This is a terribly bad idea, as it puts your entire database at risk. Use of QuotedStr does absolutely nothing to reduce that risk. See Little Bobby Tables for information about why this is such a security risk.


text:
Q: Laravel API check if client http connection is still alive In Laravel we have an api endpoint that may take a few minutes. It's processing an input in batches and giving a response when all batches are processed. Pseudo-code below.
Sometimes it takes too long for the user, so the user navigates away and the connection is killed client-side. However, the backend processing still continues until the backend tries to return the response with a broken pipe error.
To save ressources, we're looking for a way to check after each batch if the client is still connected with a function like check_if_client_is_still_connected() below. If not, an error is raised and processing is stopped. Is there a way to achieve this ?
function myAPIEndpoint($all_batches){
    $result = [];
    for ($batch in $all_batches) {
       $batch_result = do_something_long($batch);
       $result = $result + $batch_result;
       check_if_client_is_still_connected();
    }
    return result;
}

PS: I know async tasks or web sockets could be more appropriate for long requests, but we have good reasons to use a standard http endpoint for this.


text:
Q: I am getting a segmentation fault while creating a program of multiplication table #include<stdio.h>

main()
{
    int x,y,z;
    z=x*y;

    10<x<20,y<10;

    x=rand()%20;
    y=rand()%10;
    printf("%2d",x);
    printf("%2d",y);
    printf("enter value of z");
    scanf("%d",z);

    if(z=x*y)
    {
       printf("correct");
    }
    else
      printf("wrong no. entered");
}

I am getting a segmentation fault error, please help.

A: The segmentation fault is because you are calling scanf() with the z value instead of a pointer to it.
When scanf() encounters a "%d" specifier it expects a pointer to int to store the resulting value there, you passed an int instead and one that is not even initialized, so scanf() will dereference a pointer that doesn't point to valid memory thus causing a SEGMENTATION FAULT.
But that's not the only problem with your code, in fact there are many for such little code:

*

*The signature of main() MUST be one of the following

*

*int main(void)

*int main(int argc, char **argv) or the equivalent int main(int argc, char *argv[])

*Your code is really bad formatted, and even if that's not a reason for it to behave worng it's a reason to worry about.

*You used x and y without first initializing them, that's undefined behavior.

*This statement
10 < x < 20 , y < 10;

does ABSOLUTELY NOTHING.

*You didn't include stdlib.h needed for rand()'s prototype.

*You did what you did with scanf() explained above.

*if (z = x * y) will simply assign to x * y to z and unless x or y is 0 (zero) evaluate to true.
The comparison operator in c is ==.
Your code should look more like the following
#include <stdlib.h>
#include <stdio.h>

int
main(void)
{
    int x, y, z;

    x = rand() % 20;
    y = rand() % 10;

    printf("%2d", x);
    printf("%2d", y);

    printf("enter value of z ");
    if (scanf("%d", &z) == 1) {
        if (z == x * y) {
            printf("correct\n");
        } else {
            printf("error\n");
        }
    }
    return 0;
}


text:
Q: Unable to implement sleep() properly I was trying to make a very simple app which has a splash screen leading to the main activity. Can someone please point out why the splash screen's sleep continues indefinitely?
If I remove the sleep functionality, the app works properly.
Splash class:
package com.example.myfirstapp.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Splash extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    Thread timer = new Thread(){
        @Override
        public void run() {
            super.run();
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                Intent open = new Intent("android.intent.action.MAINACTIVITY");
                startActivity(open);

            }

        }
    };

}

}
Manifest:
<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.myfirstapp.app.Splash"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name="com.example.myfirstapp.app.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAINACTIVITY" />

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

</application>

A: The thread needs to be started. Call timer.start().

A: You're not starting the thread. That's the answer to the question, but you really should not be starting a thread for this.
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    new Handler().postDelayed(new Runnable(){
        @Override
        public void run() {
                Intent intent = new Intent(this, com.example.myfirstapp.app.MainActivity.class);
                startActivity(intent);
                finish();
            }
        }, 1000);
}

I have also shown you a better way of starting the activity (not by string), and I call finish() to close the splash screen so that when they press back it doesn't show the splash again.
A quick note on threads
Threads are expensive, they take time and memory to spin up. So spinning them up for a one off task never makes sense. In addition, the code that runs on them requires threadsafety considerations, whereas my solution will run on the same ui thread that requested it to run later. If you do require code to run in parallel (and here you don't) I'd still recommend in 99% of cases you use AsyncTask over thread.


text:
Q: Does Access Control lists override group or owner permissions? I came across the following task:

Add 3 new users - alice, bob, charles

*

*Create a new group - marketing - and add alice, bob and charles to
that group

*Create a directory - /marketing - whose owner is alice and group is
marketing

*Set appropriate permissions so that the marketing group can share
documents in the new directory but nobody else can see the documents.

*Give charles read-only permission.

*Create an empty file in /marketing named "empty".
Here is my answer:

*

*useradd alice

*useradd bob

*useradd charles

*mkdir /marketing

*chown alice:marketing /marketing

*chmod g=rwx,o=x /marketing

*setacl -m  u:charles:r  d /marketing

*touch /marketing/empty

I guess I got everything right except to give charles only read permissions.
As you can see in my answer I did using acls, however, since charles is also the marketing group, i believe it ignores the acls, because I switches to user Charles and I was able to create a file in /marketing.
That makes me question if the task itself doesn't make sense!
or do i have to remove charles from the marketing group?


text:
Q: Best way to handle emoji? I have a textview that can contain multiple words and emoji's.  However, I've noticed that some emoji's can crash my app
How I'm currently handling emoji's:
let data: NSData = myTextView.dataUsingEncoding(NSNonLossyASCIIStringEncoding)!
let valueUnicode: NSString = NSString(data: data, encoding: NSUTF8StringEncoding)!

Sometimes I get this error:
"Invalid hex digit in unicode escape sequence around character 273."
The reason why I'm encoding is because I'm using json to store the textview into my db and later on I'm pulling it back down from the db


text:
Q: How do I add circle list style to a bullet list in RichTextBox? Running into an issue with adding a "circle" bullet style to my list. I have tried coding it into an WebBrowser object and then passing that into the RTB, I have also tried richtextbox.rtf with no success.
For the HTML I tried:
WebBrowser webBrowser1 = new WebBrowser();
string content;
        content = "" + projects[0].ProjectName.ToString() + "
 Description: "
            + projects[0].Objective.ToString() + "
Benefits:

Near-Term --
"
            + "

" + projects[1].ShortTerm.ToString() + "

";
webBrowser1.Navigate("about:blank");
webBrowser1.Document.Write(content);
webBrowser1.Document.ExecCommand("SelectAll", false, null);
webBrowser1.Document.ExecCommand("Copy", false, null);
projectsEditor1.RichTextBox.Paste();

This will output everything correctly, however the nested bullet which should be an open circle is just the default "disc" value. I tried putting the type in both li and ul with no luck on either. This example just shows me doing it on both hoping it would work. I've seen that RTB's "only support" disc value. But if I take a bullet list from word and copy/paste it into my RTB it displays the circle bullet. Is it at all possible to program the circle value into a RTB?
My current code because HTML didn't work is just to do it like this:
                projectsEditor1.RichTextBox.SelectionBullet = true;
                projectsEditor1.RichTextBox.BulletIndent = 20;
                projectsEditor1.RichTextBox.AppendText("Near-term –");
                projectsEditor1.RichTextBox.AppendText(Environment.NewLine);
                projectsEditor1.RichTextBox.SelectionBullet = false;
                projectsEditor1.RichTextBox.SelectionFont = new System.Drawing.Font("Calibri", 11.0F, FontStyle.Regular);
                projectsEditor1.RichTextBox.SelectionIndent = 45;
                projectsEditor1.RichTextBox.SelectionBullet = true;
                projectsEditor1.RichTextBox.BulletIndent = 20;
                projectsEditor1.RichTextBox.SelectionFont = new System.Drawing.Font("Calibri", 11.0F, FontStyle.Regular);
                projectsEditor1.RichTextBox.AppendText(project.ShortTerm.ToString());
                projectsEditor1.RichTextBox.AppendText(Environment.NewLine);
                projectsEditor1.RichTextBox.SelectionBullet = false;
                projectsEditor1.RichTextBox.SelectionIndent = 0;

But again this just produces the same result as the HTML.
Current Output:

Desired Output:

Like I said what i've been able to find says RTB doesn't support anything other than default bullets but you can paste them into the RTB, so it makes me think it can be done.

A: You can use Unicode character:
projectsEditor1.RichTextBox.BulletIndent = 20;
projectsEditor1.RichTextBox.AppendText("Near-term –");
projectsEditor1.RichTextBox.AppendText(Environment.NewLine);
//projectsEditor1.RichTextBox.AppendText("\u25E6".PadLeft(20));
projectsEditor1.RichTextBox.AppendText("\t\u25E6");
projectsEditor1.RichTextBox.AppendText("Some Benefits...");

Edit: A workaround to your problem may be,
 var benefits = "string1\nstring2\nstring3";
 var text = benefits.Split(new char[] { '\n' })
                    .Select(t =>
                    string.Format("{0}{1}{2}", "\t\u25E6 ", t, "\n"))
                    .ToArray();
 benefits = string.Join("", text);

 // Then
 projectsEditor1.RichTextBox.AppendText(benefits);


text:
Q: lambdify to py function: How to maintain the order of symbols constant I have some symbolic expressions that I have stored in a text file (because they are too large) to read them later in order to find their numerical estimates. So, after I read those expressions (say foo_sym), I convert those expressions into python function as follow:
import sympy as sym
foo_fn = sym.lambdify(tuple(foo_sym.free_symbols), foo_sym)

Some of the symbolic variables in the expression are arrays, so I setup the vectorized version of the function as:
import numpy as np
foo_fn_vec = np.vectorize(foo_fn)

Now, I find the numerical estimate of the vectorized function as follow:
foo_num = foo_fn_vec(var_1, var_2, var_3, ...., var_12)

In above code, the order of symbolic values in var_1, var_2, var_3, ...., var_12 is consistent with the order of symbols I get through tuple(foo_sym.free_symbols). However, every time I restart python and run the above code, I get a ValueError: math domain error because the order of symbolic variables as given by tuple(foo_sym.free_symbols) seem to have changed, but the order of values in foo_fn_vec(var_1, var_2, var_3, ...., var_12) is unchanged.
Is there a method to hold the order of symbols constant in both steps, i.e. while converting to function in sym.lambdify((var_1, var_2, var_3, ...., var_12), foo_sym) and while finding the numerical value of the function as foo_num = foo_fn_vec(var_1, var_2, var_3, ...., var_12)?

A: If you use sym=tuple(ordered(foo_sym.free_symbols)) the symbols retrieved will always be in the same order. You may then want to use these as foo_fn_vec(*sym) and then sym.lambdify(sym, foo_sym).


text:
Q: Adding data from 2 TextFields in one View Controller, and displaying it in a second VC I'm new to iOS, and I'm looking for a solution to the following situation:
I have 2 view controllers: the first VC has 2 text fields and a button, and the second VC has a "result" text field, which must contain the sum of the 2 text fields in the previous VC. I connected those 2 VCs with a push segue.
The app is ok with the entry data, but it's not making the sum appear in the "result" textField. How can I make the result textField show the sum I want? Code snippets would be great! I'm using Xcode 4.4.1.
Thanks in advance!

A: Use prepareForSegue:sender:. The segue parameter can give you access to both controllers through the sourceViewController and destinationViewController properties. You should have properties in you source controller that either point to the text fields or their values, so you can get the sum from them. The destination controller should have a property, sum perhaps, that you then set equal to the sum you got from the source controller.
You really should study the View Controller Programming Guide for iOS, this and many other things you need to know are in there.


text:
Q: SciChart IOS fixed grid line and tick labels I am trying to make the  X direction grid line and tick labels fixed at mid of the visible range, whether the chart is zoomed or paned.
I had try to create custom TickProvider for my xAxis:
class CustomTickProvider: SCIDateTimeTickProvider {
    private var tickCount: Int

    init(tickCount: Int) {
        self.tickCount = tickCount
    }

    override func getMajorTicks(fromAxis axis: SCIAxisCoreProtocol!) -> SCIArrayController! {
        let visibleRange = axis.visibleRange
        let min = visibleRange?.min.doubleData
        let max = visibleRange?.max.doubleData

        let array: SCIArrayController = SCIArrayController.init(type: SCIDataType.double)
        let step = (max! - min!) / Double(self.tickCount - 1)
        var current = min!
        while current <= max! {
            array.append(SCIGeneric(current))
            current += step
        }
        return array
    }
}

xAxis.tickProvider = CustomTickProvider.init(tickCount: 3)

When I set xAxis.autoTicks = true, the grid line and tick labels will be relocated,they can't stay at the same position either.
When I set xAxis.autoTicks = false, no grid line and tick labels will be
drawn.
How can I get the effect of fixed grid line and tick labels?

A: Maybe not the cleanest way to do it, but it worked for me in a comparable situation:
Edit the MajorDelta/MinorDelta after the visibleRange changed.


text:
Q: Searching for Extensionless Files in Windows 7 I cannot for the life of me figure out a way to have Windows 7 Explorer search for files with no extension. In XP it was nice and simple: just search for files named *. but in 7, that does not work and returns all files, as does ext:..
Searching has become extremely burdensome in Windows 7. Does anyone know how to perform this previously simple task?

A: As @surfasb points out the [] can be used to represent 'nothing', and you can use it with the ext: filter.
You can then use that in combination with the type: filter and tell it to NOT show file folders:
ext:[] type:NOT"file folder"

A: According to MSDN, the nothing character is [].  So press F3 and enter ext:[].

A: I was facing this issue today on Windows 8 and have noticed it on previously on Windows 7 as well. I finally found a way to do this right and I hope this answer helps the original posters and others who come here via google searches.
Typically for normal as well as advanced power searches I used Nirsoft SearchMyFiles and stopped using Windows Search.

But, for some reason I was having trouble getting it to find files without any extensions. I figured the same bug was there in this app as well.
But, I was wrong and apparently Nir Softer has redesigned his wild card & regular expression engine from scratch; as per this little gem I found posted on the page in "Versions History" section:

*

*Version 2.40:

*

*SearchMyFiles now uses an internal wildcard parser instead of basing the search result on the wildcard parser of Windows. This
  change solves an annoying bug caused by Windows wildcard parser: In
  previous versions, SearchMyFiles sometimes returned incorrect results,
  because Windows also matches the wildcard with the short filename (8.3
  DOS format).

*Notice: The new wildcard parser may cause some compatibility issues, for example: When you scanned using . wildcard with Windows
  parser, it returned all files, including files without extension. With
  the new SearchMyFiles wildcard parser, . returns only files with
  extension. In order to return all files, you should use * instead of
  .

*When loading old config files, SearchMyFiles automatically converts all . wildcards to *

*The new wildcard parser has some advantages, for example: if you search for ..., you'll get all files with 3 dot characters or
  more. With Windows wildcard parser in previous versions, you simply
  got the list of all files.

*You can now exclude files by using wildcards list. You have to select this option from the combo-box, because the default option is
  to exclude files by extension.

*You can now specify environment strings in the 'Base Folders' and 'Excluded Folders' fields (For example: %AppData% )

So to find files without extensions don't use these:
*.* or *.

Just use a simple:
*

For example :

Files Wildcard: *
Subfolders Wildcard: *

Note: Please don't go by the wild cards shown in the 'old' screenshot posted above.


text:
Q: Построить вектор из производного каждого ряда, и найти производное вектора Немогу понять в чем ошибка, вместо производного каждого ряда, выводит производное только первого ряда несколько раз.
Так же он перестраивает матрицу по производному рядов в поредке роста.
Вот Код:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define N 15

int multiply (int* a, int n)
{
        int i, dobutok = 1;

        for (i=0; i<n; i++)

                if (a[i] == 0)
                        return 0;
                else
                        dobutok *= a[i];
        return dobutok;
}
void change(int a[][N], int n)
{
int i, j, k, x;
        for (i=n-1; i; i--)
                for (j=0; j<i; j++)
                         if (multiply(a[j], n) > multiply(a[j+1], n))
                                for (k = 0; k < n; k++)
                                        x = a[j][k],
                                        a[j][k] = a[j+1][k],
                                        a[j+1][k] = x;
}
int mult(int n, int i, int* a)
{
        int j, dobu = 1,vector = 1;
        for (j=0; j<n; j++)
             dobu *= a[j];
             vector *= dobu;
        return vector;

}
 int main()
{
  int n,a[N][N],i,j,*array,vector=0,dobutok;
  printf("Enter n: ");
  scanf("%d",&n);
  array=malloc(n*sizeof(int));

  srand(time(NULL));

 for (i=0; i<n; i++, puts(""))
                for (j=0; j<n; j++)

                        printf("%3d", a[i][j] = 1 + rand() %11);
        puts("");
   for (j=0; j<n; j++){
        printf("%d ", array[i] = mult(n, i, a));
}
printf("\n");
printf("\n");
change(a,n);
for (i=0; i<n; i++, puts(""))

                for (j=0; j<n; j++)

                        printf("%3d", a[i][j]);
  }


text:
Q: Displaying SQL table data in html table not working I am trying to query and select data from an sql table and then display it in html. This is my code.
$result = mysqli_query($dbhandle, $query)
    or die(mysql_error().'
SQL:'.$query);
echo '
';

while($row = mysqli_fetch_array($result)) {
    echo '
';
    echo '{$row['first_name']}	';
    echo '{$row['last_name']}	';
    echo '{$row['grade']}	';
    echo '{$row['gpaP']}	';
    echo "{$row['AGP']}	";
    echo "{$row['awardP']}	";
    echo "{$row['awardTP']}	";
    echo "{$row['rigorP']}	";
    echo "{$row['APP']}	";
    echo "{$row['positionP']}	";
    echo "{$row['hoursP']}	";
    echo "{$row['selectionP']}	";
    echo "{$row['activityTypeP']}	";
    echo "{$row['activityYearsP']}	";
    echo "{$row['date']}	";
    echo "{$row['IP']}	";
    echo '
';
}
echo '
';

It gives me an error saying there is an unexpected string at the last_name cell. If I remove the style parameters from the cells it works. Somebody point out my error please?

A: Your single and double quptes are getting mixed up between the PHP and HTML.  The easiest way to fix it is to use the heredoc syntax:
echo <<<EOT

{$row['first_name']}
{$row['last_name']}
{$row['grade']}
{$row['gpaP']}
{$row['AGP']}
{$row['awardP']}
{$row['awardTP']}
{$row['rigorP']}
{$row['APP']}
{$row['positionP']}
{$row['hoursP']}
{$row['selectionP']}
{$row['activityTypeP']}
{$row['activityYearsP']}
{$row['date']}
{$row['IP']}

EOT;

This syntax makes it much easier since you can use both single and double quotes without escaping them and variables will be evaluated.  Also, in your original code, the variables aren't going to be evaluated since they're in single quotes.

A: Your code mixes two different styles of quotes, both of which are valid in PHP and both of which require some additional escaping.
You should pick a style (either wrap in single quotes or wrap in double quotes) and then make sure you escape quotes of the same type within the string.

A: You are mixing single quotes ' with double quotes "". For example, if you start the line with " and then use it again before the end of the line, you need to escape it with \". My suggestion is for you to stick with one style, and use it for all the lines. For example, usign "":
  echo "{$row['first_name']}	";
  echo "{$row['IP']}	";


text:
Q: Partial derivative of $x$ with respect to $x^2$ What is the partial derivative of $x$ with respect to $x^2$?
$$\frac\partial{\partial x^2}x$$It is zero? What is the derivative in this case? Can you provide an explanation.

A: By a chain rule we have $$\frac{df}{dx}=\frac{df}{d(x^2)}\cdot \frac{d(x^2)}{dx}$$
If $f(x)=x$, then we arrive at $$1=\frac{d(x)}{d(x^2)}\cdot 2x.$$ Finally $$\frac{d(x)}{d(x^2)}=\frac{1}{2x}$$ for $x\ne 0$.

A: Write $u = x^2$. If $x > 0$ then $x = \sqrt u$ and
$$\frac{\partial\ }{\partial x^2} x = \frac{\partial\ }{\partial u} \sqrt u = \frac{1}{2\sqrt u} = \frac{1}{2x}$$
If $x < 0$ then $x = -\sqrt u$ and the derivative remains the same.
Thus for all $x \neq 0$,
$$\frac{\partial\ }{\partial x^2} x = \frac{1}{2x}$$
The derivative at $x = 0$ does not exist.

A: Hint :
Derivative of $f(x)$ w.r.t. $g(x)$ is :
$$\frac{\partial f(x)}{\partial \big(g(x)\big)}=\frac{\dfrac{d}{dx}f(x)}{\dfrac{d}{dx}g(x)}$$


text:
Q: Question about the problem in the shadow menu The shadow of my menu has a problem and when I click on the item that open a submenu , the shadow of opened submenu has a problem and it dosen't have any effect on the right of submenu that opened for the down item in the menu, what can I do ? I am too confused, I Appreciate it if you get the code instead of the link, thanks.
The Code:

ul {
/*  border: 1px solid #555;*/
  position:relative;

  font-family: 'Roboto', sans-serif;
  list-style: none;
  padding: 0;
  margin: 0;
  background: #FFFFFF;
}

.borderm{
 border-right:#606060 0.25px solid;
 border-left:#606060 0.25px solid;
}

ul li {
 position:relative;
  text-align: center;
  font-family: 'Roboto', sans-serif;
  display: block;
  position: relative;
  float: right;
  background: #FFFFFF;
}

/* This hides the dropdowns */

li ul { display: none;}

ul li a {
  font-size: 13px;
  font-family: 'Roboto', sans-serif;
  display: block;
  padding: 1em;
  text-decoration: none;
  white-space: nowrap;
  color: black;
}

/* Display the dropdown */

li:hover > ul {
  font-family: 'Roboto', sans-serif;
  display: block;
  position: absolute;
}

li:hover li { float: none;font-family: 'Roboto', sans-serif;}

li:hover li a:hover { background: #ff4718; color: white;font-family: 'Roboto', sans-serif;}

ul:hover ul{
 -webkit-box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) inset;
       -moz-box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) outset;
            box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) inset;

 -webkit-box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) outset;
       -moz-box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) inset;
            box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) outset;
}
.main-navigation li ul li { border-top: 0;}

/* Displays second level dropdowns to the right of the first level dropdown */

ul ul ul {
 width: 105px;
  font-family: 'Roboto', sans-serif;
  right: 100.1%;
  top: 0;
}

/* Simple clearfix */

ul:before,
ul:after {
  font-family: 'Roboto', sans-serif;
  content: " "; /* 1 */
  display: table; /* 2 */
}

ul:after { clear: both;font-family: 'Roboto', sans-serif;}

.expand{font-size:24px;float: left;margin: -9px -5px;}

.right {
    transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
}

.left {
    transform: rotate(135deg);
    -webkit-transform: rotate(135deg);
}

.up {
    transform: rotate(-135deg);
    -webkit-transform: rotate(-135deg);
}

.down {
    transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
}

.effect1{
    -webkit-box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) inset;
       -moz-box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) inset;
            box-shadow:0 8px 8px rgba(0, 0, 0, 0.3), 0 0 80px rgba(0, 0, 0, 0.1) inset;
 /*box-shadow: 1px 1px 0px grey;*/
}

.tri
{
    width: 0;
 height: 0;
 border-top: 25px solid transparent;
 border-right: 50px solid #555;
 border-bottom: 25px solid transparent;
}

Menu

◂Front End Design

HTML

◂CSS

Resets

Grids

Frameworks

◂Javascript

Ajax

jQuery

About Us

A: If you have so many uls in css, it will be the solution
ul ul ul {
    z-index: 1;
}


text:
Q: Using `on` to replace placeholders in Scala SQL query I'm trying to create a findBy method that takes in a key and value to search a table.  For some reason the following does not find anything:
def findBy(key: String, value: String): Option[Authentication] = DB.withConnection { implicit connection =>
  SQL("select * from authentications where {key}='{value}' limit 1")
    .on("key" -> key, "value" -> value).as(authentication.singleOpt)
}

But when I just use the plus sign, it does.  I wouldn't mind leaving it this way but there are benefits to being able to use on
def findBy(key: String, value: String): Option[Authentication] = DB.withConnection { implicit connection =>
  SQL("select * from authentications where " + key + "='" + value + "' limit 1")
    .as(authentication.singleOpt)
}

Example Query: Authentication.findBy("email", "test@example.com")

A: Play escapes the query parameters in prepared SQL statements. So you don't actually need to wrap {value} in single quotes. Unfortunately, this means the column names will be escaped with quotes as well by Play, so it'll be interpreted by the database as a string. I don't see a way around this without using string concatenation or string interpolation.
Scala string interpolation would look the code look a little better:
def findBy(key: String, value: String): Option[Authentication] = DB.withConnection { implicit connection =>
    SQL(s"select * from authentications where `$key` = {value} limit 1")
       .as(authentication.singleOpt)
       .on("value" -> value).as(authentication.singleOpt)
}

Notice the "s" before the beginning of the string. The scala compiler will replace the token $key with the string key that's in scope. This should work, but key won't be escaped. So you'll have to sanitize the input for key yourself, unless you're using it internally only. Also, it's important to note that an input for key that isn't a column in the table will raise an SQLException.


text:
Q: (Alsamixer settings) Bluetooth microphone noisy sound I am new to Ubuntu. I have Ubuntu 20.10 installed on my Ausus. Yesterday I used my bluetooth JBL microphone for the the first time. It worked quite well, eventually I changed the settings on Alsamixer. I guess I messed up the right balance but I really do not know to restore them. I also installed QuasMixer but I have not clue which settings I should change.
I attached a series of screenshots to give you a general idea:

Please help me as I am a teacher, I definitively need to use a microphone to teach my online courses. Many thanks in advance


text:
Q: Issue creating Signed URL for google storage bucket I am trying to create a Signed URL & run it into missing library pyopenssl issue. My command is the following one:
gsutil signurl -d 10d -u /Users/dineshc/Development/my_key.json gs://console.cloud.google.com/storage/browser/my_data
I am getting following error:
CommandException: The signurl command requires the pyopenssl library (try pip install pyopenssl or easy_install pyopenssl)
My OS configuration is the following one:
uname      :    Darwin
ProductName:    macOS
ProductVersion: 11.4
BuildVersion:   20F71

I have python3.7 installed & I created symbolic link:

ln -s /usr/local/bin/python3.7 /usr/local/bin/python

$ls -l /usr/local/bin/python*
lrwxr-xr-x  1 root  wheel  24  6 Oct 16:50 /usr/local/bin/python -> /usr/local/bin/python3.7
lrwxr-xr-x  1 root  wheel  69  6 Oct 16:04 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3
lrwxr-xr-x  1 root  wheel  76  6 Oct 16:04 /usr/local/bin/python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config
lrwxr-xr-x  1 root  wheel  71  6 Oct 16:04 /usr/local/bin/python3.7 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
lrwxr-xr-x  1 root  wheel  78  6 Oct 16:04 /usr/local/bin/python3.7-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
lrwxr-xr-x  1 root  wheel  72  6 Oct 16:04 /usr/local/bin/python3.7m -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m
lrwxr-xr-x  1 root  wheel  79  6 Oct 16:04 /usr/local/bin/python3.7m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config

$python --version
Python 3.7.9

$which pip3
/usr/local/bin/pip3

$which pip

<nothing is coming up here but the command below shows that pip is installed>

$pip3 install pip
Requirement already satisfied: pip in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (21.2.4)

$pip install pyopenssl
-bash: pip: command not found

$pip3 install pyopenssl
Requirement already satisfied: pyopenssl in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (21.0.0)
Requirement already satisfied: six>=1.5.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pyopenssl) (1.16.0)
Requirement already satisfied: cryptography>=3.3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pyopenssl) (35.0.0)
Requirement already satisfied: cffi>=1.12 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from cryptography>=3.3->pyopenssl) (1.14.6)
Requirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from cffi>=1.12->cryptography>=3.3->pyopenssl) (2.20)

$echo $PATH
/Users/dineshc/Development/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

$ls -l /usr/local/bin/python*
lrwxr-xr-x  1 root  wheel  24  6 Oct 16:50 /usr/local/bin/python -> /usr/local/bin/python3.7
lrwxr-xr-x  1 root  wheel  69  6 Oct 16:04 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3
lrwxr-xr-x  1 root  wheel  76  6 Oct 16:04 /usr/local/bin/python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config
lrwxr-xr-x  1 root  wheel  71  6 Oct 16:04 /usr/local/bin/python3.7 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
lrwxr-xr-x  1 root  wheel  78  6 Oct 16:04 /usr/local/bin/python3.7-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
lrwxr-xr-x  1 root  wheel  72  6 Oct 16:04 /usr/local/bin/python3.7m -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m
lrwxr-xr-x  1 root  wheel  79  6 Oct 16:04 /usr/local/bin/python3.7m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config

My issue: For some reason (I think) gsutil is still referring to python2.5, which is the version that comes with MacOS & does not have pip installed. Any idea how to make gsutil use the latest version of python & subsequent libraries?

A: You can run gsutil -D version and get lots of helpful debugging information about your gsutil installation, the Python version being used to run it, the config files being loaded, etc.
If you're running a gcloud installation of gsutil, you should see a line that looks like this in your output:
gsutil path: <path-to-google-cloud-sdk>/bin/gsutil

In that case, you should be able to specify the path to your preferred Python interpreter using the CLOUDSDK_GSUTIL_PYTHON environment variable, as mentioned in these docs.
But, if you're running a standalone installation gsutil (not part of a gcloud installation), you should make sure the Python version launched via the command /usr/bin/env python is the correct version -- this will be the first Python binary discoverable from the directories specified in your PATH environment variable, so you may have to edit and export your PATH appropriately.


text:
Q: Algolia synonym search adding characters Hi I have a problem on this page
https://www.hwl.dk/da/frontpage?q=sp%C3%A6kbr%C3%A6t&hPP=6
Where the italic text in the search result says things like spækbrætt8 and spækbrættn when I have a two way synonym set up for [spækbræt,skærebræt] and the original text in the search result is "skærebræt".
My question is this:
Why does algolia add t8 and tn and so on to the end of the result when using synonyms.
PS.
The æøå, ÆØÅ letters are native to Denmark by the way.

A: This was a bug in Algolia's API, which is now fixed (as of Friday, November 10th, 2017).


text:
Q: Customizing Drop Folder Structure with TFS Team Build I'm using TFS 2012 to automate a build of a solution which contains multiple windows services and two web applicaitons.
I've used the guide I found here to customize the build process template so that the windows services are put in a folder structure that I like. Specifically:

*

*\dropserver\droproot\MyApp\BuildNumber\

*

*\Service1

*\Service2

*\Service3

*\Service4

This works great, but unfortunately it doesn't work for web applicaitons. If I used the same strategy for those, I just get the contents of /bin for each web app, rather than the full site contents.
MSBuild typically uses the web application targets to handle this, but for some reason, this doesn't work when you customize the build as I have. I no longer get the _PublishedWebSites folder in the build output. (I'm guessing that's because I cleared our the OutDir property of the MSBuild task.)
Has anybody done something like this and gotten it to work with web applications as well?

A: I think I can help with this, it looks like in the build targets that the published websites folder isn't created if the OutDir is the same as the OutputPath.
So this isn't perfect, but if you add the following into the csproj file in the first property group, you'll get everything deployed into "\bin\deploy\" including the _PublishedWebsites folder
<DeployOnBuild>True</DeployOnBuild>
<OutDir>bin\deploy\</OutDir>

A: With a bit of customization, this solution ended up working for me:
http://www.edsquared.com/2011/01/31/Customizable+Output+Directories+For+TFS+2010+Build.aspx
Basically, did what that link recommended, but also leveraged a new solution configuration (which I called TeamBuild) rather than conditional property definitions.
I believe the key to making this all work was the passing of the outputDirectory as the TeamBuildOutDir argument to MSBuild. Embedding this variable reference in the OutDir or OutputPath variable was allowed Team Build to build to the correct staging location and then automatically copy files from that location to the drop folder.
I'm going to take this a little futher and get rid of the whole _PublishedWebSites thing, but that will be done entirely in the build workflow.
EDIT: TFS 2013 supports this natively with a simply build configuration option:

A: Take a look at this thread as this post as well.
Team Build: Publish locally using MSDeploy
Since you need all the files for your web projects, you need to trigger the publishing process, and by tweaking the destination of that process, you can have all of your files copied where you need them.
I think option (2) from his answer will work for you.
I hope that helps.

A: As I can see in your reference link, it will just compile and package the binaries. It does not deploy the website by the steps mentioned in that.
If you want to get the .html, .css, .js etc. under the _PublishedWebSites folder, you need to do a Web Deployment. This manually we can do by clicking the publish option from right click menu of your VS project and by selecting Publish Method as File System.
But, since you need to automate this in your build and drop it in custom drop folder, you may need to manipulate your MSBuild script by calling a AspNetCompiler task. You can get more information on this at the MSDN link. By specifying the TargetPath while you call this target you can get your Web files deployed at the appropriate custom drop folder.
Happy Scripting.

A: Have you check this blog, this solved my problem where I wanted customized TeamBuild Ouput Directory.
Customizable O/P with TFS 2013
Customizaable O/P with TFS 2012 and .NET Framework 4.5


text:
Q: Which book in Asimov's Foundation series describes a video communication system just like our "Zoom" Long ago I read all the books in Asimov's Foundation series. In one of them, people are living alone or very few at a time on separate worlds that are far apart. They communicate via a video system that I remember as being very much like today's "Zoom." I can't find which book that is in. Can anyone help?

A: The story identification answer is in the comments to the question. The story is no doubt The Naked Sun, book two of the "Robot Novels". The confusing part of the question is "on separate worlds that are far apart". I think that is just the OP misremembering the story. On Solaria, the planet in the book, there were just a few people living there very far apart on very large estates. They were so far apart for so long that it was taboo to actually see or gasp touch anyone else in person.
Here is a spoiler filled link to how and why the "Robot Novels" were linked to "Foundation Novels".
When did Asimov decide to unify the Foundation and Robots series?

A: I wanted to write a comment, but I fear it could be somehow a spoiler (for somebody who still needs to start the Foundation series).
The book is Foundation's Edge:

 The second Foundation use of mentalics to communicate with each other, in chapter 48*, is described as very similar to a video call: Gendibal (a Second Foundation Speaker) can speak to another member of the second Foundation through the mind, and the description evidences the shaping of an image of the interlocutor, even with some "artifacts" in the image itself (because of lack of concentration)!

 *hoping that the chapters are the same in all editions of the novel...

A: Possibly "Mother Earth", a novelette in Isaac Asimov's Positronic Robots series which, for reasons unknown, Asimov later merged with his Foundation series; first published in Astounding Science Fiction, May 1949. available at the Internet Archive. (Asimov's "Mother Earth" was also the answer to the question Short sci-fi story about Earth blockaded by other human colonies.)

Take the home of Franklin Maynard, for instance, who, with his wife, three children, and twenty-seven robots lived on an estate more than forty miles away, in distance, from the nearest neighbor. Yet by community-wave he could, if he wished, share the living room of any of the seventy-five million on Aurora—with each singly; with all simultaneously.
Maynard knew every inch of his valley. He knew just where it ended, sharply, and gave way to the alien crags, along whose undesirable slopes the angular, sharp leaves of the native furze clung sullenly—as if in hatred of the softer matter that had usurped its place in the sun.
Maynard did not have to leave that valley. He was a deputy in the Gathering, and a member of the Foreign Agents Committee, but he could transact all business, but the most extremely essential, by community-wave, without ever sacrificing that precious privacy he had to have in a way no Earthman could understand.
Even the present business could be performed by community-wave. The man, for instance, who sat with him in his living room, was Charles Hijkman, and he, actually, was sitting in his own living room on an island in an artificial lake stocked with fifty varieties of fish, which happened to be twenty-five hundred miles distant, in space.
The connection was an illusion, of course. If Maynard were to reach out a hand, he could feel the invisible wall.
Even the robots were quite accustomed to the paradox, and when Hijkman raised a hand for a cigarette, Maynard's robots made no move to satisfy the desire, though a half-minute passed before Hijkman's own robot could do so.


text:
Q: Using animation and thread I would like to create an animation.
Why do I get this error?

01-16 12:09:33.388: E/AndroidRuntime(895): FATAL EXCEPTION: Thread-10
01-16 12:09:33.388: E/AndroidRuntime(895):
java.lang.NullPointerException 01-16 12:09:33.388:
E/AndroidRuntime(895):    at
com.example.pages.Comments.initialImageViewSms(Comments.java:38) 01-16
12:09:33.388: E/AndroidRuntime(895):  at
com.example.pages.Comments.access$0(Comments.java:36) 01-16
12:09:33.388: E/AndroidRuntime(895):  at
com.example.pages.Comments$1.run(Comments.java:24) 01-16 12:09:33.388:
E/AndroidRuntime(895):    at java.lang.Thread.run(Thread.java:1020)
01-16 12:09:45.587: E/AndroidRuntime(906): FATAL EXCEPTION: Thread-10
01-16 12:09:45.587: E/AndroidRuntime(906):
java.lang.NullPointerException 01-16 12:09:45.587:
E/AndroidRuntime(906):    at
com.example.pages.Comments.initialImageViewSms(Comments.java:38) 01-16
12:09:45.587: E/AndroidRuntime(906):  at
com.example.pages.Comments.access$0(Comments.java:36) 01-16
12:09:45.587: E/AndroidRuntime(906):  at
com.example.pages.Comments$1.run(Comments.java:24) 01-16 12:09:45.587:
E/AndroidRuntime(906):    at java.lang.Thread.run(Thread.java:1020)
01-16 12:15:11.178: E/AndroidRuntime(990): FATAL EXCEPTION: Thread-10
01-16 12:15:11.178: E/AndroidRuntime(990):
java.lang.NullPointerException 01-16 12:15:11.178:
E/AndroidRuntime(990):    at
com.example.pages.Comments.initialImageViewSms(Comments.java:37) 01-16
12:15:11.178: E/AndroidRuntime(990):  at
com.example.pages.Comments.access$0(Comments.java:35) 01-16
12:15:11.178: E/AndroidRuntime(990):  at
com.example.pages.Comments$1.run(Comments.java:23) 01-16 12:15:11.178:
E/AndroidRuntime(990):    at java.lang.Thread.run(Thread.java:1020)

BaseFragment:
package com.example.pages;

import android.support.v4.app.Fragment;

public class BaseFragment extends Fragment {

}

Comments:
package com.example.pages;

import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

public class Comments extends BaseFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    new Thread(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            initialImageViewSms();
        }
    }).start();

}

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

private void initialImageViewSms(){

    ImageView imageview_sendsms = (ImageView)getView().findViewById(R.id.imagebutton_send_sms);
    imageview_sendsms.setBackgroundResource(R.drawable.send_sms_anim);
    AnimationDrawable animdrawable = (AnimationDrawable)imageview_sendsms.getBackground();
    animdrawable.start();
}
}

send_sms_anim.xml:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false"
>

<item
android:drawable="@drawable/send_sms_one"
android:duration="100"/>
<item
android:drawable="@drawable/send_sms_two"
android:duration="100"/>

</animation-list>

A: you can't update your UI in new Thread, UI must be update in UI thread
you try update UI in initialImageViewSms(); that is not in UI Thread
you can use runOnUiThread , Handler or AsyncTask class to run in UI thread or move out you method from thread because i don't see any other code in that.


text:
Q: Smallest sum of triplet products where the middle element is removed using Dynamic Programming I have given a sequence of N numbers (4 ≤ N ≤ 150). One index i (0 < i < N) is picked and multiplied with the left and the right number, in other words with i-1 and i+1. Then the i-th number is removed. This is done until the sequence has only two numbers left over. The goal is to find the smallest sum of these products which obviously depends on the order in which the indices are picked.
E.g. for the sequence 44, 45, 5, 39, 15, 22, 10 the smallest sum would be 17775
using the indices in the following order: 1->3->4->5->2 which is the sum:
44*45*5 + 5*39*15 + 5*15*22 + 5*22*10 + 44*5*10 = 9900 + 2925 + 1650 + 1100 + 2200 = 17775
I have found a solution using a recursive function:
public static int smallestSum(List<Integer> values) {
    if (values.size() == 3)
        return values.get(0) * values.get(1) * values.get(2);
    else {
        int ret = Integer.MAX_VALUE;

        for (int i = 1; i < values.size() - 1; i++) {
            List<Integer> copy = new ArrayList<Integer>(values);
            copy.remove(i);

            int val = smallestSum(copy) + values.get(i - 1) * values.get(i) * values.get(i + 1);
            if (val < ret) ret = val;
        }

        return ret;
    }
}

However, this solution is only feasible for small N but not for a bigger amount of numbers. What I am looking for is a way to do  this using an iterative Dynamic Programming approach.

A: The optimal substructure needed for a DP is that, given the identity of the last element removed, the elimination strategy for the elements to the left is independent of the elimination strategy for the elements to the right. Here's a new recursive function (smallestSumA, together with the version from the question and a test harness comparing the two) incorporating this observation:
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Foo {
  public static void main(String[] args) {
    Random r = new Random();
    for (int i = 0; i < 10000; i++) {
      List<Integer> values = new ArrayList<Integer>();
      for (int n = 3 + r.nextInt(8); n > 0; n--) {
        values.add(r.nextInt(100));
      }
      int a = smallestSumA(values, 0, values.size() - 1);
      int q = smallestSumQ(values);
      if (q != a) {
        System.err.println("oops");
        System.err.println(q);
        System.err.println(a);
        System.err.println(values);
      }
    }
  }

  public static int smallestSumA(List<Integer> values, int first, int last) {
    if (first + 2 > last)
      return 0;
    int ret = Integer.MAX_VALUE;
    for (int i = first + 1; i <= last - 1; i++) {
      int val = (smallestSumA(values, first, i)
          + values.get(first) * values.get(i) * values.get(last) + smallestSumA(values, i, last));
      if (val < ret)
        ret = val;
    }
    return ret;
  }

  public static int smallestSumQ(List<Integer> values) {
    if (values.size() == 3)
      return values.get(0) * values.get(1) * values.get(2);
    else {
      int ret = Integer.MAX_VALUE;

      for (int i = 1; i < values.size() - 1; i++) {
        List<Integer> copy = new ArrayList<Integer>(values);
        copy.remove(i);

        int val = smallestSumQ(copy) + values.get(i - 1) * values.get(i) * values.get(i + 1);
        if (val < ret)
          ret = val;
      }

      return ret;
    }
  }
}

Invoke as smallestSum(values, 0, values.size() - 1).
To get the DP, observe that there are only N choose 2 different settings for first and last, and memoize. The running time is O(N^3).

A: If anyone is interested in a DP solution, based on David Eisenstat's recursive solution, here is an iterative one using DP (for many big numbers it's useful to replace int's with long's):
public static int smallestSum(List<Integer> values) {
    int[][] table = new int[values.size()][values.size()];

    for (int i = 2; i < values.size(); i++) {
        for (int j = 0; j + i < values.size(); j++) {
            int ret = Integer.MAX_VALUE;

            for (int k = j + 1; k <= j + i - 1; k++) {
                int val = table[j][k] + values.get(j) * values.get(k) * values.get(j + i) + table[k][j + i];
                if (val < ret) ret = val;
            }

            table[j][j + i] = ret;
        }
    }

    return table[0][values.size() - 1];
}


text:
Q: Resolve "Id must be a String" in CloudFormation Template error The following is in the Resources Section of my CloudFormation Template:
  myAlbTargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      HealthCheckPath: /
      HealthCheckIntervalSeconds: 10
      HealthCheckTimeoutSeconds: 5
      HealthyThresholdCount: 2
      Matcher:
        HttpCode: 200,302
      Name: myWebServer
      Protocol: HTTP
      Port: 80
      Targets:
        - Id: Fn::ImportValue: myVPC-myWebServer1
          Port: 80
        - Id: Fn::ImportValue: myVPC-myWebServer2
          Port: 80
      TargetType: instance
      UnhealthyThresholdCount: 5
      VpcId:
        Fn::ImportValue: myVPC

When I load the Template I get an error indicating "Id must be a String" for Targets.
Per another thread I read, I've wrapped the value in quotes, and also tried to use !Sub, but to no avail.
Does anyone know how to resolve this issue? I've been through the Docs, but I'm obviously missing something (probably basic).
Thanks in advance for any guidance!

A: This has been resolved. It was an alignment / formatting issue. I'll post the proper format here for anyone that might be interested.
      Targets:
        - Id:
            Fn::ImportValue:
             !Sub 'myVPC-myWebServer1'
          Port: 80
        - Id:
            Fn::ImportValue:
             !Sub 'myVPC-myWebServer2'
          Port: 80


text:
Q: How to update the source location in symbol (.pdb) files What I am trying to do is run a batch script to update .pdb files to point to a different source location. I'm not sure if there is a way to update the absolute paths in the pdb file, but currently I'm looking into inserting a source stream into the pdb file so the debugger can get the source files.
I am inserting a source stream using pdbstr.exe:
pdbstr -w -i:c:\test\pdbstream.txt -p:"C:\test\somelibrary.pdb" -s:srcrv

The pdbstream.txt contents are pretty basic:
SRCSRV: ini ------------------------------------------------
VERSION=1
SRCSRV: variables ------------------------------------------
SRCSRVTRG=%var1%
SRCSRVCMD=cmd echo %var1% >> c:\test\output.txt
SRCSRV: source files ---------------------------------------
C:\somedifferentpath\somelibrary\sources\firstclass.cs
C:\somedifferentpath\somelibrary\sources\secondclass.cs
SRCSRV: end ------------------------------------------------

According to the info on MSDN I added only the required parameters. To my understanding, this should run the command in the SRCSRVCMD variable when the debugger loads the pdb file and searches for the source files. So I would expect some output in c:\test\output.txt.
I have verified that the correct pdb file is loaded for the module, but when i'm debugging in Visual Studio it does not find any source file. The output shows:
"SRCSRV: The module 'C:\test\somelibrary.dll' does not contain source server information."

Is the source stream not valid, or am I simply overlooking a particular step? Or can I change the absolute source location in the pdb file without inserting a datastream?
Edit
To clarify, I am currently using the Visual Studio debugger. The code I am trying to debug is in private libraries I created myself. I want the .pdb files to point to the correct source files after everything (dll, pdb & source files) is moved to a different location on disk.


text:
Q: Textbox Text was truncated in jquery if contains any space i'm trying to update text to textbox but it ignore text after whitespace
$.each(areas, function(i, value) {
    $("#Area_block_edit").append("
" +
        "
Name
" +
        "<input type='text' readonly='true' class='newregionText' value=" + value + " />
");
});

×

Edit Multiple Area

        + Add More
        <input type="button" value="Save Area" title="SaveArea" class='AreaBtn okBtn' id='AddNewAreas' />

i'm updating like above  . . areas contain following texts testing 123 , testing 1234 but it added only testing , testing in textbox


text:
Q: Why do I have to replay the first level every time I open Dungeon Defenders? Every time I open the game, I have to restart at the first map. My characters and items save but not the gaming levels themselves. I can play level 2 if I do it right after beating level 1, but if I close the game only the level 1 map is available. Is there a way to fix this?

A: Found a fix here, on the official forums.

Right click on the game in steam -> Properties -> Verify game cache
  When I did that it said "2 files failed to validate and will be reaquired"
Then I restarted my game and got all my progress back. I never had the problem with deleted characters or lost items though. I was just unable to access levels I had unlocked. It might be a steam updating problem.


text:
Q: How would you return an Observable from a function I have this function:
  getData(): Observable<ServerResponse> {
    const data = {} as ServerResponse;

    data.client = this.getClientData().pipe(
      map(response =>
        response.map(x => {
          return x.data.client;
        }),
      ),
    );

    data.otherData = this.otherData().pipe(
      map(response =>
        response.map(x => {
          return this.groupByTimePeriod(x.data.other, 'day', 'week');
        }),
      ),
    );
  }

The function need to return data with all the properties that gets assigned to that inside a function. How would you do that?
If I just do return data it is does not work as this.getClientData() and this.otherData() has not yet being completed.

A: Well, you have multiple questions/problems here. I'll start with the easiest. How do you get an observable from a function/object? The answer is via observable of:
return of(data);

But you eluded to a larger problem, which is: how do you defer returning data until child observables emit their values? You are looking for forkJoin. Via the docs:

forkJoin will wait for all passed Observables to complete and then it will emit an array with last values from corresponding Observables. So if you pass n Observables to the operator, resulting array will have n values, where first value is the last thing emitted by the first Observable, second value is the last thing emitted by the second Observable and so on. That means forkJoin will not emit more than once and it will complete after that.

You also have several other problems. For example, you are never subscribing to this.getClientData() or this.otherData(). Observables are lazily executed. Code in your observable will not execute until something subscribes to it. From the docs:

The code inside Observable.create(function subscribe(observer) {...}) represents an "Observable execution", a lazy computation that only happens for each Observer that subscribes.

It also appears as though you are using pipe/map in an attempt to set a property on your data object. But you're never setting data.client or data.other, so they will always be empty.
So, putting it all together, here's what your code might look like, with simulated server latency to show that forkJoin waits for completion of both observables:
import { Injectable } from '@angular/core';
import { Observable, of, forkJoin } from 'rxjs';
import { delay } from 'rxjs/operators';

@Injectable({
    providedIn: 'root'
})
export class TestService {
    getData(): Observable<ServerResponse> {
        const allOperations = forkJoin(
            this.getClientData(),
            this.getOtherData()
        );

        const observable = Observable.create(function subscribe(observer) {
            // Wait until all operations have completed
            allOperations.subscribe(([clientData, otherData]) => {
                const data = new ServerResponse;
                // Update your ServerReponse with client and other data
                data.otherdata = otherData.other;
                data.client = clientData.client;
                // Now that data is 100% populated, emit to anything subscribed to getData().
                observer.next(data);
                observer.complete();
            });

        });
        // We return the observable, with the code above to be executed only once it is subscribed to
        return observable;
    }

    getClientData() : Observable<any> {
        return of({ client: 'Client 1' });
    }
    getOtherData(): Observable<any> {
        // Fake server latency
        return of({ other: 'Other data that takes a while to return from server...' })
            .pipe(delay(2000));
    }
}

export class ServerResponse {
    client: string;
    otherdata: string;
}

If you call getData() and subscribe to the observable, you will see that forkJoin works as intended and we have to wait 2 seconds for both child observables to complete and our observable to emit a value:
this.testService.getData().subscribe(data => {
  console.log(data);
});

It seems that you might be new to RxJS / asynchronous programming. I suggest reading the excellent introduction to RxJs when you get a chance. It can be tricky at first but with practice this will come to be second nature.


text:
Q: jQuery ajax chat reload I'm working on a simple webchat application for my website. However, for me, it feels wrong using interval and requesting the chat with ajax every second?
What I'm doing today is this,

Is there any other better way?

A: you could use Server Side Events which should allow the same thing but send the data to the browser when it has changed so the user isnt constantly requesting to see if a change has been made.

A: This is  really cool article regarding chat application and best way to implement comet using jQuery.
Its works for me.
There is few hack needed in order to make it perfect because its work in timestamp so when you change your machine date its fail to perform but on server its work fine.
Replace text file implementation using xml that is good practice.

A: I wrote this couple of times. Ajax chat with polling from DB is not really a chat in real time. And you are right, using interval to poll data sucks. Anyway this is solution (one and only real solution).
You need to read this book. If you do not have jabber server I will give you acces to mine (user register update etc). Read the book and then contact me. It is XMPP + Strophe library chat (that what google and facebook are using)! So it is better to start over and learn something new!


text:
Q: Inserting Binary Array in SQLite DB with JDBC I'm not terribly familiar with the serialization of objects in java but I'm trying to insert an object that I serialized into a table that consists of 2 columns: sampleTimestamp INTEGER, data BLOB. Using the code:
// Binary Serialization of the object
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                ObjectOutputStream os = new ObjectOutputStream(bos);
                os.writeObject(result.getTopicInstance());
                byte[] byteArray = bos.toByteArray();
                os.close();

                String query = SQLiteInterface.getInstance().insertOI("data", "sampleTimestamp, data", "" + result.getTimestamp() + "," + byteArray);

public String insertOI(String tableName, String columnList, String values)
{
    return "INSERT OR IGNORE into " + tableName + "(" + columnList + ") values(" + values + ")";
}

The query returned from this is:
INSERT OR IGNORE into data(sampleTimestamp, data) values(1520448720940000000,[B@d32e4c)
The query indeed gets to SQLite and issued but returns the error:
[SQLITE_ERROR] SQL error or missing database (unrecognized token: "[B@d32e4c)")

This is likely a sqlite formatting error because it doesn't like the "[" being in the query. Edited based on comments below - This is the .toString representation of the byte array. How do I correctly get the byte array into an insert statement for SQLite?


text:
Q: How do you use the Convert function with RowFilter/CustomFilter when column name has special characters? I want to convert all my column fields to string for easy filtering, but one of my columns is named item#.  How can I use Convert() in this way or is there a better solution?
dv.CustomFilter = string.Format("Convert('{0}', 'System.String') LIKE '%{1}%'", columnname, text)

I tried the following syntaxes with the '[]' brackets, but neither are working.
dv.CustomFilter = string.Format("Convert('[{0}]', 'System.String') LIKE '%{1}%'", columnname, text)

dv.CustomFilter = string.Format("[Convert('{0}', 'System.String')] LIKE '%{1}%'", columnname, text)

A: Right... i'd suggest following. [] is to escape # character that you've talked about. Also, I'm putting % before and after "text" so that it searches for any column name with that.
dv.CustomFilter = string.format("CONVERT(["+columnname+"], System.String) LIKE '%"+text+"%'");