text:
Q: Need a solution for mass Windows 10 deployment in computer charity I am a volunteer technician for a computer charity, which provides computers for distance education. Recently, demand has significantly increased and we're struggling to keep up.
I would like to ask you for help.
We need to install Windows the most efficient way possible. Unfortunately, the hardware we work with (all old computers collected from people or companies) is very diverse, most of it is 5 to 15 years old – which means we need to support both UEFI (ideally with Secure boot enabled) and legacy BIOS. Also, while many of the computers have Windows Pro, about 25-30% have Home, so we need to be able to deploy both editions.
I've been researching this thoroughly, but my head hurts from all of it. I've tried using answer files for unattended installation, but failed. Another problem I had was getting PXE to work with UEFI machines. I've decided not to go that way, since everyone recommended me to use some image deploying solution. WDS looks promising, but we would need to buy an expensive Windows Server licence, so I'm trying to avoid that (however, if everything else fails, this seems to be the most straightforward and, most importantly, the best documented approach).
We need to deploy Windows with correct configuration (surveillance turned off, fast boot disabled etc.) and software (Chrome, Libreoffice, MS Teams, Eset Internet Security) to 10-15 computers at once. We want to do it over network with minimal operator input needed. We have a solid enough network infrastructure (we can invest into it more if needed) and a Xeon workstation, which we can use as a PXE server.
I have found this tutorial for creating a golden Windows 10 image and I'd like to use it in some way: https://www.youtube.com/watch?v=PdKMiFKGQuc
Summary of requirements we have:

*

*Both UEFI and legacy

*Both Home and Pro editions of Windows 10

*Automatically create user account without password (and password expiration)

*Do not join / require a domain or any other enterprise stuff. These computers do not need to be administered centrally, nor will we update them using this method.

*Free (and open source), if possible. We can afford to spend a couple hundred dollars, but prefer not to.

*It would be great, if it automatically installed all updates including all available drivers, instead of us having to run Windows update and manually select all the optional driver updates.

*I would like to use NIC bonding to increase bandwidth, if possible.

Do you have any ideas?
Thanks in advance for your help.


text:
Q: pop up confirmed + alert in javascript how do I make confirmed pop up by alert for user's data in form, for example :confirmed box: dear (user name) are you sure? alert box: thanks for submission (user name)

A: There are the functions confirm and alert:
username = document.getElementById("Username").value;
confirm("dear " + username + " are you sure?");
alert("thanks for submission, " + username);

redpajama_set_name: RedPajamaStackExchange


text:
Q: Calculating wind direction from U and V components of the wind using lapply or ifelse Averaging scalar wind direction data yields inaccurate values due to the compass headings ranging from 0-360 degrees, so I have converted my list to u and v components from the magnitude and wind direction angles already.
In order to back out the proper wind direction, for averaging purposes, I need to develop some sort of apply, ifelse, function for the 3 following scenarios:
V > 0...((180 / pi) * atan((Ucomp/Vcomp)) + 180)
U and V < 0...((180 / pi) * atan((Ucomp/Vcomp)) + 0)
U > 0 and V < 0...((180 / pi) * atan((Ucomp/Vcomp)) + 360)

In the data set I am looking to analyze, Ucomp is greater than 0 and Vcomp is less than zero, but there will undoubtedly be scenarios where all 3 will pan out, so I need a function to parse through and calculate iteratively and applying the correct formula for each time step.  I have not used lapply or functions before, so me playing around with them has not worked.
I provide a sample of data below...
  DateTime Wind.Spd Wind.Direction Air.Density   Temp.C GEP.GE16XLE GCF.GE16XLE    Ucomp      Vcomp
1     1981 7.662370       248.3395   0.9148207 11.28967    597.7513    37.35946 5.253453 -0.7404972
2     1982 8.199412       251.6763   0.9172176 10.12751    678.8595    42.42872 5.867979 -0.6191475
3     1983 8.188782       251.7889   0.9162767 10.30619    667.9461    41.74663 5.777208 -1.0473982
4     1984 7.942632       246.7908   0.9174074 10.05093    642.6374    40.16484 5.415773 -0.6796723
5     1985 8.016558       252.7305   0.9171721 10.38414    654.2588    40.89117 5.649406 -0.9999082
6     1986 7.739984       249.6431   0.9158740 10.99859    607.0542    37.94089 5.305971 -0.9118965

A: You should look at using the atan2 function, it will probably remove the need for all the if statements and extra computing.
If you are doing a lot with directions then you should also look into the circular and CircStats packages which take care of a lot of these details for you (some is similar to what you did, just more automatic).

A: First define the function to do the calculation:
windDir <- function(u, v) {
  if(v > 0)         ((180 / pi) * atan(u/v) + 180)
  if(u < 0 & v < 0) ((180 / pi) * atan(u/v) + 0)
  if(u > 0 & v < 0) ((180 / pi) * atan(u/v) + 360)
}

Then apply it to each row. Here I'm using ddply, which is a nice "apply" variety for data frames:
> library(plyr)
> ddply(data, 'DateTime', summarize, windDir=windDir(Ucomp, Vcomp))
  DateTime  windDir
1     1981 278.0232
2     1982 276.0232
3     1983 280.2760
4     1984 277.1531
5     1985 280.0370
6     1986 279.7517

A: Check out:
https://www.eol.ucar.edu/content/wind-direction-quick-reference
In short, you want to use atan2 to take care of the different quadrants, but don't forget that the angles are defined differently in meteorology! We measure the wind direction in degrees clockwise from North, whereas atan2-type functions generally work in radians from the X-direction (i.e. East). So you want to use something like:
WDIR= 270-atan2(V,U)*180/pi
Add a %360 to ensure the output is between 0 and 360:
WDIR= (270-atan2(V,U)*180/pi)%360

A: windDir <- function(u, v) {
  (180 / pi) * atan(u/v) + ifelse(v>0,180,ifelse(u>0,360,0))
}


text:
Q: Como pasar datos de una clase a otra clase dentro del mismo archivo en angular //en un componente de mi aplicacion de angular estoy usando un Bootom sheet, la clase de ese componente y la clase del componente original están dentro del mismo component.ts, lo que quiero es que al abrir el Booton sheet quiero ingresar datos del componente original pero no se como pasar esos datos, dejo mi componente
@Component({
   selector: 'app-publicaciones',
   templateUrl: './publicaciones.component.html',
   styleUrls: ['./publicaciones.component.css']
})
 export class PublicacionesComponent implements OnInit {

   constructor(
     private httpPublic: PublicacionesService,
     private auth: PrivateService,
     private _bottomSheet: MatBottomSheet,
   ) { }

   public URL: string = 'http://localhost:3000'
   public id: string;

   ngOnInit(): void {
     console.log(this.nombre)
     this.httpPublic.verPublic()
       .subscribe((res: any) => {
         this.publicaciones = res
         console.log(this.publicaciones)
       })
     this.auth.datosUser()
       .subscribe((res: any)=>{
         this.id = res._id
       })
   }

   publicaciones: any[]

   openBottomSheet(index): void {
     this._bottomSheet.open(BottomSheetOverviewExample)
   }

 }

 @Component({
   selector: 'aviso',
   templateUrl: 'actividad-publicacion.html'
 })
 export class BottomSheetOverviewExample {
   constructor(
     private _bottomSheetRef: MatBottomSheetRef<BottomSheetOverviewExample>
     ) {}

   openLink(event: MouseEvent): void {
     this._bottomSheetRef.dismiss()
     event.preventDefault()
   }

 }

//Me pueden indicar una solucion para que cuando se ejecute el metodo openBottomSheet(index) pueda pasar datos de ese componente al que esta abajo

A: Prueba con esto:

*

*En el componente padre, envia la data a travez de la propiedad data
@Component({
   selector: 'app-publicaciones',
   templateUrl: './publicaciones.component.html',
   styleUrls: ['./publicaciones.component.css']
})
 export class PublicacionesComponent implements OnInit {

   constructor(
     private httpPublic: PublicacionesService,
     private auth: PrivateService,
     private _bottomSheet: MatBottomSheet,
   ) { }

   public URL: string = 'http://localhost:3000'
   public id: string;

   ngOnInit(): void {
     console.log(this.nombre)
     this.httpPublic.verPublic()
       .subscribe((res: any) => {
         this.publicaciones = res
         console.log(this.publicaciones)
       })
     this.auth.datosUser()
       .subscribe((res: any)=>{
         this.id = res._id
       })
   }

   publicaciones: any[]

   openBottomSheet(index): void {
     this._bottomSheet.open(
        BottomSheetOverviewExample,
        // Enviando data al Bottom-Sheet.
        { data: { nombres: ['Frodo', 'Bilbo'] } }
     );
   }

 }

*En el componente Bottom-Sheet:

import {Component, Inject} from '@angular/core';
import {MAT_BOTTOM_SHEET_DATA} from '@angular/material/bottom-sheet';

 @Component({
   selector: 'aviso',
   templateUrl: 'actividad-publicacion.html'
 })
 export class BottomSheetOverviewExample {
   constructor(
     // Recibiendo data desde componente padre...
     @Inject(MAT_BOTTOM_SHEET_DATA) public data: any
     private _bottomSheetRef: MatBottomSheetRef<BottomSheetOverviewExample>
     ) {}

   openLink(event: MouseEvent): void {
     this._bottomSheetRef.dismiss()
     event.preventDefault()
   }

 }

Mas información y detalles los puedes encontrar en la documentación: https://material.angular.io/components/bottom-sheet/overview


text:
Q: gradle can not resolve any dependency for configuration: classpath all my projects using gradle builder has this error. gradle can not sync and none of the dependencies resolve.
this is the error:
Could not resolve all artifacts for configuration ':classpath'.

Could not find com.android.tools.build:gradle:6.7.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/6.7.1/gradle-6.7.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/6.7.1/gradle-6.7.1.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/6.7.1/gradle-6.7.1.pom
Required by:
project :
Could not find android.arch.navigation:navigation-safe-args-gradle-plugin:2.3.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/android/arch/navigation/navigation-safe-args-gradle-plugin/2.3.0/navigation-safe-args-gradle-plugin-2.3.0.pom
- https://jcenter.bintray.com/android/arch/navigation/navigation-safe-args-gradle-plugin/2.3.0/navigation-safe-args-gradle-plugin-2.3.0.pom
- https://repo.maven.apache.org/maven2/android/arch/navigation/navigation-safe-args-gradle-plugin/2.3.0/navigation-safe-args-gradle-plugin-2.3.0.pom
Required by:
project :
Possible solution:

*

*Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

this is my build.gradle file:
buildscript {

repositories {
    google()
    jcenter()
    mavenCentral()

}
dependencies {
    classpath 'com.android.tools.build:gradle:6.7.1'
    classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:2.3.0'

}
}
allprojects {
repositories {
    google()
    jcenter()

}
}

task clean(type: Delete) {
delete rootProject.buildDir}

and this is my :app build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'androidx.navigation.safeargs'

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"

defaultConfig {
    applicationId "com.example.jartest2"
    minSdkVersion 16
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}}

dependencies {
def nav_version = "2.3.0"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
implementation "androidx.navigation:navigation-runtime:$nav_version"
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'}

and this is the log file:
INFO - j.ide.actions.RevealFileAction - Exit code 1
2020-12-10 05:19:12,205 [47703891]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:12,596 [47704282]   INFO - rationStore.ComponentStoreImpl - Saving Project(name=JarTest2, containerState=COMPONENT_CREATED, componentStore=D:\computer\Java\IdeaProjects\JarTest2)JavacSettings took 16 ms 2020-12-10 05:19:12,706 [47704392]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:22,712 [47714398]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:23,226 [47714912]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:24,230 [47715916]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:24,746 [47716432]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:25,754 [47717440]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:26,263 [47717949]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:26,779 [47718465]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:27,294 [47718980]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:27,810 [47719496]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:28,326 [47720012]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:28,838 [47720524]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:29,344 [47721030]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:29,846 [47721532]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:30,354 [47722040]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:30,870 [47722556]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:31,385 [47723071]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:31,901 [47723587]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:31,932 [47723618]   INFO - System.util.ExternalSystemUtil - External project [D:/computer/Java/IdeaProjects/JarTest2] resolution task started` 2020-12-10 05:19:32,010 [47723696]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Program Files/Java/jdk1.8.0_72  2020-12-10 05:19:32,010 [47723696]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Program Files/Java/jdk1.8.0_72  2020-12-10 05:19:32,042 [47723728]   INFO - oject.common.GradleInitScripts - init script file sync.studio.tooling contents "initscript {\n    dependencies {\n        classpath files(['C:\\\\Program Files\\\\JetBrains\\\\IntelliJ IDEA Community Edition 2020.3\\\\plugins\\\\android\\\\lib\\\\android.jar', 'C:\\\\Program Files\\\\JetBrains\\\\IntelliJ IDEA Community Edition 2020.3\\\\plugins\\\\android\\\\lib\\\\android.jar', 'C:\\\\Program Files\\\\JetBrains\\\\IntelliJ IDEA Community Edition 2020.3\\\\lib\\\\kotlin-stdlib-1.4.0.jar'])\n    }\n}\nallprojects {\n    apply plugin: com.android.ide.gradle.model.builder.AndroidStudioToolingPlugin\n}\n"  2020-12-10 05:19:32,057 [47723743]   INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: -Didea.sync.active=true -Didea.resolveSourceSetDependencies=true -Porg.gradle.kotlin.dsl.provider.cid=47899959731139 --init-script C:\Users\M.H\AppData\Local\Temp\sync.studio.tooling11867.gradle -Djava.awt.headless=true --stacktrace -Pandroid.injected.build.model.only=true -Pandroid.injected.build.model.only.advanced=true -Pandroid.injected.invoked.from.ide=true -Pandroid.injected.build.model.only.versioned=3 -Pandroid.injected.studio.version=10.4.0.203.5981.155 -Pandroid.injected.build.model.disable.src.download=true -Pidea.gradle.do.not.build.tasks=false --init-script C:\Users\M.H\AppData\Local\Temp\ijinit5.gradle  2020-12-10 05:19:32,409 [47724095]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:32,925 [47724611]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:42,652 [47734338]   INFO - .project.GradleProjectResolver - Gradle project resolve error  org.gradle.tooling.GradleConnectionException: Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.7.1-all.zip'.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55)
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:43)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:69)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.gradle.api.UncheckedIOException: java.io.StreamCorruptedException: invalid type code: 00
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:61)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
at org.gradle.tooling.internal.provider.serialization.PayloadSerializer.deserialize(PayloadSerializer.java:78)
at org.gradle.tooling.internal.provider.ProviderConnection.throwFailure(ProviderConnection.java:231)
at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:219)
at org.gradle.tooling.internal.provider.ProviderConnection.runPhasedAction(ProviderConnection.java:179)
at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:245)
at org.gradle.tooling.internal.consumer.connection.PhasedActionAwareConsumerConnection.run(PhasedActionAwareConsumerConnection.java:56)
at org.gradle.tooling.internal.consumer.connection.ParameterValidatingConsumerConnection.run(ParameterValidatingConsumerConnection.java:62)
at org.gradle.tooling.internal.consumer.DefaultPhasedBuildActionExecuter$1.run(DefaultPhasedBuildActionExecuter.java:78)
at org.gradle.tooling.internal.consumer.DefaultPhasedBuildActionExecuter$1.run(DefaultPhasedBuildActionExecuter.java:70)
at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:130)
at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)
at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:61)
at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:67)
... 6 more Caused by: java.io.StreamCorruptedException: invalid type code: 00
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1710)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.readArray(ObjectInputStream.java:2102)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1667)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2464)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2358)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2196)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:493)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:451)
at org.gradle.tooling.internal.provider.serialization.PayloadSerializer.deserialize(PayloadSerializer.java:76)
... 19 more 2020-12-10 05:19:42,663 [47734349]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Program Files/Java/jdk1.8.0_72  2020-12-10 05:19:42,665 [47734351]   INFO - g.jetbrains.kotlin.idea.script - [KOTLIN_SCRIPTING] IllegalStateException loading gradle script templates: Unable to get Gradle home directory  2020-12-10 05:19:42,668 [47734354]   INFO - g.jetbrains.kotlin.idea.script - [KOTLIN_SCRIPTING] Cannot find valid gradle home for null with version = null, script models cannot be saved  2020-12-10 05:19:42,669 [47734355]   INFO - System.util.ExternalSystemUtil - External project [D:/computer/Java/IdeaProjects/JarTest2] resolution task executed in 10737 ms.  2020-12-10 05:19:42,961 [47734647]   INFO - .deployment.AsyncDevicesGetter - adb not found 2020-12-10 05:19:43,067 [47734753]   INFO - ge.ExternalProjectsDataStorage - Save external projects data in 46 ms  2020-12-10 05:19:43,462 [47735148]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:43,963 [47735649]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:44,467 [47736153]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:44,983 [47736669]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:45,487 [47737173]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:45,992 [47737678]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:46,487 [47738173]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:47,518 [47739204]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:52,052 [47743738]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:55,073 [47746759]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:55,588 [47747274]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:56,104 [47747790]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:56,620 [47748306]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:57,128 [47748814]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:19:57,630 [47749316]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:02,671 [47754357]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:03,678 [47755364]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:04,175 [47755861]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:09,781 [47761467]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:10,278 [47761964]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:10,778 [47762464]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:11,282 [47762968]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:12,282 [47763968]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:12,785 [47764471]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:13,287 [47764973]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:13,787 [47765473]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:14,291 [47765977]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:14,806 [47766492]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:15,322 [47767008]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:15,822 [47767508]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:16,338 [47768024]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:16,853 [47768539]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:17,360 [47769046]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:17,861 [47769547]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:19,365 [47771051]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:19,881 [47771567]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:21,420 [47773106]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:21,921 [47773607]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:22,421 [47774107]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:22,921 [47774607]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:23,418 [47775104]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:23,780 [47775466]   INFO - rationStore.ComponentStoreImpl - Saving appLangManager took 16 ms  2020-12-10 05:20:23,921 [47775607]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:28,929 [47780615]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:56,843 [47808529]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:20:57,358 [47809044]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:21:05,930 [47817616]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:21:06,430 [47818116]   INFO - .deployment.AsyncDevicesGetter - adb not found  2020-12-10 05:22:26,483 [47898169]   INFO - .deployment.AsyncDevicesGetter - adb not found

I check the internet connection. it works fine. after I use proxy but still have this error. I update my intellij to 11.0.9 and java to 10 but do not help. I check the JAVA_HOME path, it has defined correctly. I delete .gradle folder in my user home and invalidate caches and restart and build the project again but it also can not help.
now I'm using windows 10, intellij IDEA 11.0.9 and jdk 1.8. any help will be appreciate.

A: after searching I found the problem was the proxy. I changed the proxy server and gradle worked correctly!


text:
Q: Promoting QListWidget in QtDesigner For example, I have a project Numerator having two files:

*

*Numerator\program.py

*Numerator\Interface\paperCounter.ui

In the program.py I define a custom class MouseTrackingList based
 on QListWidget. I use Qt Designer to generate user interface and to use it with uic.loadUiType in my program.py.
The problem is how to properly promote example QListWidget in Qt Designer. When I do right mouse click "promote to" and select name  of promoted class MouseTrackingList it automatically creates name of header file mousetrackinglist.h. Then I press "add" and "promote".
From this answer I see Header file must be the python import path for the module that contains this class. But I cannot understand where my mousetrackinglist.h is generated and how to import him in program.py.


text:
Q: javascript - combine the object if the value of its field is the same Below is the current data
const data = [
  { id: 1, type: "call", strike: 3000, volume: 50000 },
  { id: 2, type: "call", strike: 5000, volume: 30000 },
  { id: 3, type: "call", strike: 7000, volume: 20000 },
  { id: 4, type: "put", strike: 3000, volume: 50000 },
  { id: 5, type: "put", strike: 5000, volume: 10000 },
  { id: 6, type: "put", strike: 7000, volume: 7000 }
]

I want to do some processing of the data based on strike, which means the object with same value in strike will be combined, so that it becomes something like
[
  { strike: 3000, callVolume: 50000, putVolume: 50000 },
  { strike: 5000, callVolume: 30000, putVolume: 10000 },
  { strike: 7000, callVolume: 20000, putVolume: 7000 },
]

How should I do it in javascript?

A: This is really just a 'group by' by strike with a computed property name based on type.

const data = [    { id: 1, type: 'call', strike: 3000, volume: 50000 },    { id: 2, type: 'call', strike: 5000, volume: 30000 },    { id: 3, type: 'call', strike: 7000, volume: 20000 },    { id: 4, type: 'put', strike: 3000, volume: 50000 },    { id: 5, type: 'put', strike: 5000, volume: 10000 },    { id: 6, type: 'put', strike: 7000, volume: 7000 },  ];

const result = Object.values(
  data.reduce((a, { type, strike, volume }) => {
    (a[strike] ??= { strike })[`${type}Volume`] = volume;

    return a;
  }, {})
);

console.log(result);

A: You could collect volume by each group.

const
    data = [{ id: 1, type: "call", strike: 3000, volume: 50000 }, { id: 2, type: "call", strike: 5000, volume: 30000 }, { id: 3, type: "call", strike: 7000, volume: 20000 }, { id: 4, type: "put", strike: 3000, volume: 50000 }, { id: 5, type: "put", strike: 5000, volume: 10000 }, { id: 6, type: "put", strike: 7000, volume: 7000 }],
    result = Object.values(data.reduce((r, { type, strike, volume }) => {
        r[strike] ??= { strike, callVolume: 0, putVolume: 0 };
        r[strike][type + 'Volume'] += volume;
        return r;
    }, {}));

console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }

A: You can use a forEach/for loop to init a item in result object. By using Array.find use can check the result exists or not to init a new result item.

const data = [
    { id: 1, type: "call", strike: 3000, volume: 50000 },
    { id: 2, type: "call", strike: 5000, volume: 30000 },
    { id: 3, type: "call", strike: 7000, volume: 20000 },
    { id: 4, type: "put", strike: 3000, volume: 50000 },
    { id: 5, type: "put", strike: 5000, volume: 10000 },
    { id: 6, type: "put", strike: 7000, volume: 7000 }
]

let result = [];
data.forEach(item => {
  let result_item = result.find(e => e.strike == item.strike);
  var isNew = false;
  if (!result_item) {
    result_item = {
      strike: item.strike
    };
    isNew = true;
  }

  if (item.type == "call")
    result_item.callVolume = item.volume;
  else
    result_item.putVolume = item.volume;

  if (isNew) result.push(result_item);
});

console.log(result);

A: I've tried to keep it as optimal as I could. First I create a hashmap by strike attribute for quick access and not double looping in each step.
After I got the hashmap, I ran a quick loop and extracted only those elements that had strike.
const data = [
  { id: 1, type: "call", strike: 3000, volume: 50000 },
  { id: 4, type: "put", strike: 3000, volume: 50000 },

  { id: 2, type: "call", strike: 5000, volume: 30000 },
  { id: 5, type: "put", strike: 5000, volume: 10000 },

  { id: 6, type: "put", strike: 7000, volume: 7000 },
  { id: 3, type: "call", strike: 7000, volume: 20000 }
];

// Processing starts here
const hash = {};

data.forEach((item) => {
  let { volume, strike, type } = item;

  if (!hash[strike]) {
    hash[strike] = {
      strike: strike,
      [`${type}Volume`]: volume
    };
  } else {
    hash[strike] = {
      ...hash[strike],
      [`${type}Volume`]: volume
    };
  }
});

// Extract hash map data into array
// Filter and remove no match strikes
let result = [];

for (let key in hash) {
  let elm = hash[key];
  if (!elm.putVolume || !elm.callVolume) continue;

  result.push(elm);
}

console.log(result);


text:
Q: IntelliJ: How to resolve java.lang.ClassNotFoundException: main.java.org.***.Main I'm using IntelliJ and the path to the directory that includes my source code is:
MyProjectFolder/src/main/java/org/***/
This directory includes a java file named Main.java, and in Run/Debug Configurations I have the path "/home/matan/Projects/java_phone_book/src/main" in Working directory field.
Still, when I run the program by IntelliJ, I get the error:

Exception in thread "main" java.lang.ClassNotFoundException:
  main.java.org.***.Main

What can resolve this problem?

A: Your class' fully-qualified name is not main.java.org.***.Main.  That is why the class main.java.org.***.Main can not be found.
If you are following a currently popular project layout, then 'main' and java are not part of the package name for your class.  Try org.***.Main instead.  (although asterisks are not a valid package name, so what you posted can't actually be it)
Otherwise, you'll need to go back to review your CLASSPATH, your package declarations, and your project layout and ensure they all agree with each other.

A: Go to the menu File > Project Structure. Click the "Modules" section, then click your module name, then click the "Sources" tab. One of the folders shown should be marked as a "Source Folder" already. I will call the name of this folder "S". Make sure Main.java is somewhere in one of the sub-folders of S.
Now, find the full directory path of Main.java. This should be something like S/<some_path>/Main.java. If the beginning of <some_path> is "java" then you should rename that directory to something else. Finally, in Main.java, change the first line of the code so that it says package <some_path>; Replace <some_path> with the one you found in the last step. Replace the slashes with dots.


text:
Q: Rectangular Approximation Method (Riemann Sums) Diagrams Does anyone know how to make relatively simple diagrams like the images below? Is there a some sort of "template" I could use perhaps? I'd like to code my Calculus notes but I'm not sure how to make the diagrams. It's Left approximation, right approximation, and middle approximation, respectively. Alas...

A: Quick and dirty:
\documentclass[tikz,border=5]{standalone}
\tikzset{declare function={y(\x)=4-\x^2;},
  plot fill/.style={fill=purple!75},
  plot/.style={draw=black!80, thick},
  bar/.style={fill=cyan, draw=white, thick},
  marking/.style={fill=cyan!50!black, draw=cyan!50!black},
  axis/.style={thick, draw=black!65, stealth-stealth}
}
\begin{document}
\begin{tikzpicture}[x=1.5cm, line cap=round, line join=round]
\foreach \k [count=\z] in {0, 1/4, 1/2}{
\begin{scope}[shift=(0:\z*3)]
\path [plot fill] plot [domain=0:2] (\x,{y(\x)}) -| cycle;
\foreach \x in {0, 1/2, 1, 3/2}
   \path [bar]  (\x,0) |- (\x+1/2, {y(\x+\k)}) |- cycle;
\path [plot]  plot [domain=0:2] (\x,{y(\x)});
\path [axis] (0,4.5) |- (2.5,0);
\foreach \t [count=\x from 0] in {0,\frac{1}{2},1,\frac{3}{2},2}
  \path [axis, -] (\x/2,0) -- ++(0,-3pt) node [below] {$\t$};
\foreach \y in {0,4}
  \path [axis, -] (0,\y) -- ++(-3pt, 0) node [left] {$\y$};
\foreach \x in {0, 1/2, 1, 3/2}
   \path [marking]  (\x+\k, {y(\x+\k)}) circle [radius=1.5pt];
\end{scope}
}
\end{tikzpicture}
\end{document}

A: I can suggest this solution, using my package xpicture. You can add colors, if you want, but for a more sophisticated design use the tikzpicture package.

\documentclass{standalone}
  \usepackage{xpicture}
  \usepackage{ifthen}
\begin{document}
\newqpoly{\f}{4}{0}{-1}               % Define f(x)=4-x^2
\referencesystem(0,0)(2,0)(0,1)       % Change reference system to get a larger x-unit
\setlength{\unitlength}{1cm}
\renewcommand{\xunitdivisions}{2}     % x-Tics at every half unit
\begin{Picture}(-1,-1)(3,5)
  \cartesianaxes(-0.1,-0.1)(2.1,4.1)
  \printxticlabel{0.5}{1/2}
  \printxticlabel{1.5}{3/2}
  \PlotFunction[20]{\f}{0}{2}         % Plot f(x)
  \COPY{0}{\x}
  \whiledo{\lengthtest{\x pt}<2 pt}{% % Loop to plot Taylor sum
      \COPY{\x}{\xzero}
      \f{\xzero}{\yzero}{\Dyzero}     % yzero=f(xzero)
      \ADD{0.5}{\x}{\x}
      \Polyline(\xzero,0)(\xzero,\yzero)(\x,\yzero)(\x,0)
   }
\end{Picture}

\begin{Picture}(-1,-1)(3,5)
  \cartesianaxes(-0.1,-0.1)(2.1,4.1)
  \printxticlabel{0.5}{1/2}
  \printxticlabel{1.5}{3/2}
  \PlotFunction[20]{\f}{0}{2}
  \COPY{0}{\x}
  \whiledo{\lengthtest{\x pt}<2 pt}{%
      \COPY{\x}{\xzero}
      \ADD{0.5}{\x}{\x}
      \f{\x}{\y}{\Dy}                 % y=f(x)
      \Polyline(\xzero,0)(\xzero,\y)(\x,\y)(\x,0)
  }
  \end{Picture}

  \begin{Picture}(-1,-1)(3,5)
  \cartesianaxes(-0.1,-0.1)(2.1,4.1)
  \printxticlabel{0.5}{1/2}
  \printxticlabel{1.5}{3/2}
  \PlotFunction[20]{\f}{0}{2}
  \COPY{0}{\x}
  \whiledo{\lengthtest{\x pt}<2 pt}{%
      \COPY{\x}{\xzero}
      \ADD{0.5}{\x}{\x}
      \ADD{0.25}{\xzero}{\xm}
      \f{\xm}{\ym}{\Dym}              % ym=f(xm)
      \Polyline(\xzero,0)(\xzero,\ym)(\x,\ym)(\x,0)
  }
  \end{Picture}
  \end{document}


text:
Q: FXMLLoader explained I am using javafx combined with FXML.
I want to apply the MVC pattern. For that I want my Model.java class to be the model, which launches the View.fxml and the controller of that view would be viewController.java.
I need to bring Model.java and Controller.java to communicate at some point. So let's say ViewController.java looks this way:
public class ViewController implements Initializable {

    private String parameter = "hello";
    @FXML
    private Label label;

    @FXML
    private Accordion acccord;

    public String getParemeter() {
        return this.parameter;
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }

}

ViewController has a private string and its own methods.
And Model.java :
public class Model extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("View.fxml") );

        Parent root = loader.load();  // Here the View is loaded and the Contoller is created along.

        loader.getController(); // ?
        //Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

        Scene scene = new Scene(root);

        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}

How can I access the ViewContoller parameters / methods (such as getPamareter() ) ?
I tried to get the controller with loader.getController() but it returns a generic type, what should I do with it, provided it has something to do with it? I went to the oracle documentation but I am not quite sure to understan, does getController() return an instance of my ViewController.java ?
HOw can I access the Model from the ViewController?
For instance a buton is triggered, the vieController would update a value in Model.java.


text:
Q: How do I remove this white space from the bottom of my page when I print? I have a picture that I want to run to the bottom of the page edge. I've put the bottom margin to 0 and in the document view it appears at the bottom of the page. However, when in print preview and when actually printed there is a white space. How do I get rid of it?

A: It is most likely coming from the printer you are printing to.  Most copiers/printers put 1-5mm of void area around the entire document.  This is intentional, to prevent jamming mainly, but other potential issues as well.  I believe the term here for what you are looking for, is called "full bleed".
Usually this is an option in the driver for color printers/copiers (depending on make/model), so your mileage may vary here.

A: @RMarkwald's answer gives the most likely reason. However, another possibility is that the aspect ratio of the photo does not match that of the paper.
Most photos have a 3 x 2 aspect ratio. My camera has 24 million pixels, or 6000 x 4000. A standard print is 6" x 4" print. In both cases the ratio is 6/4 = 3/2.
Paper does not have that aspect ratio. For example, an A4 page is 210 mm x 297 mm, an aspect ration of 3 x 2.1212. Thus, the only way to fit a photo on this paper is to either distort the photo by squashing it vertically, or by cropping part of the photo. As the application will not do that, it cannot fill the paper. Hence the margins.


text:
Q: How do I change permissions of folders on a hard drive from a booted USB drive I am trying to save my files on my Hard Drive that has a crashed OS. I created a Bootable USB with Ubuntu and successfully booted.
I can see my folders, but I can't actually open them because I don't have permission.
I tried to do this:
sudo chmod 777 -R Pictures

Where Pictures is the name of the folder I want to change permissions to.
All I want to be able to do is to copy the folders & files from my Hard Drive to my USB drive.
How do I do that?

A: For anyone else that has this issue, the guys over at AskUbuntu solved it for me.
You can find the answer, along with other good answers, here:
https://askubuntu.com/questions/563054/how-do-i-change-permissions-of-folders-on-a-hard-drive-from-a-booted-usb-drive


text:
Q: Where can I learn about optimal math in C on a micro-controller like, say, ARMv7? I'm trying to optimize some functions and I realized that I know next to nothing about how long certain things take.
I can ask all the questions here, but I'd rather just find a good article on the subject if anyone knows one.
I'm using IAR to write a program in C for an ATMEL SAM7S processor. I have a sort function that takes 500uS or so, and I wanted to see if I could speed it up. I could also just post it here but I was hoping to learn for myself.
Like, is it any faster to subtract two 16 bit integers than it is to subtract two 32 bit integers? And how long does an operation like that take? Just one cycle or more? How long does multiplication take compared to subtraction?
Anyone know a place to look? I tried googling for some stuff but I couldn't come up with any useful search terms.
If anyone has an ideas on my specific function, I can post details. I'm basically trying to match two analog values to the closest index in a table of calibrated values. Right now I iterate through the whole table and use least squares to determine the closest match. Its pretty straightforward and I'm not sure there is a faster way without applying some extra logic to my table. But if I at least knew how long certain things took, I could probably optimize it myself.

A: A good first stage could be to study the assembly language of the architecture you are coding for.
After you should be able to read the binary file generated by your compiler and finally compare what the computer will really have to do with two different implementation.

A:
is it any faster to subtract two 16 bit integers than it is to subtract two 32 bit integers?

Not on an ARM architecture which has native 32-bit registers, no.

Anyone know a place to look?

The canonical place for instruction cycle timings would be the Tech Ref Manual for the particular architecture your chip implements, eg. ARM7TDMI; timings for simple alu ops here and yes, it is one cycle. This is not friendly doc to be reading if you're not already well familiar with the instruction set, though...

Right now I iterate through the whole table

You'll be much better off looking at algorithmic optimisations here (eg indexing the table, sorting by one co-ordinate to narrow it down, etc) than worrying about instruction-level micro-optimisations.

A: You can use the timers in your SAM7S.  Read a timer on start, and read it after N number of searches and subtract to get the difference.  Try different algorithms and see what you see.
As far as 16 bit math vs 32 bit math, yes there can be a huge difference, but you have to look at your architecture.  A subtract operation between two registers will take the same one clock be it 16 bit or 32 bit.  But coming from C code eventually the variables may land in memory and you have to know if you have a 16 bit or 32 bit data bus (yes ARM7s can have a 16 bit bus, look at the GameBoy Advance, thumb code runs significantly faster than ARM code on that processor).  Takes twice as many cycles to read or write 32 bit numbers on a 16 but bus.  You likely do NOT have a 16 bit bus though.  Using 16 bit variables on a 32 bit processor causes the processor to have to add extra instructions to strip or extend the upper bits so that the math is correct for a 16 bit variable.  Those extra instructions can cause performance hits, a simple subtract which might have been say 3 or 4 instructions worst case might now be 5 or 6 and that is noticeable if it is in a tight loop.  Generally you want to use variables that match the processors register size, on a 32 bit ARM use 32 bit variables as much as possible even if you are only counting to 10.
Hopefully I am understanding the problem you are trying to solve here, if not let me know and I will edit/remove this response:
Depending on how many bits in your measurement the typical solution for what you are doing is to use a look up table.  So that I can show an example lets say you are taking a 4 bit measurement that you want to calibrate.  Call it 0 to 15.  Calibration of the sensor generated a list of data points, lets say:
raw cal
0x03  16
0x08  31
0x14  49

I assume what you are doing runtime is something like this, if the sensor reads a 0x5 you would look through the list looking for entries your sensor reading matches or is between two of the cal points.
searching you will find it to be between 0x03 and 0x08 to get the calibrated result from the raw 0x05 measurement
cal=  (((0x05-0x03)/(0x08-0x03))*(31-16)+16 = 22

You have a divide in there which is a HUGE performance killer on most processors, ARM7 in particular as it doesnt have a divide.  Not sure about the multiply but you want to avoid those like the plague as well.  And if you think about how many instructions all of that takes.
Instead what you do is take the algorithm you are using run-time, and in an ad-hoc program generate all the possible outputs from all the possible inputs:
0  7
1  10
2  13
3  16
4  19
5  22
6  25
7  28
8  31
9  34
10 37
11 40
12 43
13 46
14 49
15 52

Now turn that into a table in your run-time code:
unsigned char cal_table[16]={7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52};
and then runtime
cal = cal_table[raw&15];
The code to implement this looks something like:
ldr r3, =cal_table
and r0, r0, #15
ldrb    r0, [r3, r0]

takes like 5 clocks to execute.
Just the math to find cal from raw after you have searched through the table:
cal=  (((raw-xlo)/(xhi-xlo))*(yhi-ylo)+ylo);

looks something like this:
docal:
    stmfd   sp!, {r3, r4, r5, lr}
    ldr r3, .L2
    ldr r5, .L2+4
    ldr lr, .L2+8
    ldr ip, [r5, #0]
    ldr r0, [r3, #0]
    ldr r1, [lr, #0]
    ldr r2, .L2+12
    rsb r0, ip, r0
    rsb r1, ip, r1
    ldr r5, [r2, #0]
    bl  __aeabi_uidiv
    ldr r4, .L2+16
    ldr r3, .L2+20
    ldr r4, [r4, #0]
    rsb r5, r4, r5
    mla r4, r0, r5, r4
    str r4, [r3, #0]
    ldmfd   sp!, {r3, r4, r5, pc}

And the divide function is as bad if not worse.  The look up table should make your code run dozens of times faster.
The problem with look up tables is you trade memory for performance so you have to have a table big enough to cover all the possible inputs.  A 12 bit sensor would give you as many as 4096 entries in the look up table for example.  If say you knew the measurement would never be below 0x100 you could make the table 0x1000 - 0x100 or 3840 entries deep and subtract 0x100 from the raw value before looking it up, trading an couple of instructions at run time to save a few hundred bytes of memory.
If the table would be too big you could try some other tricks like make a look up table of the upper bits, and the output of that might be a pre-computed offset into the cal table to start your search.  So if you had a 12 bit ADC, but didnt have room for a 4096 entry look up table you could make a 16 entry look up table, take the upper 4 bits of the ADC output and use it to look in the table.  The table would contain the entry in the cal table to start searching.  Say your cal table had these entries:
....
entry 27 raw = 0x598 cal = 1005
entry 28 raw = 0x634 cal = 1600
entry 29 raw = 0x6AB cal = 1800
entry 30 raw = 0x777 cal = 2000

your 16 deep look up table would then have these entries
...
[6] = 27;
[7] = 29;
...

And how you would use it is
start = lut[raw>>8];
for(i=start;i<cal_tab_len;i++)
{
...
}

instead of
for(i=0;i<cal_tabl_len;i++)
{
}

It could potentially greatly shorten the time it takes to find the entry in the table for you to perform the math needed.
For the particular problem of taking a raw value and turning that into a calibrated value at runtime, there are many many similar shortcuts.  I dont know of one book that would cover them all.  Which path to take has a lot to do with your processor, memory system and availability, and the size and nature of your data.  You generally want to avoid divides in particular and multiples sometimes if your processor does not support them (using very few clock cycles).  Most processors do not.  (Yes, the one or two processors most programmers target, do have a single cycle multiply and divide).  Even for processors that have a single cycle multiply and divide they often have to be wrapped with a C library to decide if it is safe to perform the operation with the hardware instruction or if it has to be synthesized with a library.  I mentioned above that for most variables you want to match the native register size of the processor.  If you have fixed point multiplies or divides you will often want to use half the register size of the processor.  A 32 bit processor, unless you take the time to examine the instructions in detail, you probably want to limit your multiples to 16 bit inputs with a 32 bit output and divides to 32 bit inputs with a 16 bit output and hope the optimizer helps you out.
Again, If I have assumed incorrectly what the problem you were trying to solve is please comment and I will edit/modify this response.


text:
Q: Objective C Command Failing When Run Through OSX Cron I've coded a standalone Objective C command application. If I run it through a LaunchDaemon, it runs just fine when connected by an ObjC client application over DistriutedObjects communication. If I run it at command line, it runs just fine. If I run it when called by a Bash script, it runs just fine. However, in various ways that I've attempted to run this through the root user's crontab, it does a crash report about pointer allocation:
Apr 14 05:27:00 volomike cron[72531]: cron(72531,0x7fff7d2fa000) malloc: *** error for object 0x7fb9c8400213: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug
Apr 14 05:27:00 volomike diagnosticd[70689]: error evaluating process info - pid: 72531, puniqueid: 72531
Apr 14 05:27:00 volomike com.apple.xpc.launchd[1] (com.vix.cron[72531]): Service exited due to signal: Abort trap: 6
Apr 14 05:27:00 volomike com.apple.xpc.launchd[1] (com.apple.ReportCrash.Root[72550]): Endpoint has been activated through legacy launch(3) APIs. Please switch to XPC or bootstrap_check_in(): com.apple.ReportCrash.DirectoryService
Apr 14 05:27:00 volomike ReportCrash[72550]: Saved crash report for cron[72531] version 39 to /Library/Logs/DiagnosticReports/cron_2016-04-14-052700_volomike.crash

The significant part of that crash report reads:
Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called
*** error for object 0x7fb9c8400213: pointer being freed was not allocated

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff9490ff06 __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff9c45e4ec pthread_kill + 90
2   libsystem_c.dylib               0x00007fff9345b6e7 abort + 129
3   libsystem_malloc.dylib          0x00007fff9c02f041 free + 425
4   cron                            0x000000010367aa41 0x103677000 + 14913
5   cron                            0x000000010367a7e4 0x103677000 + 14308
6   cron                            0x0000000103679572 0x103677000 + 9586
7   cron                            0x000000010367925a 0x103677000 + 8794
8   cron                            0x000000010367885e 0x103677000 + 6238
9   libdyld.dylib                   0x00007fff949835ad start + 1

In the various ways, I've done it with these various cron lines, but they crash immediately when trying to call the command, and even when I have NSLog() writing stuff to /var/log/system.log all the way from the start of main to the end of the application, nothing writes -- it's like when cron tries to call my command, it dies immediately with a crash report about pointer allocation.
41 5 * * * /bin/bash '/Applications/My App.app/Contents/Resources/mytoolcommand.sh' /q /sched

41 5 * * * /bin/bash '/Applications/My App.app/Contents/Resources/mytoolcommand.sh' /q /sched &

41 5 * * * '/Applications/My App.app/Contents/Resources/mytoolcommand' /q /sched

41 5 * * * '/Applications/My App.app/Contents/Resources/mytoolcommand' /q /sched &

Note again that if I do '/Applications/My App.app/Contents/Resources/mytoolcommand.sh' /q /sched, it runs just fine, as does /bin/bash '/Applications/My App.app/Contents/Resources/mytoolcommand.sh' /q /sched, as does '/Applications/My App.app/Contents/Resources/mytoolcommand' /q /sched
I even did a variation where cron called my mytoolcommand.sh script and simply wrote Hello World to /tmp/out.txt, and it ran just fine. So, I know my crontab is working.
Can you help me figure out what I'm doing wrong? Some suspected possible issues:

*

*Perhaps OSX El Capitan is shutting my application down for some reason, such as not being signed properly. (I'm debugging right now. I never had signature issues come up before unless it dealt with .app folders. Besides, I can run it just fine from command line without having a signature warning.)

*I have debug messages loading from main() right off the bat. They should be writing to /var/log/system.log, but they're not. This tells me the application is crashing immediately when called by cron. So, is there something special I need to load into my application's libraries in order for it to run properly when called under cron?
DEVELOPMENTS
I suspected that El Capitan Gatekeeper may have been the cause. So, I created a simplistic Objective C console application like so in a main.mm file and compiled.
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSString *sTest = @"Hello World";
        [sTest writeToFile:@"/tmp/test.txt" atomically:YES encoding:NSUTF8StringEncoding error:nil];
    }
    return 0;
}

Cron seems to run this just fine, so it's not looking like a Gatekeeper problem.
I got the problem to go away, but only briefly. I recompiled the project in a brand new project, copying over source code and settings. I then ran the command through the cron about 4 times without an issue. However, when I ran it the fifth time, it failed again and continued failing.
So, I guess I'm going to have to figure out how to convert this into a LaunchAgent.

A: The answer is YOU DON'T. You don't use cron anymore on OSX for your applications you are coding. Instead, switch to a LaunchAgent. Sure, Apple keeps it around for POSIX support, and therefore may keep it around for a very long time, but even their website encourages people to no longer use cron for application coding.

"Note: Although it is still supported, cron is not a recommended
solution. It has been deprecated in favor of launchd."
SOURCE: https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html

Unfortunately, though, LaunchAgents don't yet (in 10.11.4 at least) support cron-style syntax. (Yeah, I've already filed that suggestion to Apple for you.) So, there's no use of dash, comma, or backslash. Instead, it only supports an integer and multiple blocks to create each timeframe. And if that's not suitable enough, then set at least the most minimal timeframes and then do the rest of the code in whatever you are launching so that, for instance, if you want something only to run on the first Monday of the month, the LaunchDaemon launches in the first seven days but your application does a shutdown if it's not the first Monday of the month.


text:
Q: Swift Regular Expressions Capture Group Difficulty Trying to work out a regular expression. The output is sporadic. Each capture group has at least one nil value in a varying place for each of my three named capture groups and sometimes the capture groups are out of order. Have checked SO for a solution but no luck so far, so thought I'd ask.
Basically, my text file contains a bunch of hex's that combine to form gradients. The relevant stuff I need to scrape within the file looks like this, repeating periodically throughout our file:
002 Tropic Thunder

#a18cd2|#fbc4eb

First, I have been reading in the rtf file:
if let rtfPath = Bundle.main.url(forResource: "mytextfile", withExtension: "rtf") {
    do {
        let attributedStringWithRtf: NSAttributedString = try NSAttributedString(url: rtfPath, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.rtf], documentAttributes: nil)
        self.testString = attributedStringWithRtf
    } catch let error {
         print("Got an error \(error)")
    }
}
let myString = self.testString?.string

Next, I create the pattern, call my function, and print the result:
do {
    pattern = try NSRegularExpression(pattern: "[0-9]{3}\\s*(?<gradientName>[a-zA-Z]{2,11}\\s[a-zA-Z]{2,11})\\s*(?<hexCode1>#[0-9a-fA-F]{6})|(?<hexCode2>#[0-9a-fA-F]{6})")
} catch {
    print(error)
}

let result = namedCaptureGroupsInMatches(of: pattern!, against: myString!)

print(result)

My function looks like this:
func namedCaptureGroupsInMatches(of regularExpression:NSRegularExpression, against string:String) -> [[String:Substring?]] {
    let names = namedCaptureGroups(inRegularExpression: regularExpression)

    let ms = regularExpression.matches(in: string, options: [],
                                         range:NSRange(string.startIndex..<string.endIndex,
                                                       in:string))
    return ms.map({ (tcr:NSTextCheckingResult) -> [String:Substring?] in
        let keyvalues = names.map({ (name:String) -> (String,Substring?) in
            let captureGroupRange = tcr.range(withName: name)
            if captureGroupRange.location == NSNotFound {
                return (name,nil)
            } else {
                return (name,string[Range(captureGroupRange, in: string)!])
            }
        })

        return Dictionary(uniqueKeysWithValues: keyvalues)
    })
}

func namedCaptureGroups(inRegularExpression regularExpression:NSRegularExpression) -> [String]
{
  let regexString = regularExpression.pattern
  let captureGroupNames = try! NSRegularExpression(pattern: "\\(\\?\\<(\\w+)\\>", options: [])
  let groupNameMatches = captureGroupNames.matches(in: regexString, options: [],
                                      range: NSRange(regexString.startIndex..<regexString.endIndex,
                                                     in:regexString))
  let names = groupNameMatches.map { (textCheckingResult) -> String in
    return (regexString as NSString).substring(with: textCheckingResult.range(at: 1))
  }
  return names
}

Any ideas?

A: You problem is that you did not escape the | so it was interpreted as alternative (same as "or") and your full match would not include the second hexa. You just need to escape it to match it literally:
let pattern = #"[0-9]{3}\s*(?<gradientName>[a-zA-Z]{2,11}\s[a-zA-Z]{2,11})\s*(?<hexCode1>#[0-9a-fA-F]{6})\|(?<hexCode2>#[0-9a-fA-F]{6})"#
do {
    let regex = try NSRegularExpression(pattern: pattern)
    let result = namedCaptureGroupsInMatches(of: regex, against: myString)
    print(result)
} catch {
    print(error)
}


text:
Q: Pip command for updating python3-matplotlib 1.3.1-1ubuntu5 How can I update my package "python3-matplotlib 1.3.1-1ubuntu5" using pip and github? I need to update because I have some rendering problems in Ubuntu 14.04.
See: https://github.com/matplotlib/matplotlib/issues/2976 for more details.
I used:
 sudo pip3 install matplotlib --upgrade

but that didn't upgrade the right package (I don't really know).


text:
Q: Powershell Script to extract Outlook .msg files Data and Rename .msg file using Msg data (e.g. Date Sent, Topic) Newby to Stackoverflow so apologies if this request is in the wrong location.
I'm also new to PowerShell and have been researching a solution that appears to be offered by PowerShell. My lack of experience has left me unable to modify an example script so I'm here looking for help.
My objective is to rename many outlook .msg files, located in folders and sub-folders, using data extracted from each .msg file. In my case, I require the date sent (Senton) (and topic, but less important). This is currently, and painfully, being done manually and takes a long time so I thought we needed something to semi-automate a solution.
I've searched around on various forums and blogs and have found a script that seems to be heading towards what I want (details below) but I just don't have the skills to do the last bit of taking the Sent Date and changing the .msg filename. I've attempted various piping solutions referring to variable $msg.Senton. The PowerShell debugger indicates that the line with comment "My code changes" have good values but produces an error (relating to parameter NewName) for each object iteration (see below).
Any help in making progress will be appreciated. In the mean time, I'll continue experimenting with the debugger.
The script was sourced from this (http://jon.glass/blog/reads-e-mail-with-powershell/) site and the script looks like...
Get-ChildItem "C:\Users\higginsr4\Test\StudyExamples\SmallMsgFolder" -Filter *.msg|
ForEach-Object{
    $outlook = New-Object -comobject outlook.application
    $msg = $outlook.CreateItemFromTemplate($_.FullName)
    $msg | Select senderemailaddress,to,subject,Senton,body|ft -AutoSize
    $msg | Rename-Item -NewName { $msg.Senton + $_.name} ## My code changes
    }

PowerShell debugger error...

Rename-Item : The input to the script block for parameter 'NewName' failed. Cannot convert argument "1", with value: "", for "op_Addition" to type "System.TimeSpan": "Cannot
  convert null to type "System.TimeSpan"."
  At My Documents\WindowsPowerShell\Modules\GetEmailDetails\RobsGetEmailDetails.ps1:6 char:33
  +     $msg | Rename-Item -NewName { $msg.Senton + $_.name}
  +                                 ~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (System.__ComObject:__ComObject) [Rename-Item], ParameterBindingException
      + FullyQualifiedErrorId : ScriptBlockArgumentInvocationFailed,Microsoft.PowerShell.Commands.RenameItemCommand

I'm using Windows 7 Enterprise but if further details are required then please let me know.

A: A couple of things to be highlighted in what you have tried:-

*

*$msg is a ComObject created by by the base type System.MarshalByRefObject and not an actual physical file. Hence, you are sort of deviating from your objective there.

*You are including the -NewName parameter in a script block. Note that, you have already done that when you piped the output of Get-ChildItem to Foreach-Object. Hence, the extra script block is redundant.
You can do something like this -
Get-ChildItem "C:\Users\higginsr4\Test\StudyExamples\SmallMsgFolder" -Filter  *.msg |
ForEach-Object{
    $outlook = New-Object -comobject outlook.application
    $msg = $outlook.CreateItemFromTemplate($_.FullName)
    $msg | Select senderemailaddress,to,subject,Senton,body|ft -AutoSize
    Rename-Item -LiteralPath $_.FullName -NewName "$($_.Basename)_$($msg.Senton.ToString('ddMMyy')$($_.Extension)"
    }


text:
Q: Error (CS0501): 'Script_Instance.myComponents.oPoints()' must declare a body because it is not marked abstract, extern, or partial (line 101) In c# in grasshopper, I defined a list and add the data(points) inside this list, but the data is not available in this list.
 private void RunScript(List<Point3d> iPoints, Point3d iTarget, ref object A)
  {

    myComponents.Target = iTarget;

    myComponents.oPoints = iPoints;

...

    A = oPoints;
  }

  public class myComponents

  {
    public static List<Point3d> oPoints(); //this is where the coding is wrong

...

  }

I expect in oPoints list there would be the points from iPoints, but there is nothing, and the error message is:
Error (CS0501): 'Script_Instance.myComponents.oPoints()' must declare a body because it is not marked abstract, extern, or partial (line 101)

A: If you intended to define a method you'd have to declare a body:
public static List oPoints()
{
    //Body
}

If you intended to define a field you need to remove the ().
public static List oPoints;


text:
Q: Extract Data from API and show in another page This question may sound silly to some people, but I am really confused on how to do it
I have 3 file: App.js, HomePage.js and Profile.js
App.js :
import React from "react"
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import HomePage from "./components/HomePage";
import Profile from "./components/Profile"

function App() {
  return (
    <Router>
      <Switch>
        <Route path="/" exact component={HomePage} />
        <Route exact path="/profile/:profileId" component= {Profile} />
      </Switch>
    </Router>
  );
}
export default App;

From here, the default page it will go to is HomePage.js
HomePage.js:
import React, { Component } from "react";
import axios from "axios";
import { Link } from "react-router-dom";

class HomePage extends Component {
    constructor() {
        super();
        this.state = {
            userData: [],
        }
    }
    componentDidMount() {
        axios.get("XXXXXXXX").then((response) => {
            const userDataList = response.data.users;
            this.setState({
                userData: userDataList
            })
        })
    }
    render() {
        const userGrid = this.state.userData.map((user, index) => {
            return (

                    <Link to={`/profile/${user.id}`}>

{user.name}

                    </Link>

            )
        })
        return (

Select An Account

                            {userGrid}

        )
    }
}

export default HomePage;

In HomePage.js, I am able to show the profile picture and name of the user from API.
In the next page which is Profile.js , I am able to print the ID of the user.
Profile.js:
import React, { Component } from "react";

class Profile extends Component{

    componentDidMount(){
        const uid = this.props.match.params.profileId;
    }
    render() {
        console.log(this.props.match);
        return(

{this.props.match.params.profileId}

        )
    }
}
export default Profile;

As you can see I am printing the ID of user.
Here I also want to show the Profile Picture of the user which I selected in HomePage.js
This I am not able to do it.
JSON file:
{ - users: [-{id:1, name:"abc", profilepicture: "xxxxx.jpeg"}, ]}

A: You need to store a global state in your applicattion, which you can access from every connected component. This is a more complex topic. redux is a good framework to handle your global state changes.
Here is a tutorial: https://appdividend.com/2018/06/14/how-to-connect-react-and-redux-with-example/
I found it pretty hard to learn redux, but in the end it takes away a lot of pain. Because this is a problem you gonna have in every app you build with react.

A: You need use Context API o redux
Example context API: https://ibaslogic.com/react-context-api/
Context's well to little projects, but Redux performs better.

A: App.js
import React from "react"
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import HomePage from "./components/HomePage";
import Profile from "./components/Profile"
import { UsersProvider } from "./UsersProvider.js";

function App() {
  return (
    <Router>
      <UsersProvider>
        <Switch>
          <Route path="/" exact component={HomePage} />
          <Route exact path="/profile/:profileId" component= {Profile} />
        </Switch>
      </UsersProvider>
    </Router>
  );
}
export default App;

UsersContext.js
import React, { Component } from "react"

const UsersContext = React.createContext();
const UsersProvider = UsersContext.Provider;
const UsersConsumer = TodosContext.Consumer;

class MyContext extends Component {
  state = {
   value: null,
  };

  setValue = (value) => {
    this.setState({ value });
  };

  render() {
    return (
      <UsersProvider value={{ setValue, value }}>{this.props.children}
      </UsersProvider>
    )
  }
}

export { UsersContext, UsersProvider, UsersConsumer }

HomePage.js
import React, { Component } from "react";
import axios from 'axios';

class HomePage extends Component {

    componentDidMount() {
        axios.get("XXXXXXXX").then((response) => {
            const userDataList = response.data.users;
            // updating your context
            this.props.context.setValue(userDataList);
        })
    }

    render() {
       const userGrid = this.props.context.value.map((user, index) => {
        return (

                <Link to={`/profile/${user.id}`}>

{user.name}

                </Link>

        )
    })
    return (

Select An Account

                        {userGrid}

    )
}
}

export default HomePage;

Profile.js
import React, { Component } from "react";
import { UsersConsumer } from "./UsersContext.js";

class Profile extends Component{

    render() {
        return(
          <UsersConsumer>
            {users => (

{users.value.find(user => user.id === this.props.match.params.profileId)}

            )}
          </UsersConsumer>
        )
    }
}

export default Profile;


text:
Q: CSS to mimic simple table within div I have used some AJAX to output HTML to a div.
I thought the AJAX would let me display a table, but since it outputs to a div, turns out, it does not.   codes etc. are ignored.  I know that table-less display is considered better, anyway, however I am very weak in CSS.
Can anyone suggest how to display the following simple output without tables.  I mainly need to make columns line up when text is different length.
HTML

Output I would like to go into div except not sure how to put table in div:

Heading

Short text option 1	<input type="checkbox">

Really long text Option 2

A: All you need to do, in simplified form is:
var output = '
Heading

Short text option 1	<input type="checkbox">

Really long text Option 2	<input type="checkbox">
',
    table = $('
').appendTo('#displayhere'),
    tbody = $('
').html(output).appendTo(table);

JS Bin demo.

A: You can have tables inside div tags..the following works fine

    Heading

    Short text option 1
    <input type="checkbox">

    Really long text Option 2
     <input type="checkbox">

A: As @DavidThomas implies, you can have an HTML table inside a
, you just can't have
 tags without wrapping them in a
 tag.
I'd note that the HTML you want to insert can also be improved in a couple of ways:

*

*There is a tag for heading cells inside tables: . If the heading applies to several rows, then you should wrap those rows in a
 tag, and set the scope attribute of the  to rowgroup

*When you're labelling a form control, you should wrap the label text in a  element, and set the 's for attribute to the id of its form control.
Here's the improved code. Screen reader users will find it easier to deal with this code:

        Heading

        Short text option 1
        <input id="option1" type="checkbox">

        Really long text Option 2
        <input id="option2" type="checkbox">


text:
Q: Selenium handling the opened file dialog with java I am new to browser automation and learning selenium. I have managed to set up jar dependencies and the driver dependency too. It is opening the webpage.., detecting the loading of the page and also detecting element is available to click. But it has opened a select file dialog box and i am unable to select file via selenium.
Here is my java code :
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");

WebDriver driver = new ChromeDriver(options);
driver.get("https://xyz.abc.pqr");

try
{
    WebDriverWait wait = new WebDriverWait(driver, 60);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("element_id_1")));

    System.out.println("Loaded and in....");

    WebElement AttachMenu = driver.findElement(By.className("Class_1"));
    AttachMenu.click();
    System.out.println("Clicked Attach menu....");

    // <input type="file" accept="image/*,video/*" multiple="" style="display: none;">

    // As you can see above input element is not having any id or class

    // How do i sendkeys to above input element that has opened dialog

    // this is the question...

}
catch (TimeoutException e)
{
    System.out.println("Element not found...");
}

// driver.quit();

IT IS NOT UPLOAD IT IS JUST SELECTION OF FILE; I WILL CLICK ON UPLOAD BUTTON THEREAFTER...
Any help / inputs will be appreciated and thank you in advance for giving your valuable time over this question.

A: There were two issues :

*

*How to click <div role="button" title="Attach"> button; which has no class and no id

*How to sendkeys to <input type="file" accept="image/*,video/*" multiple="" style="display: none;"> which also has no class and no id.

It has been solved after a lots of try and errors as ...
driver.findElement(By.xpath("//div[@title='Attach']")).click();
System.out.println("Attach clicked....");

WebElement MediaButton = driver.findElement(By.className("xyzmm"));
MediaButton.click();

System.out.println("Select clicked....");
WebElement uploadElement = driver.findElement(By.xpath("//input[@accept='image/*,video/*']"));

uploadElement.sendKeys("/Users/Apple/Desktop/logos/Team1.png");

Still uploadElement dialog is visible.. and how to execute javascript to make it display none is in question..., trying on it now... The question has been resolved


text:
Q: aws-sdk-go-v2 set custom header on PutObjectInput I am in a situation where i need to set a custom header on putting an object to an s3 compatible storage system.
    _, err := uploader.Upload(ctx, &s3.PutObjectInput{
    Bucket: aws.String(util.GlobalConfig.S3.Bucket),
    Key:    aws.String(filename),
    Body:   w,
    ContentMD5: func() *string {
        h := md5.New()
        h.Write(w.Bytes())
        return aws.String(base64.StdEncoding.EncodeToString(h.Sum(nil)))
    }(),
    Metadata:                  metadata,
    ObjectLockMode:            types.ObjectLockModeCompliance,
    ObjectLockRetainUntilDate: &objectLockTime,
})

How can one specify a custom header?

A: You can do this by registering BuildMiddleware to the middleware stack. Please see Customizing the AWS SDK for Go V2 Client Requests for more information.
Here is a simple example:
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/credentials"
    "github.com/aws/aws-sdk-go-v2/feature/s3/manager"
    "github.com/aws/aws-sdk-go-v2/service/s3"
    "github.com/aws/smithy-go/middleware"
    smithyhttp "github.com/aws/smithy-go/transport/http"
)

func SetHttpHeader(key, value string) func(*middleware.Stack) error {
    return func(stack *middleware.Stack) error {
        return stack.Build.Add(middleware.BuildMiddlewareFunc("IDoEVaultGrant", func(
            ctx context.Context, in middleware.BuildInput, next middleware.BuildHandler,
        ) (
            middleware.BuildOutput, middleware.Metadata, error,
        ) {
            switch v := in.Request.(type) {
            case *smithyhttp.Request:
                v.Header.Add(key, value)
            }
            return next.HandleBuild(ctx, in)
        }), middleware.Before)
    }
}

func main() {
    client := s3.New(s3.Options{
        Credentials: credentials.NewStaticCredentialsProvider("your-key-id", "your-key-secret", ""),
    }, s3.WithAPIOptions(SetHttpHeader("key", "value")))

    uploader := manager.NewUploader(client, func(uploader *manager.Uploader) {
        uploader.PartSize = 64 * 1024 * 1024 // 64MB
    })

    file, err := os.Open("your-file")
    if err != nil {
        fmt.Println(err)
        return
    }

    output, err := uploader.Upload(context.TODO(), &s3.PutObjectInput{
        Bucket: aws.String("your-bucket"),
        Key:    aws.String("your-key"),
        Body:   file,
    })
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(output.Location)
    return
}


text:
Q: Plot in Improved Euler's Method problem It is given the following problem:
$$x'=rx-bx^2-cxy-\frac{\beta xy}{\alpha+x}$$
$$y'=-\mu y+\frac{\beta xy}{\alpha+x}$$
With parameters $r=1,b=1,c=0.01, \mu=0.4,\alpha= 0.36$ and initial values $x(0)=0.2, y(0)=0.05$
I have solved this problem with the NDSolve command
r = 1;
b = 1;
c = 0.01;
a = 0.36;
\[Mu] = 0.4;
deq1 = x'[t] ==
  r* x[t] - b*x[t]^2 - c*x[t]*y[t] - 0.75*x[t]*y[t]/(a + x[t])
deq2 = y'[t] == -\[Mu]*y[t] + 0.75*x[t]*y[t]/(a + x[t])
soln = NDSolve[{deq1, deq2,  x[0] == 0.2, y[0] == 0.05}, {x[t], y[t]}, {t, 0, 200}]
soln[t_] =
   NDSolveValue[{deq1, deq2, x[0] == 0.2, y[0] == 0.05}, {x[t],
       y[t]}, {t, 0, 200}];
Plot[soln[t], {t, 0, 200}, PlotRange -> All]

Now, I am trying the same with the Improved Euler's Method
UPDATED
r = 1;
b = 1;
c = 0.01;
a = 0.36;
\[Mu] = 0.4;
f[x_,y_]:=r* x[t] - b*x[t]^2 - c*x[t]*y[t] - 0.75*x[t]*y[t]/(a + x[t])
g[x_,y_]:=y'[t] == -\[Mu]*y[t] + 0.75*x[t]*y[t]/(a + x[t])
Q[a_, b_, h_, N_] := (u[0] = a; v[0] = b;
  Do[{u[n + 1] =
     u[n] + h*
       F[u[n] + (h/2)*F[u[n], v[n]],
        v[n] + (h/2)*
          G[u[n], v[
            n]]],                                                     \

    v[n + 1] =
     v[n] + h*
       G[u[n] + (h/2)*F[u[n], v[n]], v[n] + (h/2)*G[u[n], v[n]]]}, {n,
     0, N}])
Q[0.2, 0.05, 1,200]
u[200]
X = Interpolation[Table[{0.05 n, u[n]}, {n, 0, 100}]]
Y = Interpolation[Table[{0.05 n, v[n]}, {n, 0, 100}]]
ParametricPlot[{X[t], Y[t]}, {t, 0, 200}]

I have run this code on Mathematica but it did not give me results for the plot.

A: There are several small issues in your code. I would list the most important:

*

*in your g[x_, y_] definition you forgot to delete y'[t], (as you properly did for f)

*in the rhs of your f and g, x and y are the variables -- in actuality they will be elements of a vector, so the dependence on t should be erased: use just x and y not x[t], y[t].

*your Euler formula uses F and G, while the functions you defined are f and g

*there are some inconsistencies with regards to the maximum t for your integration.

The code below, based on yours, attempts (and succeeds) to create the same graphic as the NDSolve version:
r = 1;
b = 1;
c = 0.01;
a = 0.36;
\[Mu] = 0.4;
f[x_,y_]:=r* x - b*x^2 - c*x*y - 0.75*x*y/(a + x);
g[x_,y_]:= -\[Mu]*y + 0.75*x*y/(a + x);
Q[a_, b_, h_, N_] := (
  u[0] = a; v[0] = b;
    Do[{
       u[n + 1] =  u[n] + h *f[u[n] + h/2*f[u[n], v[n]],v[n] + h/2* g[u[n], v[n]]],
       v[n + 1] =   v[n] + h  *g[u[n] + h/2*f[u[n], v[n]], v[n] + h/2*g[u[n], v[n]]]
    }, {n,0, N-1}]);
Q[0.2, 0.05, 1,200];
X = Interpolation[Table[{ n, u[n]}, {n, 0, 200}]];
Y = Interpolation[Table[{n, v[n]}, {n, 0, 200}]];
Plot[{X[t], Y[t]}, {t, 0, 200}]


text:
Q: Bootstrap 3 two columns in container with 100% width backgrounds can anybody help me to make in bootstrap 3 layout with 2 columns with background with 100% width?
Example:

A: Are you having trouble with the columns staying within the container? The columns also need to be in a row. This article may help: http://www.helloerik.com/the-subtle-magic-behind-why-the-bootstrap-3-grid-works
If you want two columns beside each other this is one way to do it.

UPDATE:
For a solution to this question see here: http://bootply.com/Y8SX4b3F6g

A: the correct way is set the background to the row width 50% width:
html:

left

right

CSS:
.row {
background-color: #e1e2e4;
background-image: url('image.jpg');
background-repeat: no-repeat;
background-size: 50% 100%;
}

bootply:
http://www.bootply.com/yDCLfN2DSb


text:
Q: Showing things one by one on screen in React/Redux Say I have the following in my React application in which my reducer holds the following state:
{
 array: ["Person 1", "Person 2", "Person 3"];
}

What I want to do is this. I want the user to press the space bar and Person 1 is shown on the screen. I want the user then to press the space bar again, and to Person 1 Person 2 is added on the screen, and so on.
I have no idea how to do this, how I could control in Redux how many of the people on the list to show.
I am sorry for this very basic question, I am fairly new to React/Redux. I know how I could just go through the array and always show one person at a time, or all at once with a map function. But i am struggling with the idea of adding them gradually to the view.

A: There are many ways to do this, here's one:
export class App extends Component {
  constructor(props){
    super(props)
    this.state = {
      players: [],
      currentPlayer: 0
    }
  }
  componentDidMount() {
    document.addEventListener('keypress', (e) => {
      if (e.keyCode !== 32) return;
      this.setState({ currentPlayer: currentPlayer + 1 })
      // You should check beforehand if you are in the last index of your array, but I'll not do it here.
    });
  }
  // You need to remove the event Listener on willUnmount as well
  render() {
    if (!this.state.players.length)
      return <div> No Players </div>
    return (
      <div>{this.state.players[this.state.currentPlayer]}</div>
    )
  }

This is some basic structure, without redux. You can add redux later, but I suggest you learn the basics of React before jumping to Redux


text:
Q: R: use bin counts and bin breaks to get a histogram I generated a random vector from normal distribution and plotted a histogram.
I modified the counts of the each bin and I want to plot another histogram with the same breaks(break_vector) and the new bin count vector (new_counts).
How to do that?
I tried barplot(), but the way it displays the bin labels is different.
x = rnorm(500,1,6)
delta = 1
break_vector = seq(min(x)-delta,max(x)+delta,by=delta)
hist_info = hist(x,breaks=break_vector)

new_counts = hist_info$counts+5

A: Try
new_hist <- hist_info
new_hist$counts <- hist_info$counts + 5
plot(new_hist)


text:
Q: System.Windows.Application.GetResourceStream returns null If I debug a WPF-application with Catalog.xaml as Content, I can't get the resource stream of it - GetResourceStream returns null:

var uri = new Uri("/Assembly;component/Catalog.xaml", UriKind.Relative);
var foo = System.Windows.Application.GetResourceStream(uri);

foo is null. What am I doing wrong?

A: I believe for type Content you only need the item name:
var uri = new Uri(**"Catalog.xaml"**, UriKind.Relative);
var foo = System.Windows.Application.GetResourceStream(uri);