text:
Q: What changes when a case class has a companion object? I originally encountered the behavior below, where code that worked fine when a case class didn't have a companion object would fail to compile when that companion object was defined. I was able to fix it by calling Bar.apply _ instead of simply Bar, but I still don't understand why that is necessary.
I'm trying to use the product-collections library from https://github.com/marklister/product-collections, and it will happily parse a CSV into a case class, but only if that case class has no companion object. This is puzzling, especially since the documentation suggests that the companion object is the ideal place to put additional implicit converters.
I see identical behavior if I define the case class and object in the opposite order, and what I see in the REPL matches my IDE.
What is the effect of defining a companion object to a case class? I would expect it to be precisely nothing, since the companion object (with apply and unapply methods) is already defined by virtue of being a case class.
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111).
Type in expressions for evaluation. Or try :help.

scala> import com.github.marklister.collections.io.CsvParser
import com.github.marklister.collections.io.CsvParser

scala> case class Foo(i: Int, d: Double, s: String)
defined class Foo

scala> case class Bar(i: Int, d: Double, s: String); object Bar {}
defined class Bar
defined object Bar

scala> CsvParser(Foo).parse(new java.io.StringReader("1, 2.4,\"hi\"\n3, 8.9,\"bye\""))
res0: Seq[Foo] = List(Foo(1,2.4,hi), Foo(3,8.9,bye))

scala> CsvParser(Bar).parse(new java.io.StringReader("1, 2.4,\"hi\"\n3, 8.9,\"bye\""))
<console>:14: error: overloaded method value apply with alternatives:
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => F)com.github.marklister.collections.io.CsvParserF22[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => F)com.github.marklister.collections.io.CsvParserF21[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => F)com.github.marklister.collections.io.CsvParserF20[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => F)com.github.marklister.collections.io.CsvParserF19[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => F)com.github.marklister.collections.io.CsvParserF18[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => F)com.github.marklister.collections.io.CsvParserF17[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => F)com.github.marklister.collections.io.CsvParserF16[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => F)com.github.marklister.collections.io.CsvParserF15[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => F)com.github.marklister.collections.io.CsvParserF14[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => F)com.github.marklister.collections.io.CsvParserF13[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => F)com.github.marklister.collections.io.CsvParserF12[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => F)com.github.marklister.collections.io.CsvParserF11[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => F)com.github.marklister.collections.io.CsvParserF10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, T9, F](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9) => F)com.github.marklister.collections.io.CsvParserF9[T1,T2,T3,T4,T5,T6,T7,T8,T9,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, T8, F](f: (T1, T2, T3, T4, T5, T6, T7, T8) => F)com.github.marklister.collections.io.CsvParserF8[T1,T2,T3,T4,T5,T6,T7,T8,F] <and>
  [T1, T2, T3, T4, T5, T6, T7, F](f: (T1, T2, T3, T4, T5, T6, T7) => F)com.github.marklister.collections.io.CsvParserF7[T1,T2,T3,T4,T5,T6,T7,F] <and>
  [T1, T2, T3, T4, T5, T6, F](f: (T1, T2, T3, T4, T5, T6) => F)com.github.marklister.collections.io.CsvParserF6[T1,T2,T3,T4,T5,T6,F] <and>
  [T1, T2, T3, T4, T5, F](f: (T1, T2, T3, T4, T5) => F)com.github.marklister.collections.io.CsvParserF5[T1,T2,T3,T4,T5,F] <and>
  [T1, T2, T3, T4, F](f: (T1, T2, T3, T4) => F)com.github.marklister.collections.io.CsvParserF4[T1,T2,T3,T4,F] <and>
  [T1, T2, T3, F](f: (T1, T2, T3) => F)com.github.marklister.collections.io.CsvParserF3[T1,T2,T3,F] <and>
  [T1, T2, F](f: (T1, T2) => F)com.github.marklister.collections.io.CsvParserF2[T1,T2,F] <and>
  [T1, F](f: T1 => F)com.github.marklister.collections.io.CsvParserF1[T1,F]
 cannot be applied to (Bar.type)
       CsvParser(Bar).parse(new java.io.StringReader("1, 2.4,\"hi\"\n3, 8.9,\"bye\""))
       ^

scala> CsvParser(Bar.apply _).parse(new java.io.StringReader("1, 2.4,\"hi\"\n3, 8.9,\"bye\""))
res1: Seq[Bar] = List(Bar(1,2.4,hi), Bar(3,8.9,bye))

A: The auto generated companion object of your case class Foo will extend (Int, Double, String) => Foo. If you define the companion object yourself for the case class Bar the compiler will no longer automatically add that inheritance relation.
For more information you can take a look at SI-3664.


text:
Q: Python Executable, PermissionError: [WinError 5] I'm trying to write a chatting app that when run the first time deletes itself from the current position. Now the code is:
import os
import sys

file=sys.argv[0]
os.remove(file)

if i run it as .py file, it works just fine. Anyway if compile it with pyinstaller, when run by terminal it raises:
Traceback (most recent call last):
  File "tests.py", line 6, in <module>
PermissionError: [WinError 5] Denied access: 'tests.exe'
[14320] Failed to execute script 'tests' due to unhandled exception!

nothing changes if i run it as administrator or assigning the file permissions with os.chmod. I have python 3.10, i tried both with python 3.9 and 3.10 and it does not work. I even tried running the command del with the subprocess module with the same result.

A: This works as .py file because the actual executable is the compiled version of the source code - a separate file/memory space. While the compilation is running the source code .py file is closed and can be removed.
When the program is compiled and run as a .exe file it will not remove itself because it is still open and running and therefore has a permission access denied error.
It is trying to remove itself because file = sys.argv[0]
(If you want to remove your running exe maybe start another program that does the removing from the exe and exit exe so that it is closed before removal - kind of awkward.)

redpajama_set_name: RedPajamaStackExchange


text:
Q: GEE NDVI time series for multiple polygons each with its own date range My question extends one asked recently and I am working with the code suggested there as answer:
This script takes a set of polygons and for each, averages NDVI over all images within the specific date range associated with it. Naturally the NDVI is reduced (averaged) to the polygon as well. It returns a feature for each polygon, with the averaged NDVI over the polygon and date range.
I have been trying to get all NDVI value within each date range, rather than averaging them. The result should be, for each polygon, a single mean-reduced (averaged for the polygon's pixels) NDVI value for each image within the range associated with the polygon.
I am stuck in the reduceRegion function. I have been trying to map it onto the NDVI images in order to add one averaged NDVI value to the feature for each image. Ideally the feature would have one NDVI value for each date. I think I can figure out myself then how to write the dates themselves to the file.
// var cohort = ee.FeatureCollection("users/miki98k/temp") // Unable to share the dataset unfortunately
var cohort = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([10, 0]).buffer(1000), {start_date: '2020-01-01', end_date_a: '2020-04-01'}),
  ee.Feature(ee.Geometry.Point([11, 0]).buffer(1000), {start_date: '2020-01-01', end_date_a: '2020-04-01'})
])
// in the real dataset, start_date and end_date_a vary between features

var l7 = ee.ImageCollection("LANDSAT/LE07/C02/T1_L2")
var results = cohort.map(calculateSeries)
print(results)

function calculateSeries(feature) {
  var sdate = ee.Date(feature.get('start_date'))
  var edate = ee.Date(feature.get('end_date_a'))
  var roi = feature.geometry()

  var filt_img = l7
    .filterDate(sdate, edate)
    .filterBounds(roi)
    .filterMetadata('CLOUD_COVER', 'less_than', 100)

  var ndvi_func = function(i) {
    var ndvi = i.normalizedDifference(['SR_B4', 'SR_B3']).rename('NDVI')
    return i.addBands(ndvi)
  }

  var ndvis = filt_img.map(ndvi_func)
    .select('NDVI') // Only NDVI band is needed

  // stuck here
  return ee.Feature(
    feature.geometry(),
    ndvis.reduceRegion({ // Mean over the roi
      geometry: roi,
      reducer: ee.Reducer.mean(),
      scale: 30
    })
  )
}

A: Following version of your code can extract all individual NDVI values involved in mean calculation for each feature (last value is feature average). I used different date ranges for corroborating that code works as expected related to dates.
// var cohort = ee.FeatureCollection("users/miki98k/temp") // Unable to share the dataset unfortunately
var cohort = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([10, 0]).buffer(1000), {start_date: '2020-01-01', end_date_a: '2020-04-01'}),
  ee.Feature(ee.Geometry.Point([11, 0]).buffer(1000), {start_date: '2020-01-01', end_date_a: '2020-06-01'})
]);

Map.addLayer(cohort);
Map.centerObject(cohort);

// in the real dataset, start_date and end_date_a vary between features

var l7 = ee.ImageCollection("LANDSAT/LE07/C02/T1_L2")
  .filterMetadata('CLOUD_COVER', 'less_than', 100);

//print(l7.size());

var cohort_lst = cohort.toList(cohort.size());

print(cohort_lst);

function calculateSeries(feature) {

  var sdate = ee.Date(ee.Feature(feature).get('start_date'));
  var edate = ee.Date(ee.Feature(feature).get('end_date_a'));
  var roi = ee.Feature(feature).geometry();

  var filt_img = l7
    .filterDate(sdate, edate)
    .filterBounds(roi);

  var ndvi_func = function(i) {
    var ndvi = i.normalizedDifference(['SR_B4', 'SR_B3']).rename('NDVI');
    return i.addBands(ndvi);
  };

  var ndvis = filt_img.map(ndvi_func)
    .select('NDVI'); // Only NDVI band is needed

  var getNDVI = function(image) {

  var value_NDVI = ee.Image(image)
    .reduceRegion(ee.Reducer.mean(), ee.Feature(roi).geometry())
    .get('NDVI');

    return value_NDVI;

  };

  var NDVI_list = ndvis.toList(ndvis.size()).map(getNDVI);

  NDVI_list = NDVI_list.add(NDVI_list.reduce(ee.Reducer.mean()));

  return NDVI_list;

}

var ndviListMean = cohort_lst.map(calculateSeries);

print("ndviListMean", ndviListMean);

After running above code in GEE code editor, I got following result. Values into red rectangles are the average of above individual values (4 and 7 values; respectively). These list values can be easily exported to Google Drive by using a label for each feature (not included in this code).


text:
Q: How to run again that cronjob when the same job finished I have a cron job that runs every 20 minutes from 9-5. Here is the code:

*/20 09-05 * * *

I want it set so that if the job ends in 10 minutes, it starts again automatically. When the scheduled time exceeds 20 minutes, the next job runs when the first is finished. It is a python server running on an Ubuntu operating system.
According to crontab.guru:

// * * * * *  // It runs after every minute

So, if anyone have any solution, please reply me.


text:
Q: google maps not rendering in a nested div I am using [this][1] tutorial to render google map on my webpage. It works fine when I use it in the way it's in this tutorial. But it doesn't render on my webpage.
I have a tabbed webpage. Each tab content is opened with a div containing its id. So when I put the div with the id of map which is used by render map function to render map, it's inside the div of a Live Map tab. And it's not working.
Here is my code:
Tabbed HTML on my webpage:

 //tabs defined
  <button class="tablinks" onclick="openCity(event, 'tab1')">tab1</button>
  <button class="tablinks" onclick="openCity(event, 'tab2')">tab2</button>
  <button class="tablinks" onclick="openCity(event, 'Live-Map')">Live Map</button>

 //map div inside tab div

  //map div

EDIT
CSS
This is css. Trying solutions from other sources, I found the height of the parent div needs to be made 100%. I did that too but still no success.
 #map {
   height: 100%;
 }
#Live-Map {
   height: 100%;
 }
 /* Optional: Makes the sample page fill the window. */
 html, body {
 height: 100%;
 margin: 0;
 padding: 0;
}

EDIT
I solved the problem with bit search. The problem basically was have to give the wrapper div also 100% height & width and also to the bootstrap container div. Because Google API requires these parameters to render,
 #Live-Map, #map {
       height: 100%;
        width: 100%;
     }
   /* Optional: Makes the sample page fill the window. */
     html, body {
     height: 100%;
     width: 100%;
     margin: 0;
     padding: 0;
}

A: if the map  is not visible during first presentation the map don't work  .. in this case you could  add the code for initMap direcly in you openCity function
    function openCity(evt, cityName) {

    var map = new google.maps.Map(document.getElementById('map'), {
          center: new google.maps.LatLng(60.378920, 24.741850),
          zoom: 7
        });

    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(cityName).style.display = "block";
    evt.currentTarget.className += " active";
}


text:
Q: Jython ignores jythonpath My jython script is using Apache Tika, and it fails to load the Tika jar even though I placed it both in CLASSPATH and in PYTHONPATH. Here's what I'm doing:
> export JYTHONPATH=/full_path_to/tika-app-1.5.jar
> export CLASSPATH=/full_path_to/tika-app-1.5.jar
> java -Xmx512m -Xss1024k -jar /full_path_to/jython-standalone-2.7-b2.jar \
     -c 'from org.apache.tika import *'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named apache

I'm using Jython 2.7 beta 2 on OSX. Java version is 1.8:
> java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

The same thing is happening on Amazon's EC2 Linux with Java 1.7.
When I'm using the non-standalone version of the jython jar (jython-2.7-b2.jar instead of jython-standalone-2.7-b2.jar), it seems to be working okay.
Any idea what's happening?

A: I think I found the problem. In Java, when using the -jar option, it more or less ignores the classpath. Just have to run the same code but with calling the jython 'main' class directly - not via '-jar'.


text:
Q: 2nd drive not filling up? First of all, i am very new to ubuntu.
I have a laptop running Ubuntu 22.04 LTS on which I run Samba to map the network drives on my main computer.
I added a second HDD so I had more storage, I formatted it to EXT4 and mounted it.
everything works fine, until I wanted to store files there, I went to the share on my main PC, transferred a file and thought that it was working fine, until I noticed that the file was on the main drive instead of the 2nd drive.
I've been searching for a couple of hours now but i can't find anything that fixes this.
let me know if there's anything you need
Edit:
The mountpoint i created is /media/Eshare this is where the 2nd drive is mounted to.
my smb.conf to create the share points:
[name]
comment = energy samba share
path = /home/energy/energy-share
read only = no
browsable = yes
guest ok = no
[name]
comment = energy2 samba share
path = /media/Eshare/Share
read only = no
browsable = yes
guest ok = no

A: i want to start off by saying, i am an idiot. The Hard drive was mounted to /mnt/sda1 instead of /media/Eshare. my bad


text:
Q: Handle Azure AAD B2C Login I have an ASP.NET Core Razor application, and want to parse the ClaimsIdentity claims when the user completes the SignUpSignIn flow.
I would go about and edit the asp-area="AzureADB2C" asp-controller="Account" codebehind controller from the _LoginPartial.cshtml but obviously this is injected through the services.AddAzureADB2C() line in the ConfigureServices
The use case is:

*

*I have defined Custom Attributes for my Users

*I want to synchronize these to the database when the user logs on, to later run queries against

How can I regsiter an "event handler" for the Login event?

A: Working code snippet:
services.AddAuthentication(AzureADB2CDefaults.AuthenticationScheme)
    .AddAzureADB2C(options => Configuration.Bind("AzureAdB2C", options));
services.Configure<OpenIdConnectOptions>(AzureADB2CDefaults.OpenIdScheme, o =>
{
    o.Events.OnTokenValidated += async ctx =>
    {
        var value = ctx.Principal.FindFirst("extension_MyCustomExtensionAttribute").Value;

        // Do stuff
    };
});


text:
Q: Undefined objects in a Gruntfile for an old AngularJS application I have an old AngularJS (1) application that used to start fine.
After upgrading my dependencies yesterday, the module and require objects (among others) are now undefined.
// Generated on 2014-10-21 using generator-angular 0.9.8
'use strict';

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  ...

}

Here is my bower.json file content:
{
  "name": "nitro-project",
  "version": "0.0.0",
  "dependencies": {
    "angular": "*",
    "json3": "*",
    "es5-shim": "*",
    "stacktrace": "*",
    "firebase": "*",
    "angular-resource": "*",
    "angular-cookies": "*",
    "angular-sanitize": "*",
    "angular-animate": "*",
    "angular-touch": "*",
    "angular-route": "*",
    "angular-ui-router": "*",
    "angular-translate": "*",
    "angular-base64": "*",
    "angular-bootstrap": "*",
    "angular-utils-pagination": "*",
    "angular-ui-utils": "*",
    "angular-file-upload": "*",
    "a0-angular-storage": "*",
    "sockjs": "*",
    "stomp-websocket": "*"
  },
  "devDependencies": {
    "angular-mocks": "*",
    "angular-scenario": "*",
    "karma-jasmine": "*"
  },
  "appPath": "app",
  "resolutions": {
    "es5-shim": "*",
    "angular": "*",
    "angular-bootstrap": "*",
    "angular-mocks": "*"
  }
}

And the package.json file content:
{
  "name": "nitroproject",
  "version": "0.0.0",
  "dependencies": {},
  "devDependencies": {
    "grunt": "*",
    "grunt-autoprefixer": "*",
    "grunt-concurrent": "*",
    "grunt-contrib-clean": "*",
    "grunt-contrib-concat": "*",
    "grunt-contrib-connect": "^1.0.2",
    "grunt-contrib-copy": "*",
    "grunt-contrib-cssmin": "*",
    "grunt-contrib-htmlmin": "*",
    "grunt-contrib-imagemin": "*",
    "grunt-contrib-jshint": "*",
    "grunt-contrib-uglify": "*",
    "grunt-contrib-watch": "*",
    "grunt-filerev": "*",
    "grunt-google-cdn": "*",
    "grunt-karma": "*",
    "grunt-newer": "*",
    "grunt-ng-annotate": "*",
    "grunt-ng-constant": "*",
    "grunt-svgmin": "*",
    "grunt-usemin": "*",
    "grunt-wiredep": "*",
    "jasmine-core": "*",
    "jshint-stylish": "*",
    "karma": "*",
    "karma-chrome-launcher": "*",
    "karma-jasmine": "*",
    "karma-phantomjs-launcher": "*",
    "load-grunt-tasks": "*",
    "serve-static": "^1.11.2",
    "time-grunt": "*"
  },
  "engines": {
    "node": ">=6.8.1"
  },
  "scripts": {
    "test": "grunt test"
  }
}

I'm running node 6.8.1.
No dependencies are outdated:
[stephane@stephane-ThinkPad-X301 nitro-project]
$ npm outdated
[stephane@stephane-ThinkPad-X301 nitro-project]

The console log shows loads of such lines:
Running "newer:jshint:all" (newer) task

Running "jshint:all" (jshint) task

Gruntfile.js
  line 2    col 1    Use the function form of "use strict".
  line 4    col 1    'module' is not defined.
  line 7    col 3    'require' is not defined.
  line 10   col 3    'require' is not defined.
  line 12   col 21   'require' is not defined.
  line 16   col 10   'require' is not defined.
  line 147  col 19   'require' is not defined.

A: In your project directory I would try:
npm uninstall
npm install -g grunt-cli
npm install

A fresh install of your dependencies (especially Grunt) may be what you need. If not, it's worth a shot before more troubleshooting.


text:
Q: DJango: show different home page based on user.is_staff and request.user.is_authenticated() Here's my simple home page view, which goes somewhere for staff, somehwere else for logged in users, and another for the rest:
def home(request):
    ipdb.set_trace()  ######### Break Point ###########

    if request.user.is_staff:
        redirect('quests:approvals')

    if request.user.is_authenticated():
        redirect('quests:quests')

    return render(request, "home.html", {})

However, the request is empty and has no info in it:
ipdb> request
<WSGIRequest: GET '/'>

What am I doing wrong?
This is just a single view within my main project app
I was previously using:
@user_passes_test(lambda user: not user.get_username(), login_url='myUrl', redirect_field_name=None)
def home(request):
...

Which works fine, except I couldn't figure out how to go somewhere else for staff users.

A: It looks like you forgot a return there.
if request.user.is_staff:
    return redirect('quests:approvals')

if request.user.is_authenticated():
    return redirect('quests:quests')


text:
Q: How to add jquery's .html() in vanilla js? I want to convert jquery to lightweight js. But I get error.
Like I want to use jquery's $('#app').html('test');
var $ = function (method_name) {
return document.querySelector(method_name);
}

$.prototype.html = function (value) {
this.innerHTML = value;
};

$('#app').html('test'); // <--- .html() is not function

How to add .html() in $()?
only $('#app').innerHTML = 'test' is working

A: You can try do it with class:

class MyJQueryObject {
  constructor(query) {
    this.target = document.querySelector(query);
  }

  html(newHTML) {
    if (typeof newHTML !== 'undefined') this.target.innerHTML = newHTML;
    return this.target.innerHTML;
  }
}

const $ = function (query) {
  return new MyJQueryObject(query);
}

const target = $('#target');

console.log(target.html());

target.html('It was easy');

Change me if you can

Also with class you can easily add/remove methods. And the best part that you can define html not as function but as property with the help of getters and setters. For me it is more clearly than check if you pass any argument or not. Example of usage:

class MyJQueryObject {
  constructor(query) {
    this.target = document.querySelector(query);
  }

  get html() {
    return this.target.innerHTML;
  }

  set html(newHTML) {
    this.target.innerHTML = newHTML;
  }
}

const $ = function (query) {
  return new MyJQueryObject(query);
}

const target = $('#target');

console.log(target.html);

target.html = 'It was easy';

Change me if you can


text:
Q: MEAN stack installation gives 304 and 404s I am getting these 304 and 404s when I go to http://myipaddress:3000 after I tried to install the MEAN stack
$ node server
Express app started on port 3000
GET / 304 973ms
GET /lib/bootstrap/js/bootstrap.js 404 371ms
GET /lib/bootstrap/css/bootstrap.css 404 489ms
GET /lib/angular/angular.js 404 371ms
GET /lib/jquery/jquery.js 404 447ms
GET /lib/bootstrap/css/bootstrap-responsive.css 404 453ms
GET /lib/angular-cookies/angular-cookies.js 404 75ms
GET /lib/angular-resource/angular-resource.js 404 217ms
GET /lib/angular-ui-utils/modules/route.js 404 217ms
GET /lib/angular-bootstrap/ui-bootstrap-tpls.js 404 221ms

All these lib/* files are found in public/lib/*.
I am on Ubuntu and did these commands:
1. wget https://codeload.github.com/linnovate/mean/legacy.tar.gz/master -O mean

2. tar -zxvf mean

3. npm install

4. sudo npm install -g bower

5. bower install

where steps 4 and 5 are from this comment. since I was getting the errors even after step 3.
Since people also mentioned a .bowerrc, which I did NOT find anywhere, I created one in the root of the mean directory.
{
  "directory": "public/lib",
  "json": "bower.json"
}

Here is the output of my npm list.
mean@1.0.0 /path/to/linnovate-mean-612b014
├── async@0.2.9
├── connect-flash@0.1.1
├─┬ connect-mongo@0.3.3
│ └─┬ mongodb@1.2.14
│   └── bson@0.1.8
├─┬ express@3.4.0
│ ├── buffer-crc32@0.2.1
│ ├─┬ commander@1.2.0
│ │ └── keypress@0.1.0
│ ├─┬ connect@2.9.0
│ │ ├── bytes@0.2.0
│ │ ├─┬ multiparty@2.1.8
│ │ │ ├── readable-stream@1.0.17
│ │ │ └── stream-counter@0.1.0
│ │ ├── pause@0.0.1
│ │ ├── qs@0.6.5
│ │ └── uid2@0.0.2
│ ├── cookie@0.1.0
│ ├── cookie-signature@1.0.1
│ ├── debug@0.7.2
│ ├── fresh@0.2.0
│ ├── methods@0.0.1
│ ├── mkdirp@0.3.5
│ ├── range-parser@0.0.4
│ └─┬ send@0.1.4
│   └── mime@1.2.11
├─┬ forever@0.10.8
│ ├─┬ cliff@0.1.8
│ │ ├── eyes@0.1.8
│ │ └─┬ winston@0.6.2
│ │   ├── async@0.1.22
│ │   ├── cycle@1.0.2
│ │   ├── pkginfo@0.2.3
│ │   ├── request@2.9.203
│ │   └── stack-trace@0.0.7
│ ├── colors@0.6.0-1
│ ├─┬ flatiron@0.3.5
│ │ ├─┬ broadway@0.2.7
│ │ │ ├── eventemitter2@0.4.11
│ │ │ └─┬ winston@0.6.2
│ │ │   ├── async@0.1.22
│ │ │   ├── cycle@1.0.2
│ │ │   ├── eyes@0.1.8
│ │ │   ├── pkginfo@0.2.3
│ │ │   ├── request@2.9.203
│ │ │   └── stack-trace@0.0.7
│ │ ├── director@1.1.10
│ │ ├─┬ optimist@0.3.5
│ │ │ └── wordwrap@0.0.2
│ │ └─┬ prompt@0.2.9
│ │   ├─┬ read@1.0.5
│ │   │ └── mute-stream@0.0.4
│ │   ├── revalidator@0.1.5
│ │   └─┬ winston@0.6.2
│ │     ├── async@0.1.22
│ │     ├── cycle@1.0.2
│ │     ├── eyes@0.1.8
│ │     ├── pkginfo@0.2.3
│ │     ├── request@2.9.203
│ │     └── stack-trace@0.0.7
│ ├─┬ forever-monitor@1.2.2
│ │ ├─┬ broadway@0.2.7
│ │ │ ├── eventemitter2@0.4.11
│ │ │ └─┬ winston@0.6.2
│ │ │   ├── async@0.1.22
│ │ │   ├── cycle@1.0.2
│ │ │   ├── eyes@0.1.8
│ │ │   ├── pkginfo@0.2.3
│ │ │   ├── request@2.9.203
│ │ │   └── stack-trace@0.0.7
│ │ ├─┬ minimatch@0.0.5
│ │ │ └── lru-cache@1.0.6
│ │ ├─┬ ps-tree@0.0.3
│ │ │ └─┬ event-stream@0.5.3
│ │ │   └─┬ optimist@0.2.8
│ │ │     └── wordwrap@0.0.2
│ │ └── watch@0.5.1
│ ├─┬ nconf@0.6.7
│ │ ├── async@0.1.22
│ │ ├── ini@1.1.0
│ │ ├─┬ optimist@0.3.7
│ │ │ └── wordwrap@0.0.2
│ │ └── pkginfo@0.2.3
│ ├─┬ nssocket@0.5.1
│ │ ├── eventemitter2@0.4.13
│ │ └── lazy@1.0.11
│ ├─┬ optimist@0.4.0
│ │ └── wordwrap@0.0.2
│ ├── pkginfo@0.3.0
│ ├── timespan@2.0.1
│ ├─┬ utile@0.1.7
│ │ ├── async@0.1.22
│ │ ├── deep-equal@0.0.0
│ │ ├── i@0.3.2
│ │ ├── mkdirp@0.3.5
│ │ ├── ncp@0.2.7
│ │ └── rimraf@1.0.9
│ ├── watch@0.7.0
│ └─┬ winston@0.7.1
│   ├── cycle@1.0.2
│   ├── eyes@0.1.8
│   ├─┬ request@2.16.6
│   │ ├── aws-sign@0.2.0
│   │ ├── cookie-jar@0.2.0
│   │ ├── forever-agent@0.2.0
│   │ ├─┬ form-data@0.0.10
│   │ │ └─┬ combined-stream@0.0.4
│   │ │   └── delayed-stream@0.0.5
│   │ ├─┬ hawk@0.10.2
│   │ │ ├── boom@0.3.8
│   │ │ ├── cryptiles@0.1.3
│   │ │ ├── hoek@0.7.6
│   │ │ └── sntp@0.1.4
│   │ ├── json-stringify-safe@3.0.0
│   │ ├── mime@1.2.11
│   │ ├── node-uuid@1.4.1
│   │ ├── oauth-sign@0.2.0
│   │ ├── qs@0.5.6
│   │ └── tunnel-agent@0.2.0
│   └── stack-trace@0.0.7
├─┬ grunt@0.4.1
│ ├── async@0.1.22
│ ├── coffee-script@1.3.3
│ ├── colors@0.6.2
│ ├── dateformat@1.0.2-1.2.3
│ ├── eventemitter2@0.4.13
│ ├─┬ findup-sync@0.1.2
│ │ └── lodash@1.0.1
│ ├─┬ glob@3.1.21
│ │ ├── graceful-fs@1.2.3
│ │ └── inherits@1.0.0
│ ├── hooker@0.2.3
│ ├── iconv-lite@0.2.11
│ ├─┬ js-yaml@2.0.5
│ │ ├─┬ argparse@0.1.15
│ │ │ ├── underscore@1.4.4
│ │ │ └── underscore.string@2.3.3
│ │ └── esprima@1.0.4
│ ├── lodash@0.9.2
│ ├─┬ minimatch@0.2.12
│ │ ├── lru-cache@2.3.1
│ │ └── sigmund@1.0.0
│ ├─┬ nopt@1.0.10
│ │ └── abbrev@1.0.4
│ ├─┬ rimraf@2.0.3
│ │ └── graceful-fs@1.1.14
│ ├── underscore.string@2.2.1
│ └── which@1.0.5
├─┬ grunt-bower-task@0.3.2
│ ├── async@0.1.22
│ ├─┬ bower@1.2.6
│ │ ├── abbrev@1.0.4
│ │ ├── archy@0.0.2
│ │ ├─┬ bower-config@0.5.0
│ │ │ └─┬ optimist@0.6.0
│ │ │   ├── minimist@0.0.5
│ │ │   └── wordwrap@0.0.2
│ │ ├── bower-endpoint-parser@0.2.1
│ │ ├─┬ bower-json@0.4.0
│ │ │ ├── deep-extend@0.2.6
│ │ │ └── intersect@0.0.3
│ │ ├── bower-logger@0.2.1
│ │ ├─┬ bower-registry-client@0.1.4
│ │ │ ├── async@0.2.9
│ │ │ ├─┬ bower-config@0.4.5
│ │ │ │ └─┬ optimist@0.6.0
│ │ │ │   ├── minimist@0.0.5
│ │ │ │   └── wordwrap@0.0.2
│ │ │ └── request-replay@0.2.0
│ │ ├─┬ cardinal@0.4.2
│ │ │ ├── ansicolors@0.2.1
│ │ │ └─┬ redeyed@0.4.2
│ │ │   └── esprima@1.0.4
│ │ ├─┬ chalk@0.2.1
│ │ │ ├── ansi-styles@0.2.0
│ │ │ └── has-color@0.1.1
│ │ ├── chmodr@0.1.0
│ │ ├─┬ fstream@0.1.24
│ │ │ └── inherits@2.0.1
│ │ ├─┬ fstream-ignore@0.0.7
│ │ │ ├── inherits@2.0.1
│ │ │ └─┬ minimatch@0.2.12
│ │ │   └── sigmund@1.0.0
│ │ ├─┬ glob@3.2.6
│ │ │ ├── inherits@2.0.1
│ │ │ └─┬ minimatch@0.2.12
│ │ │   └── sigmund@1.0.0
│ │ ├── graceful-fs@2.0.1
│ │ ├─┬ handlebars@1.0.12
│ │ │ ├─┬ optimist@0.3.7
│ │ │ │ └── wordwrap@0.0.2
│ │ │ └─┬ uglify-js@2.3.6
│ │ │   ├── async@0.2.9
│ │ │   └─┬ source-map@0.1.29
│ │ │     └── amdefine@0.0.8
│ │ ├─┬ inquirer@0.3.3
│ │ │ ├── async@0.2.9
│ │ │ ├─┬ cli-color@0.2.3
│ │ │ │ ├── es5-ext@0.9.2
│ │ │ │ └─┬ memoizee@0.2.5
│ │ │ │   ├── event-emitter@0.2.2
│ │ │ │   └── next-tick@0.1.0
│ │ │ ├── lodash@1.2.1
│ │ │ └── mute-stream@0.0.3
│ │ ├── junk@0.2.1
│ │ ├── lru-cache@2.3.1
│ │ ├── mkdirp@0.3.5
│ │ ├── mout@0.6.0
│ │ ├── nopt@2.1.2
│ │ ├── open@0.0.4
│ │ ├── osenv@0.0.3
│ │ ├─┬ promptly@0.2.0
│ │ │ └─┬ read@1.0.5
│ │ │   └── mute-stream@0.0.4
│ │ ├── q@0.9.7
│ │ ├─┬ request@2.27.0
│ │ │ ├── aws-sign@0.3.0
│ │ │ ├── cookie-jar@0.3.0
│ │ │ ├── forever-agent@0.5.0
│ │ │ ├─┬ form-data@0.1.1
│ │ │ │ ├── async@0.2.9
│ │ │ │ └─┬ combined-stream@0.0.4
│ │ │ │   └── delayed-stream@0.0.5
│ │ │ ├─┬ hawk@1.0.0
│ │ │ │ ├── boom@0.4.2
│ │ │ │ ├── cryptiles@0.2.2
│ │ │ │ ├── hoek@0.9.1
│ │ │ │ └── sntp@0.2.4
│ │ │ ├─┬ http-signature@0.10.0
│ │ │ │ ├── asn1@0.1.11
│ │ │ │ ├── assert-plus@0.1.2
│ │ │ │ └── ctype@0.5.2
│ │ │ ├── json-stringify-safe@5.0.0
│ │ │ ├── mime@1.2.11
│ │ │ ├── node-uuid@1.4.1
│ │ │ ├── oauth-sign@0.3.0
│ │ │ ├── qs@0.6.5
│ │ │ └── tunnel-agent@0.3.0
│ │ ├─┬ request-progress@0.3.1
│ │ │ └── throttleit@0.0.2
│ │ ├── retry@0.6.0
│ │ ├── rimraf@2.2.2
│ │ ├── semver@2.1.0
│ │ ├── stringify-object@0.1.7
│ │ ├─┬ sudo-block@0.2.1
│ │ │ └─┬ chalk@0.1.1
│ │ │   ├── ansi-styles@0.1.2
│ │ │   └── has-color@0.1.1
│ │ ├─┬ tar@0.1.18
│ │ │ ├── block-stream@0.0.7
│ │ │ └── inherits@2.0.1
│ │ ├── tmp@0.0.21
│ │ ├─┬ unzip@0.1.9
│ │ │ ├─┬ binary@0.3.0
│ │ │ │ ├── buffers@0.1.1
│ │ │ │ └─┬ chainsaw@0.1.0
│ │ │ │   └── traverse@0.3.9
│ │ │ ├─┬ match-stream@0.0.2
│ │ │ │ └── buffers@0.1.1
│ │ │ ├─┬ pullstream@0.4.0
│ │ │ │ ├── over@0.0.5
│ │ │ │ └── slice-stream@0.0.0
│ │ │ ├── readable-stream@1.0.17
│ │ │ └── setimmediate@1.0.1
│ │ ├─┬ update-notifier@0.1.5
│ │ │ ├─┬ chalk@0.1.1
│ │ │ │ ├── ansi-styles@0.1.2
│ │ │ │ └── has-color@0.1.1
│ │ │ ├─┬ configstore@0.1.5
│ │ │ │ ├─┬ js-yaml@2.1.0
│ │ │ │ │ ├─┬ argparse@0.1.15
│ │ │ │ │ │ ├── underscore@1.4.4
│ │ │ │ │ │ └── underscore.string@2.3.3
│ │ │ │ │ └── esprima@1.0.4
│ │ │ │ └── lodash@1.3.1
│ │ │ ├─┬ request@2.22.0
│ │ │ │ ├── aws-sign@0.3.0
│ │ │ │ ├── cookie-jar@0.3.0
│ │ │ │ ├── forever-agent@0.5.0
│ │ │ │ ├─┬ form-data@0.0.8
│ │ │ │ │ ├── async@0.2.9
│ │ │ │ │ └─┬ combined-stream@0.0.4
│ │ │ │ │   └── delayed-stream@0.0.5
│ │ │ │ ├─┬ hawk@0.13.1
│ │ │ │ │ ├─┬ boom@0.4.2
│ │ │ │ │ │ └── hoek@0.9.1
│ │ │ │ │ ├── cryptiles@0.2.2
│ │ │ │ │ ├── hoek@0.8.5
│ │ │ │ │ └─┬ sntp@0.2.4
│ │ │ │ │   └── hoek@0.9.1
│ │ │ │ ├─┬ http-signature@0.10.0
│ │ │ │ │ ├── asn1@0.1.11
│ │ │ │ │ ├── assert-plus@0.1.2
│ │ │ │ │ └── ctype@0.5.2
│ │ │ │ ├── json-stringify-safe@4.0.0
│ │ │ │ ├── mime@1.2.11
│ │ │ │ ├── node-uuid@1.4.1
│ │ │ │ ├── oauth-sign@0.3.0
│ │ │ │ ├── qs@0.6.5
│ │ │ │ └── tunnel-agent@0.3.0
│ │ │ └── semver@2.0.11
│ │ └── which@1.0.5
│ ├── colors@0.6.2
│ ├── lodash@0.10.0
│ ├─┬ rimraf@2.0.3
│ │ └── graceful-fs@1.1.14
│ └── wrench@1.4.4
├─┬ grunt-cli@0.1.9
│ ├─┬ findup-sync@0.1.2
│ │ ├─┬ glob@3.1.21
│ │ │ ├── graceful-fs@1.2.3
│ │ │ ├── inherits@1.0.0
│ │ │ └─┬ minimatch@0.2.12
│ │ │   ├── lru-cache@2.3.1
│ │ │   └── sigmund@1.0.0
│ │ └── lodash@1.0.1
│ ├─┬ nopt@1.0.10
│ │ └── abbrev@1.0.4
│ └── resolve@0.3.1
├─┬ grunt-concurrent@0.3.1
│ └── lpad@0.1.0
├─┬ grunt-contrib-jshint@0.6.4
│ └─┬ jshint@2.1.11
│   ├─┬ cli@0.4.5
│   │ └─┬ glob@3.2.6
│   │   └── inherits@2.0.1
│   ├── console-browserify@0.1.6
│   ├─┬ minimatch@0.2.12
│   │ ├── lru-cache@2.3.1
│   │ └── sigmund@1.0.0
│   ├── shelljs@0.1.4
│   └── underscore@1.4.4
├─┬ grunt-contrib-watch@0.5.3
│ ├─┬ gaze@0.4.1
│ │ └─┬ globule@0.1.0
│ │   ├─┬ glob@3.1.21
│ │   │ ├── graceful-fs@1.2.3
│ │   │ └── inherits@1.0.0
│ │   ├── lodash@1.0.1
│ │   └─┬ minimatch@0.2.12
│ │     ├── lru-cache@2.3.1
│ │     └── sigmund@1.0.0
│ └─┬ tiny-lr@0.0.4
│   ├── debug@0.7.2
│   ├── faye-websocket@0.4.4
│   ├─┬ noptify@0.0.3
│   │ └─┬ nopt@2.0.0
│   │   └── abbrev@1.0.4
│   └── qs@0.5.6
├─┬ grunt-mocha-test@0.7.0
│ └─┬ mocha@1.13.0
│   ├── commander@0.6.1
│   ├── debug@0.7.2
│   ├── diff@1.0.7
│   ├─┬ glob@3.2.3
│   │ ├── graceful-fs@2.0.1
│   │ ├── inherits@2.0.1
│   │ └─┬ minimatch@0.2.12
│   │   ├── lru-cache@2.3.1
│   │   └── sigmund@1.0.0
│   ├── growl@1.7.0
│   ├─┬ jade@0.26.3
│   │ └── mkdirp@0.3.0
│   └── mkdirp@0.3.5
├─┬ grunt-nodemon@0.1.1
│ └── nodemon@0.7.10
├─┬ jade@0.35.0
│ ├── character-parser@1.2.0
│ ├── commander@2.0.0
│ ├─┬ constantinople@1.0.2
│ │ └─┬ uglify-js@2.4.0
│ │   ├─┬ optimist@0.3.7
│ │   │ └── wordwrap@0.0.2
│ │   ├─┬ source-map@0.1.29
│ │   │ └── amdefine@0.0.8
│ │   └── uglify-to-browserify@1.0.1
│ ├── mkdirp@0.3.5
│ ├─┬ monocle@1.1.50
│ │ └─┬ readdirp@0.2.5
│ │   └─┬ minimatch@0.2.12
│ │     ├── lru-cache@2.3.1
│ │     └── sigmund@1.0.0
│ ├─┬ transformers@2.1.0
│ │ ├─┬ css@1.0.8
│ │ │ ├── css-parse@1.0.4
│ │ │ └── css-stringify@1.0.5
│ │ ├─┬ promise@2.0.0
│ │ │ └── is-promise@1.0.0
│ │ └─┬ uglify-js@2.2.5
│ │   ├─┬ optimist@0.3.7
│ │   │ └── wordwrap@0.0.2
│ │   └─┬ source-map@0.1.29
│ │     └── amdefine@0.0.8
│ └─┬ with@1.1.1
│   └─┬ uglify-js@2.4.0
│     ├─┬ optimist@0.3.7
│     │ └── wordwrap@0.0.2
│     ├─┬ source-map@0.1.29
│     │ └── amdefine@0.0.8
│     └── uglify-to-browserify@1.0.1
├── mean-logger@0.0.1
├─┬ mongoose@3.6.20
│ ├── hooks@0.2.1
│ ├─┬ mongodb@1.3.19
│ │ ├── bson@0.2.2
│ │ └── kerberos@0.0.3
│ ├── mpath@0.1.1
│ ├─┬ mpromise@0.2.1
│ │ └── sliced@0.0.4
│ ├── ms@0.1.0
│ ├── muri@0.3.1
│ ├── regexp-clone@0.0.1
│ └── sliced@0.0.5
├─┬ passport@0.1.17
│ ├── pause@0.0.1
│ └── pkginfo@0.2.3
├─┬ passport-facebook@1.0.1
│ └─┬ passport-oauth2@1.1.1
│   ├── oauth@0.9.10
│   ├── passport-strategy@1.0.0
│   └── uid2@0.0.3
├─┬ passport-github@0.1.5
│ ├─┬ passport-oauth@0.1.15
│ │ └── oauth@0.9.10
│ └── pkginfo@0.2.3
├─┬ passport-google-oauth@0.1.5
│ ├─┬ passport-oauth@0.1.15
│ │ └── oauth@0.9.10
│ └── pkginfo@0.2.3
├─┬ passport-local@0.1.6
│ └── pkginfo@0.2.3
├─┬ passport-twitter@1.0.2
│ ├─┬ passport-oauth1@1.0.1
│ │ ├── oauth@0.9.10
│ │ ├── passport-strategy@1.0.0
│ │ └── utils-merge@1.0.0
│ └─┬ xtraverse@0.1.0
│   └── xmldom@0.1.16
├── should@1.3.0
├─┬ supertest@0.8.0
│ ├── methods@0.0.1
│ └─┬ superagent@0.15.1
│   ├── cookiejar@1.3.0
│   ├── debug@0.7.2
│   ├── emitter-component@1.0.0
│   ├── formidable@1.0.9
│   ├── mime@1.2.5
│   └── qs@0.6.5
├── underscore@1.5.2
└── view-helpers@0.1.2

Thanks for helping out.

A: I had this same problem installing on bitnami. It turns out there is a permissions related issue in creating the directory where the actual content is located which MEAN serves up to you.
The following command worked for me from the directory in which I checked out MEAN:
sudo bower install --allow-root


text:
Q: Android Java : Error when submit form(post) on Webview I want to load in webview this page, https://pkfieur.gares.io/pk2geo/, and past data in "Ligne" and "PK" and click on "Rechercher".
Past data isn't a problem, but the submit yes.
Here the html:
<form id="form-id" method="post">

...

  <input type="submit" value="Rechercher">
</form>

And the code :
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setDomStorageEnabled(true);
web.loadUrl("https://pkfieur.gares.io/pk2geo/");

go.setOnClickListener(new View.OnClickListener()     {
@Override
public void onClick(View v) {
   web.loadUrl("javascript: document.getElementById('id_ligne').value ='" +  ligne.getText() + "';"
+ "document.getElementById('id_pk').value ='" + pk.getText() + "';"
+ "document.getElementById('form-id').submit();");
 }

});
When my edit text is ready, i click on my button GO (in my app) and the webview telling me this :
image
Can someone help me, i know it is maybe a cookie, or debugging problem, but i try so much without find solution.
EDIT : When we quick in research, we have a latitude & longitude : I just want to take this data, and for this i use Webiew, ( not custom tabs because it will be open a new tabs ..)and after i set WebView Visibility to false !
If you have better solution like http or other, i dont know.. :/
Ty!

A: Regarding edit from TS, TS should probably use an API for that and then use Retrofit or something else in order to call the API.
https://square.github.io/retrofit/
Edit2: I extracted the calls from the website. Use this endpoint in your Retrofit instance or API call adapter in order to call the API. Look below for the request method & API endpoint.
Request Method: GET
Request URL: https://pkfieur.gares.io/data_pk2geo/?ligne=XXXX&pk=XXXX

Where XXXX are the query strings (which you would normally type in the fields on the website), you should change those when calling the API.


text:
Q: easier way to get mouse movenment on window control IN WINDOW LOOP than subclassing First of all, yes I have read the other articles deal (I like your "similar question title"-window ), I am just curious if there are better ways of doing that.
Problem: When using effects or anythings else that involes tracking, WinAPI appearantly decided that buttons, edits and maybe all other Common Controls do not pass WM_MOUSEMOVE to their parent handle. This comes unhandy, when the user - for example - stays (actually moves) too long on a button and the event is unintentionally triggered.
Initial Question: How to solve that ?
Answer 1: Subclassing. Quite handy and safe but needs also some time so skip that for now.
Answer 2: TrackMouseEvent + "if-conditioning" --> may be slow and surely gets very complex.
NoGo: Using notify flags as BS_NOTIFY for buttons do not work because they take care about mouse clicks and focus.
QUESTION: Any other ideas? Did Windows 7  "secretly" introduce a flag for that or does some pro-grammer know a trick to deal with it easier?
NOTE: I do not want to annoy somebody. I just want to ask before adding unnecessarly much code.

A: Subclassing is by far your simplest option. If you are looking for a easier option, you won't find one. As shown by the link, with a very minimal amount of code you can already solve your problem. If you wish to have the functionality such that the parent handle does pass the WM_MOUSEMOVE message up the window hierarchy, simply subclass it, then when handling that message forward the parameters onto the parent.
I'm slightly unclear however, about what you mean by:

for example - stays (actually moves) too long on a button and the event is unintentionally triggered.

For example:
LRESULT CALLBACK ButtonProc(HWND hWnd, UINT uMsg, WPARAM wParam,
                               LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
    switch (uMsg)
    {
    case WM_MOUSEMOVE:
        SendMessage((HWND)dwRefData, uMsg, wParam, lParam);
    }

    return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}

This is assuming that you passed in the parent HWND under dwRefData.


text:
Q: Loading of images using multi-threading in android I have a class that extends Activity and within it got a private class that extends View which i calling it to load the images. However, i wasn't whether i should use AsyncTask, Handler or other ways to perform the loading of images on the background and showing the progressBar at the same time while loading. For AsyncTask, the task instance must be created on the UI thread (which i presume is in the Activity class). But all the function is in the View class and have trouble using AsyncTask. Is using Handler a good choice?
public class LargeImageScroller extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            setContentView(new SampleView(this));
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {...}

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {...}

    private static class SampleView extends View {

        public SampleView(Context context) {...}
        public boolean onTouchEvent(MotionEvent event) {...}
        protected void onDraw(Canvas canvas) {...}
        private boolean createMap(Context context) {...}
}

This is the rough skeleton of the program. createMap() is the function where i load images into a canvas so as to display the images. But if i declare a class that extends AsyncTask, the task instance can only be created in the onCreate() and not anywhere else so i have problem calling the createMap() to load the images. I was thinking of using Handler so as to load the images on a separate thread from the main thread. Can anyone tell me is there a better way of doing things?

A: There's a really good post on multithreading in Android here. Should give you a few hints on what to do.
http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html


text:
Q: Are Kerberos service tickets cached by mount.cifs or kernel? When mounting a CIFS share using krbr5i and destroying my Kerberos tickets with kdestroy afterwards its still possible to mount other shares on the same server. How is this possible? Doesn't mount.cifs have to send the service ticket to the sharing server again? Is the ticket cached somewhere? Is this handled by the kernel (or cifs.upcall)?
After unmounting all shares mount.cifs will fail (as expected).
Steps to reproduce:
$ # Aquire tgt:
$ kinit
Password for sahisb@DOMAIN.EXAMPLE.COM:
$ # Mount share1 and get cifs ticket:
$ sudo mount.cifs -v -o sec=krb5i,cache=strict,rw,user=sahisb,cruid=$UID,cifsacl,nounix,multiuser,vers=2.1 //dc.domain.example.com/share1 /share1
mount.cifs kernel mount options: ip=[redacted],unc=\\dc.domain.example.com\share1,sec=krb5i,cache=strict,cifsacl,nounix,multiuser,vers=2.1,cruid=1297401199,user=sahisb,pass=********
$ # Destroy tgt and cifs ticket:
$ kdestroy
$ # Mount share2. I expected this to fail but it will succeed:
$ sudo mount.cifs -v -o sec=krb5i,cache=strict,rw,user=sahisb,cruid=$UID,cifsacl,nounix,multiuser,vers=2.1 //dc.domain.example.com/share2 /share2
mount.cifs kernel mount options: ip=[redacted],unc=\\dc.domain.example.com\share2,sec=krb5i,cache=strict,cifsacl,nounix,multiuser,vers=2.1,cruid=1297401199,user=sahisb,pass=********

At this point klist still cannot find a credentials cache.
Now let's try to unmount the shares and mount them again:
$ umount /share1
$ umount /share2
$ sudo mount.cifs -v -o sec=krb5i,cache=strict,rw,user=sahisb,cruid=$UID,cifsacl,nounix,multiuser,vers=2.1 //dc.domain.example.com/share2 /share2
mount.cifs kernel mount options: ip=[redacted],unc=\\dc.domain.example.com\share2,sec=krb5i,cache=strict,cifsacl,nounix,multiuser,vers=2.1,cruid=1297401199,user=sahisb,pass=********
mount error(126): Required key not available

Which fails as expected.

A: When mounting a CIFS/SMB share a session is created (if the credentials - in this case a kerberos service ticket - to the service are correct). After a session is created we don't have to authenticate ourselves anymore.
Since share1 and share2 are provided by the same service (dc.domain.example.com) all requests to these files are using the same session.


text:
Q: HTML Text not showing over Image My text/header is not showing over my image which I'm trying to use as a background to this webpage. This is the code I have right now:
HTML:

Lorem ipsum

CSS:

 body {
    background-color:black
}

 backgroundimg {
    position:relative;
    width:1175px;

}

 name {
    position:absolute;
    color: white;
    z-index;
}

Any tips?
P.S. I took out the '#' and '.' to the appropriate names in CSS.

A: Use z-index to show the text over image.

A: You can use z-index, like Anil Panwar said(https://stackoverflow.com/a/34374513/4900669)
#name {
   position:absolute;
   color: white;
   z-index: 10;
}

https://jsfiddle.net/08voh0fp/

A: Add this to your css file
h2 {
   position: absolute;
   top: 200px;
   left: 0;
   width: 100%;
}

adjust top,left and width according your need,
let me know if this helped


text:
Q: WAF at Transparent Mode I want to use Mod Security as transparent mode. Mod security web application firewall (WAF) should be between server and client and client provided with only server's IP address to access the site. The client should not aware about the presence of Mod security since it provided server's IP address unlike in reverse proxy mode. Is it possible to use mod security as mentioned above?
I want to deploy mod security as transparent proxy (layer 7).

A: My first question would be why?
If mod_security is on the actual server it will be transparent.
If mod security is on a gateway then the client will only ever see the gateway server address.
Just use x-forwarded-for to see the client IP in the server logs.
It may be possible to use TPROXY in the linux kernel in a two subnet configuration where the servers default gateway is translated through the mod sec box (servers would NOT be able to have a public IP address).
But I'm not sure if apache/mod_sec even supports TPROXY it needs code specifically to support it (like in HAProxy).


text:
Q: Selecting multiple hyper-parameters via successive nested cross-validation Selecting multiple hyper-parameters via successive nested cross-validation
I am currently working in a classification task on motion data. Each sample to classify is represented by a set of features computed using a sliding window of size X and with a step of length L. Once all the features are computed, I would like to do the following:

*

*Currently, each sample is represented by 264 different features. The total number of samples depends of both X and L. From expert knowledge, I know that it might be possible to use a simpler model (with less features) for this classification task. I would like to prove it empirically, i.e, iteratively increase the number of features (up to 264) and see how a standard classifier behaves as the number of features increases.

*Do some feature selection and keep as many features as indicated in the previous step.

*Search the best hyper-parameters for all the models to be compared, e.g, SVM, Random Forest, etc...

*Select the best model with the best parameters, based on its performance on the hold-out data set.

*Train and deploy the final model.
I want to use classical K-fold cross-validation for each step. However, after reading all the related questions on stats (Model Tuning and Model Evaluation in Machine Learning, Feature selection and cross-validation, Model selection and cross-validation: The right way), I am still not sure about the best strategy to use. Intuitively and following the idea of nested cross-validation, I would do the following:
                    All-data
                    /      \
                   /        \
                train_set   test_set (hold out) --> Final performance
                 /      \                            evaluation
                /        \
              train_set   test_set --> Hyper-parameter search
             /      \
            /        \
         train_set   test_set --> Feature selection
        /        \
       /          \
   train_set  test_set  --> Model complexity analysis (No. of features
   /      \                        to use)
  /        \
 train_set   test_set --> Sliding window parameters

As the final model depends on the results of the previous steps and all of them are data-driven, I want to be sure that for each step, my decision is based on a not-biased test error and that there is no 'peeking into the future'. However, with so many nested cross-validation procedures, I am afraid of not having enough data for all them.
Do you think this is a good strategy? Should I use something else than cross-validation (bootstrapping for example)? Will this strategy lead to too optimistic scores? Once I find the best model, do I need to cross-validate the best hyper-parameters again on the whole dataset?

A: I have done things like that in the past, where I needed to optimize both hyperparameters of the model and parameters of the post-processing pipeline (I include feature selection there). But it's very expensive computationally speaking.
So finally I tried to make my own standard solution and I have released a package that can help implementing nested cross validation in Python (for the moment, it only works for binary classifiers). If you want to check it out, it's here:
https://github.com/JaimeArboleda/nestedcvtraining
It's my first Python package, so any comments, suggestions or critics will be more than welcome!!
I post it as an answer because nested cross validation is performed inside the main function and you don't have to take care of how to implement it. Anyway, the code is visible in my github account, so that you can check how I implemented it if you are curious. Also, the readme explain it in detail (although, maybe, not very clearly!).
After the function is called, you get a model (that in fact will be a pipeline if there is a post-process to perform) and a complete report of what happened inside, so that you can assess the estimates of the different scoring functions. It comes with many options thay may be enough for a lot of common settings, I hope.
If you have any doubt, comment, whatever, you can contact me through github.

A: The important thing is that the entire model fitting procedure is performed independently in each fold, including all of the feature and hyper-parameter tuning, as that is what is needed to avoid bias due to over-fitting in model selection.
I implement this by making a function, something like:
model = train_model(x, t)

where x is the input and t is the targets for the training data, and another function:
y = generate_outputs(model, x)
where x is the test inputs and y will be the test predictions from the model.
Now train_model will encode how the hyper-parameters etc. are tuned.  As @marc_claesen suggests, it is better to perform hyper-paremeter and feature selection jointly, especially for things like SVM* where the regularisation parameter depends on the feature set.  I then use those two functions for implementing the outer cross-validation.
I would probably perform all of the other steps jointly using a single inner-cross-validation.  Note however the more you tune the model using cross-validation, the more you will tend to overfit the model, so exhaustively searching for the best possible model tends to end up giving a rather poor one.  In many machine learning challenges (e.g. at conferences), the models at the top of the leader board tend to be towards the bottom of the final rankings because they have often been over-fitted to the leaderboard data by too much manual model selection (I call this "cyberML", which is a bit like "autoML" but where the operator has become part of the machine).
*for SVMs I normally find feature selection make generalisation worse rather than better, at least for linear SVMs, as they are based on a learning bound that is independent of the size of the feature space, so regularisation tends to work well.  The generalisation theory for feature selection is much less rigorous, and invalidates the generalisation bounds for the SVM, and tuning one continuous regularisation parameter tends to be less prone to over-fitting the model selection criterion than fitting one binary hyper-parameter for each feature (which is essentially what feature selection is doing).  So for things like SVMs, I tend only to do feature selection if selecting the features is a primary goal for the analysis.
I agree with @gung's suggestion of using e.g. LASSO penalty for feature selection (fewer degrees of freedom, and less pressure on CV to find the best model)


text:
Q: Is the image of a injective immersion that is a homeomorphism onto its image from an open set, open? Let $f:U\to \mathbb{R}^n$ be a $C^1$ map from a connected open set $U$ of $\mathbb{R}^k$ where $1\leq k \leq n$ into $\mathbb{R}^n$ such that :

*

*$f$ is an injective immersion,

*$f$ is an homeomorphism from $U$ onto its image $f(U)$.

Does this imply that $f(U)$ is an open set of $\mathbb{R}^n$ ?

A: if you simply include the x-axis into $R^2$ it seems to me that you get a counterexample.


text:
Q: выдача кода с сервера Как реализовать выдачу рандомного кода с сервера. То есть при нажатии "получить код" происходила его выдача. Есть код на Javascript, но не знаю как его портировать на сервер. В качестве сервера, локальный компьютер с выделенным ip.

A: NodeJS, express, за образец взял код из вашего предыдущего вопроса
const express = require('express');
const app = express();
const str_rand = () => {
    let result = '';
    const words = '0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
    while(result.length < 15) result += words[Math.floor(Math.random()*words.length)];
    return result;
}
app.use('/code', (req, res) => res.end(str_rand()));
app.use('/', (req, res) => res.end(`

      Your code:
      <input type="text" name="code" id="short_link" style="border: 1px solid #3E7EFF; border-radius: 5px 5px 5px 5px;" value="${str_rand()}">

Generate

`));
app.listen(8888, () => console.log('Started http://localhost:8888'));


text:
Q: Polymorphism in Dart/Flutter I have a number of classes that all extend StatefulWidget. I want each class to provide its own version of a method bool foo(), so that I can iterate over a collection of objects of these classes, calling foo() on each. What is the best/correct way to do this in Dart/Flutter? Mixins? What would the type of that collection be?

A: The functionality described can be achieved with Interfaces in Dart
class Widget {

}

abstract class MyCustomWidget extends Widget {
  String foo( String argName);
}

class Widget1 implements MyCustomWidget {
  String foo( String argName) {
    return argName;
  }
}

class Widget2 implements MyCustomWidget {
  String foo( String argName) {
    return '$argName$argName';
  }
}

void main() {
  Widget1 w = new Widget1();
  Widget2 w2 = new Widget2();
  var widgets = [w, w2];
  for (int i = 0; i < widgets.length; i++) {
    print(widgets[i].foo('hello ${i + 1}'));
  }
}

That said, flutter recommends composition over inheritance.
See: Flutter StatefulWidget - State class inheritance?


text:
Q: Convolution of sine and cosine. So I came across this question while studying for the GRE Subject Exam, and I am not really sure how I am supposed to handle it. Let
$$ f(x) = \int _0 ^{\pi} \sin t \cos (x+t) dt $$
I am to find where $f$ gets its minimum and maximum values when $x \in [0,2\pi]$.
Since it is a GRE-question, I believe that the answer should not be that difficult. Could someone please explain?

A: Using the formula $\cos(x + t) = \cos x \cos t - \sin x \sin t$, you can split the integral and just calculate it.
\begin{align*}\int_0^\pi \sin t\cos(x + t)\ dt &= \int_0^\pi \sin t(\cos x \cos t - \sin x \sin t)\ dt\\
&=\cos x \underbrace{\int_0^\pi \sin t \cos t\ dt}_{=\,0} - \sin x\underbrace{\int_0^\pi \sin^2 t\ dt}_{=\, \pi/2} \\
&=-\frac{\pi}{2}\sin(x),
\end{align*}
which is maximized at $x = 3\pi/2$.
I'm sure there's a better perspective or way to do things, but this isn't that bad.

A: By the Cauchy-Schwarz inequality, we have
$$\begin{aligned}
\left|\int_0^{\pi}\sin(t)\cos(x+t)dt\right| &\leq \left(\int_{0}^{\pi}\sin^2(t) dt\right)^{1/2} \left(\int_0^{\pi}\cos^2(x+t)dt\right)^{1/2} \\
&= \frac{\pi}{2} \\
\end{aligned}$$
The right hand side is independent of $x$ because both integrands have period $\pi$.
Equality is achieved if and only if $\sin(t)$ and $\cos(x+t)$ are scalar multiples of each other. But this happens if and only if $x = \pi/2$ and $x=3\pi/2$. Specifically,
$$\cos(t+3\pi/2) = \cos(t-\pi/2) = \sin(t) \quad\text{and}\quad\cos(t+\pi/2) = -\sin(t)$$
so the minimum is achieved at $x=\pi/2$, and the maximum is achieved at $x = 3\pi/2$.

A: easiest way: calculate integral
$$\int _0 ^{\pi} \sin t \cos (x+t) dt=\frac{1}{2}\int _0 ^{\pi} (\sin (2t+x) -\sin (x) )dt=\\ \frac{1}{2}(-\frac{1}{2}\cos (2t+x)-t\sin (x))|^{\pi}_{0}=-\frac{\pi}{2}\sin (x)$$


text:
Q: Why is the semisimple rank of a connected reductive group equal to the rank of the commutator? I am trying to learn the theory of linear algebraic groups over an algebraically closed field. I know that if $R(G)$ denotes it radical, then $G/R(G)$ is semisimple and is therefore equal to its own commutator. So $G/R(G)=[G/R(G),G/R(G)]=[G,G]R(G)/R(G)=[G,G]/(R(G) \cap [G,G])$. So it's a quotient of the commutator by a finite normal subgroup.
But why would the rank (dimension of a maximal torus) of $[G,G]$ be equal to the rank of the quotient of $[G,G]$ by a finite subgroup? In general, is the rank additive in short exact sequences? I know it is true for the sequence
$1 \rightarrow SL_n(k) \rightarrow GL_n(K) \rightarrow \mathbb{G}_m \rightarrow 1$.

A: If $G$ is a semisimple group (such as $[G,G]$ in your question) with maximal torus $T$, then the rank of $G$ is by definition the dimension of $T$.  If $S$ is a finite subgroup of $G$ which is contained in the center of $G$ (such as $R(G) \cap [G,G]$ in your question), the point is that $G/S$ is semisimple with maximal torus $T/S$.  Since $S$ is finite, $\operatorname{Dim}(T/S) = \operatorname{Dim}(T)$, so the ranks of $G$ and $G/S$ are the same.


text:
Q: Laravel: Action @index not defined
InvalidArgumentException Action BookingController@index not defined.

In my web.php I have used the following code:
Route::resource('bookings', 'App\Http\Controllers\BookingController');

I've also tried the following:
Route::resource('bookings', 'App\Http\Controllers\BookingController@index');

Full code of web.php: https://pastebin.com/SGGr3uAm
In my BookingController.php (relevant code):
    public function index()
    {
        $bookings = DB::table('bookings')->get();
        return view('bookings.index')
        ->with('bookings', $bookings);
    }

    public function store(Request $request)
    {
        $id = DB::table('bookings')->insertGetId([
            'room_id' => $request->input('room_id'),
            'start' => $request->input('start'),
            'end' => $request->input('end'),
            'is_reservation' => $request->input('is_reservation', false),
            'is_paid' => $request->input('is_paid', false),
            'notes' => $request->input('notes'),

        ]);
        DB::table('bookings_users')->insert([
        'booking_id' => $id,
        'user_id' => $request->input('user_id'),

        ]);
        return redirect()->route('BookingController@index');
    }

    public function update(Request $request, Booking $booking)
    {
        DB::table('bookings')
        ->where('id', $booking->id)
        ->update([
            'room_id' => $request->input('room_id'),
            'start' => $request->input('start'),
            'end' => $request->input('end'),
            'is_reservation' => $request->input('is_reservation', false),
            'is_paid' => $request->input('is_paid', false),
            'notes' => $request->input('notes'),

        ]);
        DB::table('bookings_users')
        ->where('booking_id', $booking->id)
        ->update([
        'user_id' => $request->input('user_id'),

        ]);
        return redirect()->route('BookingController@index');
    }

    public function destroy(Booking $booking)
    {
        DB::table('bookings_users')->where('booking_id', $booking->id)->delete();
        $booking->delete();
        return redirect()->action('BookingController@index');

    } }

Full code of BookingController.php: https://pastebin.com/TyXpdpH6
I'm using Laravel 8.19.0
php artisan route:list

What could be the issue? Thanks!!

A: Use this instead,
public function destroy(Booking $booking)
{
    DB::table('bookings_users')->where('booking_id', $booking->id)->delete();
    $booking->delete();
    return redirect()->route('bookings.index');

}

A: You have to import the class and then use it like this:
use App\Http\Controllers\BookingController;

Route::resource('bookings', BookingController::class);

A: One must either use the Route::resource() method or define the routes manually - don't club them for the same methods.
Remove all other route definitions from the web.php file for the bookings resource and just keep the Route::resource() one
//routes/web.php

Route::resource('bookings', BookingController::class);

Then in the terminal run
php artisan route:clear

php artisan route:list

Then check in the output, you should be able to see the entry for index

A: add
use App\Http\Controllers\BookingController;

then refer it like this
return redirect()->route(BookingController::class,'index');

I had the same problem, I fixed it using that

A: Ensure that all the routes are different
wrong
Route::post('/Remove','App\Http\Controllers\TaskController@Remove1');
Route::post('/Remove','App\Http\Controllers\Task2Controller@Remove2');

right
Route::post('/Remove1','App\Http\Controllers\TaskController@Remove1');
Route::post('/Remove2','App\Http\Controllers\Task2Controller@Remove2');

it doesn't have to be the same as the function name
you could also do something like this
Route::post('/Task/Remove','App\Http\Controllers\TaskController@Remove2');


text:
Q: Internal DNS issue Our internal network has been setup with the same domain as our external website.
We currently point a www record at the server IP (acquia) - this works but  means we don't get cloudflare's management and SSL etc
I'm wondering if there's any way to actually get our internal DNS to resolve to cloudflare?
Thanks,
Stuart

A: Yes you can add NS records internally for the www subdomain and point it to your public dns nameservers, you could also add a 'forward zone' if you provided more information like what dns server you're using you'd get a more precise answer.
Basically;
Nameserver
dig +short NS example.com

then add
www.example.com IN NS <result from above> to your internal DNS
Or
zone forward
zone "www.example.com" {
    type forward;
    forward only;
    forwarders { 1.1.1.1; 8.8.8.8; };
};

Next time, use a subdomain like ad.contoso.com or lan.contoso.com


text:
Q: Erlang Message passing between process I am writing code that reads two input files and checks if the words in the first file are present in the second file. I want to check elements of the list one by one via process message passing.
Here is my code:
start()->
    Pid2 = spawn(?MODULE,check2,[]),
    spawn(?MODULE,check1,[Pid2]).

check1(Pid2) ->
    {ok, Data} = file:read_file("input.txt"),
    B = binary:split(Data, [<<" ">>], [global]),
    K = [binary_to_list(Item) || Item <- B],
    [Pid2 ! Element || Element <- K].

check2() ->
    {ok,IoDevice} = file:open("check.txt", [read]),
    L = string:tokens(io:get_line(IoDevice,""), "! ."),
    receive
        Element ->
            case lists:member(Element,L)of
                true ->
                    io:format(Element);
                false ->
                    io:format("not_ok")
            end
    end.

The problem is that when I want to send an element of the list, it sends just the first element. How can I modify my code to send all strings and check them?

A: The primary issue is that your check2/0 function only receives a single element and then exits. It needs to loop to receive all elements, and it also needs something to tell it when to stop. Let's change the functions one by one below, starting with start/0:
start()->
    Pid2 = spawn(?MODULE,check2,[]),
    check1(Pid2).

The change here is that there's no need to spawn check2/1 — it can just be run directly by start/0.
Next, here's our revised check1/1 function:
check1(Pid2) ->
    {ok, Data} = file:read_file("input.txt"),
    B = binary:split(Data, [<<" ">>,<<"\n">>], [global,trim_all]),
    K = [binary_to_list(Item) || Item <- B],
    [Pid2 ! Element || Element <- K++[stop]].

First, we added newline to the split pattern, and also the trim_all option to get rid of empty elements from the split. We also appended the atom stop to the list of elements we send to Pid2. Let's look at our revised check2/0 function to see why:
check2() ->
    {ok,IoDevice} = file:open("check.txt", [read]),
    L = string:tokens(io:get_line(IoDevice,""), "! .\n"),
    check2(L).

Note that we've split the original check2/0 into two functions: check2/0 and check2/1. This is because the check2/1 function has to be recursive so it can receive all the elements sent to it:
check2(L) ->
    receive
        stop ->
            ok;
        Element ->
            case lists:member(Element,L)of
                true ->
                    io:format("found: ~s\n", [Element]);
                false ->
                    io:format("not found: ~s\n", [Element])
            end,
            check2(L)
    end.

Notice that inside the receive we first check to see if we've received the atom stop, and if we do, we exit the function. Otherwise, we receive and check an Element, and after that call check2/1 recursively so it can receive either the next Element or the stop atom.


text:
Q: How to solve Jquery Datepicker Validation issue? I did jquery validation on my form in play framework which is working properly when i directly click on submit button without entering values in textboxes validation messages come.
  But the issue is, when i am selecting a date from datepicker(bootstrap-datepicker.js), validation message does not disappear for date field. after clicking twice it disappears. please help me.
Jquery Code:
$("form input.date").datepicker({
        autoclose: true,
        onClose: function() {
            $(this).valid();
        }

});
Validation Function:
$("#register").validate({
        focusCleanup: true,
        rules: {
            name: "required",
            email: {
                required: true,
                email: true
            },
            phone: {
                required: true,
                number:true,
                minlength:10,
                maxlength:10
            },
            date:{
                required: true,
                date: true
            }
        },
        messages: {
            name: "Please provide your full name",
            email: {
                required: "Please provide your email address",
                email: "Please provide a valid email address"
            },
            phone: {
                required: "Please provide your mobile number",
                number: "Please provide a valid mobile number",
                minlength:"Please provide a valid mobile number",
                maxlength:"Please provide a valid mobile number"
            },
            date: {
                required: "Please select date ",
                date: "Please select valid date"
            }
        },
        submitHandler: function(form) {
        }
});

A: I experienced the same issue and found a solution here:
jQuery validator and datepicker click not validating
Op was very close, issue resolved with following (modified) code from user Sparky:
   $("#datepicker").datepicker({
         autoclose: true,
         dateFormat: 'dd/mm/yy',
   }).change(function() {
         $(this).valid();  // triggers the validation test
   });

A: you should specify when your validation function will be executed, there is 'keyup' which execute your function when you finish the inputs filling.
this is the documentation keyup.
you verify your the date and if it's correct you use the function hide(), but remember the validation code should be inside keyup()


text: Q: Just to be sure, do copy softwares like HTTRACK download script files too? So I am pretty new to web-building and have completed building a website recently and about to put it online. Question is straight-forward, do these back-up softwares like HTTRACK  also download script files such as php and js-files etc. It may not be a bright question and I think that mostly the answer is no, but as a newbie I want to be sure.