text:
Q: How to get the content of console log of jenkins build in email body? I am running a scan on docker images using a whitesource scanner through Jenkins. I want to take the portion of build log and send it in an email. I am searching for specific keywords like the 'Project name:' and sending it via email-ext in Jenkins. But i am unable to do it with ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}. It just shows a blank output in email.
Code:
stage('Send Email') {
   emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} Regards, DT ''',
   subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}

*

*I have tried this ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}, but the result is empty.

*I tried with ${BUILD_LOG, maxLines=99, escapeHtml=false}, but it shows all the log content in the email.

*Unable to append the log to a file. ${BUILD_LOG, maxLines=99, escapeHtml=false} > log.txt

This is the jenkins log.
Started by user
[Pipeline] node
Running on DevNode in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] dir
Running in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] stage
[Pipeline] { (WorkSpace CleanUp)
[Pipeline] cleanWs
[WS-CLEANUP] Deleting project workspace...[WS-CLEANUP] done
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Checkout SCM)
[Pipeline] dir
Running in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] sh
[geoshield-dataconnector] Running shell script

Login Succeeded
[Pipeline] sh
[geoshield-dataconnector] Running shell script
+ sudo docker pull registry.abcd/dataconnector:V.1.0.0.0
V.1.0.0.0: Pulling from dataconnector
e7c96db7181b: Already exists
584a4cfc5c76: Pulling fs layer
ec4c1f08eb03: Pulling fs layer
73021472167d: Pulling fs layer
a86ac7fa4ae3: Pulling fs layer
28d2d93bdc6e: Pulling fs layer
a8ff63a747fc: Pulling fs layer
c9fd118fb9fc: Pulling fs layer
a86ac7fa4ae3: Waiting
28d2d93bdc6e: Waiting
a8ff63a747fc: Waiting
c9fd118fb9fc: Waiting
584a4cfc5c76: Verifying Checksum
584a4cfc5c76: Download complete
a86ac7fa4ae3: Verifying Checksum
a86ac7fa4ae3: Download complete
73021472167d: Verifying Checksum
73021472167d: Download complete
28d2d93bdc6e: Verifying Checksum
28d2d93bdc6e: Download complete
c9fd118fb9fc: Verifying Checksum
c9fd118fb9fc: Download complete
a8ff63a747fc: Verifying Checksum
a8ff63a747fc: Download complete
584a4cfc5c76: Pull complete
ec4c1f08eb03: Verifying Checksum
ec4c1f08eb03: Download complete
ec4c1f08eb03: Pull complete
73021472167d: Pull complete
a86ac7fa4ae3: Pull complete
28d2d93bdc6e: Pull complete
a8ff63a747fc: Pull complete
c9fd118fb9fc: Pull complete
Digest: sha256:cf62e8ba5a8a499b4a0e421a861511f7485304842ecac7de59d5a463fdab18e5
Status: Downloaded newer image for registry.abcd/dataconnector:V.1.0.0.0
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Fabric OSS scanning)
Running in /home/cyberadmin/workspace/scanner/geoshield-oss
[Pipeline] dir
[Pipeline] {
[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
+ sudo chmod 755 wss-unified-agent-19.7.2.jar
[Pipeline] sh
[geoshield-oss] Running shell script
+ java -jar wss-unified-agent-19.7.2.jar -c dataconnector-image.config -d /opt/Whitesource/Apps/geoshield_images/geoshield-dataconnector -product Fabric -project engine-14
[INFO] [2019-09-30 13:37:58,361 +0530] -
------------------------------------------------------------------------
-------------------- Start: Fetch Configuration ------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:58,409 +0530] - UnifiedAgent version (pluginVersion) : 19.7.2
[INFO] [2019-09-30 13:37:58,438 +0530] - UA Configuration {
DEFAULT_TIMEOUT_PROCESS_MINUTES=15
failErrorLevel=DEFAULT
projectPerFolder=false
connectionTimeOut=60
checkPolicies=true
serviceUrl=https://app-eu.whitesourcesoftware.com/agent
forceCheckAllDependencies=true
forceUpdate=true
forceUpdateFailBuildOnPolicyViolation=false
updateTypeValue=OVERRIDE
enableImpactAnalysis=false
updateInventory=true
generateScanReport=false
scanReportTimeoutMinutes=10
analyzeFrameworks=false
analyzeFrameworkReference=analyzeFrameworks.txt
updateEmptyProject=true
euaOffline=
euaDep=euaDep.json
euaVul=euaVul.json
euaRes=euaRes.json
offline=false
zip=false
prettyJson=true
resolveAllDependencies=false
ignoreSourceFiles=false
appPath=null
cargoResolveDependencies=false
cargoRunPreStep=false
cargoIgnoreSourceFiles=true
npm: {npmRunPreStep=false, npmIgnoreScripts=false, npmResolveDependencies=false, npmIncludeDevDependencies=false, npmTimeoutDependenciesCollector=60, npmIgnoreNpmLsErrors=false, npmYarnProject=false, npmYarnFrozenLockfile=false, npmIgnoreSourceFiles=true, npmIdentifyByNameAndVersion=false, npmResolveMainPackageJsonOnly=false, npmProjectNameFromDependencyFile=false, npmRemoveDuplicateDependencies=true, npmResolveAdditionalDependencies=false}
bower: {bowerResolveDependencies=false, bowerRunPreStep=false, bowerIgnoreSourceFiles=false}
nuget: {nugetResolveDependencies=false, nugetRestoreDependencies=false, nugetRunPreStep=false, nugetIgnoreSourceFiles=true, nugetResolvePackagesConfigFiles=true, nugetResolveCsProjFiles=true, nugetResolveNuspecFiles=true, nugetPreferredEnvironment=, nugetPackagesDirectory=}
ant: {antResolveDependencies=false, antPathidIncludes=, antExternalParameters=}
maven: {mavenResolveDependencies=false, mavenIgnoredScopes=, mavenAggregateModules=false, mavenIgnorePomModules=true, mavenIgnoreSourceFiles=true, mavenRunPreStep=false, mavenIgnoreDependencyTreeErrors=false, mavenEnvironmentPath=, mavenM2Path=, mavenDownloadMissingDependencies=true, mavenAdditionalArguments=}
python: {pythonResolveDependencies=false, pipPath=pip, pythonPath=python, pythonIgnorePipInstallErrors=false, pythonInstallVirtualenv=false, pythonResolveHierarchyTree=true, pythonRequirementsFileIncludes=requirements.txt,Pipfile, pythonResolveSetupPyFiles=false, pythonIgnoreSourceFiles=true, ignorePipEnvInstallErrors=false, pipenvInstallDevDependencies=false, pythonIndexUrl=, runPipenvPreStep=false, pythonIsWssPluginInstalled=false, pythonUninstallWssPlugin=false}
gradle: {gradleResolveDependencies=false, gradleRunAssembleCommand=true, gradleAggregateModules=false, gradlePreferredEnvironment=gradle, gradleLocalRepositoryPath=, gradleAdditionalArguments=, gradleIncludeScopes=, gradleBuildFileIncludes=, gradleIgnoreSourceFiles=false, gradleRunPreStep=false, gradleIgnoredScopes=, gradleDownloadMissingDependencies=true, gradleWrapperPath=}
paket: {paketResolveDependencies=false, paketIgnoredScopes=, paketRunPreStep=false, paketPath=, paketIgnoreSourceFiles=true}
go: {goResolveDependencies=false, goDependencyManager=, goCollectDependenciesAtRuntime=false, goGlideIgnoreTestPackages=true, goIgnoreSourceFiles=false, goGradleEnableTaskAlias=false}
ruby: {rubyResolveDependencies=false, rubyRunBundleInstall=false, rubyOverwriteGemFile=false, rubyInstallMissingGems=false, rubyIgnoreSourceFiles=true}
php: {phpResolveDependencies=false, phpRunPreStep=false, phpIncludeDevDependencies=false}
sbt: {sbtResolveDependencies=false, sbtAggregateModules=false, sbtRunPreStep=false, sbtTargetFolder=, sbtIgnoreSourceFiles=false}
html: {htmlResolveDependencies=false}
cocoapods: {cocoapodsResolveDependencies=false, cocoapodsRunPreStep=false, cocoapodsIgnoreSourceFiles=true}
hex: {hexResolveDependencies=false, hexRunPreStep=false, hexAggregateModules=false, hexIgnoreSourceFiles=true}
r: {rResolveDependencies=false, rRunPreStep=false, rIgnoreSourceFiles=true, rCranMirrorUrl=}
bazel: {bazelResolveDependencies=false, bazelRunPreStep=false}
imageNames=
imageTags=
imageDigests=
forceDelete=false
remoteDockerEnabled=false
maxScanImages=0
forcePull=false
maxPullImages=10
loginSudo=true
defaultamazonRegistryIds=
remoteDockerAmazonEnabled=false
amazonRegion=east
amazonMaxPullImages=0
remoteDockerAzureEnabled=false
azureUserName=
azureUserPassword=
azureRegistryNames=
remoteDockerArtifactoryEnabled=false
dockerArtifactoryUrl=
dockerArtifactoryUserName=
dockerArtifactoryUserPassword=
dockerArtifactoryRepositoryNames=
dockerArtifactoryDockerAccessMethod=
remoteDockerGoogleContainerEnabled=false
googleRepositoryNames=
googleActiveAccount=
remoteDockerHubEnabled=false
dockerHubUserName=
dockerHubUserPassword=
dockerHubOrganizationsNames=
dockerHubAccessToken=
serverlessConfiguration=
fileListPath=
dependencyDirs=Whitesource/Apps/geoshield_images/geoshield-dataconnector
configFilePath=dataconnector-image.config
includes=**/*.jar,**/*.js,**/*.ts,**/*.deb,**/*.tgz,**/*.py,**/*.dll,**/*.apk
excludes=**/*sources.jar,**/*javadoc.jar,**/*pom.xml,**/*build.gradle
dockerIncludes=.*dataconnector.*
dockerExcludes=
dockerContainerIncludes=.*.*
dockerContainerExcludes=
pythonRequirementsFileIncludes=requirements.txt
archiveExtractionDepth=7
archiveIncludes=**/*.jar
archiveExcludes=
followSymbolicLinks=true
globCaseSensitive=false
projectPerFolderIncludes=*
projectPerFolderExcludes=
failErrorLevel=DEFAULT
excludeDependenciesFromNodes=
enableGenerateProjectDetailsJson=false
artifactoryUrl=
artifactoryRepoKeys=
apiToken=******
userKey=
projectVersion=
projectToken=
projectPerSubFolder=false
requesterEmail=
productToken=
productName=Fabric
productVersion=
projectName=unityengine-14
scanComment=
requireKnownSha1=true
scanReportFileNameFormat=project_with_timestamp
artifactoryEnableScan=false
scanPackageManager=false
scanDockerImages=true
scanDockerContainers=false
scanServerlessFunctions=false
logLevel=info
logFilesLevel=DEBUG
logFilesMaxFileSize=10
logFilesMaxFilesCount=3
}
[INFO] [2019-09-30 13:37:58,438 +0530] -
------------------------------------------------------------------------
-------------------- End: Fetch Configuration --------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:58,450 +0530] -
------------------------------------------------------------------------
-------------------- Start: Docker Resolver Scan -----------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:59,277 +0530] - Filtering docker list by includes and excludes lists
[INFO] [2019-09-30 13:37:59,285 +0530] - Handle 1 docker entities
[INFO] [2019-09-30 13:37:59,285 +0530] - Image 1 of 1
[INFO] [2019-09-30 13:38:04,628 +0530] - Extracting file /tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd-dataconnector.tar - Size 185261568 Bytes (176 MBs)- Free Space 31528574976 Bytes (30067 MBs)
[INFO] [2019-09-30 13:38:06,566 +0530] - Found 50 system packages in image 'registry.abcd/dataconnector'
[INFO] [2019-09-30 13:38:06,577 +0530] - Starting Archive Extraction (may take a few minutes)
[INFO] [2019-09-30 13:38:06,849 +0530] - Starting analysis
[INFO] [2019-09-30 13:38:06,849 +0530] - Scanning directories [/tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd-dataconnector] for package dependencies (may take a few minutes)
[INFO] [2019-09-30 13:38:06,849 +0530] - Included file types: **/*.jar,**/*.js,**/*.ts,**/*.deb,**/*.tgz,**/*.py,**/*.dll,**/*.apk
[INFO] [2019-09-30 13:38:06,849 +0530] - Excluded file types: **/*sources.jar,**/*javadoc.jar,**/*pom.xml,**/*build.gradle
[INFO] [2019-09-30 13:38:06,849 +0530] -
------------------------------------------------------------------------
-------------------- Start: Scan Files Matching Includes Pattern -------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:06,949 +0530] - Scanning directories [/tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd/dataconnector] for matching source/binary file types (may take a few minutes)
[INFO] [2019-09-30 13:38:07,376 +0530] - Total files found according to the includes/excludes pattern: 399
------------------------------------------------------------------------
-------------------- End: Scan Files Matching Includes Pattern ---------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,197 +0530] - Finished analyzing Files
[INFO] [2019-09-30 13:38:12,365 +0530] -
------------------------------------------------------------------------
-------------------- End: Docker Resolver Scan -------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,374 +0530] - Initializing WhiteSource Client
[INFO] [2019-09-30 13:38:12,376 +0530] - Service URL is https://app-eu.whitesourcesoftware.com/agent
[INFO] [2019-09-30 13:38:12,430 +0530] - UpdateType set to OVERRIDE
[INFO] [2019-09-30 13:38:12,433 +0530] -
------------------------------------------------------------------------
-------------------- Start: Check Policies -----------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,433 +0530] - Checking policies
[INFO] [2019-09-30 13:38:19,225 +0530] - Some dependencies violate open source policies, however all were force updated to organization inventory.
[INFO] [2019-09-30 13:38:20,161 +0530] - Check Policies Support Token: 399b1607baf0b46d5ab370883736896d01569830894289
[INFO] [2019-09-30 13:38:20,404 +0530] - Policies report generated successfully
[INFO] [2019-09-30 13:38:20,404 +0530] -
------------------------------------------------------------------------
-------------------- End: Check Policies -------------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:20,404 +0530] - Sending Update
[INFO] [2019-09-30 13:38:20,405 +0530] -
------------------------------------------------------------------------
-------------------- Start: Update Inventory ---------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:21,556 +0530] -
------------------------------------------------------------------------
-------------------- End: Update Inventory -----------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:21,556 +0530] -
[INFO] [2019-09-30 13:38:21,556 +0530] - No new projects found.
[INFO] [2019-09-30 13:38:21,556 +0530] - Updated projects:
[INFO] [2019-09-30 13:38:21,556 +0530] - # registry.abcd/dataconnector V.1.0.0.0 (7afaac1a588a)
[INFO] [2019-09-30 13:38:21,557 +0530] - Project name: registry.abcd/dataconnector V.1.0.0.0 (7afaac1a588a), URL: https://app-eu.whitesourcesoftware.com/Wss/WSS.html#!project;id=295252
[INFO] [2019-09-30 13:38:21,557 +0530] - Support Token: 2c5caed97ddad4fde8b085ee5c83484c71569830900960
[INFO] [2019-09-30 13:38:21,730 +0530] -
------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------- WhiteSource Scan Summary: --------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
======================================================================================================================================================
Scan Origin: Local Docker Images
======================================================================================================================================================
Step                                 Completion Status                              Elapsed                              Comments
======================================================================================================================================================
Fetch Configuration                     COMPLETED                                 00:00:00.079                           --------
Scan Files Matching Includes Pattern    COMPLETED                                 00:00:04.918                   399 source/binary files
   dll                                  COMPLETED                                   --------                     399 source/binary files
Docker Resolver Scan                    COMPLETED                                 00:00:13.080                           --------
   image-tag-sha256                     COMPLETED                                 00:00:13.080                   registry.abcd/dataconnector-V.1.0.0.0-7afaac1a588a
      alpine                            COMPLETED                                   --------                     50 packages
Check Policies                          COMPLETED                                 00:00:07.971                           --------
Update Inventory                        COMPLETED                                 00:00:01.151                   1 updated projects

[Pipeline] { (Send Email)
[Pipeline] emailext
Sending email to:
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

I am expecting the below line in email body via email-ext.
Project name: registry.abcd/dataconnector V.1.0.0.0 (7afaac1a588a), URL: https://app-eu.whitesourcesoftware.com/Wss/WSS.html#!project;id=295252

A: It would be helpful if you post your code portion where you're calling emailext. The below example works for me as expected, where I've got a process that prints hostnames after the string "Hostname" to the build log.
Email Extension Plugin v2.66
    stage('Email the results') {
        emailext attachLog: true,
            attachmentsPattern: '*',
            to: "Me@Somewhere.com",
            subject: "Result: ${currentBuild.currentResult}",
            body: '''
Body
${BUILD_LOG_REGEX, regex="Hostname", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}

'''
    }

Solution for your code, remove the caret ^
stage('Send Email') {
   emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex="Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} Regards, DT ''',
   subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}

Next question on getting rid of everything before "Project name:" - Everything in parenthesis represents "$1", and we'll replace the line with the contents of "$1" using substText="$1"
stage('Send Email') {
   emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex=".*(Project name:.*)", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true, substText="$1"} Regards, DT ''',
   subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}


text:
Q: How to config Apache via command line? I'd like to manage servers/virtual-hosts through an interface programmed in node.js. However, I'm struggling to get/set configurations on Apache.
Executing apachectl -S is the only way I've found to do that, but its response is not friendly to use.
Is there any easier way? Something I do that returns a JSON or Array with the configuration?

redpajama_set_name: RedPajamaStackExchange


text:
Q: timing javascript and src changes? ok so i have this javascript to use the arrow keys to send these javascripts when i press arrowkeys. i have a collaborating script that makes the right('img') command move the image but im trying to change the image as it moves with src changes and delays. Help?
<script type="text/javascript">
document.onkeydown = KeyCheck;
function KeyCheck(event) {

  var spacebar=32
  var KeyID = event.keyCode;
  switch(KeyID) {

      case 39:
        right('img');
        document.getElementById('img').src = 'guyr.png';
        setTimeout("right('img');
        document.getElementById('img').src = 'runr.png';
        setTimeout("right('img');
        document.getElementById('img').src = 'guyr.png';",100);",100);
      break;

   }

}
</script>

A: Changing the src attribute of an image is going to trigger an asynchronous GET request, and may be slow at first before the browser has cached the images. It looks like you are implementing a game of some sort? Instead of changing the src of a single image, I would keep all of the images hidden initially, and toggle the visibility CSS attribute of images you want to show/hide. That way, you can pre-fetch all of the images that you'll need during load time, and simply show/hide elements as the handlers for your onkeydown events.

A: If you want to do some sort of a game or animation, try to read a little about it, how to structure your game loop, animations and etc.
But if you are doing just some sort of test try something like this, is not a beautiful code but the idea of an animation should work:
document.onkeydown = KeyCheck;

function KeyCheck(event) {

    var spacebar = 32;
    var KeyID = event.keyCode;

    switch (KeyID) {

    case 39:

        function guy(fn) {
            right('img');
            document.getElementById('img').src = 'guyr.png';
            setTimeout(function() {
                fn(guy);
            }, 100);
        }
        function run(fn) {
            right('img');
            document.getElementById('img').src = 'runr.png';
            setTimeout(function() {
                fn(run);
            }, 100);
        }

        guy(run);

        break;
    }

}

One function calls another, receiving it by parameter, in order to to continue the animation.


text:
Q: How does Linux generate ssh keys after reboot? I installed CentOS 7, and noticed that I have rsa and ecdsa keys generated. I deleted all of them and rebooted the machine. I got a new pair of rsa and ecdsa keys.
How does Linux generate the keys? When is ssh-keygen called..? I couldn't find the configuration for this...

A: sshd's daemon is started by /etc/init.d/sshd (more precisely from a link located in /etc/rc$x.d ).
upon starting sshd, a check is made over existence of key files. if those file are missing ssh-keygen will be call.


text:
Q: Creating a list of points within each group of Pandas data frame I've got a dataset that is structured as example_df presented below:
example_df = pd.DataFrame({'measurement_id': np.concatenate([[0] * 300, [1] * 300]),
                           'min': np.concatenate([np.repeat(range(0, 30), 10),
                                                  np.repeat(range(0, 30), 10)]),
                           'grp': list(np.repeat(['A', 'B'], 5)) * 60,
                           'grp2': list(np.random.choice([0, 1, 2], 10)) * 60,
                           'obj': np.array(list(range(0, 10)) * 60),
                           'x': np.random.normal(0.0, 10.0, 600),
                           'y': np.random.normal(50.0, 40.0, 600)})

I also have a function that takes a list of groups of points as input and perform some calculations. I'd like to prepare my data and create a list of list of points within grouped data frame.
My current solution is as follows:
def df_to_points(df):
    points = []
    for index, row in df.iterrows():
        points.append(tuple(row))
    return(points)

res = example_df \
    .groupby(['measurement_id', 'min', 'grp']) \
    .apply(lambda x: [df_to_points(g[['x', 'y']]) for _, g in x.groupby('grp2')])

res.head(5)
measurement_id  min  grp
0               0    A      [[(7.435996920897324, 63.64844826366264), (-9....
                1    B      [[(-10.213911323779579, 108.64263032884301), (...
                2    A      [[(6.004534743892181, 38.11898691750269), (12....
                3    B      [[(-11.486905682289555, 68.26172126981378), (-...
                4    A      [[(7.5612638943199295, 28.756743327333556), (-...

where each row of res series looks like this:
[[(7.435996920897324, 63.64844826366264),
  (-9.722976872232584, 11.831678494223155),
  (10.809492206072777, 82.9238481225157),
  (-7.918248246978473, 58.46902598333271)],
 [(6.270634566510545, 59.10653240815831),
  (-5.765185730532471, 22.232739287056663),
  (-13.129531349093371, 85.02932179274353)],
 [(0.6686875099768917, 60.634711491838786),
  (-7.373072676442981, 30.897262347426693),
  (-11.489744246260528, 6.834296232736001)]]

The problem is that my original DataFrame has few millions of rows and it feels like this solution could benefit from some optimisation.
Current runtime of the example is:
%timeit res = example_df \
    .groupby(['measurement_id', 'min', 'grp']) \
    .apply(lambda x: [df_to_points(g[['x', 'y']]) for _, g in x.groupby('grp2')])
289 ms ± 1.36 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

Therefore, my question are:

*

*will replacing list of tuples with numpy multidimensional arrays improve the performance?

*are there any significant bottlenecks that should be avoided in order to increase speed up?

@Edit: An example with various number of objects within groups defined by grp
example_df2 =  pd.DataFrame({'measurement_id': np.concatenate([[0] * 300, [1] * 300]),
                           'min': np.concatenate([np.repeat(range(0, 30), 10),
                                                  np.repeat(range(0, 30), 10)]),
                           'grp': list(np.repeat(['A', 'B', 'C'], [4, 4, 2])) * 60,
                           'grp2': list(np.random.choice([0, 1, 2], 10)) * 60,
                           'obj': np.array(list(range(0, 10)) * 60),
                           'x': np.random.normal(0.0, 10.0, 600),
                           'y': np.random.normal(50.0, 40.0, 600)})

A: You could use .pivot_table() and as aggfunc= simple list:
example_df['combined'] = example_df[['x', 'y']].values.tolist()
example_df = example_df.pivot_table(index=['measurement_id', 'min', 'grp'], columns=['grp2'], values=['combined'], aggfunc=list)
example_df['res'] = example_df.values.tolist()
example_df = example_df.drop(columns=['combined'])

Prints:
                                                                      res
grp2
measurement_id min grp
0              0   A    [[[0.9303000896627107, 42.806752849742715], [-...
               1   B    [[[-18.605643711859955, 117.83261611194004], [...
               2   A    [[[-7.304055455430749, 18.06452177236371], [-1...
...

Benchmark with timeit:
example_df = pd.DataFrame({'measurement_id': np.concatenate([[0] * 300, [1] * 300]),
                           'min': np.concatenate([np.repeat(range(0, 30), 10),
                                                  np.repeat(range(0, 30), 10)]),
                           'grp': list(np.repeat(['A', 'B'], 10)) * 30,
                           'grp2': list(np.random.choice([0, 1, 2], 10)) * 60,
                           'obj': np.array(list(range(0, 10)) * 60),
                           'x': np.random.normal(0.0, 10.0, 600),
                           'y': np.random.normal(50.0, 40.0, 600)})

def get_df():
    return example_df.copy()

def solution_1():
    def df_to_points(df):
        points = []
        for index, row in df.iterrows():
            points.append(tuple(row))
        return(points)

    example_df = get_df()
    res = example_df \
        .groupby(['measurement_id', 'min', 'grp']) \
        .apply(lambda x: [df_to_points(g[['x', 'y']]) for _, g in x.groupby('grp2')])
    return res

def solution_2():
    example_df = get_df()
    example_df['combined'] = example_df[['x', 'y']].values.tolist()
    example_df = example_df.pivot_table(index=['measurement_id', 'min', 'grp'], columns=['grp2'], values=['combined'], aggfunc=list)
    example_df['res'] = example_df.values.tolist()
    example_df = example_df.drop(columns=['combined'])
    return example_df

t1 = timeit(lambda: solution_1(), number=100)
t2 = timeit(lambda: solution_2(), number=100)

print(t1)
print(t2)

Prints:
21.74300919502275
3.124330924008973

EDIT: With updated question, you can do this:
example_df['combined'] = example_df[['x', 'y']].values.tolist()
example_df = example_df.pivot_table(index=['measurement_id', 'min', 'grp'], columns=['grp2'], values=['combined'], aggfunc=list)
example_df.apply(lambda x: list(x[x.notna()]), axis=1)

Benchmark with:
from timeit import timeit

example_df = pd.DataFrame({'measurement_id': np.concatenate([[0] * 300, [1] * 300]),
                           'min': np.concatenate([np.repeat(range(0, 30), 10),
                                                  np.repeat(range(0, 30), 10)]),
                           'grp': list(np.repeat(['A', 'B'], 5)) * 60,
                           'grp2': list(np.random.choice([0, 1, 2], 10)) * 60,
                           'obj': np.array(list(range(0, 10)) * 60),
                           'x': np.random.normal(0.0, 10.0, 600),
                           'y': np.random.normal(50.0, 40.0, 600)})

example_df =  pd.DataFrame({'measurement_id': np.concatenate([[0] * 300, [1] * 300]),
                           'min': np.concatenate([np.repeat(range(0, 30), 10),
                                                  np.repeat(range(0, 30), 10)]),
                           'grp': list(np.repeat(['A', 'B', 'C'], [4, 4, 2])) * 60,
                           'grp2': list(np.random.choice([0, 1, 2], 10)) * 60,
                           'obj': np.array(list(range(0, 10)) * 60),
                           'x': np.random.normal(0.0, 10.0, 600),
                           'y': np.random.normal(50.0, 40.0, 600)})

def get_df():
    return example_df.copy()

def solution_1():
    def df_to_points(df):
        points = []
        for index, row in df.iterrows():
            points.append(tuple(row))
        return(points)

    example_df = get_df()
    res = example_df \
        .groupby(['measurement_id', 'min', 'grp']) \
        .apply(lambda x: [df_to_points(g[['x', 'y']]) for _, g in x.groupby('grp2')])
    return res

def solution_2():
    example_df = get_df()
    example_df['combined'] = example_df[['x', 'y']].values.tolist()
    example_df = example_df.pivot_table(index=['measurement_id', 'min', 'grp'], columns=['grp2'], values=['combined'], aggfunc=list)
    return example_df.apply(lambda x: list(x[x.notna()]), axis=1)

t1 = timeit(lambda: solution_1(), number=100)
t2 = timeit(lambda: solution_2(), number=100)

print(t1)
print(t2)

Prints:
45.391786905995104
13.506823723029811

A: You can convert the whole dataframe to a numpy array before iterate it with just array = np.array(df). It will sure improve the performance.
You can also use the multi thread module to parallel process and gain performance as well.
You can also use the pandas  .apply() instead of using .iterrows()

A: One slight optimisation would be:
def df_to_points(df):
    return [tuple(x) for x in df.values]

Then you get
In [59]: %timeit res = example_df \
    ...:     .groupby(['measurement_id', 'min', 'grp']) \
    ...:     .apply(lambda x: [df_to_points(g[['x', 'y']]) for _, g in x.groupby('grp2')])
241 ms ± 14.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

as opposed to (with the original definition of df_to_points)
In [58]: %timeit res = example_df \
    ...:     .groupby(['measurement_id', 'min', 'grp']) \
    ...:     .apply(lambda x: [df_to_points(g[['x', 'y']]) for _, g in x.groupby('grp2')])
284 ms ± 10.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)


text:
Q: Laravel 6 config mail dynamic problem at job using ShouldQueue I have a listener which implement ShouldQueue, the listener is handling a mail sending when event occurs. The job detects which type of user gets the email and config the mail sender name :
$displayName = $user->is_type() == 1 ? 'sender_name1' : 'sender_name2';

config(['mail.from' =>
                    [
                        'name' =>  $displayName
                    ]]);

On multiple actions the sender name is sent incorrectly even though the config occurs.
By printing getmypid() looks like the job runs on a process that already took care of
an older job and the sender name that used was of the older one.
Any suggestions for a solution please?


text:
Q: uninitialized constant Uglifier after deployment I get following error in production.log:
ActionView::Template::Error (uninitialized constant Uglifier
I deploy with asset pipeline enabled and everything works on another server (same configuration, same environment)

A: Ok, I was using custom capistrano tasks to compile assets only if really needed (similar to that one)
That error shows that assets were not compiled (because it was skipped by the custom task). Solution is to compile assets manually for the first time (like bundle exec rake assets:precompile)


text:
Q: Hardware solutions for enabling 150MB/Second constant speed file writes? I am working on a java application and we are IO constrained with our current disc setup.  The performance of the removable RDX discs degrades as they fill until the data write speed < data input speed and data starts having to be discarded.
Just wondering what architecture you would use if you want to be able to process and write data at speeds ~ 150 MB/Second?

A: Any SSD would do this. You could also use a RAID set of HDD which would also give you greater capacity. (You would need at least 3-5 to get 150 MB/s depending on your exact hardware)
I suggest you use an SSD to spool the data to it first and then move the data to your RDX as quickly as possible or at least before your SSD fills up.  This would allow you to continue writing data when the removal-able drive is not in place.
In Jun 2018, an 500 GB SSD costs about £110. This would give you about 50 mins of buffer @150 MB/s sustained.


text:
Q: QRegExp. grab all links I write regular expression to grab all ref links from html
QRegExp bodylinksrx("(<a\\s+href\\s*=\\s*[^<>]*\\s*>[^<>]*)");
QStringList bodylinks;
pos = 0;
while ((pos = bodylinksrx.indexIn(htmlcode, pos)) != -1)
{
    bodylinks << bodylinksrx.cap(1);
    pos += bodylinksrx.matchedLength();
}

I recieve list as result:
("href text...", "href text...", ......")

But I need receive list with only "http://somehref" "href text..." "http://somehref" "href text..." ....

A: First off have you read this? secondly if you're sure you know what you're doing and definitely know you want to do it try using lookahead and lookbehind assertions for your anchor tags.
((?<=<a\\s+href\\s*=\\s*[^<>]*\\s*>)[^<>]*(?=))

EDIT: unfortunately this will not work (at least with qt4.8) as lookbehind assertions are not supported.  You could just iterate through the list created and match the desired bit with:
[^<>]*(?=<)

and use that, alternatively use the captured texts function to extract the part you want which you will surround with brackets like so:
<a\\s+href\\s*=\\s*[^<>]*\\s*>([^<>]*)


text:
Q: La pila de fragments no retrocede de uno en uno, se cierran todos los fragments a la vez He creado un proyecto de prueba con la plantilla "Navigation Drawer Activity".
Al seleccionar alguna de las opciones que hay por defecto, se abre su respectivo fragment que indica su contenido (home, gallery, slider...)
Lo que trato de hacer es añadir subcategorías a una categoría concreta. Por ejemplo, quisiera añadir subcategorías a Gallery y de esta forma navegar de gallery a gallery2 y de gallery2 a gallery3.
Navegar "hacia adelante" lo hace correctamente, el problema surge al retroceder.
Al pulsar el botón de retroceder, en vez de pasar de gallery3 a gallery2 y luego a gallery1, salta directamente a home (ni siquiera a gallery).
Utilizo el código siguiente y he probado con "add" y "replace" en la transacción sin ningún resultado:
public class GalleryFragment extends Fragment{

    private GalleryViewModel galleryViewModel;
    private ImageView boton_cambio;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        galleryViewModel = new ViewModelProvider(this).get(GalleryViewModel.class);

        View root = inflater.inflate(R.layout.fragment_gallery, container, false);

        boton_cambio = root.findViewById(R.id.button);
        boton_cambio.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Fragment galleryFragment_2 = new GalleryFragment2();
                FragmentManager fragManager = getActivity().getSupportFragmentManager();
                FragmentTransaction fragTransacion = fragManager.beginTransaction();
                fragTransacion.replace(R.id.nav_host_fragment, galleryFragment_2);
                fragTransacion.addToBackStack(null);
                fragTransacion.commit();
            }
        });

        return root;
    }

}

Para pasar de Gallery2 a Gallery3, el código es el siguiente:
public class GalleryFragment2 extends Fragment{

    private GalleryViewModel galleryViewModel;
    private ImageView boton_cambio;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        galleryViewModel = new ViewModelProvider(this).get(GalleryViewModel.class);

        View root = inflater.inflate(R.layout.fragment_gallery2, container, false);

        boton_cambio = root.findViewById(R.id.button2);
        boton_cambio.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Fragment galleryFragment_3 = new GalleryFragment3();
                FragmentManager fragManager = getActivity().getSupportFragmentManager();
                FragmentTransaction fragTransacion = fragManager.beginTransaction();
                fragTransacion.replace(R.id.nav_host_fragment, galleryFragment_3);
                fragTransacion.addToBackStack(null);
                fragTransacion.commit();
            }
        });

        return root;
    }

}

En MainActivity he sobre escrito el método onBackPressed() con lo siguiente:
@Override
public void onBackPressed() {
    if (getFragmentManager().getBackStackEntryCount() == 0) {
        super.onBackPressed();
    } else {
        getFragmentManager().popBackStack();
    }
}

Al código anterior le puse un "Toast" para ver que condición se cumplía y siempre entra en el "if", nunca en el "else"
No acabo de ver si es que me estoy dejando algo o tengo un error de concepto.
El código expuesto lo he realizado después de consultar stack, backstack tanto en SO en español como en inglés, pero la mayoría de las respuestas tienen 2 o 3 años y no sé si eso puede afectar.
Entre otros he consultado lo siguiente sin éxito:
FragmentTransaction se lleva contenido del fragment anterior
Aplicar onBackPressed en un fragment
https://developer.android.com/guide/components/activities/tasks-and-back-stack
https://developer.android.com/reference/android/app/FragmentTransaction (obsoleto en API 28)
https://developer.android.com/reference/android/app/FragmentManager.FragmentLifecycleCallbacks (obsoleto en API 28)

A: Para crear un fragment hazlo de dicha manera te paso captura.

Beras que se te creara tanto el archivo java como el layout, entonces en el mainactivity el primero se carga de esta manera.
getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, Home.newInstance(), Home.FragmentHome).commit();

Esto lo que hace es cargar dicho fragmento pero siempre lo tienes en memoria. La función de NewInstance solamente entra la priemra vez cuando tiene que crear el fragmento no hagas cada vez que haces click cargar el fragmento porque te quedaras sin memoria en el dispositivo.
Para hacer que al tirar atras funcione correctamente lo que tienes que hacer es lo siguiente:
@Override
public void onBackPressed() {
    FragmentManager fm = getSupportFragmentManager();
    for(final Fragment frag : fm.getFragments()){
        if(frag.getTag() != null) {
            switch (frag.getTag()) {
            }
        }
     }
}

Yo lo hago de esta manera cada fragment le pongo un Tag cuando los cargo en el fragmentmanager les digo que tag es cada uno de esta manera al tirar hacia atras cargo Fragmentmanager y con la funcion de getFragments() me dice todos los fragmentos que tengo en memoria si esta el que estoi buscando que me lo cargue de nuevo o que tire hacia atras haciendo " super.onBackPressed(); "


text:
Q: Simple method to bypass ssl certificate checking in groovy def connection = new URL( 'someURL.com')
    .openConnection() as HttpURLConnection
    connection.setRequestProperty( 'Accept', 'application/json' )

    // get the response code - automatically sends the request
    println connection.responseCode + ": " + connection.inputStream.text

I used this simple method to make REST call and I get the below error:
    Caught: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at Example.findUserInUsamPGroup(findUserInUsamPGroup.groovy:33)
    at Example.main(findUserInUsamPGroup.groovy:3)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    ... 2 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    ... 2 more

Could you suggest an easy way to bypass SSL certificate verification without having to use httpBuilder like this
Thanks for the help.


text:
Q: Getting the coordinates of elements in clusters without a loop in numpy I have a 2D array, where I label clusters using the ndimage.label() function like this:
import numpy as np
from scipy.ndimage import label

input_array = np.array([[0, 1, 1, 0],
                        [1, 1, 0, 0],
                        [0, 0, 0, 1],
                        [0, 0, 0, 1]])

labeled_array, _ = label(input_array)

# Result:
# labeled_array == [[0, 1, 1, 0],
#                   [1, 1, 0, 0],
#                   [0, 0, 0, 2],
#                   [0, 0, 0, 2]]

I can get the element counts, the centroids or the bounding box of the labeled clusters. But I would like to also get the coordinates of each element in clusters. Something like this (the data structure doesn't have to be like this, any data structure is okay):
{
    1: [(0, 1), (0, 2), (1, 0), (1, 1)],  # Coordinates of the elements that have the label "1"
    2: [(2, 3), (3, 3)]  # Coordinates of the elements that have the label "2"
}

I can loop over the label list and call np.where() for each one of them but I wonder if there is a way to do this without a loop, so that it would be faster?

A: You can make a map of the coordinates, sort and split it:
# Get the indexes (coordinates) of the labeled (non-zero) elements
ind = np.argwhere(labeled_array)

# Get the labels corresponding to those indexes above
labels = labeled_array[tuple(ind.T)]

# Sort both arrays so that lower label numbers appear before higher label numbers. This is not for cosmetic reasons,
# but we will use sorted nature of these label indexes when we use the "diff" method in the next step.
sort = labels.argsort()
ind = ind[sort]
labels = labels[sort]

# Find the split points where a new label number starts in the ordered label numbers
splits = np.flatnonzero(np.diff(labels)) + 1

# Create a data structure out of the label numbers and indexes (coordinates).
# The first argument to the zip is: we take the 0th label number and the label numbers at the split points
# The second argument is the indexes (coordinates), split at split points
# so the length of both arguments to the zip function is the same
result = {k: v for k, v in zip(labels[np.r_[0, splits]],
                               np.split(ind, splits))}

A: Method 1:
You can try this, still looping using dictionary comprehension:
{k: list(zip(*np.where(labeled_array == k))) for k in range(1,3)}

Output:
{1: [(0, 1), (0, 2), (1, 0), (1, 1)], 2: [(2, 3), (3, 3)]}

Method 2 (slow):
Here's a way using pandas probably slower that Mad Physicist's method:
(pd.DataFrame(labeled_array)
  .stack()
  .reset_index()
  .groupby(0).agg(list)[1:]
  .apply(lambda x: list(zip(*x)), axis=1)
).to_dict()

Output:
{1: [(0, 1), (0, 2), (1, 0), (1, 1)], 2: [(2, 3), (3, 3)]}

Timings with this data:
Dictionary comprehension

8.73 µs ± 216 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

Using map coordinates, sort and split:

57.3 µs ± 5.55 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)

pandas

5.16 ms ± 283 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)


text:
Q: ruby on rails using the paypal gem don' return the payer id I want to user the paypal gem for ruby on rails to do the paying stuff with.
Most of the suff works fine, but I don't get the payer ID, for the last step the payment.execute() I need the payerID
my code looks like this:
##################################################################################
# Build Payment object
@payment = Payment.new({
   :intent => "sale",
   :payer => {
     :payment_method => "paypal"
   },
   :redirect_urls => {
       :return_url => url_for(:controller=>:movies,:action=>:play,:id=>@movie.id),
       :cancel_url => url_for(:controller=>:movies,:action=>:play,:id=>@movie.id)},
   :transactions => [{
     :item_list => {
         :items => [{
            :name => @movie.movietitle,
            :sku => "item",
            :price => @movie.movieprice,
            :currency => "USD",
            :quantity => 1 }]},
     :amount => {
         :total => @movie.movieprice,
         :currency => "USD" },
     :description => "This is the payment transaction description." }]})

   # Create Payment and return the status(true or false)
    if @payment.create
      @payment.id     # Payment Id
      redirect_to @payment.links[1].href
    else
     @payment.error  # Error Hash
    end

how can I get the payerID?
Thanks


text:
Q: Xamarin Forms, Error:java.lang.UnsupportedClassVersionError I am having this issue with Xamarin Forms, when trying to run the application, please share your knowledge so that i can fix this issue.
Thanks in advance.

Severity  Code    Description Project File    Line    Suppression State
  Error     java.lang.UnsupportedClassVersionError:
  com/android/dx/command/Main  :  Unsupported major.minor version
  52.0  App.Droid


text:
Q: Increase height of TextView on runtime I have a TextView and I want to increase its height on runtime.
I have used android:layout_height="wrap_content" but it did not gave me the desired result.
I'm using a Relative Layout.
i get text through edittext and i want to set it on textview.
when i do this it shows only one line, and when i click on edittext it get expanded and full message is shown.

A:
Add in Oncreate method of your
  Activity class,
((TextView)
  findViewById(R.id.YOURTEXTVIEWIDHERE)).setHeight(IntegerValuePixels);

A: hard to tell without more details - but do you really need to change it on runtime? because obviously you're not happy with the height at startup.
have you thought about using android:layout_height="fill_parent", eventually in combination with the android:minHeight attribute of other components?


text:
Q: Read Directory of Timeseries CSV data efficiently with Dask DataFrame and Pandas I have a directory of timeseries data stored as CSV files, one file per day.  How do I load and process it efficiently with Dask DataFrame?
Disclaimer: I maintain Dask.  This question occurs often enough in other channels that I decided to add a question here on StackOverflow to which I can point people in the future.

A: Simple Solution
If you just want to get something quickly then simple use of dask.dataframe.read_csv using a globstring for the path should suffice:
import dask.dataframe as dd
df = dd.read_csv('2000-*.csv')

Keyword arguments
The dask.dataframe.read_csv function supports most of the pandas.read_csv keyword arguments, so you might want to tweak things a bit.
df = dd.read_csv('2000-*.csv', parse_dates=['timestamp'])

Set the index
Many operations like groupbys, joins, index lookup, etc. can be more efficient if the target column is the index.  For example if the timestamp column is made to be the index then you can quickly look up the values for a particular range easily, or you can join efficiently with another dataframe along time.  The savings here can easily be 10x.
The naive way to do this is to use the set_index method
df2 = df.set_index('timestamp')

However if you know that your new index column is sorted then you can make this much faster by passing the sorted=True keyword argument
df2 = df.set_index('timestamp', sorted=True)

Divisions
In the above case we still pass through the data once to find good breakpoints.  However if your data is already nicely segmented (such as one file per day) then you can give these division values to set_index to avoid this initial pass  (which can be costly for a large amount of CSV data.
import pandas as pd
divisions = tuple(pd.date_range(start='2000', end='2001', freq='1D'))
df2 = df.set_index('timestamp', sorted=True, divisions=divisions)

This solution correctly and cheaply sets the timestamp column as the index (allowing for efficient computations in the future).
Convert to another format
CSV is a pervasive and convenient format.  However it is also very slow.  Other formats like Parquet may be of interest to you.  They can easily be 10x to 100x faster.


text:
Q: Mapping styles when converting from Rmd to docx with RStudio and Bookdown I am using RStudio with the bookdown package to convert my dissertation from Rmd to docx. When I build the file, the output docx uses the 'compact' style for any ordered or unordered list, rather than the expected 'Numbered list 1' or 'List bullet 1' etc.
I tried deleting the 'compact' style from the reference.docx but then it defaulted to all lists being 'Normal'.

A: You can use a Lua filter:
local function add_item_style (item_style)
  return function (list)
    for i, item in ipairs(list.content) do
      item = item:map(function (blk)
        return blk.t == 'Plain' and pandoc.Para(blk.content) or blk
      end)
      list.content[i] = {pandoc.Div(item, {['custom-style'] = item_style})}
    end
    return list
  end
end

OrderedList = add_item_style 'List Number'
BulletList = add_item_style 'List Bullet'

Save the above to a file item-style.lua and use it with
---
output:
  word_document:
    pandoc_args:
      - '--lua-filter=item-style.lua'
---


text:
Q: Picture will not change table td I want to add table to my website that will not change height or width when I added a picture. The picture needed to automatic resize to td.
How can I do it?

                    dsfdsfs
sdfdsdsf

A: Use max-width and max-height and set it to size of td or 100%
And I would like to suggest you NOT to write inline styles...

A: you using the % value to the table. So table are using current resolution i mean of the window in which you opened the page. In order to say for the table to stay in same height you need to use pixels for example:
570px; not 100% or 50% of the viewing screen.
so for the fist line i believe you can simple use the pixel value.
for example:

for the image don't forget to add 100% values for example:


text:
Q: iOS encryption AES128/CBC/nopadding why is not working? I have an app that needs to encode some data using AES/CBC/no padding. The app is ported also on android. There the encoding is done like this:
byte[] encodedKey = getKey();
    SecretKeySpec skeySpec = new SecretKeySpec(encodedKey, "AES");
    AlgorithmParameterSpec paramSpec = new IvParameterSpec(initializationVector);

    Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
    cipher.init(Cipher.ENCRYPT_MODE, skeySpec, paramSpec);

    int blockSize = cipher.getBlockSize();
    int diffSize = decrypted.length % blockSize;
    System.out.println("Cipher size: " + blockSize);
    System.out.println("Current size: " + decrypted.length);
    if (diffSize != 0) {
      diffSize = blockSize - diffSize;
      byte[] oldDecrypted = decrypted;
      decrypted = new byte[decrypted.length + diffSize];
      System.arraycopy(oldDecrypted, 0, decrypted, 0, oldDecrypted.length);
      for (int i = 0; i < diffSize; i++) {
        decrypted[i + oldDecrypted.length] = " ".getBytes()[0];
      }
      System.out.println("New size: " + decrypted.length);

    }
    return cipher.doFinal(decrypted);

the initializationVector looks like this:
private byte[] initializationVector = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

on iOS i have something like this for encryption:
- (NSData *)AES128EncryptWithKey:(NSString *)key
{
    // 'key' should be 16 bytes for AES128, will be null-padded otherwise
    char keyPtr[kCCKeySizeAES128+1]; // room for terminator (unused)
    bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)

    // fetch key data
    [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];

    NSUInteger dataLength = [self length];

    //See the doc: For block ciphers, the output size will always be less than or
    //equal to the input size plus the size of one block.
    //That's why we need to add the size of one block here
    size_t bufferSize = dataLength + kCCBlockSizeAES128;
    void *buffer = malloc(bufferSize);

    size_t numBytesEncrypted = 0;
    CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
                                          kCCAlgorithmAES128,
                                          0x0000,
                                          keyPtr,
                                          kCCKeySizeAES128,
                                          NULL /* initialization vector (optional) */,
                                          [self bytes], dataLength, /* input */
                                          buffer, bufferSize, /* output */
                                          &numBytesEncrypted);
    if (cryptStatus == kCCSuccess) {
        //the returned NSData takes ownership of the buffer and will free it on deallocation
        return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
    }

    free(buffer); //free the buffer;
    return nil;
}

the method described above is part of a category over NSData.
the method is called like this:
NSData *data = [@"4915200456727" dataUsingEncoding:NSUTF8StringEncoding];
    NSData *cipher  = [data AES128EncryptWithKey:@"@x#zddXekZerBBw6"];
    NSString *ecriptedString = [NSString stringWithFormat:@"%.*s", [cipher length], [cipher bytes]];

the problem that i have is that i don't receive the same encrypted data on iOS and android. On iOS the encrypted data has 0 bytes in length.
Could you give any pointers on how to encrypt a string using AES128 with CBC and no padding and perhaps an example?
Thank you

A: I found the solution to my problem. In order to make the encryption work without padding i had to add 0x0000 instead of kCCOptionPKCS7Padding or kCCOptionECBMode which are treated.
Also if the data that needs to be encoded doesn't have a length multiple of kCCKeySizeAES128 ( 16 ) then the vector that holds the data must be resized to have the length multiple with kCCKeySizeAES128 and the empty values filled with something. I added spaces.
    - (NSData *)AES128EncryptWithKey:(NSString *)key
{
    char keyPtr[kCCKeySizeAES128+1];
    bzero(keyPtr, sizeof(keyPtr));

    [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];

    int dataLength = [self length];
    int diff = kCCKeySizeAES128 - (dataLength % kCCKeySizeAES128);
    int newSize = 0;

    if(diff > 0)
    {
        newSize = dataLength + diff;
    }

    char dataPtr[newSize];
    memcpy(dataPtr, [self bytes], [self length]);
    for(int i = 0; i < diff; i++)
    {
        dataPtr[i + dataLength] = 0x20;
    }

    size_t bufferSize = newSize + kCCBlockSizeAES128;
    void *buffer = malloc(bufferSize);

    size_t numBytesEncrypted = 0;
    CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
                                          kCCAlgorithmAES128,
                                          0x0000, //No padding
                                          keyPtr,
                                          kCCKeySizeAES128,
                                          NULL,
                                          dataPtr,
                                          sizeof(dataPtr),
                                          buffer,
                                          bufferSize,
                                          &numBytesEncrypted);

    if(cryptStatus == kCCSuccess)
    {
        return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
    }

    return nil;
}


text:
Q: Automatically input a response (bash/php) I put up a Jitsi Server. I just created a web interface for user management based on prosody.
So, I want to change a user password via HTML form.
So I created the following PHP code:
<?php

if(isset($_POST['reset'])) {
$username=$_POST['resetname'];
$password=$_POST['resetpw'];
$password2=$_POST['resetpw2'];

if($password == $password2){
$param1= escapeshellarg($username);
$param2= escapeshellarg($password);
$param3= escapeshellarg($password2);

$reset = system("echo prosodyctl passwd $param1@$Website '<<!'\n $param2\n $param3\n ! >> /var/www/content/exe/reset.sh");
[...]

The prosodyctl command need su rights, so I pipe this command + input in a new file and execute this script with cron after a few minutes.
But when I wrote \n in the commandline, it went blank.
Prosody syntax for this command:
prosodyctl passwd user@host
(Asking for a new password)
(Retype new password)

Do you know why it won't work with \n in PHP? Did I make a mistake somewhere?
Thanks


text:
Q: How to draw border arround arrow? I want to draw border around entire arrow and the problem is on the right side cause it draws around square.
The reason is the right triangle is transparent and it sees it like that. Without that arrows won't be seen if they are colored the same.
Any ideas how to do that?
Here is jsfiddle
HTML

.firstArrow {
  position: relative;
  background: red;
  text-align: center;
  margin-right: 10px;
  margin-left: 0px;
  height: 50px;
  width: 330px;
  float: left;
  z-index: 3;
  padding-left: 50px;
  padding-top: 7px;
}

.firstArrow:before {
  content: '';
  position: absolute;
  width: 20px;
  height: 50%;
  left: 100%;
  top: 0;
  background: linear-gradient(to right top,red 50%,transparent 50%);
}

.firstArrow:after {
  content: '';
  position: absolute;
  width: 20px;
  height: 50%;
  left: 100%;
  bottom: 0;
  background: linear-gradient(to right bottom,red 50%,transparent 50%);
}

.secondArrow {
  position: relative;
  background: blue;
  margin-right: 10px;
  padding-left: 50px;
  padding-top: 7px;
  left: -20px;
  float: left;
  z-index: 2;
  height: 50px;
  width: 330px;

}
.secondArrow:before {
  content: '';
  position: absolute;
  width: 20px;
  height: 50%;
  left: 100%;
  text-align: center;
  top: 0;
  background: linear-gradient(to right top,blue 50%,transparent 50%);
}

.secondArrow:after {
  content: '';
  position: absolute;
  width: 20px;
  height: 50%;
  left: 100%;
  bottom: 0;
  background: linear-gradient(to right bottom,blue 50%,transparent 50%);
}
.thirdArrow {
  position: relative;
  background: green;
  text-align: center;
  padding-top: 7px;
  height: 50px;
  width: 330px;
  left: -40px;
  float: left;
  z-index: 1;
}

.thirdArrow:after {
  content: '';
  position: absolute;
  width: 20px;
  height: 50%;
  left: 100%;
  bottom: 0;
  background: linear-gradient( to right bottom, green 50%,transparent 50%);
}
.thirdArrow:before {
  content: '';
  position: absolute;
  width: 20px;
  height: 50%;
  left: 100%;
  top: 0;
  background: linear-gradient( to right top, green 50%, transparent 50%);
}

 1

 2

 3

A: You can do the shape differently using skew transformation:

.arrow {
  position: relative;
  text-align: center;
  padding: 20px 0;
  width: 100px;
  float: left;
  color: #fff;
  z-index: 0;
}

.arrow:before,
.arrow:after {
  content: "";
  position: absolute;
  box-sizing: border-box;
  z-index: -1;
  top: 0;
  height: 50%;
  left: -3px;
  right: 0;
  transform: skewX(45deg);
  transform-origin: bottom;
  background: var(--c, red);
  border: 3px solid #000;
  border-bottom: 0;
}

.arrow:after {
  transform: scaleY(-1) skewX(45deg);
}

.arrow:first-child {
  overflow: hidden;
  border-left: 3px solid #000;
}

 1

 2

 3

A:

* {
  margin: 0;
  padding: 0;
}

.wrapper {
  position: relative;
  width: 30%;
}

.firstArrow {
  background: red;
}

.secondArrow {
  background: blue;
}

.thirdArrow {
  background: green;
}

.firstArrow, .secondArrow, .thirdArrow {
  margin-bottom: 20px;
  padding: 20px;
  text-align: center;
}

.firstArrow::before, .secondArrow::before, .thirdArrow::before {
    content: '';
    position: absolute;
    width: 41px;
    height: 41px;
    background: red;
    right: -21px;
    top: 9px;
    transform: rotate(45deg);
    box-sizing: border-box;
}

.secondArrow::before {
  background: blue;
}

.thirdArrow::before {
  background: green;
}

.firstArrow::after, .secondArrow::after, .thirdArrow::after {
  content: '';
  position: absolute;
  width: 49px;
  height: 49px;
  right: -26px;
  border: 1px solid;
  transform: rotate(45deg);
  box-sizing: border-box;
  top: 5px;
}

.firstArrow::after {
  border-color: red;
}

.secondArrow::after {
  border-color: blue;
}

.thirdArrow::after {
  border-color: green;
}

.blue-border::before, .red-border::before, .green-border::before {
    content: '';
    position: absolute;
    border: 1px solid red;
    transform: rotate(0);
    width: 100%;
    height: 68px;
    left: 0;
    top: -5px;
    background: transparent;
}

.blue-border::before {
  border: 1px solid blue;
}

.green-border::before {
  border: 1px solid green;
}
<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>

 1

 2

 3

Check if you wanted something like this!

A: Please check the below sample. Hope it will meet your requirements.The right side arrow head and its border are created using pseudo elements ::before and ::after

.firstArrow {
    position: relative;
    background: #eee;
    height: 50px;
    width: 150px;
    float: left;
    text-align: center;
    line-height: 50px;
    border: solid 3px #999;
}
.firstArrow:after,
.firstArrow:before {
    content: '';
    position: absolute;

}
.firstArrow:before {
    top: 0;
    right: -50px;
    z-index: 2;
    border: 25px solid;
    border-color: transparent transparent transparent #eee;
}
.firstArrow:after{
    top: -3px;
    right: -58px;
    z-index: 1;
    border: 28px solid;
    border-color: transparent transparent transparent #999;
}

shape 1

shape 2

shape 3


text:
Q: Limit of resonant converters I am currently trying to design a converter with GaN technology. The converter needs to regulate a wide range of current and consequently the power goes from ~1kW to ~10kW.
I took a look on Texas Instrument and Infineon and it appaers that all their design examples with GaN technology are resonant converter (if I exclud PFC converter).

It is the same on Infineon.
I know that GaN technology allows to reduce parasitic effect due to reverse recovery effect. So I was thinking at the beginning that resonant converter would be the future and I could say goodbye to hard switching converter...
I do not know resonants converters but it seems that they are not appropriate for wide output range and their transient response is not as good as hard switching converter. And the analysis of their regulation is quit complicated, so finally I think that TI and Infineon have just designed resonant converter with GaN for showing that GaN allows high power density. It would be interesting if they could compare the power density with a resonant converter with MOSFET at the same power... As resonant converter has already a better power density than hard switching converter.
Generally, when I read an app note on resonant converter, the app note says all the pros over hard switching converter but it doesn't say the cons...
So what are the cons of resonant converter with respect to hard switching converter ? Other than better efficiency ... Is this possible to do a regulation of wide range of current with a resonant converter ?

A: As with most things when it comes to switching converters, performance under a wide range of loads or even no load is highly dependent on the topology.
Resonant converters are an entire class of topologies, rather than a single topology, so there is only so much that can be generalized about them.
What you describe is true for series resonant converters (SRCs) and parallel resonant converters (PRCs), for somewhat different reasons.  Neither of those converters has a particularly wide useful load regulation range.
However, those topologies are also ancient and obsolete.  Most resonant converters (and controllers) available today use more advanced resonant topologies that combine both forms of resonance into a series parallel resonant converter (SPRC).
The most common SPRC is the LLC converter, though LCC converters also exist.  LLC converters readily achieve good efficiency over a 10% to 100% load range, and can ensure regulation down to no-load conditions, though they do maintain a minimum circulating current which dissipates power in the switches.  This results in relatively high idle power usage, but if your expected range is 1kW to 10kW, this should not be an issue.
LLCs can be designed to provide peak efficiency at full load where it is needed most, with a modest (<5%) reduction in efficiency even at light load (10%) conditions.
It is important to understand that the controller you select can often overcome the limitations of a given topology.  While a basic LLC converter would be well suited to your load range, there is no reason you have to accept high standby power or that light load efficiency reduction.
Even modestly more advanced controllers will use some variation of burst mode, pulse skipping, or PWM+PFM control to achieve very good no load and light load performance by simply switching off the LLC as needed (while keeping the output in regulation of course), or simply transitioning to a more traditional, hard switched PWM control method when the load is low enough that hard switching becomes more efficient.
As for transient response, this is not so much determined by the topology per se (though it plays a heavy part) but rather the controller you are using and the control method it employs.  Topology does dictate the available control methods, but there is nothing inherent to resonant converters, particularly LLC converters, that limits their transient response performance.
Many LLC converters use direct frequency control (DFC), and this does indeed have relatively poor transient response.  A 90% load step can take 1-5 milliseconds to get back into regulation.
However, there are other control methods, like hybrid hysteretic control (HHC) which can achieve very good transient response performance in the range of 100-200µs to get back into regulation for a 90% load step.
There are controllers available with both excellent no load to light load efficiency as well as HHC control.  I believe TI has an active patent on HHC, so they may be the only vendor, but this is also far from an exhaustive list of 'dirty tricks'.
Every topology has a wide variety controllers available, and they can typically work around many of a topology's limitations to greater or lesser degrees.
Regardless, at such high power levels, using a resonant mode topology is the best option.  You get excellent efficiency, so now you can start looking at controllers (or control schemes if you plan on doing the control yourself) and see what your options are.  Those options will almost always have dirty tricks up their sleeves to mitigate or even eliminate topology limitations.
I always advise people to select a topology very generally and loosely, but try to maintain a controller-centric design process, as the controller selection can have at least as much of an impact on the final performance of a converter as the topology itself does.


text:
Q: How to extend a defined response in OpenAPI? I want to extend the "200SuccessDefault" response with a schema or example.
paths:
  /home:
      ...
      responses:
        200:
          $ref: '#/components/responses/200SuccessDefault'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PieChartElement'
              examples:
                PieChart:
                  $ref: '#/components/examples/PieChart_1'

This approach runs into an error, the schema and examples fields are ignored:

Sibling values alongside $refs are ignored. To add properties to a $ref, wrap the $ref into allOf, or move the extra properties into the referenced definition (if applicable).

I tried allOf:
paths:
  /home:
      responses:
        200:
          allOf:
            - $ref: '#/components/responses/200SuccessDefault'
            - content:
                application/json:
                  schema:
                    type: array
                    items:
                      $ref: '#/components/schemas/PieChartElement'
                  examples:
                    PieChart:
                      $ref: '#/components/examples/PieChart_1'

This approach runs into the error:

should NOT have additional properties additionalProperty: allOf
should have required property 'description' missingProperty: description

A: You cannot extend a referenced response object. But, you can use a shared schema object and extend it utilizing allOf within schema.
Inside allOf you can put:

*

*your $ref

*a new type extending your default response
If you want to give an example of an entire extended response (JSON), just put it into "application/json".
An example of OpenAPI would be:
    "202":
      description: Extended response sample
      content:
        application/json:
          schema:
            allOf:
              - $ref: "#/components/schemas/application"
              - type: object
                properties:
                  anotherProperty:
                    type: string
                    maxLength: 200
                    example: "Property example"
          example: {id: 1234, anotherProperty: "Hello"}


text:
Q: New Intent triggered but not working I have created a AWS LEX BOT. I have used 2 intents. In 1st Intent i have used lambda function which triggered the 2nd Intent. This triggering works but i am getting error from 2nd Intent. Here is the Lambda function for 2nd Intent and the error.
def build_response(message):
    return {
        "dialogAction":{
            "type":"Close",
            "fulfillmentState":"Fulfilled",
            "message":{
                "contentType":"PlainText",
                "content":message
            }
        }
    }

def perform_action(intent_request):
    source = intent_request['invocationSource']
    output_session_attributes = intent_request['sessionAttributes'] if intent_request['sessionAttributes'] is not None else {}

    if source == 'FulfillmentCodeHook':
        # action fulfillment code
        build_response('PhotoTakingKIT is triggered and closed...')

def dispatch(intent_request):
    intent_name = intent_request['currentIntent']['name']
    if intent_name == 'PhotoTakingKIT':
        return perform_action(intent_request)
    raise Exception('Intent with name ' + intent_name + ' not supported')

def lambda_handler(event, context):
    return dispatch(event)

What is the problem, how can i work further with my 2nd Intent.


text:
Q: SQL Server using a local temp table in a stored procedure created in a different stored procedure I have inherited a database that contains a lot of stored procedures that create a local temporary table, calls a procedure that uses the temp table, and then deletes the temp table. Like this:
CREATE PROCEDURE procSelectFromTable
    AS
    BEGIN
        SELECT *
    FROM #myTable
END;
GO

CREATE PROCEDURE procMakeTable
AS
BEGIN
    SELECT 1 AS [ID]
        ,'NestedProcedure' AS [Message]
    INTO #myTable;

    EXEC procSelectFromTable

    DROP TABLE #myTable;
END;
GO

EXEC procMakeTable;
GO

--Clean up
IF OBJECT_ID('tempdb..#myTable') IS NOT NULL
    DROP TABLE #myTable;

DROP PROCEDURE procMakeTable;

DROP PROCEDURE procSelectFromTable

I have not seen procedures written in this manner before. Is it safe for me to assume this is ok because the nested procedure will always be called in the same spid and will always be able to access the temp table?

A: Yes, the nested procedure will have access to the local temp table. This was common use before the introduction of table-valued parameters or when the procedures exist in different databases in the same instance. The procedures are tightly coupled and might be a problem to test the 'child' procedure, but it has the advantage that it can be called from multiple procedures.


text:
Q: Is this a high-pass filter? I am not very sure about how to completely solve this question. I tried to calculate the equivalent impedance by C and R and got R/(1+jwRC). Then I calculated the transmittance by using the voltage divider rule and got G(w) = (1+jwRC)/(2+jwRC). Which shows me that at w=0, g = 1/2 and as w goes to infinity g approaches 1. Am I right? Is this enough for the solution? What about the characteristic frequence and magnitude/phase responses? Which type of filter is it?

A:
Which type of filter is it?

In the field of audio processing and tone controls it's a type of shelving filter: -

Ignore the red line - that is also a shelving filter but working at bass frequencies. Yours is equivalent to a treble shelving filter (blue line). Picture from here.
Of course, it needn't be associated with audio; it can be used in many signal processing applications. I've used one (converted into code) to counter the poor frequency response of a lame anti-alias filter in front of an ADC.

A: It looks like a high pass shelving filter as Andy says.
Whether it is or not depends on the load impedance. If that has a capacitive component it may be a compensated attenuator, such as found in a 10x scope probe.

A: Well, the transfer function of this circuit is given by:
$$\mathscr{H}\left(\text{s}\right):=\frac{\text{v}_\text{out}\left(\text{s}\right)}{\text{v}_\text{in}\left(\text{s}\right)}=1-\frac{1}{2+\text{CRs}}\tag1$$
When working with sinusoidal signals, we can use \$\text{s}:=\text{j}\omega\$:
$$\underline{\mathscr{H}}\left(\text{j}\omega\right)=1-\frac{1}{2+\text{CR}\omega\text{j}}=1-\frac{2-\text{CR}\omega\text{j}}{2^2+\left(\text{CR}\omega\right)^2}=1+\frac{\text{CR}\omega\text{j}-2}{4+\left(\text{CR}\omega\right)^2}\tag2$$
So, the absolute value is given by:
$$\left|\underline{\mathscr{H}}\left(\text{j}\omega\right)\right|=\sqrt{\left(1-\frac{2}{4+\left(\text{CR}\omega\right)^2}\right)^2+\left(\frac{\text{CR}\omega}{4+\left(\text{CR}\omega\right)^2}\right)^2}\tag3$$
And the argument:
$$\arg\left(\underline{\mathscr{H}}\left(\text{j}\omega\right)\right)=\arg\left(1+\frac{\text{CR}\omega\text{j}-2}{4+\left(\text{CR}\omega\right)^2}\right)=\arg\left(1-\frac{2}{4+\left(\text{CR}\omega\right)^2}+\frac{\text{CR}\omega\text{j}}{4+\left(\text{CR}\omega\right)^2}\right)=$$
$$\begin{cases}
\frac{\pi}{2}\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\text{if}\space1-\frac{2}{4+\left(\text{CR}\omega\right)^2}=0\\
\\
\arctan\left(\frac{\text{CR}\omega}{2+\left(\text{CR}\omega\right)^2}\right)\space\space\space\space\space\space\space\space\space\text{if}\space1-\frac{2}{4+\left(\text{CR}\omega\right)^2}>0
\end{cases}\tag4$$
Now, it is not hard to see that:
$$\lim_{\omega\to0}\left|\underline{\mathscr{H}}\left(\text{j}\omega\right)\right|=\frac{1}{2}\tag5$$
And:
$$\lim_{\omega\to\infty}\left|\underline{\mathscr{H}}\left(\text{j}\omega\right)\right|=\lim_{\omega\to\infty}\sqrt{\left(1-\frac{2}{4+\left(\text{CR}\omega\right)^2}\right)^2+\left(\frac{1}{\frac{4}{\text{CR}\omega}+\text{CR}\omega}\right)^2}=1\tag6$$


text:
Q: Gost Apahche2 Processes Can Not Be Removed I have a 20.04 server installation. Once I installed apache2 http server and switch to nginx..
Before to do that I run the following command to clean uninstall
sudo apt-get remove --purge --autoremove apache2
Apache2 gets removed, everything was removed. But I realized that when I ran ps aux --sort=-%mem. There are still apache2 processes and I don't know how to turn them off.
Is there any way to kill them permanently or am I missing something ?


text:
Q: clone a branch from GIT I want to check out OpenStack Neutron's branch JUNO from the git repository. What is the right URI to do this? If I do
% git clone git://github.com/openstack/neutron/tree/stable/juno/

it says:
openstack/neutron/tree/stable/juno is not a valid repository name

However I do see this branch at https://github.com/openstack/neutron/tree/stable/juno/.
What am I doing wrong? Thanks.

A: You don't clone a branch, you clone an entire project:
$ git clone git://github.com/openstack/neutron
Cloning into 'neutron'...
remote: Counting objects: 105856, done.
remote: Total 105856 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (105856/105856), 44.17 MiB | 1.06 MiB/s, done.
Resolving deltas: 100% (68444/68444), done.

After doing that, you can simply check out the branch you're interested in. E.g.:
$ git checkout -b juno -t origin/stable/juno
Branch juno set up to track remote branch stable/juno from origin.
Switched to a new branch 'juno'


text:
Q: How do I upgrade from Windows 10 1803 to 1809? I'm getting a failure 0x80070003 When attempting to upgrade from Windows 10 1803 to 1809, I get a failure every time. I tried Microsoft support and three reps were unable to assist me. I tried disabling all the startup programs, running the update troubleshooting tool, running Windows 10 update assistant, and downloading / installing from a USB drive. The result is consistently failure with the logs below:
setuperr.log
2019-02-22 19:32:40, Error                 MOUPG  CFCDCATQuery::RetrieveResponse(311): Result = 0x80072EE7[gle=0x00002ee7]
2019-02-22 19:32:40, Error                 MOUPG  CFCDCATQuery::Query(210): Result = 0x80072EE7[gle=0x00002ee7]
2019-02-22 19:32:40, Error                 MOUPG  CFCAcquirerDCAT::QueryWeb(653): Result = 0x80072EE7
2019-02-22 19:32:40, Error                 MOUPG  CFCAcquirerDCAT::Download(878): Result = 0x80072EE7
2019-02-22 19:32:40, Error                 MOUPG  CFCPayloadDU::Download(267): Result = 0x80072EE7
2019-02-22 19:32:40, Error                 MOUPG  DUSetup: Error on downloading SetupDU Payload: [0x80072EE7]
2019-02-22 19:32:40, Error                 MOUPG  CDlpActionDU::ExecuteFacilitatorDUSetup(2159): Result = 0x80072EE7
2019-02-22 19:32:56, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:32:56, Error                 SP     pDUSearchAndDownload: DU search failed. hr = 0x80240438
2019-02-22 19:32:56, Error                 MOUPG  DUSetup: Failed to execute DUSetup seach and download  [0x80240438]
2019-02-22 19:32:56, Error                 CONX   Windows::Compat::Appraiser::IsMeteredConnection (188):   Failed to get NetworkCostType assuming metered network [0x80004005].[gle=0x80004005]
2019-02-22 19:33:36, Error                 CONX   Windows::Compat::Appraiser::Utilities::SendRequest (1363):   Failed to connect to the internet or send request: [12007].[gle=0x80072ee7]
2019-02-22 19:33:36, Error                 CONX   Windows::Compat::Appraiser::Utilities::DownloadCabFile (4292):   Failed to send request using default proxy[gle=0x80072ee7]
2019-02-22 19:34:16, Error                 CONX   Windows::Compat::Appraiser::Utilities::SendRequest (1363):   Failed to connect to the internet or send request: [12007].[gle=0x80072ee7]
2019-02-22 19:34:16, Error                 CONX   Windows::Compat::Appraiser::Utilities::DownloadCabFile (4303):   Failed to send request using auto proxy[gle=0x80072ee7]
2019-02-22 19:34:16, Error                 CONX   Windows::Compat::Appraiser::Utilities::DownloadAndExtractCab (4094):   Failed to download cab file: [0x80072ee7].[gle=0x80072ee7]
2019-02-22 19:34:16, Error                 CONX   Windows::Compat::Appraiser::SetupAppraiser::GetAlternateData (2982):   Error downloading alternate cab http://adl.windows.com/appraiseradl/2019_01_31_04_51_x64.cab: [0x80072ee7].[gle=0x80072ee7]
2019-02-22 19:34:16, Error                 CONX   Windows::Compat::Appraiser::SetupAppraiser::InitializeRunOptions (757):   Error checking for latest SDB, swallowing: [0x80072ee7].[gle=0x80072ee7]
2019-02-22 19:37:18, Error                 MOUPG  CFCDCATQuery::RetrieveResponse(311): Result = 0x80072EE7[gle=0x00002ee7]
2019-02-22 19:37:18, Error                 MOUPG  CFCDCATQuery::Query(210): Result = 0x80072EE7[gle=0x00002ee7]
2019-02-22 19:37:18, Error                 MOUPG  CFCAcquirerDCAT::QueryWeb(653): Result = 0x80072EE7
2019-02-22 19:37:18, Error                 MOUPG  CFCAcquirerDCAT::Download(878): Result = 0x80072EE7
2019-02-22 19:37:18, Error                 MOUPG  CFCPayloadDU::Download(267): Result = 0x80072EE7
2019-02-22 19:37:18, Error                 MOUPG  DUImage: Error on downloading ImageDU Payload: [0x80072EE7]
2019-02-22 19:37:18, Error                 MOUPG  CDlpActionDU::ExecuteFacilitatorDUImage(1465): Result = 0x80072EE7
2019-02-22 19:37:18, Error                 CSI    00000001 (F) STATUS_OBJECT_NAME_NOT_FOUND #38# from Windows::Rtl::SystemImplementation::DirectRegistryProvider::SysQueryValueKey(flags = 0, key = a34 ('\REGISTRY\MACHINE\SYSTEM\Setup'), vn = [l:7 ml:8]'Compact', kvic = 2, kvi = 2, disp = 0)[gle=0xd0000034]
2019-02-22 19:37:18, Error                 CSI    00000002 (F) STATUS_OBJECT_NAME_NOT_FOUND #37# from Windows::Rtl::SystemImplementation::CKey::QueryValue(flags = 0, kn = [l:31]'\Registry\Machine\SYSTEM\Setup\', vn = [l:7 ml:8]'Compact', ic = KeyValuePartialInformation, info = {l:0 b:}, disp = 0)[gle=0xd0000034]
2019-02-22 19:37:19, Error                 CSI    00000003 (F) STATUS_OBJECT_NAME_NOT_FOUND #70# from Windows::Rtl::SystemImplementation::DirectRegistryProvider::SysQueryValueKey(flags = 0, key = 9c4 ('\REGISTRY\MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'), vn = [l:21 ml:22]'Arial Nova (TrueType)', kvic = 2, kvi = 2, disp = 0)[gle=0xd0000034]
2019-02-22 19:37:19, Error                 CSI    00000004 (F) STATUS_OBJECT_NAME_NOT_FOUND #69# from Windows::Rtl::SystemImplementation::CKey::QueryValue(flags = 0, kn = [l:69]'\Registry\Machine\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\', vn = [l:21 ml:22]'Arial Nova (TrueType)', ic = KeyValuePartialInformation, info = {l:0 b:}, disp = 0)[gle=0xd0000034]
2019-02-22 19:37:27, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:37:27, Error                 SP     CDownloadDUUpdates::DoExecuteInternal: Failed to search for updates. hr = 0x80240438
2019-02-22 19:37:27, Error                 SP     CSetupPlatform::DownloadDynamicUpdates: Failed to download updates. Error: 0x80240438
2019-02-22 19:37:27, Error                 MOUPG  DUImage: Failed to execute critical search and download [0x80240438]
2019-02-22 19:37:36, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:37:36, Error                 SP     CDownloadDUUpdates::DoExecuteInternal: Failed to search for updates. hr = 0x80240438
2019-02-22 19:37:36, Error                 SP     CSetupPlatform::DownloadDynamicUpdates: Failed to download updates. Error: 0x80240438
2019-02-22 19:37:36, Error                 MOUPG  DUImage: Failed to execute GDR search and download [0x80240438]
2019-02-22 19:37:36, Error                 DU     DU::CDUSession::Search: Failed to set WU internal configuration property for targeted scans. hr = 0x80070057
2019-02-22 19:37:45, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:37:53, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:38:01, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:38:10, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:38:10, Error                 SP     CDownloadDUUpdates::DoExecuteInternal: Failed to search for updates. hr = 0x80240438
2019-02-22 19:38:10, Error                 SP     CSetupPlatform::DownloadDynamicUpdates: Failed to download updates. Error: 0x80240438
2019-02-22 19:38:10, Error                 MOUPG  DUImage: Failed to execute driver search and download [0x80240438]
2019-02-22 19:38:18, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:38:18, Error                 SP     CDownloadDUUpdates::DoExecuteInternal: Failed to search for updates. hr = 0x80240438
2019-02-22 19:38:18, Error                 SP     CSetupPlatform::DownloadDynamicUpdates: Failed to download updates. Error: 0x80240438
2019-02-22 19:38:18, Error                 MOUPG  DUImage: Failed to execute FOD search and download [0x80240438]
2019-02-22 19:38:27, Error                 DU     DU::CDUSession::Search: Failed to end the asynchronus search. hr = 0x80240438
2019-02-22 19:38:27, Error                 SP     CDownloadDUUpdates::DoExecuteInternal: Failed to search for updates. hr = 0x80240438
2019-02-22 19:38:27, Error                 SP     CSetupPlatform::DownloadDynamicUpdates: Failed to download updates. Error: 0x80240438
2019-02-22 19:38:27, Error                 MOUPG  DUImage: Failed to execute LangPack search and download [0x80240438]
2019-02-22 19:38:36, Error                 CONX   0xd0000034 Failed to add user mode driver [%SystemRoot%\system32\DRIVERS\UMDF\uicciso.dll]

2019-02-22 19:41:01, Error                 SP     pSPRemoveUpgradeRegTree: failed to delete reg tree HKLM\SYSTEM\Setup\Upgrade[gle=0x00000005]
2019-02-22 19:41:25, Error                 CSI    00000001 (F) 80220008 [Error,Facility=FACILITY_STATE_MANAGEMENT,Code=8] #95107# from CWcmScalarInstanceCore::GetCurrentValue(options = 393216, status = '(null)', value = { type: 40972, bytes ( 12 ): 65006e002d00550053000000 })
[gle=0x80004005]
2019-02-22 19:41:40, Error                 CSI    00000002 (F) 80220008 [Error,Facility=FACILITY_STATE_MANAGEMENT,Code=8] #177818# from CWcmScalarInstanceCore::GetCurrentValue(options = 393216, status = '(null)', value = { type: 40972, bytes ( 12 ): 65006e002d00550053000000 })
[gle=0x80004005]
2019-02-22 19:41:52, Error      [0x080831] MIG    CSIAgent: Invalid xml format: FormatException: Component with display name: Plugin/{C939EC0F-2F56-4CE8-AF56-2336596A5FA7} already loaded __cdecl Mig::CMXEMigrationXml::CMXEMigrationXml(class Mig::CPlatform *,class UnBCL::String *,class UnBCL::XmlDocument *,class UnBCL::String *,class UnBCL::String *)
2019-02-22 19:43:40, Error                        CSetupAutomation::Resurrect: File not found: C:\$WINDOWS.~BT\Sources\Panther\automation.dat[gle=0x00000002]
2019-02-22 19:43:40, Error                 SP     CSetupPlatform::ResurrectAutomation: Failed to resurrect automation: 0x80070002[gle=0x00000002]
2019-02-22 19:43:40, Error                 SP     CMountWIM::DoExecute: Failed to mount WIM file C:\$WINDOWS.~BT\Sources\SafeOS\winre.wim. Error 0x80070003[gle=0x00000003]
2019-02-22 19:43:40, Error                 SP     Operation failed: Mount WIM file C:\$WINDOWS.~BT\Sources\SafeOS\winre.wim, index 1 to C:\$WINDOWS.~BT\Sources\SafeOS\SafeOS.Mount. Error: 0x80070003[gle=0x000000b7]
2019-02-22 19:43:40, Error                 SP     ExecuteOperations: Failed execution phase Pre-Finalize. Error: 0x80070003
2019-02-22 19:43:40, Error                 MOUPG  MoSetupPlatform: ExecuteCurrentOperations reported failure!
2019-02-22 19:43:40, Error                 MOUPG  MoSetupPlatform: Using action error code: [0x80070003]
2019-02-22 19:43:40, Error                 MOUPG  CDlpActionPreFinalize::ExecuteRoutine(545): Result = 0x80070003
2019-02-22 19:43:41, Error                 MOUPG  CDlpActionImpl<class CDlpErrorImpl<class CDlpObjectInternalImpl<class CUnknownImpl<class IMoSetupDlpAction> > > >::Execute(441): Result = 0x80070003
2019-02-22 19:43:41, Error                 MOUPG  CDlpTask::ExecuteAction(3259): Result = 0x80070003
2019-02-22 19:43:41, Error                 MOUPG  CDlpTask::ExecuteActions(3413): Result = 0x80070003
2019-02-22 19:43:41, Error                 MOUPG  CDlpTask::Execute(1644): Result = 0x80070003
2019-02-22 19:43:41, Error                 MOUPG  CSetupManager::ExecuteTask(2478): Result = 0x80070003
2019-02-22 19:43:41, Error                 MOUPG  CSetupManager::ExecuteTask(2441): Result = 0x80070003
2019-02-22 19:43:41, Error                 MOUPG  CSetupManager::ExecuteInstallMode(883): Result = 0x80070003
2019-02-22 19:43:41, Error                 MOUPG  CSetupManager::ExecuteDownlevelMode(390): Result = 0x80070003
2019-02-22 19:43:41, Error                 SP     CDeploymentBase::CleanupMounts: Unable to unmount the directory C:\$WINDOWS.~BT\Sources\SafeOS\SafeOS.Mount. Error: 0xC142011C[gle=0xc142011c]
2019-02-22 19:43:42, Error                 MOUPG  CSetupManager::Execute(282): Result = 0x80070003
2019-02-22 19:43:42, Error                 MOUPG  CSetupHost::Execute(400): Result = 0x80070003


text:
Q: Salesforce, SOQL, Developer Console, sObject is not supported In Developer Console in SOQL I try to select Product, but that is not possible.
SELECT Id FROM Product

Error:
"sObject type 'Product' is not supported."
image
I found this advice:
"There is a checkbox 'Use tooling API' at the bottom of the screen. Uncheck it if it is checked and try."
from here
But, it didn't help. Any idea?

A: The actual object's name is Product2.

As of API version 8.0, the Product object is no longer available.
Requests that contain Product are refused, and responses don't contain
the Product object.

Here's the Entity Relationship Diagram: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_erd_products.htm
API v8 would be ancient history, 14 years ago ;) https://gs0.salesforce.com/services/data/


text:
Q: how to stub react-redux useReducer hook - using cypress could someone please help me understand how to stub useReducer from react-redux? This code looks like it should work, but it just doesnt (stub never intercepts the useReducer function).
import React from 'react';
import { mount } from '@cypress/react';
import * as ReactReduxModule from 'react-redux';
const { Provider } = ReactReduxModule;

import { Button } from './button';
import { store } from './store';
import * as SomethingModule from './something';

describe('<Button />', () => {
  it('uses stubbed things', () => {
    cy.stub(ReactReduxModule, 'useSelector')
      .as('useSelector')
      .returns({ moo: 'woof' });
    cy.stub(SomethingModule, 'something').as('something').returns('scary!!');

    cy.get('@something').should('not.have.been.called');
    cy.get('@useSelector').should('not.have.been.called');

    mount(
      <Provider store={store}>
        <Button />
      </Provider>,
    );
    // cy.contains('moo: woof scary').should('exist');
    cy.get('@something').should('have.been.called'); // passes
    cy.get('@useSelector').should('have.been.called'); // fails! :(
  });
});

the "something" stub does indeed trigger and intercept the import, but the useSelector stub does not. :(
help
the component in question is SUPER simple too:
import React from 'react';
import { useSelector } from 'react-redux';

import { something } from './something';
import { StoreState } from './store';

export const Button = ({}) => {
  const { moo } = useSelector((store: StoreState) => {
    return { moo: store.moo };
  });
  return (
    <button>
      moo: {moo} {something()}
    </button>
  );
};

A: Incase anyone else ever ends up in this thread, I eventually managed to do all this (with the help of a plugin and some babel config changes).
I just added this little plugin into my babel build: https://github.com/asapach/babel-plugin-rewire-exports which allows you to rewire most* imports contained inside a module file (presuming ur working inside an esmodule codebase).
I've got some demo code here: https://github.com/glomotion/stripped-down-next-rewire-ts/blob/tryout/rewire-exports/src/components/Moo/Moo.cy.test.jsx
* note: To mock npm components is a little trickier, unless the component in question is an esmodule, in which case you configure babel to parse it, and ur good to go!


text:
Q: How to use mock in django? I tried to install a mock library for django from http://www.voidspace.org.uk/python/mock/
But when i type in
pip install -U mock

while in virtualenv, and then try to
import mock

from django project's shell i get:
ImportError: No module named mock

What can I do?

A: Check to see if the module is in the path. To do this, in the Python shell:
>>> import sys
>>> print sys.path

If it was installed correctly, you should see the mock directory in one of the directories printed out.
If you do not find the mock directory, I'm assuming that pip is not installing the module in the virtualenv packages directory.

A: OK, it was my fault.
I ran shell and tests by:
./manage.py

instead of
python manage

so my virtualenv directory wasn't included in sys.path, and mock package was unavaible. Thanks for help.


text:
Q: Is it valid to use the "return" keyword in a useEffect to stop code execution? I was debating with a collegue today about using the "return" key in a useEffect to stop code execution. I have learned that using return should only be done in a cleanup.
The issue:
  useEffect(() => {
    if (stateCondition) {
      //do fancy stuff
      return;
    }

    // more code to execute if condition is not met
  }, [props]);

The way I see this is that we should perhaps have yet another useEffect that only execute if the state is false and not use the "return" as above.
I am trying to find some documentation to support my claim but so far I have not been able to.
What I am looking for:
Am I right here? is there documentation that supports my claim or the other way arround?

A: Technically it doesn't really make a difference in this case.  Because return; explicitly returns undefined, which is already implicitly returned by any JavaScript function which doesn't return anything.
The React framework knows not to execute an undefined cleanup function, so no harm is done.
Returning anything else from a useEffect function other than a cleanup function or undefined could potentially cause bugs.  You could test it if you want, but it's kind of a moot point and nothing more than a passing curiosity, since you simply shouldn't do it as cleaning up from useEffect is documented to happen from returning a function.

As an opinion, I would recommend never using return in any useEffect unless it's explicitly a cleanup function.  Even if no harm is done in this particular case, another developer who happens upon this pattern may not know that and may get confused about returning from an effect.
For this particular case, it seems a simple else block would produce the same logic.


text:
Q: Error DBI1189E installing DB2 on Mac Os X El Capitan I have followed the instructions to install DB2 Express-C found here (which is the official guide on the IBM community forum). Everything worked quite fine until I had to run the db2_install.
When I execute it, it gives me the DBI1189E error:
"DBI1189E There has been an attempt to use db2_install
on an image for a platform that does not match the current platform
'MacOS' on which it is being run.
Explanation:
Possible causes include:

*

*This DB2 install image is not valid for the current
platform.

*The current platform is not supported by DB2.
User Response:
Install DB2 using the DB2 install image that corresponds
with the current platform 'MacOS'. "
Anyone knows what went wrong?

A: I am finding references to seemingly the same problem for example here and here. All I am doing is googling for "DBI1189E mac os". Good luck and let me know if this has worked. Thanks!

A: The last 2 days I also struggled with installing db2 on My Os X with the El Capitan.
First of all, important to know is that only version 10.1 is supported for mac, while for windows/linux, version 10.5 is supported.
This can cause troubles when migrating an existing database in 10.5 to your mac database in version 10.1. It is off course important to have the right distribution for mac os x.
I also tried the official guide on the IBM community forum, but it didn't work out for me too...
What I did was follow these instructions.
With these instructions, the installation went find, but I encountered some issues with the line:

*Initialize the sample database using this command:
db2sampl

Make sure you issue the db2start command using the db2inst1 user.
After my db was started I had some issues with locked files.
I could solve them by issuing the command:

sudo chown db2inst1 /Users/db2inst1/sqllib/adm/*

And then everything worked fine.
Good luck!