text:
Q: File Management advice needed (Adobe Lightroom Classic) I'm finally getting around to moving my old Aperture library (~150,000 images) into Lightroom Classic and need a bit of advice regarding file management.
Here is my scenario:

*

*All of my images (from my current LR catalog and my Aperture library) were in a PHOTO_MASTERS folder, which is organzied by Year/Month (2021/01, 2021/02, etc)

*Over 15 years or so, there are other "extra" files in the PHOTOS_MASTERS folder that are NOT part of my current LR Catalog, nor part of my Aperture Library.

*I consolidated all the masters from my Aperture Library into Aperture, so they are no longer in the PHOTO_MASTERS folder

*Now in my PHOTO_MASTERS folder I have all the images from my LR Catalog, AND the extra images that are not in my LR Catalog.

*I want to separate these two groups of files so that I can review the extra images and decided what to do with them.

How can I separate the files that are part of my LR catalog from the remaining "extra" files?
I've reviewed all the options available in LR, but seems they are only useful for finding missing files, not extras.
Thank you...

A: This might work for you (if I have understood the problem correctly):
I am going to find the Extra photos and (optionally) import them into a new folder in LR.

*

*In LR Classic, do an Import and choose your PHOTO_MASTERS folder.

*At the top click New Photos.

That will show you all the photos which are NOT in LR.
It might take a while if you already have lots of photos in the folder (or its sub-folders).
You can, if your want, import those files into the new LR folder:

*

*Choose Move at the top.

*On the right, as a Destination, create a new LR folder.

*Any other processing you want. That might include Into Subfolder by date.

*and Import (at the bottom-right).

Now you have identified the 'Extras' and separated them from the other photos whilst loading them into LR.


text:
Q: OpenCV optimization for Tegra 2 In my search of trying to find a way of implementing some computer vision algorithms on the GPU of a tablet, I came across the OCV 2.4 pack NVIDIA Tegra 3. From this post: Optimization of OpenCV on android (neon-instruction, GLSL on tegra 3 ) I understood that this OpenCV pack contains GLSL and NEON optimizations for NVIDIA Tegra 3. Does anybody know if there is such an OpenCV pack with optimizations for Tegra 2? My tablet has Android 3.1 as operating system.

A: From the very important paper, neon instruction is not supported by tegra 2, so I think acceleration on CPU parallelism of OpenCV is not on tegra 2. For GPU acceleration, I suppose that as long as OpenGL ES 2.0 is supported on Tegra 2, so I think it is enabled.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to cut bytearray? I have a bytearray, and when I list the array, I get the following data: (b'v10 \ xc73 \ x9a & \ x9edv \ x19 \ xc3B \ xbf \ x95 \ xc8 \ xd8 \ x9dN \ x8f \ xe9 \ x90J \ xax> r1 \ x1d \ xa7 \ x1fU \ x90 \ XE2 (| p \ XF1 \ x02 \ xbdw \ XB8 \ xb9 \ xf3 \ x0e \ xb2n \ xc7 ',).
And I need to decrypt this data. But the decryption function only receives data, for example, b'v10 \ xc73 \ x9a & \ x9edv \ x19 \ xc3B \ xbf \ x95 \ xc8 \ xd8 \ x9dN \ x8f \ xe9 \ x90J \ xax> r1 \ x1d \ xa7 \ x1fU \ x90 \ xe2 (| p \ xf1 \ x02 \ xbdw \ xb8 \ xb9 \ xf3 \ x0e \ xb2n \ xc7' without () and ,
What can I do?

A: Supposing we have
data = (b'foo',)

then this data is not a bytearray, nor is it a bytes object:
>>> type(data)
<class 'tuple'>

Because it is a tuple, we may extract that element:
>>> data[0]
b'foo'
>>> type(data[0])
<class 'bytes'>


text:
Q: Django CMS "No module named html5lib" I have a basic Django CMS site installed with all the default and recommended modules however I recieve and error saying...
Updated
Request Method: GET
Request URL:    http://teamdjango.lnukapps.co.uk/admin/cms/page/21/
Django Version: 1.3.1
Exception Type: ImportError
Exception Value:
No module named html5lib
Exception Location: /usr/lib/python2.6/site-packages/django_cms-2.2-py2.6.egg/cms/utils/html.py in <module>, line 2
Python Executable:  /usr/bin/python
Python Version: 2.6.6
Python Path:
['/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg',
 '/usr/lib/python2.6/site-packages/html5lib-0.90-py2.6.egg',
 '/usr/lib/python2.6/site-packages/django_classy_tags-0.3.4.1-py2.6.egg',
 '/usr/lib/python2.6/site-packages/django_mptt-0.4.2-py2.6.egg',
 '/usr/lib/python2.6/site-packages/django_sekizai-0.4.2-py2.6.egg',
 '/usr/lib/python2.6/site-packages/django_cms-2.2-py2.6.egg',
 '/usr/lib/python2.6/site-packages/django_filer-0.9a1-py2.6.egg',
 '/usr/lib/python2.6/site-packages/django_polymorphic-0.2-py2.6.egg',
 '/usr/lib/python2.6/site-packages/easy_thumbnails-1.0_alpha_18-py2.6.egg',
 '/usr/lib/python2.6/site-packages/cmsplugin_filer-0.8.0-py2.6.egg',
 '/usr/lib64/python26.zip',
 '/usr/lib64/python2.6',
 '/usr/lib64/python2.6/plat-linux2',
 '/usr/lib64/python2.6/lib-tk',
 '/usr/lib64/python2.6/lib-old',
 '/usr/lib64/python2.6/lib-dynload',
 '/usr/lib64/python2.6/site-packages',
 '/usr/lib64/python2.6/site-packages/PIL',
 '/usr/lib/python2.6/site-packages',
 '/usr/lib/python2.6/site-packages']

 Server time:   Fri, 14 Oct 2011 14:05:59 +0100

html5lib has been installed via easy_install html5lib and if I import html5lib in a default Python shell it imports fine.
Python 2.6.6 (r266:84292, May 20 2011, 16:42:11)
[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import html5lib
>>>

This is set up on a clean install of Scientific Linux with Python 2.6.6.
I am using Django 1.3.1.
My INSTALLED_APPS is as shown.
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'cms',
    'mptt',
    'menus',
    'south',
    'sekizai',
    'cms.plugins.flash',
    'cms.plugins.googlemap',
    'cms.plugins.link',
    'cms.plugins.snippet',
    'cms.plugins.text',
    'cms.plugins.twitter',
    'filer',
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_image',
    'cmsplugin_filer_teaser',
    'cmsplugin_filer_video',
    # 'reversion',
)

My question (if it isn't obvious by now ;) ) is why is there a problem importing html5lib and how can I fix it.
Update 1
@matt-williamson
Thanks, here is the html5lib file info
>>> html5lib.__file__
'/usr/lib/python2.6/site-packages/html5lib-0.90-py2.6.egg/html5lib/__init__.pyc'

I have updated the Django error to give more of the error page.  As you can see the Python Path includes /usr/lib/python2.6/site-packages/html5lib-0.90-py2.6.egg which suggests to me it should be able to find it.

A: Either you have two versions of python installed or you need to set your python path.
Get the path the module is installed to
>>> import html5lib
>>> html5lib.__file__

'/Library/Python/2.7/site-packages/html5lib-0.90-py2.7.egg/html5lib/init.pyc'

^D

Set the PYTHONPATH environment variabled.
export PYTHONPATH="$PYTHONPATH:/Library/Python/2.7/site-packages/"
python manage.py runserver


text:
Q: Connecting Power BI to S3 Bucket Need some guidance as I am new to Power BI and Redshift ..
My Raw JSON data is stored in Amazon S3 bucket in the form of .gz files (Each .gz file has multiple rows of JSON data)
I wanted to connect Power BI to Amazon s3 Bucket. As of now based on my research I got three ways:

*

*Amazon S3 is a web service and supports the REST API. We can try to use web data source to get data

Question: Is it possible to unzip the .gz file (inside the S3 bucket or Inside Power BI), extract JSON data from S3 and connect to Power BI

*Importing data from Amazon S3 into Amazon Redshift. Do all data manipulation inside Redshift using SQL workbench. Use Amazon Redshift connector to get data in Power BI

Question 1: Does Redshift Allows Loading .gzzipped JSON data from the S3 bucket? If Yes, is it directly possible or do I have to write any code for it?
Question 2: I have the S3 account, do I have to separately purchase Redshift Account/Space? What is the cost?

*Move data from an AWS S3 bucket to the Azure Data Lake Store via Azure Data Factory, transform the data with Azure Data Lake Analytics (U-SQL), and then output the data to PowerBI

U-SQL recognize GZip compressed files with the file extension .gz and automatically decompress them as the part of the Extraction process. Is this process valid, if my gzipped files contain JSON data rows?
Please let me if there is any other method, also your valuable suggestions on this post.
Thanks in Advance.

A: About your first Question: I've just faced a similar issue recently (but extracting a csv) and I would like to register my solution.
Power BI still don't have a direct plugin to download S3 buckets, but you can do it using a python script.
Get data --> Python Script
PS.: make sure that boto3 and pandas libraries are installed in the same folder (or subfolders) of the Python home directory you informed in Power BI options,
OR in Anaconda library folder (c:\users\USERNAME\anaconda3\lib\site-packages).
Power BI window for Python scripts options

import boto3
import pandas as pd

bucket_name= 'your_bucket'
folder_name= 'the folder inside your bucket/'
file_name = r'file_name.csv'  # or .json in your case
key=folder_name+file_name

s3 = boto3.resource(
    service_name='s3',
    region_name='your_bucket_region',  ## ex: 'us-east-2'
    aws_access_key_id=AWS_ACCESS_KEY_ID,
    aws_secret_access_key=AWS_SECRET_ACCESS_KEY
)

obj = s3.Bucket(bucket_name).Object(key).get()
df = pd.read_csv(obj['Body'])   # or pd.read_json(obj['Body']) in your case

The dataframe will be imported as a new query( named "df", in this example case)
Apparently pandas library can also also get a zipped file (.gz for example). See the following topic: How can I read tar.gz file using pandas read_csv with gzip compression option?


text:
Q: concatenate dataframe with dataframe from list I want to concatenate a dataframe (df) with another dataframe that is stored in a list of dataframes.
dflist = [df1, df2, df3]
What I want is a dataframe like below
new_dflist = [df+df1, df+df2, df+df3]
new_dflist=[]
for n in dflist:
    new_dflist.append(pd.concat(df, dflist[n]))

but I get the error,
TypeError: list indices must be integers or slices, not DataFrame
I also tried with enumerate but I get the error,
TypeError: list indices must be integers or slices, not tuple

A: Try this:
dflist = [df1, df2, df3]
new_dflist=[]
for n in dflist:
    new_dflist.append(pd.concat([df, n]))

n is a dataframe and you are trying to put it in list index

A:
but I get the error, TypeError: list indices must be integers or slices, not DataFrame

That is because n is a dataframe, not an integer. You seem to think that  for loop gives you the indexes in a list, but it actually gives you the items directly. Just change your code to use the dataframe from the for loop iterator:
new_dflist=[]
for new_df in dflist:
    new_dflist.append(pd.concat([df, new_df]))

Alternatively, you can do this in a single line with a list comprehension:
new_dflist=[pd.concat([df, new_df]) for new_df in dflist]


text:
Q: Downloaded JAR from Artifactory using Maven, but it is different from the original file on Artifactory My goal
To download a single jar file from Artifactory, and deploy it to a remote server.

POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>fruit.apple</groupId>
    <artifactId>fruit-extension-3</artifactId>
    <version>4.3.3</version>
    <packaging>pom</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>fruit.apple</groupId>
                                    <artifactId>fruit-extension-3</artifactId>
                                    <version>LATEST</version>
                                    <type>jar</type>
                                    <outputDirectory>${WORKSPACE}/dist</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
EOF

maven-metadata.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>fruit.apple</groupId>
  <artifactId>fruit-extension-3</artifactId>
  <versioning>
    <latest>4.3.3</latest>
    <release>4.3.3</release>
    <versions>
      <version>4.3.1</version>
      <version>4.3.3</version>
    </versions>
    <lastUpdated>20220623075621</lastUpdated>
  </versioning>
</metadata>

Run Command (by Jenkins)
java -classpath /jenkins/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven/boot/plexus-classworlds-2.6.0.jar -Dmaven.home=/jenkins/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven -DbuildInfoConfig.propertiesFile=/tmp/buildInfo7748499452581243161.properties -Dm3plugin.lib=/jenkins/jenkins/cache/artifactory-plugin/2.7.2 -Dclassworlds.conf=/tmp/classworlds7563001544912268993conf -Dmaven.multiModuleProjectDirectory=/jenkins/jenkins/workspace/S3_CbbCustom_Deploy_UAT/pom.xml org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml install

Result
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Scanning for projects...
[main] INFO org.jfrog.build.extractor.maven.BuildInfoRecorderLifecycleParticipant - [buildinfo] Properties file found at '/tmp/buildInfo7748499452581243161.properties'
[main] INFO org.jfrog.build.extractor.maven.BuildInfoRecorder - Initializing Artifactory Build-Info Recording
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------< fruit.apple:fruit-extension-3 >------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Building fruit-extension-3 4.3.3
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - --------------------------------[ pom ]---------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-dependency-plugin:2.3:copy (copy) @ fruit-extension-3 ---
[main] INFO org.apache.maven.plugin.dependency.fromConfiguration.CopyMojo - Configured Artifact: fruit.apple:fruit-extension-3:LATEST:jar
Downloading from central: http://localhost:8081/artifactory/vbpidev/fruit/apple/fruit-extension-3/maven-metadata.xml
Progress (1): 357 B

Downloaded from central: http://localhost:8081/artifactory/virtual-repo/fruit/apple/fruit-extension-3/maven-metadata.xml (357 B at 364 B/s)
[main] INFO org.apache.maven.plugin.dependency.fromConfiguration.CopyMojo - Copying fruit-extension-3-4.3.3.jar to /jenkins/jenkins/workspace/Distribute_fruit-extension-3/dist/fruit-extension-3-4.3.3.jar
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-install-plugin:2.4:install (default-install) @ fruit-extension-3 ---
[main] INFO org.codehaus.plexus.PlexusContainer - Installing /jenkins/jenkins/workspace/Distribute_fruit-extension-3/pom.xml to /home/jenkins/.m2/repository/fruit/apple/fruit-extension-3/4.3.3/fruit-extension-3-4.3.3.pom
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - BUILD SUCCESS
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Total time:  2.651 s
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Finished at: 2022-06-28T12:57:43+08:00
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------

Problem
The downloaded fruit-extension-3-4.3.3.jar is different from fruit-extension-3-4.3.3.jar.
It's not that the downloaded one is complete trash file, they are just different versions.
But I can't see why their versions are different.

Question 1.
Why is the downloaded jar different from the original Artifactory jar?
Question 2.
Can I just simply download jar file without using shit-tons of libraries?
I had to add the whole maven2 repository just to download a single jar file.
I know Artifactory is not meant to be used in this way, but surely it couldn't be this inefficient?
I found a shellscript for Question2:
https://stackoverflow.com/a/17773424/9336478


text:
Q: Bulk rename files and folders, stripping all spaces from the name to underscore in Windows I want to do this as in this link, but I need to remove all spaces with underscores, also folders and files, but when i put in a root of a folder I want it to go through all subfolders and files.
Thank you!

A: Assume you meant 'replace' all spaces with underscores...
in PS Get-ChildItems or gci is pretty powerful
 > gci -r -n
   Silly Windows
   Silly Windows\empty file2
   Silly Windows\emptyfile1

 > gci -r | where-object { $_.name.Contains(" ") } | rename-item -NewName { $_.name -replace " ","" }

 > gci -r -n
   SillyWindows
   SillyWindows\emptyfile1
   SillyWindows\emptyfile2


text:
Q: How to test my php script for sql injection and prevent it I have input values like user can upload a photo, enter a username, password...etc
I want to test the SQL injection by myself and I want some way to prevent it.
I am using MySQL I know some of you will say use PDO or MySqli BUT at this time I am still having Mysql as database.
Thank You!

A: When testing an application of this sort, put values like this in every field:

It's Buggy

If that isn't inserted correctly, you'll have errors. If it is inserted correctly and rendered as unescaped HTML you'll know immediately.
This applies to every single parameter that can come in via $_GET or $_POST.
Writing with mysql_query is hazardous at the best of times, and downright reckless if you're not extremely careful. PDO works well with MySQL and doesn't take that long to learn if you follow a good tutorial.
You should be writing queries like this:
INSERT INTO users (name) VALUES (?)

The ? is a data placeholder that you can safely bind against.
A better approach is to use something like Propel or Doctrine to provide a proper database layer. This makes your code much more readable and portable between MySQL and other databases.

A: Many documentation on google. See : https://stackoverflow.com/a/60496/2226755
Try putting ' or " in your input, if you've an error it's a sql injection.
Understanding SQL Injection

A: you can inject in SQl with code like
    anything' OR 'x'='x
you can easily prevent this, just google "sql injection example(s)" and see for yourself

A: Injection techniques vary based on the use case. As an example for username/password checks, given this SQL:
SELECT user_id
FROM users
WHERE name = "$_POST['name']"
AND password = "$_POST['pass']";

...in this case, passing a simple " OR "" = " for the POSTed password field would yield this:
SELECT user_id
FROM users
WHERE name = ""
AND password = ""
OR "" = "";

...and BAM! There are user_id results where in reality there aren't supposed to be.
This is just one isolated case. I'd suggest looking into using PDO as your database driver to do injection checking for you!


text:
Q: Remus on Amazon EC2: If and When? Slashdot recently brought word that the Remus project (which implements hot-backup Xen instances) has been merged into the core Xen. Since Amazon have leveraged Xen in building out EC2, I naturally can't help but wonder if Remus:

*

*has been deployed as part of EC2?

*has been considered by Amazon for use with EC2?

*has been rejected for some reason(s) unknown to me?

The possibilities introduced to the realities of EC2 by Remus make me want to jump out of my pants. If anyone knows anything on the subject, please post an answer.

A: Remus is still young, eight months since first release.  I feel that it could be useful technology for Amazon once it has matured sufficiently.  I feel that Amazon will wait for Remus to stabilize, get a happy pool of users, get the bugs out of the system, and see the results of other smaller sites using it.
Amazon EC2 is big so if they make a new feature go live, I think they will have thousands of people hitting them with support issues for any tiny thing that might go wrong!
Give it a year or two perhaps?


text:
Q: How to implement simple string pattern-matching using standard libraries (including boost) I wish to add very simple pattern-matching functionality to some C++ code, e.g. I have a map<string,int> and want to write a method sumMatchingEntries(string pattern) which will sum all values where the key matches the input pattern. The pattern would be simple e.g. the only wildcards would be * and possibly ?.
I believe boost has regex support but that seems a bit overkill, so are there any other standard library functions one might use?
Note I'm using VC++ 2K8 so no C++03/11 features, but boost is OK. If a regex solution is best, an example would be great.

A: VC++2008 includes TR1 regexps as a feature pack: http://www.codeproject.com/Articles/26285/Quick-Start-for-C-TR1-Regular-Expressions.   Re-inventing the wheel is probably not worth it.


text:
Q: How to do slow motion effect in side view flash game with box2d As i am working on side view bike stunt game in which am trying to add slow motion effect when a bike performs stunts.
Is there any solution for showing such kind of slow motion effect in Box2D. can anybody help me in this regard
Thanks and regards,
Chandrasekhar

A: An easy way to do this effect with or without Box2D is to step up a time modifier.
so lets say you move the player in a run function like so:
player.x += vel_x;
player.y += vel_y;

you could setup a time modifier variable that is initialized to 1
var time_mod:Number = 1;

then update all your movements as followed
player.x += vel_x * time_mod;
player.y += vel_y * time_mod;

then when you want "the slow motion effect" change your time_mod variable.  For half of real time change your time_mod to 0.5.  If you want to super speed change it to 2 or 3, super slow? change to 0.3
you get the idea?

A: As mentioned already, changing the length of the time step can give a slow motion effect. It also has the side-effect of altering the way gravity affects bodies, and can complicate other things like recording a replay or syncing state across multiplayer games for example.
Another option is to use a fixed time step length for every time step, and keep track of the previous position and angle for all bodies. Then you can interpolate between the last frame and the current frame to draw them at an in-between frames position. This means that you are always drawing things a tiny bit behind their current position in the physics engine, but it should not be noticeable with typical frame-rates of 30-60fps.


text:
Q: Installing py-ldap on Mac OS X Mavericks (missing sasl.h) I can't seem to be able to get the python ldap module installed on my OS X Mavericks 10.9.1 machine.
Kernel details:
uname -a
Darwin  13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
I tried what was suggested here:
http://projects.skurfer.com/posts/2011/python_ldap_lion/
But when I try to use pip I get a different error
Modules/LDAPObject.c:18:10: fatal error: 'sasl.h' file not found
*#include sasl.h
I also tried what was suggested here:
python-ldap OS X 10.6 and Python 2.6
But with the same error.
I am hoping someone could help me out here.

A: using pieces from both @hharnisc and @mick-t answers.
pip install python-ldap \
   --global-option=build_ext \
   --global-option="-I$(xcrun --show-sdk-path)/usr/include/sasl"

A: I had the same problem. I'm using Macports on my Mac and I have cyrus-sasl2 installed which provides sasl.h in  /opt/local/include/sasl/. You can pass options to build_ext using pip's global-option argument. To pass the include PATH to /opt/local/include/sasl/sasl.h run pip like this:

pip install  python-ldap --global-option=build_ext  --global-option="-I/opt/local/include/sasl"

Alternatively you could point it to whatever the output from xcrun --show-sdk-path provides. On my box that's:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
Then you need to determine the PATH to the sasl header files. For me that's:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sasl/
Let me know if that helps or you need a hand.

A: A workaround
/usr/include appears to have moved
$ xcrun --show-sdk-path
$ sudo ln -s <the_path_from_above_command>/usr/include /usr/include

Now run pip install!

A: In my particular case, I couldn't simply use the pip arguments noted in other answers because I'm using it with tox to install dependencies from a requirements.txt file, and I need my tox.ini to remain compatible with non-Mac environments.
I was able to resolve this in much simpler fashion: exporting CFLAGS such that it adds an include path to the sasl headers already installed by Xcode:
$ pip install python-ldap
    ...
    building '_ldap' extension
    creating build/temp.macosx-10.10-x86_64-2.7
    creating build/temp.macosx-10.10-x86_64-2.7/Modules
    clang -fno-strict-aliasing -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.19 -IModules -I/opt/openldap-RE24/include -I/usr/include/sasl -I/usr/include -I/Users/bc/.pyenv/versions/2.7.10/include/python2.7 -c Modules/LDAPObject.c -o build/temp.macosx-10.10-x86_64-2.7/Modules/LDAPObject.o
    Modules/LDAPObject.c:18:10: fatal error: 'sasl.h' file not found
    #include <sasl.h>
             ^
    1 error generated.
    error: command 'clang' failed with exit status 1

$ export CFLAGS="-I$(xcrun --show-sdk-path)/usr/include/sasl"

$ pip install python-ldap
...
Successfully installed python-ldap-2.4.19

Depending on whether or not you use any userspace-friendly Python tools (I use pyenv), you may have to prefix your pip commands with sudo.

A: I used a combination of posts I found about this problem (including this one) to eventually come up with this (copied from a larger script):
export XC_SDK=$(xcrun --show-sdk-path)
export USR_INC=$XC_SDK/usr/include
export PATH=$USR_INC:$PATH

echo "installing python-ldap"
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install python-ldap

You can test it with python -c "import ldap"
The main reason I didn't follow the advice of @hharnisc was that on my local machine /usr/local had not moved, so I just temporarily put $XC_SDK before it on the path, and that seems to work.
some sources:
how to install PIL on Macosx 10.9?

A: I got this error when running buildout.
I fixed it, first finding the sasl.h file:
mdfind -name sasl.h

then defining the corresponding CFLAGS environment variable:
export CFLAGS="-I/opt/local/include/sasl"

and finally running buildout again.


text:
Q: Unable to generate equals method with xjc gradle plugin I'm using the gradle-xjc-plugin to generate Java classes from xsd. Everything works fine until I try to generate equals/hashCode methods on my generated classes. Then I'm getting this exception:
 xjc-demo ./gradlew clean build --stacktrace
> Task :xjcGenerate FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':xjcGenerate'.
> A failure occurred while executing org.unbrokendome.gradle.plugins.xjc.work.xjc23.XjcGeneratorWorkAction
   > unrecognized parameter -Xequals

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':xjcGenerate'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$3(ExecuteActionsTaskExecuter.java:186)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:268)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:184)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:173)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:411)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:398)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:391)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:377)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing org.unbrokendome.gradle.plugins.xjc.work.xjc23.XjcGeneratorWorkAction
        at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:336)
        at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:142)
        at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:94)
        at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForAll(DefaultAsyncWorkTracker.java:80)
        at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForCompletion(DefaultAsyncWorkTracker.java:68)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.run(ExecuteActionsTaskExecuter.java:502)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:479)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:462)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$400(ExecuteActionsTaskExecuter.java:105)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:273)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:251)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$executeOperation$1(ExecuteStep.java:66)
        at org.gradle.internal.execution.steps.ExecuteStep.executeOperation(ExecuteStep.java:66)
        at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:34)
        at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:47)
        at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:44)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:44)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:34)
        at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:72)
        at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:42)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:53)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:39)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:44)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:77)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:58)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:54)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:32)
        at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:57)
        at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:38)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:63)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:30)
        at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:176)
        at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:76)
        at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:47)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:43)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:32)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:39)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:25)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:102)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:95)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:83)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:44)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:96)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:52)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:83)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:54)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:88)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:88)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:46)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:34)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:43)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution$3.withWorkspace(ExecuteActionsTaskExecuter.java:286)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:43)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:33)
        at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:40)
        at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:30)
        at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:54)
        at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:40)
        at org.gradle.internal.execution.impl.DefaultExecutionEngine.execute(DefaultExecutionEngine.java:41)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:183)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:183)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:173)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:411)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:398)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:391)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:377)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: com.sun.tools.xjc.BadCommandLineException: unrecognized parameter -Xequals
        at com.sun.tools.xjc.Options.parseArguments(Options.java:830)
        at org.unbrokendome.gradle.plugins.xjc.work.common.AbstractXjcGeneratorWorkAction.buildOptions(AbstractXjcGeneratorWorkAction.kt:164)
        at org.unbrokendome.gradle.plugins.xjc.work.common.AbstractXjcGeneratorWorkAction.execute(AbstractXjcGeneratorWorkAction.kt:31)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
        at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
        at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
        at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
        at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.lambda$execute$0(IsolatedClassloaderWorkerFactory.java:58)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
        at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.execute(IsolatedClassloaderWorkerFactory.java:50)
        at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:214)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
        ... 3 more

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
3 actionable tasks: 2 executed, 1 up-to-date

Here is my setup in brief. In build.gradle (details skipped for brevity) I have:
plugins {
    id 'org.springframework.boot' version '2.4.5'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
    id 'org.unbroken-dome.xjc' version '2.0.0'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'javax.xml.bind:jaxb-api:2.3.0'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

sourceSets {
    main {
        xjcGenerateEpisode = true
        xjcTargetPackage = 'eu.balev.generated'
        //xjcExtraArgs.addAll '-Xequals', '-XhashCode'
    }
}

xjc {
    srcDirName = 'resources/xsd'
}

When I run ./gradlew clean build everything is fine and my classes are generated. If I uncomment this line though:
//xjcExtraArgs.addAll '-Xequals', '-XhashCode'

as advised in the documentation here I'm getting the exception above. I'm using Java 11 and gradle 6.8.3 if this matters. Any hint what is wrong here?

A: You need to have the respective plugins that implement -Xequals and -XhashCode on the classpath as pointed out a section earlier in the documentation that you referenced. Specifying the plugin classpath lists:
dependencies {
    xjcClasspath 'org.jvnet.jaxb2_commons:jaxb2-basics:0.12.0'
}

The example is using JAXB2 Basics plugin suite. However, any other plugin will work similar.


text:
Q: initialization vectors in CBC mode encryption what is the purpose of initialization vectors in CBC mode encryption?

A: For a given plaintext input and a key, the IV is used to ensure the ciphertext is different each time the plaintext is encrypted with the key.


text:
Q: System JS load multiple dependencies in one call Looking at the docs for systemjs I can not find an example of loading multiple dependencies at the same time. I would expect an api something like...
System.import(['jquery.js','underscore.js']).then(function($, _) {
    // ready to go with both jQuery and Underscore...
});

I would expect it to use promises to load all dependencies in parallel, and execute the callback once all are complete. Is this possible? If not, is there a reason why this functionality is not implemented?

A: This is how i would do it, take it carrefully: it's not tested.
var SystemImport = System.import;
System.import = function (name, options) {
    if (Object.prototype.toString.call(name) !== '[object Array]')
        return SystemImport.apply(this, arguments);
    var self = this,
        imports = Promise.all(name.map(function (name) {
            return SystemImport.call(self, name); // should i pass options ?
        }));
    return {
        then: function (onfulfill, onreject) {
            return imports.then(function (dependencies) {
                return onfulfill.apply(null, dependencies);
            }, onreject);
        }
    };
};

This snippet will replace System.import with a wrapped version of itself allowing to use array of dependencies.
It returns a "thennable" object, this should work fine with any compliant promise implementation.
As the .spread method is not in the Promise A+ spec, this is the most spec compliant way I can think of...

A: Possibly the shortest and DRYest way would be applying a [].map() to the System.import and then destructure its results:
Promise.all([
    'jquery',
    'underscore'
].map(url => System.import(url))).then(function ([$, _]) {
    // do stuff with results
});

Keep in mind that Destructuring still needs to be transpiled at the moment of writing this.
If you don't want to transpile you could write your own wrapper and spread script:
function spread(callback) {
    return function (args) {
        return callback.apply(undefined, args);
    }
}
function import(deps) {
    return Promise.all(deps.map(function (url) {return System.import(url);}));
}

and load it like:
import(['jquery', 'underscore']).then(spread(function ($, _) { /*...*/ }));

A: This is possible with Promise.all:
Promise.all([
    System.import('jquery'),
    System.import('underscore')
]).then(function(modules) {
    var jquery = modules[0];
    var underscore = modules[1];
});

But it is ugly as you can see. There is talk of considering allowing an array like your example at the spec level, but it would need to be in the module spec since this is a spec loader.
The better alternative really is to only have one entry point for an application, app.js and then have that load dependencies.

A: I was looking for the same thing.
I'm currently using Bluebird, Promise.all and Promise.spread to do this.
That's as "nice" as I could write it.

Promise.all([
  SystemJS.import('jquery'),
  SystemJS.import('axios')
]).spread(function(jquery, axios){
  return jquery < axios;
});


text:
Q: Android GCM : issue with message I have implemented Google GCM for android exactly as written in this tutorial :
http://developer.android.com/google/gcm/client.html
When sending message, BroadcastReceiver catch the Intent and call the GcmIntentService class :
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        // Explicitly specify that GcmIntentService will handle the intent.
        ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());

        // Start the service, keeping the device awake while it is launching.
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);

    }
}

But in the 'sendNotification' method (in the Service class), "msg" is not the message I have sent, but something like :
Bundle[{android.support.content.wakelockid=1, collapse_key=do_not_collapse, from=153438952475}]

My Service :
public class GcmIntentService extends IntentService {

    public static final int NOTIFICATION_ID = 1;
    public NotificationCompat.Builder builder;
    private String TAG = this.getClass().getSimpleName();

    public GcmIntentService() {
        super("GcmIntentService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {

        Bundle extras = intent.getExtras();
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

        // The getMessageType() intent parameter must be the intent you received
        // in your BroadcastReceiver.
        String messageType = gcm.getMessageType(intent);

        if (!extras.isEmpty()) {

            if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
                Log.e(TAG,"GoogleCloudMessaging: error: "+ extras.toString());
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
                Log.e(TAG,"GoogleCloudMessaging: deleted: "+ extras.toString());
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                sendNotification(extras.toString());
            }

        }

        // Release the wake lock provided by the WakefulBroadcastReceiver.
        GcmBroadcastReceiver.completeWakefulIntent(intent);
    }

    private void sendNotification(String msg) {
        GcmResult gcm = GcmResult.getGcm(msg);
        GcmResultAsync async = new GcmResultAsync();
        async.setInfo(getApplicationContext(),gcm );
        async.execute();
    }
}

By the ways, all permissions are present.
Thank you for reading !

A: That Google example is a bit misleading, as it lumps all the extras into one. Exactly how you get your message out of the bundle depends on how you sent it. Whichever method you used, it will require you to get an 'extra' out in the client.
Assuming you use PHP to send, then your data block might have looked like:
$fields = array(
           'registration_ids' => $registrationIDs,
             'data' => array( "message" => $message,
                              "moredata" => $morestuff),
             'delay_while_idle'=> false,
             'time_to_live' => 86400,
             'collapse_key'=>"".$randomNum.""
            );

where 'message' and 'moredata' are keys of my invention. To extract the values in the client you would have:
if (intent.hasExtra("message")) {
  String theMessage = intent.getStringExtra("message");
}

and
if (intent.hasExtra("moredata")) {
  String moreData = intent.getStringExtra("moredata");
}

You should be able to translate this code to make use of your own key/value pairs.


text:
Q: Chocolatey failing to install Sass in cmd I tried installing Sass using Chocolatey in both the CMD and Powershell and this is the error I'm getting, How do I solve it?
C:\WINDOWS\system32>choco install sass
Chocolatey v0.12.1
Installing the following packages:
sass
By installing, you accept licenses for the packages.
Progress: Downloading sass 1.49.9... 100%
sass v1.49.9 [Approved]
sass package files install completed. Performing other installation steps.
The package sass wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): Y
Fetching Dart dependencies...
ERROR: The term 'pub' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
The install of sass was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\sass\tools\chocolateyInstall.ps1'.
See log for details.
Chocolatey installed 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Failures

*

*sass (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\sass\tools\chocolateyInstall.ps1'.
See log for details.


text:
Q: Interactive Spell Checking Programs Available for emacs I recently switched to emacs24 and upgraded to Ubuntu 12.04. I can't seem to get hunspell working correctly again. I find hunspell to be better than aspell generally. Hunspell only wants to use the Australian dictionary and not English US dictionary or freezes up my system. With aspell I have no problem switching dictionaries or running flyspell mode.
My question is how do people have setup interactive spelling in emacs24?? Still using ispell and flyspell or any other setups preferred. Are you using hunspell with emacs24? I may continue to try to get this working but want to confirm elsewhere people don't have any issues.

A: I use hunspell on OS X (installed via homebrew) with Emacs 24 built from bzr.  The relevant portions of my .emacs are below.  I have not switched dictionaries however, so I can't help with that.  It took me a while to get things set up, and it was a while ago so I don't remember why everything is the way it is.
(setq-default ispell-program-name "hunspell")
(setq ispell-dictionary "american"
  ispell-extra-args '() ;; TeX mode "-t"
  ispell-silently-savep t
  )

(setq flyspell-mode-map nil)

(add-hook 'ispell-initialize-spellchecker-hook
      (lambda ()
    (setq ispell-base-dicts-override-alist
          '((nil ; default
         "[A-Za-z]" "[^A-Za-z]" "[']" t
         ("-d" "en_US" "-i" "utf-8") nil utf-8)
        ("american" ; Yankee English
         "[A-Za-z]" "[^A-Za-z]" "[']" t
         ("-d" "en_US" "-i" "utf-8") nil utf-8)
        ("british" ; British English
         "[A-Za-z]" "[^A-Za-z]" "[']" t
         ("-d" "en_GB" "-i" "utf-8") nil utf-8)))))


text:
Q: ¿Cómo verificar si dos archivos son realmente el mismo? Necesito comparar dos cadenas que indican nombres de archivo y ver si efectivamente están apuntando al mismo. De entrada podríamos intentar compararlas, pero tiene su complejidad, por ejemplo:
fname1 = "prueba.txt"
fname2 = "Prueba.txt"

¿Se trata del mismo archivo? En Windows podríamos llegar a decir que sí, en Linux obviamente No (Notar la P en mayúscula de uno de ellos). Por lo que mi pregunta es ¿Hay alguna forma dados dos paths absolutos de, saber si se trata del mismo archivo? que además sea consistente entre sistemas operativos. Aclaración: las cadenas siempre apuntan a archivos reales.

A: Esta respuesta explica como comparar dos archivos y saber si son los mismos. La idea entonces, es usar os.stat() que nos retorna un objeto stat_result con información de cada archivo, los datos que nos importan son: st_ino el número del inodo en Unix, o bien el índice del archivo en Windows, y st_dev que es índice del dispositivo dónde se aloja el archivo.
import os

def are_same_files(fname1, fname2):
  stat1 = os.stat(fname1)
  stat2 = os.stat(fname2)

  return True if stat1.st_ino == stat2.st_ino and stat1.st_dev == stat2.st_dev else False

print(are_same_files("c:\autoexc.bat", "C:\AUTOEXEC.BAT"))
True

A: Para saber si dos archivos son iguales debes de comparar su hash, cualquier otro método no te asegura al 100% que así sea. Cuando te descargas un archivo en internet, te suelen dar el hash (checksum) para que compruebes que lo que te has descargado es el archivo original y no cualquier otro.
Para ello:
import hashlib

def sha256sum(filename):
    h  = hashlib.sha256()
    b  = bytearray(128*1024)
    mv = memoryview(b)
    with open(filename, 'rb', buffering=0) as f:
        for n in iter(lambda : f.readinto(mv), 0):
            h.update(mv[:n])
    return h.hexdigest()

Y llamando a la función sha256sum(filename) puedes obtener el hash de un archivo para comparar ambos.


text:
Q: Potential null pointer access: The variable stream may be null at this location I received this error in this function and do not know exactly how to solve.
"Potential null pointer access: The variable stream may be null at this location"
Below is the code:
public void downloadAudioIncrement(String mediaUrl) throws IOException {
        /*URLConnection cn = new URL(mediaUrl).openConnection(Proxy.NO_PROXY);

        cn.connect();
        InputStream stream = cn.getInputStream();*/
        URL url = new URL(mediaUrl);

        InputStream stream = url.openStream();
        //Toast.makeText(this.context, "here3", Toast.LENGTH_LONG);

        if (stream == null) {
            Log.e(getClass().getName(), "Não é possível criar InputStream para a url: " + mediaUrl);
        }

        //downloadingMediaFile = new File(context.getCacheDir(),"downloadingMedia_" + (counter++) + ".dat");
        downloadingMediaFile = new File(context.getCacheDir(),"downloadingMedia_.dat");
        FileOutputStream out = new FileOutputStream(downloadingMediaFile);
        byte buf[] = new byte[16384];

        int totalBytesRead = 0, incrementalBytesRead = 0;
        do {
            int numread = ***stream***.read(buf);
            if (numread <= 0)
                break;

            out.write(buf, 0, numread);
            totalBytesRead += numread;
            incrementalBytesRead += numread;
            totalKbRead = totalBytesRead/1000;

            testMediaBuffer();
            fireDataLoadUpdate();
        } while (validateNotInterrupted());

        if (validateNotInterrupted()) {
            fireDataFullyLoaded();
            //testMediaBuffer();
            //fireDataLoadUpdate();
        }
        ***stream***.close();
        out.close();
    }

How do I fix this error? The error occurs here:
 numread ***stream***.Read = int (buf);

and here:
 ***stream***.Close ();

A:     if (stream == null) {
        Log.e(getClass().getName(), "Não é possível criar InputStream para a url: " + mediaUrl);
    }

Here, you check if stream is null, and log it, but you still proceed with the method, and you never make a new stream or anything. My suggestion: add a return; to your block:
    if (stream == null) {
        Log.e(getClass().getName(), "Não é possível criar InputStream para a url: " + mediaUrl);
        return;
    }

A: Change this line to read
 if (stream == null) {
            Log.e(getClass().getName(), "Não é possível criar InputStream para a url: " +     mediaUrl);
return;
    }

that way, the erroneous lines won't be reached with a null value.


text:
Q: Skype Bypass UFW While Transmission Can't Even Open Port I'm new to Linux.
On Windows I'm used to have the firewall triggered automatically by an application and then I authorize whether or not to let the application access real world.
Linux using UFW has more manual approach which is OK by me.
What I found is an interesting phenomenon.
I opened port 51413 for Transmission on GUFW (Both TCP and UDP):

Yet still on Transmission it seems the port isn't open:

I thought maybe something isn't working with the UPNP (Though the same computer with Windows configure the Router with UPNP perfectly on Transmission for Windows). So I downloaded small utility to see the UPNP configuration - UPnP Router Control.
What I saw was very strange:

Skype configured ports using UPNP which means UPNP works.
Now the questions:

*

*It seems the UPNP is working, how come Transmission isn't able to properly open the port? Or even do it like Skype?

*How the hell Skype could bypass the UFW and open port to the outside world without any permission?

*What's the UPNP policy? Can any UPNP application just bypass the UFW?

Thank You.


text:
Q: How can I turn this jquery into a function? I would like to turn the below jquery code into a function so i could add links to the list and not have to touch the jquery. I'm assuming I will have to put the image name into the  tag somewhere.
html code

Link 1

Link 2

Link 3

jquery
$('a.newslink1').bind('mouseover', function() {
    $('img#storyimg').attr("src", "1.png");
});
$('a.newslink2').bind('mouseover', function() {
    $('img#storyimg').attr("src", "2.png");
});
$('a.newslink3').bind('mouseover', function() {
    $('img#storyimg').attr("src", "3.png");
});

A: Add a data attribute called data-src:
Link 1

jQuery:
$("a.newslink").bind("mouseover", function() {
    $("img#storyimg").attr("src", $(this).data("src"));
});

Works with jQuery 1.5+.

A: Change your HTML markup and put the desired image in a data attribute, and change your class to a generic newslink:

Link 1

Link 2

Link 3

Then do a generic event using that data attribute:
$('a.newslink').bind('mouseover', function(){
    $('img#storyimg').attr("src", $(this).data('img'));
});

A: You can add a data-img attribute to your links:

which you can then access in the event handler using:
$(this).data('img');

e.g.:
$('.sb_menu a').bind('mouseover', function() {
    $('#storyimg').attr(src, $(this).data('img'));
});

A: Here is a good example:
http://jsfiddle.net/maniator/tac3t/
JS:
$('a.newslink').live('mouseover', function() {
    $('img#storyimg').attr("src", $(this).attr('ref'));
});

HTML:

Link 1

Link 2

Link 3

A: You can do this without changing the markup at all:
$('a[class^="newslink"]').bind('mouseover', function (e) {
    var num = this.className.match(/newslink(\d+)/i)[1];
    $('img#storyimg').attr('src', num + '.png');
});

A: Could give this a try:
$('a.newslink').bind('mouseover', function(){
              var imgname = $(this).attr("src");
              $('img#storyimg').attr("src", imgname);

});

A:

Link 1

Link 2

Link 3

$('a.newslink').hover(function(){
    $('img#storyimg').attr("src", $(this).attr('title'));
});

A:

Link 1

Link 2

Link 3

$('a.newslink').bind('mouseover', function() {
    $('img#storyimg').attr("src", $(this).attr('rel'));
});


text:
Q: nodejs express Error: Can't set headers after they are sent I am reading a growing file in nodejs. Using below code in my app.js.
app.post('/readfile',function (req,res) {
    var fullfilename = req.body.filepath+"\\"+req.body.filename;
    var bite_size = 256;
    var readbytes = 0;
    var file;

    fs.open(fullfilename, 'r', function(err, fd) {
        file = fd;
        if(err){console.log(err); throw err; return;};
        var mybuff;
        var func = (function readsome() {
        var stats = fs.fstatSync(fd); // yes sometimes async does not make sense!
                if(stats.size<readbytes+1) {
                    setTimeout(readsome, 1000);
                }
                else {
                    fs.read(fd, new Buffer(bite_size), 0, bite_size, readbytes, function (err, bytecount, buff) {
                    //console.log(buff.toString('utf-8', 0, bytecount));
                    res.json(buff.toString('utf-8', 0, bytecount));
                    readbytes+=bytecount;
                    process.nextTick(readsome);
                    });
                };
        })();
    });
});

And calling this in html like below ,
var myApp= angular.module("myApp", [])
myApp.controller('Ctrl1', function ($scope, $http,$q) {
        var FileName = "test.txt"
        var obj = {"filepath" : 'D:\\Temp', "filename" : FileName};

        $http({
                url: '/readTfile',
                method: "POST",
                data: JSON.stringify(obj)
                //timeout: canceller.promise,
                //headers: {'Content-Type': 'application/json','charset' : 'utf-8'}
                }).success(function(result) {
                $scope.myfiledata = result;
                }).error(function(data, status) {
                console.log(data);
                });
});

This is working fine when i put this app.js code in a separate file (readfile.js) but when i put in app.js it gives error.
_http_outgoing.js:357
    throw new Error('Can\'t set headers after they are sent.');
    ^
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:357:11)
    at ServerResponse.header (D:\myapp\node_modules\express\lib\response.js:725:10)
    at ServerResponse.send (D:\myapp\node_modules\express\lib\response.js:170:12)
    at ServerResponse.json (D:\myapp\node_modules\express\lib\response.js:256:15)
    at D:\myapp\app.js:130:10
    at FSReqWrap.wrapper [as oncomplete] (fs.js:682:17)
[nodemon] app crashed - waiting for file changes before starting...

Please help to find where is the mistake and what to be changed. Secondly i want to stop this call on button click, how can i do that ?

A: This is just a guess, but, did you remove the old code, before adding the code in app.js ?
Maybe your /readfile route is added by both app.js and in the separate file, so that first route sends out the response, and when the second route starts to do the same, it gets the error of response already been sent.

A: You can only call res.json once on a request. It sets the relevant headers, JSON encodes the data, sends it as the response and then ends the request.
If you just want to write some of the data you can use write: https://nodejs.org/api/http.html#http_response_write_chunk_encoding_callback
Or maybe you could using piping to do it all for you instead?
var readStream = fs.createReadStream(fullfilename);
readStream.pipe(res);


text:
Q: Why SBT is publishing a JAR which is skipped? Need help to understand why SBT would try to publish a JAR which is already skipped? And how to fix this issue?
Like in the following build log, publishing of my-service_2.13-0.45.13-tests.jar was skipped but still the sbt publish shows [error] java.io.IOException in putting it on artifactory.
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13-tests.jar
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13-sources.jar
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13.pom
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13-it.jar
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13.jar
[error] java.io.IOException: PUT operation failed because the destination file exists and overwriting is disabled:
[error]     source     : /home/my-system/my-service/target/scala-2.13/my-service_2.13-0.45.13-tests.jar
[error]     destination: https://my-artifactory.com/artifactory/com/my-org/my-service_2.13/0.45.13/my-service_2.13-0.45.13-tests.jar
[error] If you have a staging repository that has failed, drop it and start over.
[error] Otherwise fix the double publishing, or relax the setting as follows:
[error]     publishConfiguration := publishConfiguration.value.withOverwrite(true)
[error]     publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)

I am using SBT 1.3.13 with Scala 2.13.3


text:
Q: About generalized Minkowski inequality For which functions $f:\mathbb{R}^+ \to \mathbb{R}^+$ does the inequality
$f^{-1}\left(\sum\limits_{k=1}^n f(x_k+y_k)\right) \leq f^{-1}\left(\sum\limits_{k=1}^n f(x_k)\right) + f^{-1}\left(\sum\limits_{k=1}^n f(y_k)\right)$
hold for any nonnegative real numbers $x_1, \dots, x_n, y_1, \dots, y_n$?
Note that for $f(x)=x^p$, $p \geq 1$, this is the classical Minkowski inequality.
We can assume that $f$ is strictly inreasing to guarantee that $f^{-1}$ exists. Any other natural conditions on $f$ are acceptable. For example: does the above inequality hold for any stricly increasing convex function with $f(0)=0$?

A: The question that you are asking was asked in "On Generalizations of Minkowski's Inequality in the Form of a Triangle Inequality" by F. Mulholland (1949). In that paper, Mulholland established a sufficient condition on $f$, namely that it should satisfy $f(0)=0$, be increasing on $x \ge 0$ and be g-convex, i.e., $\log f(e^x)$ is convex on the reals.
However, Mulholland's condition is not necessary, which seems to have been very recently shown in On functions that solve Mulholland inequality
and on compositions of such functions by M. Petrík (2013)---but given the elementary nature of the question, perhaps the non-necessity of the above g-convexity hypothesis of Mulholland has also previously been observed.


text:
Q: Draw a line chart dynamically using sql server database using highchart.js Not able to generate dynamic line chart with x-axis and series dynamically
I want month wise count for different destination.
I have done like this
function GetDestinationData() {

    $.ajax({
    async: false,
    type: "POST",
    url: "DataAnalysis.aspx/getDestination",
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    success: OnSuccess1_,
    error: OnErrorCall1_

    });
    }

    function OnSuccess1_(response) {
    var Xaxis = [];//skapa tre olika array
    var dataseries = [];
    for (var i = 0; i < response.d.length; i++) {
    var items = response.d[i];
    var XcategoreisItem = items.Month;
    var seriesData = items;
    if ($.inArray(XcategoreisItem, Xaxis) == -1) {
    Xaxis.push(XcategoreisItem);
    }
    dataseries.push(seriesData);
    // console.log(dataseries);
    }

    drawLineChart(Xaxis, dataseries);

    }

        function drawLineChart(Xaxis, dataseries) {
        //categories = seriesData.map(function (a) { return a.x; });
        //categories = categories.filter(function (v, i) { return categories.indexOf(v) == i; });
        var chart = Highcharts.chart('container', {
        chart: {
        type: 'line',
        //zoomType: 'xy',
        //panning: true,
        //panKey: 'shift'
        },
        //chart: {
        // renderTo: 'container',
        // type: 'line',
        // marginRight: 130,
        // marginBottom: 25
        //},
        title: {
        text: 'Destination Count Month Wise'
        },
        plotOptions: {
        series: {
        dataLabels: {
        enabled: true,
        format: '{y}',

        }
        }
        },
        xAxis: {
        categories: Xaxis
        },
        yAxis: {
        labels: {
        formatter: function () {
        return this.value ;
        }
        },
        plotLines: [{
        //value: 0,
        width: 1,
        color: '#808080'
        }]
        },

        series: [{
        //name: 'Id',
        data: dataseries
        }],
        legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'middle'
        },
        });
        for (var i = 0; i < dataseries.length; i++) {
        //dataseries = dataseries.filter(function (e) {
        // return e.Month == dataseries[i].Month

        //}
        //);

        chart.addSeries({
        name: dataseries[i].destination,
        data: [dataseries[i].A1ResultCount]
        });
        //chart.series[i].setData(dataseries[i].data);
        }
        //chart.redraw();
        }

Rendered Chart

A: Maybe consider using a web-component that handles dynamic data?
Using highcharts-chart you could do:

const chart = $('#Chart')[0]
function OnSuccess1_(response) {
    var Xaxis = [];//skapa tre olika array
    var dataseries = [];
    for (var i = 0; i < response.d.length; i++) {
        var items = response.d[i];
        var XcategoreisItem = items.Month;
        var seriesData = items;
        if ($.inArray(XcategoreisItem, Xaxis) == -1) {
            Xaxis.push(XcategoreisItem);
            dataseries.push({name: items.month, data: items.data_maybe})
        }
        chart.data = dataseries
    }
}

//Example Data
chart.xAxis = {categories: ['Jan','Feb','Mar','Apr','May','Jun']}
chart.data = [43,81,52,84,53,45]
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="import" href="https://user-content-dot-custom-elements.appspot.com/avdaredevil/highcharts-chart/v2.0.1/highcharts-chart/highcharts-chart.html">

<highcharts-chart id='Chart' title='Destination Count Month Wise' type='line' y-label='Destinations' x-label='Month'></highcharts-chart>

Note: Click Run code snippet to see the chart

Edit:
As I was writing this answer, I also realized you were setting categories for a line series? You don't need categories, instead, you need multiple series itself, each with their own name corresponding to the month.


text:
Q: How to use Incomplete paths in app get (Express js) Hay everyone, I wrote a simple express js code that has six different routes: "/,"/routes/show-stocks","/routes/show-stocks/btc","/routes/show-stocks/eth","/routes/show-stocks/ada","/routes/show-stocks/doge".I used app.use to be able to use "/show-stocks" as the path insted the full one: "/routes/show-stocksthis is how I did it: (app.js)
const express = require("express");

const app = express();
const port = 4000;

app.get("/", (req, res) => res.send("Testing on Mac"));

const get_stocks = require("./routes/show-stocks");
app.use("/show-stocks", get_stocks);

app.listen(port, () => console.log("Testing on Mac on port: " + port));

So if the user want to reach /routes/show-stocks/btc he only need to type /show-stocks/btc
This is my "/routes/show-stocks.js":
import express from "express";
const router = express.Router();

router.get("/btc", (req, res) => {
  // ...
});

router.get("/ada", (req, res) => {
  // ...
});

router.get("/eth", (req, res) => {
  // ...
});

router.get("/doge", (req, res) => {
  // ...
});

module.exports = router;

But now I need to use import instead of require in my app.js file. My problem is that I do not know how I can implement this code with "import" instead, and preserve the same logic.Can anyone help me do that?

A: This seems to work:
notice the import express from "express"; and import get_stocks from "./routes/show-stocks.js";
import express from "express";

const app = express();
const port = 4000;

app.get("/", (req, res) => res.send("Testing on Mac"));

import get_stocks from "./routes/show-stocks.js";
app.use("/show-stocks", get_stocks);

app.listen(port, () => console.log("Testing on Mac on port: " + port));

You'll need to add the "type": "module" to your package.json
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.1"
  }
}

My quick improvised route file:
Notice the export default router at the bottom.
import express from "express";
const router = express.Router();

router.get("/btc", (req, res) => {
  res.send("btc");
});

router.get("/ada", (req, res) => {
  res.send("ada");
});

router.get("/eth", (req, res) => {
  res.send("eth");
});

router.get("/doge", (req, res) => {
  res.send("doge");
});

export default router;


text:
Q: Rails No route matches [GET] "/accounts/sign_out So, I stubbled on this error which seemed old enough and no recent update. The answers I found turned around routes missing: (of course), Javascript includes missing and finally the config edit to send the delete call into a get.
Nothing worked for me except changing the config of devise which to me seemed like a patch. Plus my button worked previously without major modifications...
My code looked like this :
    document.toggleMenu = function(e) {
      var menu = document.getElementById('menu-content');
      menu.style.visibility = menu.style.visibility == 'visible' ? 'hidden' : 'visible';
      e.stopPropagation();
    }

    document.closeMenu = function() {
      document.getElementById('menu-content').style.visibility = 'hidden';
    }

The function closeMenu() is called onClick from the body.

Mon profil

                      Mon profil

                      <%=current_account.email%>

                      Modifier mon profil

                      <%=current_account.profile.first_name%> <%=current_account.profile.last_name%> (<%=current_account.profile.registration_number%>)

                  <%= link_to 'Se déconnecter', destroy_account_session_path, method: "delete", class: "button button-primary" %>

A: Since Rails transform the [GET] "/accounts/sign_out" into a [DELETE] "/accounts/sign_out" using Javascript, the onclick="event.stopPropagation();" stops it from working properly.
I replaced

with

  document.stopPropagation = function(e){
    var senderId = e.path[0].id;
    if(senderId != "disconnect"){
      event.stopPropagation();
    }
  }

that makes the event generated by Rails from the button continue to bubble up and work as intended.


text:
Q: How to deploy AWS resources across all regions via terraform? I need to deploy AWS GuardDuty across all accounts/regions in my AWS Organization.
My first step is to delegate GuardDuty's administration to a designated account. Since, GuardDuty is a regional resource, I need to perform such delegation across all regions. Note that we are operating in pretty much every region of AWS.
Here is a brute-force approach for accomplishing this task:
provider "aws" {
  region  = "us-east-1"
  alias   = "us-east-1"
}
provider "aws" {
  region  = "us-east-2"
  alias   = "us-east-2"
}
# Do the same for the remaining regions

resource "aws_guardduty_organization_admin_account" "us-east-1" {
   provider = aws.us-east-1
   admin_account_id = "123456789..."
}
resource "aws_guardduty_organization_admin_account" "us-east-2" {
 provider = aws.us-east-2
 admin_account_id = "123456789..."
}

# Do the same for the remaining regions

This works, but has several disadvantages:

*

*A lot of repetition

*I need to remember to update this code when a new region is added

Question: Is there a better way of doing this?
There is an old thread on this scenario here:
https://github.com/hashicorp/terraform/issues/451
However, it does not appear that a good options existed at that time, so I want to see if better options are available now.
Ideally, I want to leverage data "aws_regions" "all" {} to loop over the existing regions and dynamically create the delegation resources and providers.
I tried the approach suggested by @Matt Schuchard:
Given this resource:
resource "aws_guardduty_organization_admin_account" "us-east-1" {
  # interpolate in for expression here since not allowed in provider argument
  for_each = toset([for region in data.aws_regions.this.names : "aws.${region}"])

  provider         = each.value
  admin_account_id = "123456789..."
}

Terraform 1.0.10, produces the following error:
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider hashicorp/each: ...

A: You would need the for_each meta-argument for both the provider and the resource blocks to iterate over all AWS regions within a single block. If one attempts to use the for_each meta-argument with the provider block, then the error message displays:

The provider argument name "for_each" is reserved for use by Terraform in a future version.

and this is on the roadmap for future development.
However, one can do this with the for_each meta-argument in the resource block. First, you suggested retrieving all available regions with the data aws_regions to always truly target all regions:
data "aws_regions" "this" {}

where the all_regions and filters arguments can down-select the desired regions. The exported resource attribute names of type list(string) would store the desired regions.
Assuming you are configuring providers and their aliases as described in the question, you would then use this list within the resource block:
resource "aws_guardduty_organization_admin_account" "us-east-1" {
  # interpolate in for expression here since not allowed in provider argument
  for_each = toset([for region in data.aws_regions.this.names : "aws.${region}"])

  provider         = each.value
  admin_account_id = "123456789..."
}

and this would manage the resource in all desired AWS regions.


text:
Q: SQL Server 2017 installation is stuck For some reason I can't get SQL Server 2017 installed on my Windows 10 machine.
First thing to do with this buggy installer is that I had to uninstall VCRuntime 2017 in order for the installer to work.
And now, the installer is stuck at this point exactly every time I try to install it:

What I've tried so far:

*

*Killing msiexec process

*Running the setup with additional parameter as mentioned here
Setup.exe /SkipInstallerRunCheck

*Restarting ... reinstalling ... turning off anti-virus ...
[Solved]
The problem was due to a background download that was taking forever especially on a low internet speed (i.e. python or R-support component).
[Solution]

*

*If you really need python or R-support just wait until download is complete

*Else, deselect python and R-support from the component list.

*(or) kill the child process for python or R-support component downloader from task manager.

A: UPDATE:

The actual problem turned out to be the R-support component(s) slowly downloading in the background locking up the installation GUI
  with no notification or warning show to the user as to what is
  actually going on.

So it seems this "locked install problem" can be caused by installing several different components, at least by Python or R-support. As mentioned below, please check any available logs or event logs for clues.
In summary, options:

*

*Maybe try to unselect such components for install if you do not need them.

*If you need the components, leave the setup to complete, and check progress in log files as explained below. Verify Internet access (proxy?).

Stuck Download?
UPDATE: Did you see this blog? Looks like the setup tries to download and install the Python runtime, and this can take forever. Are you behind a proxy btw? No direct connection to the Internet? If so I suppose this could also cause further problems. Probably not the cause, but worth a mention.
Apparently you can check the following log file for progress for the installation:

%ProgramFiles%\Microsoft SQL Server\140\Setup
  Bootstrap\Log\DATE_TIME\RSetup.log

DATE_TIME in the above path must be converted to your valid values. For example: 20170804_162723 (date part and time part).
See this answer as well: SQL server 2016 installation freeze. You could also try the suggestion to deselect all components you do not need to prevent any background downloads?

General Debugging
Leaving in the general purpose debugging suggestions below.
Generic Advice: From experience I would create a new local admin user and try to install using that account. This is to avoid any "unclean" or special conditions that have occurred in your user profile or registry during regular Windows use. Might not do much, but sometimes it gets the job done with surprising ease. Worth a try I think.
Some Further Things: I wrote up a little check list a while back, I'll add it and see if it inspires some new ideas that can help you. See under "Core Deployment Problems". That first "check list" was condensed from a longer and somewhat excessive first writeup - one of those answers that unintentionally turned into a blog and maybe a hard one to read.
Logging: Did you check log files and / or event logs properly for clues as to what is happening? I find the best approach for deployment to enable logging for all MSI installations. The performance hit it triggers is minuscule compared to the benefit of having a real log-file always available when you suddenly need one. You can enable logging for all MSI files as explained on installsite.org (section: "Globally for all setups on a machine"). MSI log files will then just sit in your %TEMP% folder after installation. They have a random hex name, and you can flush them all regularly if you do not need them. You sort by modify date / time to find the latest one(s) created - obviously.
Jedi trick: You will want to go home and re-think your life if you don't enable logging for all MSI files. Moral of the story: MSI log files are cool. They are very verbose, but they are beautiful. There are some hints on interpreting them here (bottom).

A: My 2 cents: SQL Server Installer consists of several small MSI installers. MSI installers can only be installed one after each other (as fas as I know). In my case, I launched another MSI setup while installing SQL Server. This caused SQL Server Setup to hold until I finished the concurrently running setup.
So, at least in my case the problem was self-made.

A: For me the solution was different.
I spent 2 days trying to figure out how to install SQL Server 2022 in my laptop (Samsung book 2)
Aparently the ssd of my system doesn't have the proper configuration for the sector size.
I finally found this post
The short solution is to add a key to windows registry so that Sql server gets the expected size. You have to run this command with elevated privileges:
REG ADD "HKLM\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device" /v "ForcedPhysicalSectorSizeInBytes" /t REG_MULTI_SZ /d "* 4095" /f
Restart windows and when I tried to install again it doesn't get stuck in sqlengineconfigaction_install_confignonrc_cpu64 anymore.

A: You have to remove configuration settings for SQL Server from Windows Registry editor.

*

*Sql server

*2017

*VS


text:
Q: How to define UpValues in a different context from within a package I'm trying to create a function (in a package) to import a lot of data and create a symbol with UpValues to return specific results about the data. I've got it working fine in a regular notebook, but when I define the function within a package I can't get it to work properly.
A simple example of my problem:
TestPackage.m:
BeginPackage["TestPackage`"];

testFunction::usage= "testFunction[] does all kind of interesting things.";

Begin["`Private`"]

testFunction[name_Symbol]:=
 Module[{},(
  ClearAll[name];
  UpValues[name]=
   {
    test[name]->"hello!"
   };
  Protect[name];
 )]

End[]

EndPackage[]

I then call the function in a regular notebook:
Needs["TestPackage`", "/path/to/TestPackage.m"]

testFunction[a]

*

*test[a] returns test[a]

*and TestPackage`Private`test[a] returns the expected "hello!"
How do I change testFunction so that test[a] also returns "hello!"?

A: The explanation can be found in the doc to BeginPackage and Begin

*

*BeginPackage["context`"] makes context` and System`the only active contexts.

*Begin["context`"] resets the current context.

Therefore, at the moment you first mention the symbol test it is not created it in the Global context. This can be seen from you (simplified) example
BeginPackage["TestPackage`"];
testFunction::usage =
  "testFunction[] does all kind of interesting things.";
Begin["`Private`"];
testFunction[name_Symbol] := name /: test[name] := "hello!";
End[];
EndPackage[]

testFunction[a]
UpValues[a]

(* {HoldPattern[TestPackage`Private`test[a]] :> "hello!"} *)

beside giving test a ::usage message, you can give the context explicitly
testFunction[name_Symbol] := name /: Global`test[name] := "hello!";

Further note

*

*I don't see why you use Module because you don't localize any variable. And if you want to input a sequence of commands, divided by ; (called a CompoundExpression) you can simply wrap it in parenthesis, as you did.

*Your combination of ClearAll and Protect is such that you can call testFunction on a given Symbol only one time.  On the second call you get messages since ClearAll cannot clear a protected symbol. What is the intention behind this?

A: You should export the test symbol, ie define it between BeginPackage["TestPackage`"] and Begin["`Private`"], for example by giving a usage to test.
test::usage = "test[name] returns ..."
(*or just*) test;

for your definition, as said already in comments, I would use
test[name] ^= "hello";

My answer to this post contains many application of UpValues, it could interest you: Struct equivalent in Mathematica?
You could also not export the symbol, that will be thus in the Private context of the package, and use the full name of test
TestPackage`Private`test[name] ^= "hello";


text:
Q: ReactJS How to use Router's props inside app.js file The app.js file of my project is following. For all other components I used this.props.history.push('/') to redirect to the specific path and it works as those components receives the props. But in this app.js I have tried to console the props values inside constructor, componentWillMount and render but all gives null array. Is there any way to use this.props.history.push('/') inside app.js ?
class App extends Component {
  constructor(props) {
    super(props);
    this.state = {};
    console.log(this.props)
  }

  componentWillMount(){
    console.log(this.props)
    this.props.history.push('/')
  }

  render() {
    console.log(this.props)
    return (
        <Router>

                <Route exact path='/' render={(props) => <Login {...props} />} />
                <Route exact path='/dashboard' render={(props) => <Dashboard {...props}/>}/>

        </Router>
    );
  }
}

export default App;

A: use withRouter
import { withRouter } from 'react-router-dom'

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {};
    console.log(this.props)
  }

  componentWillMount(){
    console.log(this.props)
    this.props.history.push('/')
  }

  render() {
    console.log(this.props)
    return (
        <Router>

                <Route exact path='/' render={(props) => <Login {...props} />} />
                <Route exact path='/dashboard' render={(props) => <Dashboard {...props}/>}/>

        </Router>
    );
  }
}

export default withRouter(App);

that will give you access to the history object and allow you to push to new routes.  (I tested and verified before posting, so I know this works).
import it on the top of the file, then wrap App with it in the export default