text:
Q: How to get Customer Id while exporting customer details in magento backend I wish to download Customer Id while exporting customer details in Magento back-end?
Systems -> Export->Customer Main file
Can anybody guide me , how to include customer id while export customer data

A: There would be no way unless we do override a class
app/code/Vendor/CustomerImportExport/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\CustomerImportExport\Model\Export\Customer" type="Vendor\CustomerImportExport\Model\Export\Customer"/>
</config>

app/code/Vendor/CustomerImportExport/Model/Export/Customer.php
<?php

namespace Vendor\CustomerImportExport\Model\Export;

use Magento\Framework\Exception\LocalizedException;

class Customer extends \Magento\CustomerImportExport\Model\Export\Customer
{

    const COLUMN_ENTITY_ID = 'entity_id';

    /**
     * Permanent entity columns.
     *
     * @var string[]
     */
    protected $_permanentAttributes = [
        self::COLUMN_ENTITY_ID,
        self::COLUMN_EMAIL,
        self::COLUMN_WEBSITE,
        self::COLUMN_STORE
    ];

    /**
     * Export given customer data
     *
     * @param \Magento\Customer\Model\Customer $item
     * @return void
     * @throws LocalizedException
     */
    public function exportItem($item)
    {
        $row = $this->_addAttributeValuesToRow($item);
        $row[self::COLUMN_WEBSITE] = $this->_websiteIdToCode[$item->getWebsiteId()];
        $row[self::COLUMN_STORE] = $this->_storeIdToCode[$item->getStoreId()];
        $row[self::COLUMN_ENTITY_ID] = $item->getId();

        $this->getWriter()->writeRow($row);
    }
}


text:
Q: Error in function azure when updating runtime python - Failure Exception: AttributeError: module 'os' has no attribute 'add_dll_directory' I've got an error when I try to update the python runtime of a function Azure, from 3.6 to 3.7 or 3.8, because version 3.6 is no longer used in Azure.
This is the full error:
Result: Failure Exception: AttributeError: module 'os' has no attribute 'add_dll_directory' Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 355, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/loader.py", line 127, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/site/wwwroot/CopyTransactionHttpTrigger/__init__.py", line 8, in <module> from confluent_kafka import avro File "/home/site/wwwroot/.python_packages/lib/site-packages/confluent_kafka/__init__.py", line 18, in <module> _delvewheel_init_patch_16682001180() File "/home/site/wwwroot/.python_packages/lib/site-packages/confluent_kafka/__init__.py", line 9, in _delvewheel_init_patch_16682001180 os.add_dll_directory(libs_dir)

Python 3.7 and 3.8
modules in requirements.txt file:
azure-functions==1.12.0 confluent-kafka==1.7.0 confluent-kafka[avro]==1.7.0 requests azure.storage.blob
I tried to update the function Azure with python 3.7 and 3.8 installing all dependencies above (modules) with such runtimes.
I think this module is necessary => module 'os' has no attribute 'add_dll_directory', and I don't know how to solve it.
What I see on the documentation of os module, it's used for windows. Do I need this module (os) in Azure?, can I avoid it by code?, if so, how?

A: I just install the function in linux on my local machine and deploy it from there adn it works. The issue was that I was deplying form a windows environtment.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Edit TinyMCE Button Functionality How can I edit the "Align Right" button functionality on Wordpress' TinyMCE to add a class "alignright" instead of "style='text-align: right'" for text.
TinyMCE already has that functionality but it only adds that class to images and other elements but not div, p, spam... etc.

A: Different Purposes
The alignright class is used for floating elements where as the "Align Right" TinyMCE button is for changing the text justification. Those are actually fundamentally different things. If the button worked as you described it, then either one or text or images wouldn't behave as expected.
Solution
Instead, I would recommend you add a class via the styleselect menu that can be applied to different elements. (I just released a plugin that makes this a little easier but I'll use custom code here. One thing the plugin does is completely replace the similar formatselect with the styleselect.)
First you need to add the styleselect to the menu. If you wanted it in the first row, it would be like this:
add_filter( 'mce_buttons', 'wpse180367_mce_buttons_1' );
function wpse180367_mce_buttons_1( $buttons ) {
    $buttons[] = 'styleselect';
}

Next, you'd have to register the class you want and define the types of elements it can apply to (this greatly effects its behavior):
add_filter( 'tiny_mce_before_init', 'wpse180367_mce_init' );
function wpse180367_mce_init( $args ) {
    $style_formats = array(
        array(
            'title' => '"Align Right"',
            'class' => 'alignright',
            'block' => 'p', // this class will always be applied to a <p> element. I don't know if you can specify multiple blocks. You could see what happens if you omit it too.
        ),
    );
    $args['style_formats'] = json_encode( $style_formats );
    return $args
}

Finally, you'd need to make sure that your theme uses an editor-style.css file (registered via add_editor_style()) to make elements actually follow the class when in the editor. I assume you have something like this in mind:
.alignright { /* you might want to qualify" this to one element e.g. p.alignright */
    float: right;
    clear: right; /* I often do this but up to you */
    margin: 0 0 20px 20px;
}

* All of this code is untested but I'm fairly confident it will mostly work... :)
Links for Reference

*

*http://codex.wordpress.org/TinyMCE_Custom_Buttons

*https://wordpress.stackexchange.com/a/128950/9844

*http://tinymce.com/wiki.php/Configuration:formats

*http://tinymce.com/wiki.php/Configuration:style_formats

*http://codex.wordpress.org/Editor_Style

*https://wordpress.org/plugins/mrw-web-design-simple-tinymce/


text:
Q: Implicits from subclass I am trying to implement template method pattern with implicits. Class A is the top class with 2 extensions.
Class A that is defining the template pattern and has some method doSomething(). This method uses several implicits inside. This class is abstract.
Class B and Class C are extending Class A, providing implicits in scope, implementing other abstract methods and are no more abstract.
Example (using spray's pipeline):
A:

abstract class A[T <: Any : Manifest] {
    ....
    abstract def method: PartialFunction[T,Unit] //not interesting

    def doSomething() {
         //method using implicit parser HttpResponse -> T
         val responseFuture: Future[T] = pipeline(Get(url))
         responseFuture.onSuccess(method)
    }
}

B:

import CaseClassB._ //importing implicits that transfer HttpResponse -> CaseClassB
class B extends A[CaseClassB] {
    def method: PartialFunction[CaseClassB,Unit] = {//not interesting}
}

This setting does not work (compilation of Class A fails because of "could not find implicit value for evidence parameter"). Is there a better way how to overcome this problem without a need to have something like "implicit abstract def" in Class A that would need to be overriden? The reason I don't like this is that Class B and Class C are providing implicits using imports.


text:
Q: How do you choose the right Ruby gem for your next project? Suppose you spent the last six months on a legacy system project, large corp obsolete web platform, integrating alien data structures.
Now you are finally off and you can go with a brand new startup project in Ruby.
The application will be built from scratch and is up to you to decide which gem you are going to use.
The question can be extended to the various aspects of building a brand new web application, but for semplicity, just suppose you need an authentication system.
Now, the last time you put in place that in Rails, was "authlogic" and it was so cool compared whith "authentication_fu", but while you where "in the cave" you just heard about several other way to authenticate, something like clearance, device, omniauth, warden, sorcery,  twitter-auth, open_id_authentication and may others.
Even worst, suppose you can "just imagine" Ruby community is not sleeping and in six months, she was blowing up new ideas and paradigms about "authentication pattern" but you didn't find the time to be updated.
You just want to go outside there, having a look at what's going on, finding all the new gem arising and deciding what fill better your next project.
How do you do it ?
Thanks in advance
Luca G. Soave
UPDATE Sep 18 10:36

Ruby toolbox compares gems in the same category by the metrics described - by Andrew Grimm
UPDATE Sep 17 02:09

Several people tried to clarify the process to discover and choose the right Ruby gem for "the next brand new Ruby project". I'd like to summarize what I learned from everyone by listing what in my comprension are the main steps :
About the process of deciding between gems in the same field:

*

*try a few of them yourself - by semperos

*give them each a test drive, make sure there is heavy activity on github, watching last
commits - by ealdent

*choose the the Loosely Coupled Gems vs Monolitic Frameworks, giving priority to agile and fast implementation and continuous refactoring - by Craig Stuntz

*getting expert of a gem/domain field, in order to be able to decide between gems - by james_schorr

*don't choose "WOW-things and Cool Fresh releases" for your production client projects, but test it daily on minor and private testing projets - by mikhailov
About the process to discover & choose the right gem, the last one by jeremiahd, is a deep, clear and very useful description of the process :

*

*search around for what seem like the most commonly installed libraries that cover my use case

*take a look at their documentation, to see how complete and readable it seems

*look at the activity in their community : updates - mailing lists - wiki -
IRC - commits - mood

*look at their code : test suites - clean code - documents - useful comments -

*use their code

*quality of the community and code

*do it as a learning process, get a better programmer and give back to your community
END UPDATE Sep 17 02:09
Feel free to add more, ... share your point of view.

A: What I do (when this problem rears it's head in any language) is I search around for what seem like the most commonly installed libraries that cover my use case. I then take a look at their documentation, to see how complete and readable it seems.
Next I look at the activity in their community -- are projects actively updated? Are there easily accessible mailing lists / a wiki/ IRC? How active are they? What's the general tone?
Next I look at their code. Are there test suites? Are they test suites that help me understand the library? Is the code clean? Documented? Commented usefully? Does it look like a ridiculous mess, or like it's had thought put into it at every point?
Next I use their code in a simplified, but similar, manner to how I actually need to use it. Did I run into any major stumbling blocks?
Screw flipping a coin and sticking with it. Sooner or later, whatever lib you're using isn't going to serve your needs, and you'll want to modify it's behavior. When that time comes, the quality of the community and the quality of the code are what make libraries stand out from one another.
This is, of course, a bit fuzzy. And it can be a challenging thing to do, but you'll be a better programmer for it, and assuming you do it enough, you'll probably be contributing back upstream to the libraries you use at some point, which is pretty awesome.

A: Pick one and run with it. The important point is not what you choose right now, but how hard it will be to change your mind six months down the road. In short, your efforts should not go into making one, permanent decision which will bind you for the lifetime of the project, but on isolating the dependencies on the authorization system to a single (as much as possible) small and easily swapped bit of code.

A: In my opinion, you should try a few of them yourself.
It seems that Devise has become somewhat of a de facto choice, with mechanisms to support a variety of authentication styles. That might be a nice place to start, but you should obviously try to make it do what you want, and if it doesn't work, try others of the gems you mention.
Rails does not have a "default" authentication mechanism pre-built because authentication tends to be specific to each project. Try several out, see which one fits your needs and programming style best.

A: I mostly agree with Craig Stuntz, you should just pick one and run with it (and build your app so that it can be swapped out, if possible).
I will suggest, however, that doing that means you give them each a test drive.  Perhaps you don't do that in your main project, but really, until you actually use the thing, you will never know just how messed up it is.  And no matter how much love the community is throwing at a gem today, you can be sure there are serious issues with it.
For relatively new gems, you also need to make sure there is heavy activity on github or whatever, so that the gem isn't going to stagnate any time soon.  If I don't see a commit in the past few weeks, it makes me really uneasy about using a gem that isn't already mature.

A: I spent a lot of time looking at authentication gems and landed on Devise.  It's been great.  All of the above tips are great.

A: I wrote a blog post on this very question - How to pick the right Ruby Gem?
http://www.railstutors.com/blog/how-to-pick-the-right-ruby-gem
The main idea - First check if really need a gem to do what you want; Then some consideration on how to evaluate a Ruby gem. I also happened to use an Authentication as use case so you may find that interesting.

A: It is my daily choice, what is the way we go tomorrow to satisfy our clients needs. How to be on the edge and keep users happy with stable and reliable system?
First off, we do not accept WOW-things and Cool Fresh releases. We will use new things in 0.5 year, as a tesing period. Yes, we still on Rails 2.3.10. Upgrade to Rails 3 will be next month for us. We have codebase with Core covered by tests, Rspec do great job for us, there is about 94 tests.
But, we try modern gems during daily development and do small projects to see how they work. It's easy and free, take the time only. Railscasts satisfy interest in cool stuff too, it's important to see each of them.


text:
Q: How to run code that needs too much RAM on OpenShift? I have a problem with OpenShift. Currently I am trying to add django_geoip to my django app. However, when I try to initialize its database, OpenShift kills it. I think it is needing too much memory.
If I run update code ./manage.py geoip_update(I also tried running with nohup), this is the output:
Downloading zipfile from ipgeobase.ru...
INFO:import:Downloading zipfile from ipgeobase.ru...
Extracting files...
INFO:import:Extracting files...
Updating locations...
INFO:import:Updating locations...
Updating CIDR...
INFO:import:Updating CIDR...
61%

After 61% of CIDR update it crashes. If I am following log or am logged in through ssh, it disconects me:
/var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/ruby_compat.rb:30:in `select': closed stream (IOError)
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/ruby_compat.rb:30:in `io_select'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/transport/packet_stream.rb:75:in `available_for_read?'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/transport/packet_stream.rb:87:in `next_packet'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:183:in `block in poll_message'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178:in `loop'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178:in `poll_message'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:461:in `dispatch_incoming_packets'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:222:in `preprocess'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:206:in `process'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:170:in `block in loop'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:170:in `loop'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh/connection/session.rb:170:in `loop'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/lib/rhc/ssh_helpers.rb:198:in `block in ssh_ruby'
from /var/lib/gems/1.9.1/gems/net-ssh-2.9.2/lib/net/ssh.rb:215:in `start'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/lib/rhc/ssh_helpers.rb:173:in `ssh_ruby'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/lib/rhc/commands/tail.rb:40:in `tail'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/lib/rhc/commands/tail.rb:21:in `run'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/lib/rhc/commands.rb:294:in `execute'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/lib/rhc/commands.rb:285:in `block (3 levels) in to_commander'
from /var/lib/gems/1.9.1/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
from /var/lib/gems/1.9.1/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
from /var/lib/gems/1.9.1/gems/commander-4.2.1/lib/commander/command.rb:155:in `run'
from /var/lib/gems/1.9.1/gems/commander-4.2.1/lib/commander/runner.rb:421:in `run_active_command'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/lib/rhc/command_runner.rb:72:in `run!'
from /var/lib/gems/1.9.1/gems/commander-4.2.1/lib/commander/delegates.rb:12:in `run!'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/lib/rhc/cli.rb:37:in `start'
from /var/lib/gems/1.9.1/gems/rhc-1.36.4/bin/rhc:20:in `<top (required)>'
from /usr/local/bin/rhc:23:in `load'
from /usr/local/bin/rhc:23:in `<main>'

I only guess it was heavy memory usage. I tried to empty my database and deleted log files so that I was sure it was not capacity problem(disk quota exceeded).
My question is: How do I run this command to make it work? May I somehow limit needed resources?

A: Well I found out it was caused by geoip creating django_geoip_iprange table, that has around ~218 000 records. Geoip probably loads all these ips into memory and then stores them to database. I was able to import table django_geoip_iprange from localhost, so django_geoip should be fully functional now.
Additionally, I should be able to use ulimit to limit resources required. Did not test that yet.


text:
Q: GCloud Storage Rewrite operation performance/latency What is the average time that a rewrite API operation takes to complete rewrite for different sizes of objects?
Assume: rewrite of the same object, same source and destination but with different CMEK (of KMS).
There is no documentation regarding this. I need this information to estimate how much time a batch re-write job takes to complete when there are many objects.
I understand that latency might be a hard question to answer, but I'm only interested in whether it finishes in seconds or minutes etc(for example for an object that is couple of GBs say 3GB).
Since all of rewrite happens inside google components itself, I'm unable to figure this out. Any help or documentation related to this would be of great help.

A: If the source and destination buckets are in the same location and storage class, rewrite will be a fast (metadata-only) operation.
Otherwise the bytes have to be copied by the service, so time grows with object size and also will be slower if the source and destination are far apart (e.g., across an ocean). You can try doing some benchmarking experiments if you want a more precise answer than that.


text:
Q: extending JSX css element In react JSX theme I have 2 CSS  elements.
button1: {
        color: 'white',
        borderColor: 'green',
        backgroundColor: 'white',
        "&:hover": {
            backgroundColor:"white"
        },
        borderTopRightRadius: "18px",
        borderBottomRightRadius: "18px",
        borderTopLeftRadius: "18px",
        borderBottomLeftRadius: "18px",
        width: '180px'
}
button2: {
        color: '#7F4095',
        borderColor: '#7F4095',
        backgroundColor: 'white',
        "&:hover": {
            backgroundColor:"white"
        },
        borderTopRightRadius: "18px",
        borderBottomRightRadius: "18px",
        borderTopLeftRadius: "18px",
        borderBottomLeftRadius: "18px",
        width: '180px'
}

If you see most of the properties are same. How do I make sure I have 2 elements but they reuse the code.

A: You can use spread syntax:
const button_proto = {
  backgroundColor: 'white',
  "&:hover": {
    backgroundColor: "white"
  },
  borderTopRightRadius: "18px",
  borderBottomRightRadius: "18px",
  borderTopLeftRadius: "18px",
  borderBottomLeftRadius: "18px",
  width: '180px'
}

const styles = {
  button1: {
    ...button_proto,
    color: 'white',
    borderColor: 'green'
  },
  button2: {
    ...button_proto,
    color: '#7F4095',
    borderColor: '#7F4095',
  }
}

Documentation for spread syntax (...)


text:
Q: How do you debug an Azure WebJob that won't start? I have a WebJob that is triggered by an Azure Storage Queue. When I test this locally everything works fine. When I publish the WebJob (as part of an Azure WebSite) and then go to the Azure Management Portal and try to start the WebJob, it throws and error.
I had this running earlier, but it was having problems so I deleted the job in the management portal and tried to republish the web site with the web job.
Any suggestions on how to figure out what's going on?

A: In the old Azure Management Portal there was no clear way I could find to kill the process (stop the Job if there was one). Using the new portal, I looked at all the processes running on the site and there was the WebJob running 26 threads. After killing the process I was able to start the recent uploaded one.


text:
Q: JDBC Connection to SQL Server 2000 reset randomly on Solaris server I have the following method being called in a Java EE web application.
public static void submitToPending()
{
    Db db;
    ResultSet rs;

    try
    {
        db = new Db("Database.properties");

        rs = db.issueQuery(getDescriptorList());

        while (rs.next())
        {
            db.insertApplicationData(rs.getString("Id"));
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    finally
    {
        db = null;
        rs = null;
    }
}

This is an abbreviated snippet of code I am running to insert about 40,000 new records into a SQL Server 2000 database. This code is executed from a JSP that is hosted on a Solaris 10 server in production. Prior to this year, this code only had to process about 18,000 records, and it worked flawlessly. This year there were some updates made and, to spare details, now processes roughly 40,000 records.
During development I test this on the same database used in production (as the record sets do not conflict) from my Windows PC, from a Tomcat server running inside of Eclipse. Everything works correctly, and all 40,000 or so records make it to the database.
When I installed the site to the production server and ran a test I noticed that over halfway through the process was failing, with the following exception message:

com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
  at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)
  at com.microsoft.sqlserver.jdbc.SQLServerStatement.checkClosed(Unknown Source)
  at com.microsoft.sqlserver.jdbc.SQLServerResultSet.checkClosed(Unknown Source)
  at com.microsoft.sqlserver.jdbc.SQLServerResultSet.next(Unknown Source)
  at (ClassNameOmittedToProtectTheInnocent.java:74)

The SQL Server is set to unlimited simulataneous connections, unlimited timeout. Assuming my code in class Db is OK (since it is working on the Windows side of things and, up until the data increase, had been performing well on the Solaris side) what are some ideas to start checking out?
I tried tracing the SQL Server to see if something was happening with the connections, but it appears to be alive even after the stack trace is written.
If I can provide any additional information, please let me know. I'll do the best I can to help.

A: I'm suspicious of your setting your database and result set reference to null without closing them. I would explicitly close these (if you have a connection pool, closing a connection doesn't actually close it, but acts as a signal to return the connection to the pool).
I'm guessing that you're running into a resource limit such as the maximum number of open file descriptors per process, and the failure to close a result set/connection will be the source of this issue.


text:
Q: Hold several jobs in Slurm I know that for a specific job ID, I can use scontrol hold $JOBID.
How can I hold jobs for several IDs or/and hold jobs for a range of jobs ids (e.g. scontrol hold 294724-294749)?
Also, how can I hold jobs based on my $USER?

A: First off, if all your jobs have the same name, you can use
scontrol hold <jobname>

to hold them all.
But the scontrol command accepts a list of job IDs, which can be either space- or comma-separated. So if your jobs have consecutive job IDs, you can use Bash's {1..n} (Brace expansion) construct to generate the list and feed it to scontrol:
scontrol hold {294724..294749}

Otherwise, one common idiom is to use squeue's output formatting capabilities to generate scontrol commands and feed them to a shell:
squeue --user $USER --format "scontrol hold %i" | sh

(When doing that, it is wise to first run the squeue command without piping to sh to review its output before running it again through sh)


text:
Q: Closure compiler removes more than what I want to remove I've followed the advice from this other SO thread to remove console.log() statements from my code.
Unfortunately, now Closure compiler is removing my entire code and not just the console.log() statements.
Might someone explain this? I'm at a loss...
JS file 1
(function(){
/** @const */
LOG = false;

function log() {
    return console.log.apply(console, arguments);
}

LOG && log('hello world !');

var foo='bar';
LOG && log("foo"+foo);
})();

JS file 2
(function(){
/** @const */
LOG = false;

function test(){
    alert('testing...');
}

var baz='bazzy';
LOG && log("baz"+baz);

})();

Closure compiler step:
$ java -jar compiler-latest/compiler.jar --js j1.js j2.js --js_output_file compiled.js

Result:
(function(){LOG=!1})();(function(){LOG=!1})();

A: Because the compiler determines that the rest of your code is unreachable.
Both files have a constant LOG set to false and you are not exporting anything (goog.export* or window['...'] = ...).
The code which could get executed has a LOG && in front of it, which means it is not executed.
Therefor nothing can get executed, and thus the compiler removes it all.
Why is function test remoed: nobody calls it, simple as that. Call it in one of your files, and the compiler won't strip it away.

You can (should, actually) define LOG and log only in one file.
For that to work, remove the anonymous function call around your code in every file.
You can tell the compiler to add it back to the compiled code with the commandline option:
--output_wrapper=(function(){ %output% })();

So your two files should look like this:
JS file 1
/** @const */
var LOG = false;

function log() {
    return console.log.apply(console, arguments);
}

LOG && log('hello world !');

var foo='bar';
LOG && log("foo"+foo);

JS file 2
function test(){
    alert('testing...');
}

var baz='bazzy';
LOG && log("baz"+baz);

// call test, so it a) isnt stripped and b) well, executed :)
test();

Also, you might want to put your global vars and functions into a "namespace" to not pollute the global scope:
// create namespace (which is just a normal object)
var MyNamespace = {};

// create a namespaced function
MyNamespace.test = function() {
    alert('test');
}

// call it
MyNamespace.test();


text:
Q: C++ Assign value of class member from a different function Let's say I have a class:
class Test
{
    public:
          int x = 1;
};

and within main I create an object of said class and call a function called setInt:
int main()
{
     Test example;
     setInt(example);
     std::cout << example;
}

void setInt(Test example)
{
     (// random if statement)
           example.x = 5;
}

This would output 1.
How would this be possible? I know in the example above the variable "example" is local to the function only, but is there a way to change the value of the variable in main()?
(Please excuse any errors in code)

A: You're just copying the integer and then assigning a new value but not manipulating with the original values. If you could've written:
void setInt(Test& example)
{
    // Now you are changing the original value here
    example.x = 5;
}

It could then work. There's an alternative of reference-to operator, that's called pointers. They works like references through function. When you change their values anywhere on dereference, the main value is also changed.

A: By default, passing an argument to a function passes it by value, which copies the argument. Changes to this copy in the function are not reflected in main.
If you want to modify the argument that is passed in, you can use references. Change your signature to:
void setInt(Test &example) { // changing example changes the argument used in main


text:
Q: sql count function Hi I have three tables and I want to know how much jobs with the wage of 1000 an employee has had
The first SQL query gives me the names of all the employees that has recieved 1000 for a job
SELECT distinct first_name
FROM employee, job, link
WHERE job.wage = 1000
  AND job.job_id = link.job_id and employee.employee_id = link.employee_id;

The second SQL query gives me the total number for all employees of how much jobs they have made for 1000
SELECT count(wage)
FROM employee, job, link
WHERE job.wage = 1000
  AND job.job_id = link.job_id and employee.employee_id = link.employee_id;

I was wondering if there was a way of joining both queries and also making the second for each specific employee???

A: Something like below should work and you shouldn't need to the distinct first_name anymore.
select first_name, COUNT(wage) FROM employee, job, link  WHERE job.wage = 1000    AND job.job_id = link.job_id and employee.employee_id = link.employee_id
GROUP BY first_name

A: you might need to use group by keyword
SELECT count(wage), first_name
FROM employee, job, link
WHERE job.wage = 1000
  AND job.job_id = link.job_id and employee.employee_id = link.employee_id;
GROUP BY first_name

the drawback on this would be if there are different employee has the same first_name it would consider to the same count.

A: I would also recommend changing your implicit joins to explicit joins:
SELECT employee.employee_id, first_name, last_name, count(wage) as wage_count
FROM
    employee
    JOIN link ON employee.employee_id = link.employee_id
    JOIN job ON job.job_id = link.job_id
WHERE job.wage = 1000
GROUP BY employee.employee_id, first_name, last_name


text:
Q: how to correctly handle object XMLHttpRequest in javascript from PHP via refreshDiv When it comes to Javascript i have no idea what I am doing just try and error method. Been trying to do my research on AJAX and Javascript with no luck so far so please point me in the right direction.
Basically I need to refresh a DIV every lets say 5s with data generated from PHP => Database,
ON first load of the page everything is fine as it gets data directly from PHP but when Javascript kicks inn all i get is [object XMLHttpRequest] in place of DIV content;
HTML

and then the DIV

    <?php include("getuserinfo.php"); ?>

And the PHP goes like this :
require_once('../mysqli_connect.php');
$userid = 1000042;
$us_credit = 0 ;
$us_prof_view = 0 ;
$us_new_msg = 0 ;

//Get $us_credit , $us_prof_view , $us_new_msg
$q="SELECT ac_ballance, prof_views, COUNT (msg_id) AS messages FROM user_details INNER JOIN com_msg ON us_name = msg_to WHERE user_id =".$userid." AND msg_new =1";
$r = mysqli_query($dbc,$q);
if(mysqli_num_rows($r)== 1) {
    $us_data = mysqli_fetch_array($r,MYSQLI_ASSOC);
    $us_credit = $us_data['ac_ballance'];
    $us_prof_view = $us_data['prof_views'];
    $us_new_msg = $us_data['messages'];
}
mysqli_free_result($r); #not needed
?>

Your Credits :
    <?php echo $us_credit ; ?>
     Profile views :
    <?php echo $us_prof_view ; ?>

    New Messages   :
        <?php echo $us_new_msg ; ?>

Thanks in advance

A: Change
if (request.readyState == 4 && request.status == 200) {
     console.log(request.responseText);
}

to
if (request.readyState == 4 && request.status == 200) {
    document.getElementById("usinfo").innerHTML=request.responseText;
}

This if statement waits for a successful response back from the server and then executes. In your case, it waits for the HTML to be received then inserts it into the div.
What you are trying to do is wrong for two reasons:

*

*You're not inserting the response text, you're trying to insert the response object. Hence the weird result.

*You're not waiting for the response to come back from the server. It may seem that because you put the code at the bottom it will have already received the server's response but in actuality because the request is asynchronous and involves another script, you will be trying to insert before you have ever received a response.


text:
Q: Can't subscribe to Pusher channel using nodejs I'm trying to use the Pusher nodejs module to subscribe to Bitstamp's live orderbook feed.
var Pusher = require('pusher');
var pusher = new Pusher('de504dc5763aeef9ff52');
var order_book_channel = pusher.subscribe('order_book')

Nodejs replies with:
TypeError: Object #<Pusher> has no method 'subscribe'

Not too sure where the problem lies, any help would be appreciated.
Kind regards,
Christian

A: Instead of pusher library, require the pusher-client library.
From there on proceed as normal..
var Pusher = require('pusher-client');
var pusher = new Pusher('de504dc5763aeef9ff52');
var order_book_channel = pusher.subscribe('order_book');
order_book_channel.bind('data', function(data) {
    console.log(data);
})


text:
Q: Obtener los registros que no están en otra tabla Buena;
Tengo la siguiente consulta;
SELECT *
FROM data_inicio_primera_etapa
INNER JOIN data_base_ct
ON data_base_ct.codct = data_inicio_primera_etapa.codigo_ct
WHERE data_base_ct.codct = data_inicio_primera_etapa.codigo_ct

Y me arroja lo siguiente:

Hasta aqui todo bien, ahora quiero lo opuesto, quiero los registros que no están, intente invertir la consulta de la siguiente manera;
SELECT *
FROM data_base_ct
INNER JOIN data_inicio_primera_etapa
ON data_base_ct.codct = data_inicio_primera_etapa.codigo_ct
WHERE data_base_ct.codct <> data_inicio_primera_etapa.codigo_ct

Pero no no obtengo ningun registro;

A: Lo que pasa es que tienes 2 condiciones que se contradicen:
ON data_base_ct.codct = data_inicio_primera_etapa.codigo_ct

y
WHERE data_base_ct.codct <> data_inicio_primera_etapa.codigo_ct

Es imposible que las 2 condiciones sean ciertas al mismo tiempo para un registro. Si la primera condición es cierta, la segunda debe ser falsa, y vice versa. Por eso no te devuelve ningún registro.
Si deseas conseguir los registros que no están en otra tabla, en mi opinión lo más sencillo es usar la claúsula NOT EXISTS:
SELECT *
  FROM data_base_ct t1
 WHERE NOT EXISTS (SELECT NULL
                     FROM data_inicio_primera_etapa t2
                    WHERE t2.codigo_ct = t1.codct)

Edición
Seguimiento a los comentarios, no me sorprendería si MySQL tienes sus caprichos en la forma de ejecutar la consulta con el NOT EXISTS, de modo que te dejo otras consultas equivalentes, pero que tal vez ejecutan más rápido, si deseas probarlos y compararlos.
Con LEFT JOIN:
SELECT t1.*
  FROM data_base_ct t1
  LEFT JOIN data_inicio_primera_etapa t2
    ON t2.codigo_ct = t1.codct
 WHERE t2.codigo_ct IS NULL

Con NOT IN:
SELECT *
  FROM data_base_ct
 WHERE codct NOT IN (SELECT codigo_ct
                       FROM data_inicio_primera_etapa)


text:
Q: Can't vertically center a paragraph inside a div I've got a container div with a paragraph and another div which contains an image. Both the paragraph and the div are inline. I can't figure out how to vertically center the paragraph. I've tried using vertical-align: middle but it didn't do much.

A: You need to set a height to your container (as I told you in comments).
And here is a method (among others) to vertically center with flex properties, no matter the container height.

.col-md-6 {
    height: 500px;
    // The container must be flexible
    display: flex;
}

.historic-story {
    font-size: 25px;
    text-align: center;
    // This is the property which centers
    align-self: center;
  }

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec commodo in tellus ut varius. Etiam posuere ultricies maximus. Donec non turpis dolor. Donec erat nulla, mollis sit amet consectetur in, tempus vitae urna. Quisque elementum in felis eget pretium. Phasellus ultrices ligula ut consequat efficitur.

A: Forget the margins.  That will only work horizontal. Set the top and bottom padding of your #historic-container to equal each other.  Try 10% top and bottom padding. Forget the vertical align too.


text:
Q: How does one get the MAUI.Graphics.IImage object from image picked from mediaPicker? I have been trying to get Microsoft.Maui.Graphics.IImage object from the image I picked using Microsoft.Maui.Media.MediaPicker.
I tried to use
var file = await MediaPicker.PickPhotoAsync(new MediaPickerOptions
            {
                Title = "Pick a photo"
            });

var memoryStream = new MemoryStream();
var filestream = await file.OpenReadAsync();
await filestream.CopyToAsync(memoryStream);

byte[] byteArray = memoryStream.ToArray();
Microsoft.Maui.Graphics.IImage image;
Microsoft.Maui.Graphics.IImage newImage;
image = Microsoft.Maui.Graphics.Platform.PlatformImage.FromStream(memoryStream);

if (image != null)
{
    newImage = image.Resize(720, 1280, ResizeMode.Stretch, true);
}

Now, the execution throws the error "Object not set to an instance of the object".
I debugged and saw that although the photo was being picked and was being loaded into the Memory Stream, the 'image' variable does not store the data after being assigned the value in the line:
image = Microsoft.Maui.Graphics.Platform.PlatformImage.FromStream(memoryStream);

The condition:
if (image != null)

returns true, but using the resize function throws the "Object not set to an instance of the object" error.

A: why don't you use your byte array ?
Try something like this :
Stream stream = await photo.OpenReadAsync();

stream.Position = 0;
byte[] byteArray;

using (BinaryReader br = new BinaryReader(stream))
{
   byteArray = br.ReadBytes((int)stream.Length);
}

And so, use LoadImageFromBytes  Here the documentation
Hope it helps.

A: Thanks for replies. For now, I have used the platforms specific code to use Android.Graphics.Bitmap class and iOS UIImage class respectively for each platform. This enables me to store the image in platform specific class objects instead of finding a multi platform class to store the image and resize it.


text:
Q: SQL Combining 2 rows into one I have the following query:
SELECT qn.ID,
       qn.Title,
       qt.Description,
       l.DisplayName AS Language,
       COUNT(q.ID) AS QuestionCount
  FROM dbo.Questionnaires AS qn
  JOIN dbo.QuestionnaireText AS qt ON qn.ID = qt.QuestionnaireID
  JOIN dbo.Questions AS q ON q.QuestionnaireID = qn.ID
  JOIN dbo.Languages AS l ON l.ID = qt.LanguageID
 WHERE (qn.QuestionnaireTypeID = (SELECT ID
                                    FROM QuestionnaireTypes
                                   WHERE Value = 'Quiz'))
GROUP BY qn.ID, qn.Title, l.DisplayName, qt.Description

which outputs the following table:
36132A45-F09C-4EB5-9BD2-34A227EC03B9     Test   NULL    English 1
36132A45-F09C-4EB5-9BD2-34A227EC03B9     Test   NULL    Spanish 1
24395BC7-A890-4514-AB35-7614E226B2A5     Quiz   NULL    English 1
24395BC7-A890-4514-AB35-7614E226B2A5     Quiz   NULL    Spanish 1
03B13E61-6D7F-4597-8BB6-83889C7BFE29    G Quiz  NULL    English 6
03B13E61-6D7F-4597-8BB6-83889C7BFE29    G Quiz  NULL    Spanish 6

What I need is the query to out put the following:
36132A45-F09C-4EB5-9BD2-34A227EC03B9     Test   NULL    English, Spanish    1
24395BC7-A890-4514-AB35-7614E226B2A5     Quiz   NULL    English, Spanish    1
03B13E61-6D7F-4597-8BB6-83889C7BFE29    G Quiz  NULL    English, Spanish    6

I am at a loss at this point.  Any suggestions?

A: This is how you'd do it with For Xml:
SELECT qn.ID,
       qn.Title,
       qt.Description,
       STUFF(
          ISNULL((SELECT ', ' + l.DisplayName
                  FROM dbo.Languages AS l
                  WHERE l.ID = qt.LanguageID
                  GROUP BY l.DisplayName
                  FOR XML PATH (''), TYPE).value('.','VARCHAR(max)'), ''), 1, 2, '')
           as Languages,
       COUNT(q.ID) AS QuestionCount
FROM dbo.Questionnaires AS qn
  JOIN dbo.QuestionnaireText AS qt ON qn.ID = qt.QuestionnaireID
  JOIN dbo.Questions AS q ON q.QuestionnaireID = qn.ID
  JOIN dbo.QuestionnaireTypes AS qtypes ON qtypes.Id = qn.QuestionnaireTypeID
WHERE qtypes.Value = 'Quiz'
GROUP BY qn.ID, qn.Title, l.DisplayName, qt.Description

Please note, I've also moved the WHERE criteria to another JOIN.


text:
Q: Popup window, how to Hide URL bar in IE8 when I open popup window and set location=0 or location=no, url bar is still shown in IE8 and readonly.
How can hide it?
Thanks

A: It cannot be done, modern browser don't allow it at that would be a major security flaw.
See also this answer, shamelessly copied from David Dorward:

In Internet Explorer 7 and later, you cannot remove the address bar in Internet Zone windows, for security (anti-spoofing) reasons.

http://msdn.microsoft.com/en-us/library/ms536651%28VS.85%29.aspx

A: Use PopupControl  instead of  pupup window.

A: You cannot hide address bar. Check the article.
Also check the link below.
http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/402ecb05-9833-4ca1-83f1-f486056a1c04


text:
Q: Fast factorization
For a given number n (we know that n = p^a * q^b, for some prime numbers p,q and some integers a,b) and a given number φ(n) ( http://en.wikipedia.org/wiki/Euler%27s_totient_function ) find p,q,a and b.

The catch is that n, and φ(n) have about 200 digits so the algorithm have to be very fast.
It seems to be very hard problem and I completely don't know how to use φ(n).
How to approach this?

A: For n = p^a * q^b, the totient is φ(n) = (p-1)*p^(a-1) * (q-1)*q^(b-1). Without loss of generality, p < q.
So gcd(n,φ(n)) = p^(a-1) * q^(b-1) if p does not divide q-1 and gcd(n,φ(n)) = p^a * q^(b-1) if p divides q-1.
In the first case, we have n/gcd(n,φ(n)) = p*q and φ(n)/gcd(n,φ(n)) = (p-1)*(q-1) = p*q + 1 - (p+q), thus you have x = p*q = n/gcd(n,φ(n)) and y = p+q = n/gcd(n,φ(n)) + 1 - φ(n)/gcd(n,φ(n)). Then finding p and q is simple: y^2 - 4*x = (q-p)^2, so q = (y + sqrt(y^2 - 4*x))/2, and p = y-q. Then finding the exponents a and b is trivial.
In the second case, n/gcd(n,φ(n)) = q. Then you can easily find the exponent b, dividing by q until the division leaves a remainder, and thus obtain p^a. Dividing φ(n) by (q-1)*q^(b-1) gives you z = (p-1)*p^(a-1). Then p^a - z = p^(a-1) and p = p^a/(p^a-z). Finding the exponent a is again trivial.
So it remains to decide which case you have. You have case 2 if and only if n/gcd(n,φ(n)) is a prime.
For that, you need a decent primality test. Or you can first suppose that you have case 1, and if that doesn't work out, conclude that you have case 2.

A: Try working out what n / (n - φ(n)) is.
Follow up:
n / (n - φ(n)) = pq.  You just keep dividing n by pq.


text:
Q: regarding conversion of php app to salesforce app I have a project for student management system running in php in my organization but now there is demand of converting that in salesforce how can i do that ?
Any help will be much appreciated.
Thanks

A: Salesforce owns the Heroku platform that can run PHP apps directly.
If you mean converting your PHP app into a native Salesforce app, then that is a re-write using Salesforce's Lightning Platform technologies. A first step would be to learn about that platform and Trailhead is a great way to do that starting with e.g. the Developer Beginner trail (that takes about 18 hours to go through). With that grounding, and given that you already have a design (presumably including a database schema) the re-write may not take too long.
Note that while the development work can be done without purchasing any licenses, to go into production usually requires licenses to be bought from Salesforce. These are priced per user per month and are not cheap.


text:
Q: LINQ to SQL caching problem this should be pretty simple.
I have LINQ to SQL (C# 3.5 / SQL Server) working well, with a simple relationship in place between two tables Conferences and ConferenceAttendees.
I have already created and committed a Conference, then I add 3 ConferenceAttendees using the following code (repeated 3 times):
ConferenceAttendee NewAttendee = new ConferenceAttendee();
NewAttendee.ConferenceId = ConferenceID;
NewAttendee.Name = ContactName;
NewAttendee.Email = ContactEmail;
db.ConferenceAttendees.InsertOnSubmit(NewAttendee);
db.SubmitChanges();

Works great and I see the 3 new attendees appear in the database.
UPDATE:
Then, using a brand new datacontext, I try the following:
string Names = String.Empty;
Conference RequestedConference = db.Conferences.FirstOrDefault(x => x.ConferenceId == ConferenceID);
   foreach (ConferenceAttendee Attendee in RequestedConference.ConferenceAttendees)
      Names += Attendee.Name + ", ";

But it doesn't have any related Attendees attached to it! (They definitely exist in the database and have been committed). But RequestedConference.ConferenceAttendees always has a count of 0 so the loop is never entered..
foreach (ConferenceAttendee Attendee in this.ConferenceAttendees)
{ Names += Attendee.Name; }

I'm doing this inside a Partial Class Conference, with a method I've made called PrintAllAttendeeNames().
What am I doing wrong and why doesn't this fresh datacontext easily see these related objects via LINQ when they ARE in the database committed already?
(Note: I've already tried calling
db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);

to no avail..)
Many thanks
CONFESSION UPDATE
I am an absolute moron. I had the dataContext setup as static. I never normally do that, that's why I never normally have problems with lazy loading.
I had this:
public static MyDataContext db = new MyDataContext(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString);

Of course, changing it to this solved the problem!!!
public MyDataContext db = new MyDataContext(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString);

A: A couple things. First, you should only submit your changes when you have made all the changes. You don't need to call SubmitChanges every time you create a new attendee. Create all three first, InsertOnSubmit each one, then make a single call to SubmitChanges. LINQ to SQL will generate more efficient, chunkier calls that way.
Second, I'm a little confused about the attendee loading issue. They should lazy load on the first access of the Attendee property. Each individual Conference would incur a separate query when its property is first accessed, so this isn't the most efficient way to handle it. You can tell L2S to pre-load all attendees for each Conference object that you load. You would do that with the DataLoadOptions class:
using (var context = new SomeContext(...))
{
    var options = new DataLoadOptions();
    options.LoadWith<Conference>(c => c.ConferenceAttendees);

    context.LoadOptions = options;

    var conferencesWithAttendees = from c in context.Conferences
                                   where c.Year = DateTime.Now.Year
                                   select c;

    foreach (var conferenceWithAttendee in conferencesWithAttendees)
    {
        conferenceWithAttendee.PrintAllAttendeeNames();
    }
}


text:
Q: Aging of objects in Gigaspaces I'm fairly new to Gigaspaces. I am using a polling container to fetch events from a space and then dispatch these over a HTTPS connection. If the server endpoint for the connection becomes unavailable, I need to update the state of the event objects to 'blocked' and re-queue them in the space for later retries (for which I have a separate polling container that specifically looks for the blocked events).
What I'm struggling with is finding a good way to ensure the blocked event polling container does not over-rotate on the blocked events (that is, read the events, discover that the endpoint is still blocked, write them back to the space and then immediately re-read them).
Is there a way I could build in a delay in re-reading the events from the space. Options might include:

*

*Setting/updating a timestamp on the object before writing it back, and then comparing this with the current time within the polling process (for this, I expect I would have to use a SQLQuery which includes SYSDATE as the EventTemplate, but would I have to query SYSDATE out of the space every time I want to update the object rather than using System.currentTimeMillias or equivalent, in order to ensure I am comparing apples to apples?)

*Applying a configuration setting of some kind on the blocked event polling container or listener that causes it to only poll periodically.

A: You can use both approach:

*

*docs.gigaspaces.com/xap97/polling-container.html#dynamic-template-definition

*docs.gigaspaces.com/sbp/dynamic-polling-container-templates-using-triggeroperationhandler.html

In the future, for GigaSpaces related questions, please use:
ask.gigaspaces.org/questions/
Thanks,
Ester.


text:
Q: how to use ls instead of find? I was using find to loop over some files ,the targets are the files that have this kind of structure:
EDI_2016-03-03_09-45-09_TARGET-TYPE_4830_453a2cbb-b8d4-4982_6549_6116_xazfzeg.PDF

the goal is to find the files that starts with EDI_ and contains TARGET-TYPE in the middle, using find the command was :
find . -name "EDI_*_TARGET-TYPE*"

And since i'm going to use the output with a loop i don't want to use find and use ls instead(i've had a lot of problem with files with spaces and find).
This works : ls EDI_

*

*does not work: ls EDI_*_TARGET-TYPE*

*and this does not work: ls "EDI_*_TARGET-TYPE*"

*and this does not work: ls 'EDI_*_TARGET-TYPE*'
and I dont really know why, if anyone can translate the find command to me that would be great .

A: What I would do :
for file in EDI_*_TARGET-TYPE*; do
    do_something "$file"
done

A: $ touch EDI_2016-03-03_0945-09_TARGET-TYPE_4830_453a2cbb.pdf
$ touch EDI_2016-03-03_0945-09_TARGET-TYPE_4830hhh_453a2cbb.pdf
$ ls EDI_*_TARGET-TYPE*
EDI_2016-03-03_09-45-09_TARGET-TYPE_4830_453a2cbb.pdf
EDI_2016-03-03_09-45-09_TARGET-TYPE_4830hhh_453a2cbb.pdf

Works for me. Bash shell Ubuntu recent LTS.


text:
Q: Can Azure Blob Storage synchronize to a source control repo? I have a web site for which the content is stored as a collection of photographs in JPEG files, along with some manually edited XML files containing metadata.  It's currently hosted with an old-school web hosting company, and I'm to migrate to Microsoft Azure in the near future.
Right now, I manually update files through FTP, and I'm like to try to improve the workflow so that it' less tedious and error-prone.  Ideally, I'd like to configure an Azure Blob Storage account so that it mirrors a version control repo (preferably Mercurial, although I could live with migrating to Git if I really had to).  I'd like to have a configuration where, when I push to the repo, it detects which files have changed and updates those files in the storage account.  Does Azure support doing this, or would I have to write my own scripts if I wanted it?

A: Azure Storage has no mechanism to do comparisons with an external set of resources. You'd need to do this on your own. To assist you, each blob does have a timestamp and an ETag (which gets updated when the blob is updated).

A: If you don't have too many files, you can try to leverage the Custom Deployment Script to create your custom script in PHP, Node.js, python or C# and implement with Azure Storage SDKs for your requirement.
Otherwise, you can leverage Microsoft Azure Storage Explorer to upload your files to Azure Storage from local with a ease.
Furthermore, we suggest you to do some modifications about your application's architecture. Please use Azure Storage to store your image files, do not store your images files on Azure Web Apps with your application. When you have several instances of your Azure Web Apps, and the files which will be effected by user operations may get out of synchronization.


text:
Q: What are the performance differences between 32 and 64 bits SWT? My team develops an Eclipse RCP application.  Should we expect any performance differences between a build using 32-bit SWT and a build using 64-bit SWT?

A: There shouldn't be any differences. Note that a 32 bit SWT/RCP will only run on a 32 bit JRE/JDK and 64 bit SWT/RCP will only run on a 64 bit JRE/JDK.
Other parts of the Eclipse RCP also have 32/64 bit versions, they must all be the same.
Also note that SWT and RCP are platform dependent so a Windows build won't run on Linux or OS X.

A: No, 32-bit and 64-bit java applications almost always have the same structure.
As I'm sure you already know, the difference between 32-bit and 64-bit is the amount of memory the application can hold. A 32-bit SWT will hold ~4GB of memory, while a 64-bit can hold +16GB (its much larger than this.).
If you find any differences, it will only be found at the back-end of SWT, or the native code.


text:
Q: Laravel 4.2 Many-to-many relationship : Can't read from pivot table I was trying to apply Jeffrey Way's many-to-many relationships tutorial into my private messaging app but I got stuck. I'm trying to get 2 conversations, haha and hehe which are associated to a user.  However, Laravel gives me the error :
Column not found: 1054 Unknown column 'Conversations.user_id' in 'where clause' (SQL: select * from `Conversations` where `Conversations`.`user_id` = 1)

I have these data in my conversations table :
+---------+----------+
| conv_id | name     |
+---------+----------+
|       1 |     haha |
|       2 |     hehe |
+---------+----------+

In my user_conversations table :
+----+-------------+--------+
| id | conv_id     | user_id|
+----+-------------+--------+
|  1 |           1 |      1 |
|  2 |           2 |      1 |
+----+-------------+--------+

1. I've tried : In controllers :
User : return $this->belongsToMany('User','id');
Conversatons : return $this->hasMany('Conversations','conv_id');
but the result I got was : haha instead of haha and hehe
2. I've also tried :
User : return $this->belongsToMany('User','user_conversations');
Conversatons : return $this->hasMany('Conversations','user_conversations');
but laravel returned me the following error :
Column not found: 1054 Unknown column 'Conversations.user_conversations' in 'where clause' (SQL: select * from `Conversations` where `Conversations`.`user_conversations` = 1)

I'm still relatively new in Laravel so I might be making some silly mistakes.

here are my codes :
MODEL
Conversations
class Conversations extends Eloquent  {

    protected $table = 'Conversations';

    protected $fillable = array('name');

    public function users(){
        return $this->belongsToMany('User');
    }

}

User
<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {

    ....

    public function conversations(){
        return $this->hasMany('Conversations');
    }
}

CONTROLLERS
Conversations Controller
public function create()
    {
        $loginuser = User::find(Auth::user()->id);
        $conversations = $loginuser->conversations;
        return View::make('msgsystem.Conversations.Conversations',array('conversations'=>$conversations));
    }

MIGRATIONS (in function up())
user
Schema::create('users',function($table)
        {
            $table->increments('id');
            $table->string('email')->unique();
            $table->string('password',100);
            $table->string('name',150);
            $table->string('usertype',50);
            $table->boolean('block');
            $table->string('remember_token',100);
            $table->timestamp('lastlogin_at');
            $table->timestamps();
            $table->softDeletes();
        });

conversations
Schema::create('Conversations', function(Blueprint $table)
        {
            $table->increments('conv_id')->index();
            $table->string('name',100);
            $table->timestamps();
        });

user_conversations
Schema::create('user_conversations', function(Blueprint $table)
        {
            $table->increments('id')->unsigned();
            $table->integer('conversation_id')->unsigned()->index();
            $table->foreign('conversation_id')->references('conv_id')->on('conversations')->onDelete('cascade');
            $table->integer('user_id')->unsigned()->index();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->timestamps();
        });

Bonus points for improvement of code. Thank you very much!

A: In your example of a many to many relationship a user can have many conversations, where the conversations can also be shared by many users.
In this case we need to use the belongsToMany() method for both the relationship on the user model, and the inverse on the conversations model.
class User
{
    public function conversations()
    {
        return $this->belongsToMany('Conversations');
    }
}

class Conversations
{
    public function users()
    {
        return $this->belongsToMany('User');
    }
}

If you need to use a different name for your pivot table, or override the associated keys, you can pass them in as optional arguments.
return $this->belongsToMany(
   'Conversations',          // related_table
   'user_conversations',     // pivot_table
   'user_id',                // key_1
   'conversations_id'        // key_2
);

A: Maybe it will help someone. I lost many hours and then look to database...
I forgot set 'deleted_at' default value to NULL (when use soft delete).


text:
Q: Python search path - python can't find my modules I'm trying to run a script from the commandline, and python is having absolutely none of it:
[graffias:~/testing.tustincommercial.com]$ export PYTHONPATH=`pwd`:$PYTHONPATH
[graffias:~/testing.tustincommercial.com]$  python -c 'import oneclickcos.mainapp; mainapp.mail.worker_loop()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named oneclickcos.mainapp
[graffias:~/testing.tustincommercial.com]$ python
Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import oneclickcos
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named oneclickcos
>>>
[graffias:~/testing.tustincommercial.com]$ ls ./oneclickcos/mainapp/mail.py
./oneclickcos/mainapp/mail.py
[graffias:~/testing.tustincommercial.com]$

Any ideas?
Note for the unwary: The command above should be $python -c 'import oneclickcos.mainapp.mail; oneclickcos.mainapp.mail.worker_loop()' (another valid variant).

A: Do you have a __init__.py in oneclickcos/ and in oneclickcos/mainapp/? If not, put one in and try again — that could cause the problem you're seeing.
For more, see http://docs.python.org/tutorial/modules.html

A: In order to import from folders like that, they have to be setup as packages. Do oneclickcos and mainapp have __init__.py files in them?


text:
Q: How do you comment out a block of text in the vhosts file? How do you comment out a block of text in the vhosts file?
Do I have to put pound/hash symbols (#) in front of EVERY line?

A: Yes, you will have to put pound/hash symbols (#) in front of ALL the lines you want commented out. There are no 'block comments' tag/symbols.
Some text editors have column-mode editing, which means you can select multiple lines and edit text in all of them at the same time. You can use this feature to insert the # symbol in front of the lines you selected.

A: This is not a solution but a workaround. You can put the code you want to comment inside an IfDefine block, so it will be ignored unless a dumb variable is defined:
<IfDefine IgnoreBlockComment>
...
</IfDefine>

Source: https://serverfault.com/a/414428


text:
Q: How to get protected property value of object in PHP I have a object with protected property that I want to get dateTime.
1)modelData->start->dateTime //2017-05-10T17:00:00+05:30
2)modelData->end->dateTime //2017-05-10T17:20:00+05:30

The object looks like
Google_Service_Calendar_Event Object
(
    [collection_key:protected] => recurrence
    [attachmentsType:protected] => Google_Service_Calendar_EventAttachment
    [created] => 2017-05-08T07:05:43.000Z
    [creatorType:protected] => Google_Service_Calendar_EventCreator
    [creatorDataType:protected] =>
    [description] =>
    [endType:protected] => Google_Service_Calendar_EventDateTime
    [endDataType:protected] =>
    [endTimeUnspecified] =>
    [etag] => "2988454353000000"
    [extendedPropertiesType:protected] => Google_Service_Calendar_EventExtendedProperties
    [extendedPropertiesDataType:protected] =>
    [gadgetType:protected] => Google_Service_Calendar_EventGadget
    [visibility] =>
    [internal_gapi_mappings:protected] => Array
        (
        )

    [modelData:protected] => Array
        (
            [creator] => Array
                (
                    [email] => pickzy.nettest@gmail.com
                    [self] => 1
                )

            [organizer] => Array
                (
                    [email] => pickzy.nettest@gmail.com
                    [self] => 1
                )

            [start] => Array
                (
                    [dateTime] => 2017-05-10T17:00:00+05:30
                    [timeZone] => Asia/Calcutta
                )

            [end] => Array
                (
                    [dateTime] => 2017-05-10T17:20:00+05:30
                    [timeZone] => Asia/Calcutta
                )

            [reminders] => Array
                (
                    [useDefault] => 1
                )

        )

)

PHP Script:
I can get etag value without producted
echo "-----".$result->getEtag(); //"2988454353000000"

I cannot get start and end value with producted
echo "-----".$result = $event->getData(); //Error undefined method

My Refer:
Get string within protected object
How to get protected property of object in PHP
Please advice!

A: Visibility

Members declared protected can be accessed only within the class
  itself and by inheriting classes.

If you need to access the property from outside, pick one:
•Don't declare it as protected, make it public instead
•Write a couple of functions to get and set the value (getters and setters)

If you don't want to modify the original class (because it's a
  third-party library you don't want to mess) create a custom class that
  extends the original one:

class My_Google_Service_Calender_Event extends Google_Service_Calendar_Event {
}


text:
Q: If $F$ is increasing and $\mu$ is the measure induce by $F$, does $\mu(A)=m(F(A))$ for all measurable set $A$? Let $F:\mathbb R\to \mathbb R$ increasing. Then $F$ induce a (unique) measure $\mu$ bu defining $$\mu((a,b])=F(b)-F(a).$$
I was wondering : If $A$ is a (Lebesgue) measurable set, does $\mu(A)=m(F(A))$ where $m$ is the Lesbegue measure ? This is obviously true if $A=[a,b]$ or $A=(a,b)$ or $A=(a,b]$ or $A=[a,b)$, but is it true when $A$ is Lebesgue measurable or if $A$ is an unspecified Borel set ?

A: This is clearly false if F has discontinuities (that is, the associated measure has atoms).
For instance consider $F(x) = 1$ if $x \geq 0$, $0$ otherwise (it is non-decreasing but this example can easily be modified to satisfy your assumptions). The associated measure is the Dirac measure at $0$.
However, $m(F(\{0\})) = m(\{1\}) = 0$.


text:
Q: Align nodes horizontally based on group with networkD3 sankeyNetwork in R I think the answer to this question is "it's not currently supported", which is fine, but I'm hoping to build a sankey diagram with the nodes aligned horizontally based on their group. I found this answer, which allows it to be done manually after rendering, but I'm hoping for a more programmatic answer.
For example, this is how it looks currently:
links <- data.frame(
  source = c(
    19, 0, 20, 20, 13, 16, 16, 21, 7, 22,
    23, 23, 8, 10, 1, 4, 2, 14, 17, 3, 5,
    9, 11, 24, 15, 25, 18
  ),
  target = c(
    26, 6, 27, 28, 16, 19, 21, 29, 12, 30,
    31, 32, 10, 14, 4, 9, 5, 17, 20, 5, 8,
    11, 13, 33, 18, 34, 25
  ),
  n = c(
    2L, 3L, 2L, 17L, 18L, 2L, 16L, 16L, 2L,
    6L, 2L, 2L, 22L, 22L, 25L, 21L, 2L, 22L,
    19L, 20L, 22L, 21L, 18L, 2L, 2L, 4L, 2L
  )
)

nodes <- data.frame(
  label = c(
    "a", "b", "c", "d", "e", "f", "g", "h",
    "i", "j", "k", "l", "m", "n", "o", "p",
    "q", "r", "s", "t", "u", "v", "w", "x",
    "y", "z", "A", "B", "C", "D", "E", "F",
    "G", "H","I"
  ),
  group = c(
    "9.1", "9.1", "9.1", "9.1", "9.2", "9.2",
    "9.2", "10.1", "10.1", "10.1", "10.2",
    "10.2", "10.2", "11.1", "11.1", "11.1",
    "11.2", "11.2", "11.2", "12.1", "12.1",
    "12.1", "12.1", "12.1", "12.1", "12.1",
    "12.2", "12.2", "12.2", "12.2", "12.2",
    "12.2", "12.2", "12.2", "12.2"
  )
)

node_colors <- '
  d3.scaleOrdinal()
  .domain(["9.1", "9.2", "10.1", "10.2", "11.1", "11.2", "12.1", "12.2"])
  .range(["red", "red", "orange", "orange", "green", "green", "blue", "blue"])
'

networkD3::sankeyNetwork(
  Links = links,
  Nodes = nodes,
  Source = "source",
  Target = "target",
  Value = "n",
  NodeID = "label",
  NodeGroup = "group",
  colourScale = node_colors,
  fontSize = 12
)

But I'd like it to look (basically) like this, without making manual alterations after the fact.

Any ideas?


text:
Q: "! Missing = inserted for \ifnum. " error when trying to cite in TexWorks I am running into the following problem. I am trying to write a document, in which I want to use a footnote citation style. However, whenever I add the package csquotes to my code in TeXworks, I get the following error:
! Missing = inserted for \ifnum. <to be read again> -
When I remove the package csquotes from my code, whenever I use \cite, instead of a footnote the entire reference is posted in the text.
This is my code:
\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[english]{babel}

%Citations
\usepackage{csquotes}
\usepackage[backend=biber,citestyle=verbose]{biblatex}
\addbibresource{./library.bib}

\begin{document}

\author{Name}
\title{Time and Earth}
\date{\today}

\frontmatter
\maketitle
\tableofcontents

\mainmatter

\include{./chapter01}

\backmatter

\printbibliography

\end{document}

I have tried updating packages, but as far as I can tell they are up-to-date. However, as I am using MikTex on a university computer, I cannot synchronize my repository to an online source automatically. I have downloaded the repository from CTAN manually.
The .bib file is generated by Mendeley and has the following format:
    @book{Heidegger2001,
address = {Oxford (UK) {\&} Cambridge (USA)},
author = {Heidegger, Martin},
publisher = {Blackwell Publishers},
title = {{Being and Time}},
translator = {Macquarrie, John and Robinson, Edward},
year = {2001}
}

I can leave the csquotes package out for now, but I would like to understand what is going wrong.


text:
Q: Containers issue with Jenkins plugin for Kubernetes I'm using kubernetes plugin in jenkins. I'm trying to use it with Pipeline and Freestyle jobs.
The jobs are running, but only in container with name jnlp-slave:3.35-5-alpine which I did't define anywhere.
Even if define the image in the pipeline nothing happanig and still running in this jnlp-slave:3.35-5-alpine image. Here is example of my pipeline:
pipeline {
    agent none
    stages {
        stage ('Stage as dsl') {
            agent {
                kubernetes {
                    cloud 'kubernetes'
                    label 'jnlp-slave'
                    containerTemplate {
                        name 'jnlp-slave'
                        image 'jnlp-slave'
                    }
                }
            }
            steps {
                sh '''
                    pwd; \
                    whoami; \
                    uname -a
                '''
            }
        }
    }
}

Where is my mistake?

A: The solution that I find is to NOT define any label for the cluster.
In my jenkinsfile example I'm testing to use diffrend docker images like this:
Working Solution
def podTemplate = """
apiVersion: v1
kind: Pod
spec:
  containers:
  - name: java-slave
    image: myrepo/java-slave:latest
    command:
    - sleep
    args:
    - infinity
  - name: jenkins-slave-dind
    image: myrepo/jenkins-slave-dind:latest
    command:
    - sleep
    args:
    - infinity
    volumeMounts:
    - name: dockersock
      mountPath: /var/run/docker.sock
  volumes:
  - name: dockersock
    hostPath:
      path: /var/run/docker.sock
"""
pipeline {
    agent {
        kubernetes {
            yaml podTemplate
            defaultContainer 'java-slave'
        }
    }
    stages {
        stage('Main') {
            steps {
                sh 'curl google.com'
            }
        }
        stage ('Stage as dsl 4'){
            steps {
                container('jenkins-slave-dind') {
                    sh '''
                        docker ps -a
                    '''
                }
            }
        }
    }
}


text:
Q: How to render multiple child components based on condition one after another in Angular 4 I have three sections in parent component, each section I want to render one child component like componentA in 1st section, componentB in 2nd section and componentC in 3rd section.
Each section should  be rendered one after another based on the condition, after submitting form in each component based on response status.

A: <ng-container *ngIf="condition1">
...
<\ng-contaner>

This will (dynamically) render(and update) anything inside, based on the condition1 boolean value.

A: Each child component will render the html based on response status.
<div>
  <app-componentA [input]="value1" (outputData)="getData1($event)"
    *ngIf="section1"></app-componentA>

<app-componentB [input]="value2" (outputData)="getData2($event)"
    *ngIf="section2"></app-componentB>

<app-componentC [input]="value3" (outputData)="getData3($event)"
    *ngIf="section3"></app-componentC>
</div>


text:
Q: GWT RunAsync - Strange behavior in release mode As suggested in this question GWT - Where should i use code splitting while using places/activities/mappers?, I created an ActivityProxy to nest my activities.
I based my implementation on this http://code.google.com/p/google-web-toolkit/issues/detail?id=5129 (6th comment), with one modification: I added a check on the provider before calling GWT.RunAsync:
if (provider != null)
{
    GWT.runAsync(new RunAsyncCallback()
    {
        @Override
        public void onFailure(Throwable reason)
        {
            // ...
        }

        @Override
        public void onSuccess()
        {
            ActivityProxy.this.nestedActivity = provider.create();
            //...
        }
    });
}

But for some reason, this doesn't work in release mode: the onFailure methode is never called but my activity is never displayed the first time I use it. If I reload the place, everything display just fine.
Then I realised that doing the following solves the problem:
GWT.runAsync(new RunAsyncCallback()
{
    @Override
    public void onFailure(Throwable reason)
    {
        // ...
    }

    @Override
    public void onSuccess()
    {
        if (provider != null)
        {
            ActivityProxy.this.nestedActivity = provider.create();
            //...
        }
    }
});

So even if I don't understand why it works, I started using it for all my activities.
I ran into the problem again when I decided to use a generator for my ActivityProxy (to avoid writing a provider for each Activity). The synthax becomes GWT.create(ActivityProxy).wrap(MyActivity.class);
Basically, the generated code looks like this:
if (clazz.getName() == "FooClass")
{
    nestedActivity = new FooClass(); //inside a RunAsync
}
if (clazz.getName() == "BarClass")
{
    nestedActivity = new BarClass(); //inside a RunAsync
}

And the same problem occurs: my app fails to display my activities the first time they are used.
So simple question : "Why?"


text:
Q: Retain cycle TableView I am trying to break the retain cycle but couldn't do it. I just can't find the source of retain cycle.
 class MyViewController: UIViewController {

    weak var refreshHeaderView: PZPullToRefreshView?

    lazy var tableView: UITableView = {
        [unowned self] in //with or without doesn't make any difference
        let tableView = UITableView()
        tableView.delegate = self
        tableView.dataSource = self
        tableView.separatorStyle = .None
        tableView.registerClass(CustomViewCell.self, forCellReuseIdentifier: "cell")
        return tableView
        }()

    deinit {
        println("Deinit View")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(tableView)
        tableView.frame = view.frame
        if refreshHeaderView == nil {
            println("Adding")

            var view = PZPullToRefreshView(frame: CGRectMake(0, 0 - tableView.bounds.size.height / 2, tableView.bounds.size.width, tableView.bounds.size.height / 2 ))
            view.delegate = self
            self.tableView.addSubview(view)
            refreshHeaderView = view
        }
…
…

extension MyViewController: UITableViewDelegate, UITableViewDataSource, PZPullToRefreshDelegate {

// Usual tableview methods
}

// Deinit part of PZPullToRefreshView
    deinit {
        delegate = nil
        activityView = nil
        statusLabel = nil
        arrowImage = nil
        lastUpdatedLabel = nil
        println("Deinit Refresh")
    }

When I push this view from navigation controller, I see   "Deinit View" once when the view is loaded. However I don't get "Deinit Refresh" from refresh controller. It means it retains. If I use below code, I see Deinit Refresh.
 override func viewDidDisappear(animated: Bool) {
        super.viewDidDisappear(animated)

        if self.navigationController?.visibleViewController == self {
            self.refreshHeaderView?.removeFromSuperview()
    }
}


text:
Q: Solution to Oracle mutating trigger I am stuck in a small requirement.
my table should restrict if any overlapping data is getting inserted or updated.
Below is my try so far:
CREATE TABLE my_table (
    ID          NUMBER,
    startdate   DATE,
    enddate     DATE,
    CONSTRAINT my_table_pk PRIMARY KEY ( ID,startdate,enddate )
);
/
CREATE OR REPLACE TRIGGER trg_my_table_biu
    BEFORE INSERT OR UPDATE
    ON my_table
    FOR EACH ROW
DECLARE
    v_count NUMBER;
BEGIN

    SELECT COUNT(*)
    INTO v_count
    FROM my_table
    WHERE  id = :new.id
    AND startdate < = :new.enddate
    AND enddate   >= :new.startdate;

    IF v_count >= 1 THEN
        raise_application_error( -20001, 'Cannot make the data overlapped.!' );
    END IF;
END;

/
--existing data - good data - Result: Success

INSERT INTO my_table VALUES (1, to_date('01/02/2018','dd/mm/yyyy '),to_date('01/03/2018','dd/mm/yyyy '));

--1 good data - Result: Success
INSERT INTO my_table VALUES (1, to_date('01/01/2018','dd/mm/yyyy '),to_date('15/01/2018','dd/mm/yyyy '));

--2 good data - Result: Success
INSERT INTO my_table VALUES (1, to_date('02/03/2018','dd/mm/yyyy '),to_date('31/03/2018','dd/mm/yyyy '));

--3 bad data - Result: Success
INSERT INTO MY_TABLE VALUES (1, TO_DATE('01/01/2018','dd/mm/yyyy '),TO_DATE('01/04/2018','dd/mm/yyyy '));

--4 bad data - Result: Success
INSERT INTO my_table VALUES (1, to_date('15/01/2018','dd/mm/yyyy '),to_date('02/02/2018','dd/mm/yyyy '));

--5 bad data - Result: Success
INSERT INTO my_table VALUES (1, to_date('16/02/2018','dd/mm/yyyy '),to_date('15/03/2018','dd/mm/yyyy '));

--6 bad data - Result: Success
INSERT INTO my_table VALUES (1, to_date('15/02/2018','dd/mm/yyyy '),to_date('20/02/2018','dd/mm/yyyy '));

--7 good data - Result: Fail
UPDATE my_table
SET enddate = TO_DATE('31/03/2018','dd/mm/yyyy') + 1
WHERE startdate = TO_DATE('02/03/2018','dd/mm/yyyy');

For the 7th statement ie, UPDATE. I am facing mutaing table error.
Please help me here.

Thanks in advance.

A: As @mic.sca's answer says, triggers are a poor/tricky way to implement rules like this.  What you really want is a constraint that can work at table-level rather than row-level.  ANSI SQL would call this an "assertion", but no DBMS vendor has yet implemented this to date (though it seems that Oracle is seriously considering doing so in a future release).
However, there is a way to simulate such a constraint/assertion using materialized views. I blogged about this way back in 2004 - your requirement is very like my example 2 there.  Modified for your table this would be:
create materialized view my_table_mv1
refresh complete on commit as
select 1 dummy
from my_table t1, my_table t2
where t1.id = t2.id
and t1.startdate <= t2.enddate
and t1.enddate >= t2.startdate;

alter table my_table_mv1
add constraint my_table_mv1_chk
check (1=0) deferrable;

This materialized view only contains instances of overlaps, so should always be empty.  As soon as an overlap is created, a row is inserted into the materialized view - but immediately violates its check constraint, which can never be satisfied!
Note that this is a deferred constraint, i.e. it will not be checked until commit time.
By the way, I don't know why I didn't use ANSI join syntax back in 2004 - maybe I just wasn't using it then.  However, there are cases (I think more with outer joins) where materialized views can't be created using ANSI syntax but can be with the equivalent old-style syntax!

A: The mutating table error occurs because during the update in the trigger you are selecting the same row that you are updating.
My advice would be not to use a trigger and instead doing all the insert and update using stored procedures that check that the dates do not overlap before doing the operation.
To prevent concurent operation on the same id. you need as well to have a mechanism to serialize the possible concurrent sessions running the operations on the data. You might have a separate parent table with your ids and all the operations which operate on a specific Id should do a select for update on that id on the parent table before running insert or updates on my_table.
Trigger might look cool but can create maintenance headaches in the long run as they are not that explicit and they apply on all the operations on a table(http://www.oracle.com/technetwork/testcontent/o58asktom-101055.html).
By the way if two users update concurrently two rows with the same id with your trigger you could end up with overlapping values without your trigger raising any error (though it is very unlikely).


text:
Q: Trying to install tm package in R but it fails Trying to install tm package in R but I get the following error.
Installing package into 'C:/Users/resmim/Documents/R/win-library/3.2' (as 'lib' is unspecified) also installing the dependency 'slam'
Packages which are only available in source form, and may need compilation of   C/C++/Fortran: 'slam' 'tm'   These will not be installed

A: Type this in your console:
chooseCRANmirror()
And choose your CRAN Mirror. I like Spain :). Then try re-installing your package.

A: In addition to trying your luck with a few different mirrors, be sure to answer 'N' when asked 'Do you want to install from sources the package which needs compilation?' This solved the problem for me.

A: update r version to latest, it just worked for me.
to do this, download latest version of R from cran and install it. no uninstall required for previous versions.


text:
Q: how can i create listview inside a fragment which should show data received by a JSON Like the title says i want to create a listview inside a fragment class.It should receive some data from a JSON and display in the listview. How can i do this?
Can someone show me how to use a adapter for listview and receive data from the JSON so that it displays the data .

A: This is several question. You must post what you did so far until that makes to us help you better.
Anyway you must do several work:
1. First create your  fragment  in MainActvity, then in OnCreateView method inflate your layout which contains a listview like this:
View view = inflater.inflate(R.layout.fragment_main, container, false);

and your layout.fragment_main :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:layout_height="fill_parent">
    <ListView
        android:id="@+id/MainList"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>

then return your view.

*

*In your OnCreateView method you must find your listview and create  JSON  object and then in on onPostExecute set your listview adapter like this:
listview.setAdapter(new MainAdapter(view.getContext(), R.layout.main_rows, your_object));

*your_object in above have your data which fill in doInBackground method.

*Then you must create a  custom adapter  and customize it with your object in constructor and in getview method inflate your custom view and set your data to related views which you want.


text:
Q: find new values in comma separated string using Javascript I have an array
       obj = ["30890560", "29092960", "28652336", "28642195", "26512957", "26190575", "25465297", "25144372", "23579449"]

and I need to compare it to a comma separated string
     "29092960,28652336,28642195,26512957,26190575,25465297,25144372"

is there a way for me to end up with an new comma separated string such as
       let newList = "30890560,23579449"

The array will always have more values then the string for the comparison.  This needs to be done using JavaScript inside a Vue.js page so no jQuery.
Do I need to split the comma separated string and compare each value in the array?
something like
        ["30890560", "29092960", "28652336", "28642195", "26512957", "26190575", "25465297", "25144372", "23579449"].includes('30890560');

Would a create a loop looking for a false value?  I would need some help to structure the loop.  Thanks

A:

const arr1 = ["30890560", "29092960", "28652336", "28642195", "26512957", "26190575", "25465297", "25144372", "23579449"];
const str = "29092960,28652336,28642195,26512957,26190575,25465297,25144372";
const arr2 = str.split(','); // Convert CSV String to array

const res = arr1.filter(v => !arr2.includes(v));

console.log(res)

String/split MDN
Array/filter MDN
Array/includes MDN

A: You can use split, set and filter

const arr1 = ["30890560", "29092960", "28652336", "28642195", "26512957", "26190575", "25465297", "25144372", "23579449"]
const str = "29092960,28652336,28642195,26512957,26190575,25465297,25144372"
const arr2 = new Set(str.split(','))

const output = arr1.filter(v => !arr2.has(v));

console.log(output)

A: You can JavaScript's split() method to separate the string into an array of strings. And then compare both the arrays.

var obj = ["30890560", "29092960", "28652336", "28642195", "26512957", "26190575", "25465297", "25144372", "23579449"];

var str = "29092960,28652336,28642195,26512957,26190575,25465297,25144372";

var list = str.split(',');

console.log(list);

// Loop over two arrays to compare their equality.
for (let i = 0; i < list.length; i++) {
   if (list[i] !== obj[i]) {
     // Do something.
   }
}


text:
Q: NoClassDefFoundError com/google/gson/Gson when trying to use gson in my project I have added gson to my java project, to be used as an extension for SmartFoxServer.
If I just add the following line:
Gson gson = new Gson();

then when I export the extension, I get the following error in the SFS console:

Exception: java.lang.NoClassDefFoundError
  Message: com/google/gson/Gson

I have tried some solutions I found online, but nothing seems to work. I'd appreciate any advice, or references to other JSON libraries which can do serialize/deserialize.

A: Just copy Gson's jar to the directory of the extension in SFS.
If you want to share the jar in multiple extensions you could put it in __lib__ dir.


text:
Q: PHP form submission and AJAX validation EDIT: document.getElementById('submit').disabled='disabled'; does the trick if I put it instead of return false; but for some reasons, it also disables the button when the username is NOT taken.

Below is basic script to check a username availability.
How can I prevent the form from being submitted if a username is already taken?
Ideally i would like to have a JS alert box pop up.
I've tried to add this to the JS but didn't work:
document.getElementById('submit').disabled
Also I've tried to add onclick="return validate();" to the form itself, but no luck either: the form still can still get submitted.
HTML
<form id="edit" action="edit.php" method="post">
   <fieldset>
     Username<input type="text" class="input" name="username"
     id="username"/>
    <button type="submit" id="submit" value="add">Save</button>
   </fielset>
</form>

Script


text:
Q: Why does this simple algebraic expression not simplify to zero? Define a simple symbolic expression a, then let b be the square root of its square:
a = A + Sqrt[A + B];

a^2 // Expand

A + A^2 + B + 2 A Sqrt[A + B]

b = Sqrt[%]

Sqrt[A + A^2 + B + 2 A Sqrt[A + B]]

The difference, when simplified under the assumption that both A and B are positive reals should give zero:
a - b

A + Sqrt[A + B] - Sqrt[A + A^2 + B + 2 A Sqrt[A + B]]

FullSimplify[%, A > 0 && B > 0 && A ∈ Reals && B ∈ Reals]

A + Sqrt[A + B] - Sqrt[A + A^2 + B + 2 A Sqrt[A + B]]

Yet in the symbolic form it doesn't. What am I missing?

A: Maybe you can "cheat" as follows:
FullSimplify[
    A+Sqrt[A+B]-Sqrt[A+A^2+B+2 A Sqrt[A+B]] /. B->c-A,
    0<A<c
]

0

Here is another variation of this idea:
FullSimplify[
    A+Sqrt[A+B]-Sqrt[A+A^2+B+2 A Sqrt[A+B]],
    A+B==c && A>0 && B>0 && c>0
]

0


text:
Q: Array to string conversion laravel In my blade view I have inputs like this:
<input type="time" class="" name="shipping_hours[saturday][from]" value="" />
<input type="time" class="" name="shipping_hours[saturday][to]" value="" />
<input type="checkbox" name="shipping_hours[saturday][all_day]" /> <label class="">24h</label>

And I have a table, shipping_hours in a mysql database. I want save data in this JSON format:
{"monday":{"from":"13:00","to":"22:00"},"tuesday":{"from":"13:00","to":"22:00"},"wednesday":{"from":"13:00","to":"22:00"},"thursday":{"from":"13:00","to":"22:00"},"friday":{"from":"13:00","to":"01:00"},"saturday":{"from":"13:00","to":"01:00"},"sunday":{"from":"12:00","to":"22:00"}}

How I can do this in laravel?
Controller (store funtion)
public function store(Request $request)
{
    $data = $this->validator($request->all())->validate();
    settings_hours::create($data);
    session()->flash('message_success', "Object added");
    return redirect(route('hours'));
}

Controller (validator function)
protected function validator($data) {
    return Validator::make($data, [
        'place_id' => 'required',
        'opening_hours.*' => 'nullable',
        'kitchen_hours.*' => 'nullable',
        'shipping_hours.*' => 'nullable',
        'breakfast_hours.*' => 'nullable',
        'launch_hours.*' => 'nullable',
        'reservation_hours.*' => 'nullable'
    ]);
}

Model
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class settings_hours extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'place_id',
        'opening_hours',
        'kitchen_hours',
        'shipping_hours',
        'breakfast_hours',
        'launch_hours',
        'reservation_hours'
    ];
}

A: $string='hello,min,max';
implode(',',$array);

A: In model im added this code and is worked, i think is be helpful
    protected $casts = [
    'place_id' => 'integer',
    'opening_hours' => 'array',
    'kitchen_hours' => 'array',
    'shipping_hours' => 'array',
    'breakfast_hours' => 'array',
    'launch_hours' => 'array',
    'reservation_hours' => 'array'
];


text:
Q: Find difference in text and add formula for next 10 rows I have a scraper pulling data from youTube for a slew of URLs. It generates a CSV and depending on the URL it can grab between 15 and 25 rows of data.
What I need to do is separate the URLs into mini sequences and add a total for each URL. I've been going in and doing this manually-scanning the rows and pasting in my ten row chunk of math to strip out the text and add the values up. It's super tedious.
Is there some way to looking at these URLs, they will be the same for 20 rows or so, and then change, when that change happens, on that row add some kind of action/math to do what I need?
Here's a look at that scraped data:

A: This will sum only the first 5 rows of each url (assuming they're sorted together)


text:
Q: Перехват ссылок Вопрос в следующем: необходимо отловить ссылки с определенным адресом, и их загружать в webbrowser внутри программы. Остальные ссылки должны открываться как положено, в браузере по умолчанию.
Т.е. если асей/скайпом на интернет странице т.д. переходят по ссылке с нужным адресом, она перехватывается программой.
A: Самый тривиальный способ, который, предположительно, будет работать для вариантов ася и скайп - написать простенькую "программу-прокси", которая принимает некоторую ссылку как параметр командной строки, и дальше (в зависимости от того, нужный адрес, или нет) делают с ней, что хотят, например, пересылают дефолтному браузеру.
После того, как эта программа написана, она в file associations вешается на дефолтное поведение для нужных протоколов (http, https, ... ) и все хорошо.

Перехватить обработку ссылки в браузере - задача очень нетривиальная, и, что самое неприятное, браузеро-зависимая. Максимум, что можно сделать безболезненно - это перехватить какойнить receive библиотеки winsock, и, в случае, если приходит HTTP-response от нужной страницы, то дублировать открытие этой страницы руками и в той программе, в которой вам нужно.
Но это не меняет того факта, что у вас все еще будет висеть открытым это окно в браузере, которое тоже необходимо закрыть. Сделать это можно по-разному, вот здесь как раз и появляется браузеро-зависимость.
Сэмулить Ctrl-W, воспользоваться Greasemonkey, если он установлен, написать плагин. Решения есть, но, они, к сожалению, либо корявые (как `Ctrl-W), либо интрузивные, как все остальные.


text:
Q: Grid View List View Toggle I currently have a page that lists products in a list format. I would like to be able to toggle between the two views. The list is populated dynamically.
Below there is a static ul, and I would like to populate it dynamically:
$('button').on('click', function(e) {
  if ($(this).hasClass('grid')) {
    $('#container ul').removeClass('list').addClass('grid');
  } else if ($(this).hasClass('list')) {
    $('#container ul').removeClass('grid').addClass('list');
  }
});

    <button class="grid">Grid View</button>
    <button class="list">List View</button>

Item 1

Item 2

Item 3

Item 4

Item 5

Item 6

Item 7

A:


text:
Q: fieldset tag presented differently in IE10 vs. older versions The following Html snippet looks different on IE10 vs. older versions:

<form>
<fieldset style="position:absolute; left: 0px; top: 0px; width: 200px; height: 30px;">
text1
</fieldset>
text2
</form>

IE10:

IE8:

Set aside the font changes, how can I change the page so that the layout is the same as in IE8 in both browsers ?

A: Adding padding: 0px seems to fix the problem, the page is now rendered the same way on all versions of IE.
The fieldset tag now looks like this:
<fieldset style="position:absolute; left: 0px; top: 0px; width: 200px; height: 30px; padding: 0px">


text:
Q: How can I open websites with selenium/webdriver? import time
from selenium import webdriver
driver = webdriver.Chrome('C:\Program Files\Google\Chrome\Application\chrome.exe')
driver.get('https://www.facebook.com')
time.sleep(5)
driver.quit()

error code: Executable_path has been deprecated, please pass in a service object.
The code above begins to open a Google Chrome tab but does not pick a user, and it will stop where Google Chrome shows all your users. I've tried using a specific profiles path but I've gotten various errors. If someone is able to resolve this issue I would appreciate it, I would like to open the Chrome tab as a guest.

A: It looks like your question has two parts. You are trying to figure out the webdriver and the user profile path. Allow me to answer both of these questions for you.
In the latest version of Selenium the executable_path parameter has been deprecated. Service objects containing the executable path are now required. There are two options for this.
Service objects
Option #1: Use your executable path
Append this import to your code:
from selenium.webdriver.chrome.service import Service

Then, include the service object as such:
driver = webdriver.Chrome(service=Service("C:\Program Files\Google\Chrome\Application\chrome.exe"))

Option #2: Let web driver manager handle it
This is great for when the driver becomes outdated. No need to redownload the driver.
First, go to the project directory in your terminal. If you are using PyCharm, there is no need to traverse to the directory, as you are already in the project directory.
Use pip to install web driver manager:
pip install webdriver_manager

Now, there is no need to enter an executable path:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.facebook.com")

Selecting a user profile
This is fairly simple. First, go to chrome and enter chrome://version/ into the URL address bar. You will see the profile path. It will look like this C:\Users\yourprofile\AppData\Local\Google\Chrome\User Data\Default.
Then, include the following chrome options as such:
options = webdriver.ChromeOptions()
options.add_argument(r"--user-data-dir=C:\Users\yourprofile\AppData\Local\Google\Chrome\User Data")
options.add_argument(r"--profile-directory=Default")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

A: This works for me.
The service is the path to the chrome driver you can download.
The chrome driver can be downloaded here: https://chromedriver.chromium.org/downloads
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

s = Service('/Users/macbook/PycharmProjects/chromedriver')
browser = webdriver.Chrome(service=s)
browser.get('https://www.facebook.com')
time.sleep(5)
browser.quit()

  [1]: https://chromedriver.chromium.org/downloads


text:
Q: Point Set Topology (open sets, polynomials, hausdorff spaces) I am trying to complete this Topological problem and I have completed it, I just would like some opinions on how to make my work better and if someone could check it for me as well. I would greatly appreciate it!
(A): Declare a set $U \subseteq \Re $ to be "open" if its complement $\Re $\ $U$ is the zero-set of a (real-valued) polynomial $p$ $\in$ $P$ ($\Re$):
$U$ is open $\Leftrightarrow$ $\exists$$p$ $\in$ $P$ ($\Re$) such that $\Re$\ $U$ = $p$ $^-$$^1$$(0)$.
Show that the collection of all "open" sets is a topology on $\Re$.
MY SOLUTION TO PART A:
Let $U$$_1$,$U$$_2$$...$$U$$_n$ be an arbitrary collection of open sets. Then $\Re$ \ $U$$_1$,$\Re$ \ $U$$_2$, $...$ $\Re$ \ $U$$_n$ would be the zero set of a polynomial $P$$_1$,$P$$_2$,$...$$P$$_n$ respectively. Now let $U$ = $\cup^{\infty}_{i=1}U_\Re$. As $\Re$ \ $U$ $\subseteq$ $\Re$ \ $U$$_1$, we get that $\Re$ \ $U$ is the zero set of a polynomial which divides $P$. Now, suppose that $V$$_1$,$V$$_2$,$...$,$V$$_n$ are open sets and $V$ = $V$$_1$ $\cap$ $V$$_2$ $\cap$ $...$ $\cap$ $V$$_n$. Then we get that $\Re$ \ $V$$_1$,$\Re$ \ $V$$_2$, $...$ $\Re$ \ $V$$_n$ are the zeros of a polynomial $P$$_1$,$P$$_2$,$...$$P$$_n$. We also get that $\Re$ \ $V$ are the roots of a polynomial $P$$_1$,$P$$_2$,$...$$P$$_n$. Thus, $V$ is open. Since open sets are closed under arbitrary unions and finite intersections, they form a topology.
(B): Show that the topology in (a) is equal to the cofinite topology.
MY SOLUTION TO PART B:
Let $U$ be an open set
$\Leftrightarrow$ $\Re$ \ $V$ is the zero set of a polynomial since every polynomial only has finite roots.
$\Leftrightarrow$ $\Re$ \ $V$ is a finite set
$\Leftrightarrow$ $V$ is an open set in the cofinite topology. Thus, the topology in (a) is equal to the cofinite topology.
(C): Prove weather the topology is Hausdorff or not.
MY SOLUTION TO PART C:
Let V be an open set $\Rightarrow$ $\Re$\V is finite, so if $\Re$=$U$$\cap$$V$ and if $U,V$ are distinct, then $V$ is finite. But, all open sets in the cofinite topology contain infinitely many elements. Thus, the topology is not Hausdorff