text:
Q: Laravel 9 Sail port forward error for mysql I have port forwarded applications mysql port to 3307 because I need my host mysql to keep running at 3306, but it gives below error.
Also I am able to get welcome page after running sail up
I am using laravel 9 latest version
Error
Illuminate\Database\QueryException

PHP 8.1.9
9.26.1

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: Temporary failure in name resolution

SELECT count(*) AS aggregate FROM `users` WHERE `email` = test@test.com

.env
APP_URL=http://127.0.0.1
APP_PORT=81

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
FORWARD_DB_PORT=3307

docker-composer.yml
# For more information: https://laravel.com/docs/sail
version: '3'
services:
    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.1
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.1/app
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${APP_PORT:-81}:80'
            - '${VITE_PORT:-5174}:${VITE_PORT:-5173}'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
            XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
            XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
    mysql:
        image: 'mysql/mysql-server:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3307}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '{DB_PASSWORD}'
            MYSQL_ROOT_HOST: '{DB_HOST}'
            MYSQL_DATABASE: '{DB_DATABASE}'
            MYSQL_USER: '{DB_USERNAME}'
            MYSQL_PASSWORD: '{DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 1
        volumes:
            - 'sail-mysql:/var/lib/mysql'
            - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
        networks:
            - sail
        healthcheck:
            test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
            retries: 3
            timeout: 5s
networks:
    sail:
        driver: bridge
volumes:
    sail-mysql:
        driver: local

Update 1
My terminal ouput is as follows
sm_v2-laravel.test-1   "start-container"   laravel.test        exited (0)
Shutting down old Sail processes...
[+] Running 0/1
 ⠙ Network sm_v2_sail  Creating                                                                                0.2s
[+] Running 3/3d orphan containers ([sm_v2-service-1]) for this project. If you removed or renamed this service in your co ⠿ Network sm_v2_sail              Created                                                                           0.2s
 ⠿ Container sm_v2-mysql-1         Created                                                                           1.5s
 ⠿ Container sm_v2-laravel.test-1  Created                                                                           0.5s
Attaching to sm_v2-laravel.test-1, sm_v2-mysql-1
sm_v2-mysql-1         | [Entrypoint] MySQL Docker Image 8.0.30-1.2.9-server
sm_v2-mysql-1         | [Entrypoint] Starting MySQL 8.0.30-1.2.9-server
sm_v2-mysql-1         | 2022-08-30T15:19:04.087084Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
sm_v2-mysql-1         | 2022-08-30T15:19:04.092964Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
sm_v2-mysql-1         | 2022-08-30T15:19:04.148193Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
sm_v2-mysql-1         | 2022-08-30T15:19:04.303213Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
sm_v2-mysql-1         | 2022-08-30T15:19:04.755173Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
sm_v2-mysql-1         | 2022-08-30T15:19:04.755609Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
sm_v2-mysql-1         | 2022-08-30T15:19:04.755681Z 0 [ERROR] [MY-010119] [Server] Aborting
sm_v2-mysql-1         | 2022-08-30T15:19:04.757223Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30)  MySQL Community Server - GPL.
sm_v2-mysql-1 exited with code 1
sm_v2-laravel.test-1  | 2022-08-30 15:19:07,746 INFO Set uid to user 0 succeeded
sm_v2-laravel.test-1  | 2022-08-30 15:19:07,751 INFO supervisord started with pid 1
sm_v2-laravel.test-1  | 2022-08-30 15:19:08,756 INFO spawned: 'php' with pid 16
sm_v2-laravel.test-1  | 2022-08-30 15:19:09,759 INFO success: php entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
sm_v2-laravel.test-1  |
sm_v2-laravel.test-1  |    INFO  Server running on [http://0.0.0.0:80].
sm_v2-laravel.test-1  |
sm_v2-laravel.test-1  |   Press Ctrl+C to stop the server
sm_v2-laravel.test-1  |
sm_v2-laravel.test-1  |   2022-08-30 15:19:21 ................................................... ~ 1s
sm_v2-laravel.test-1  |   2022-08-30 15:19:23 /favicon.ico ...................................... ~ 0s
sm_v2-laravel.test-1  |   2022-08-30 15:19:23 ................................................... ~ 1s
sm_v2-laravel.test-1  |   2022-08-30 15:19:24 /build/assets/app.ac81e540.css .................... ~ 0s
sm_v2-laravel.test-1  |   2022-08-30 15:19:24 /build/assets/app.ab93cf8a.js ..................... ~ 0s
sm_v2-laravel.test-1  |   2022-08-30 15:19:24 /favicon.ico ...................................... ~ 0s
sm_v2-laravel.test-1  |   2022-08-30 15:19:27 ................................................... ~ 0s
sm_v2-laravel.test-1  |   2022-08-30 15:19:29 /favicon.ico ...................................... ~ 0s
    sm_v2-laravel.test-1  |   2022-08-30 16:07:14 ................................................... ~ 0s

Update 2
I get different error now
SQLSTATE[HY000] [1045] Access denied for user 'root'@'192.168.128.3' (using password: YES)

A: I finally solved it after mental frustation of more than a week. But it is very strange that no one was able to provide any answer in any forums, yes I tried all the famous forums possible.
I made sure that two users are added on my host(main computer) machine not the docker mysql, and I granted them full grant using mysql cli, there were 2 entries like these along with other entries
root | %
root | localhost

I ran following commands one after another. I don't know which commands exactly solved the problem as I am a beginner in docker and sail but here are my steps that I tried after which it started working.
I was getting Docker is not running. , so I tried following to make docker running.
sudo systemctl enable docker.service
sudo systemctl enable docker.socket

After that I tried sail up but it did not work, so ran following
sudo systemctl stop docker
sudo systemctl start docker
sudo systemctl disable docker.service
sudo systemctl enable docker.service
sail up

After that I rebooted my computer (I am on Ubuntu 22.04)
reboot

Removed some unnecessary files, also I got some failed error in docker service which I solved by running line 2&3 of the code below
sudo rm /etc/systemd/system/docker.service.d/override.conf
sudo systemctl reset-failed docker.service
sudo systemctl start docker.service
systemctl daemon-reload
sudo systemctl start docker.service

sail down
sail build --no-cache
sail up

php artisan config:clear

After that I migrated database and it worked
sail artisan migrate

After that
sudo systemctl enable docker
sail up
sail build
sail ps
sudo usermod -aG docker ${USER}

Removed daemon.json
sudo rm daemon.json

Removed old volumes
I think this was helpful
sail down --rmi all -v
sail up / (you can use sail up --no-cache)

Now mysql works on host computer port 3306 as well as other ports used for docker 3307,3308 simultaneously
I Appreciate @Mihai  effort becoz only @Mihai responded in the comments
Update 2
I had to add platform: 'linux/x86_64'  in docker-compose.yml file
mysql:
        image: 'mysql/mysql-server:8.0'
        platform: 'linux/x86_64'
        ports:
            - '${FORWARD_DB_PORT:-3307}:3306'


text:
Q: Creating a group by of a group by I'm sure this is really straightforward, but I'm struggling! I'd like to create a group by for the count of the incidence of a value, eg. there are two incidences of case_id '10' and two of case_id '20', so there would be two counts of 'two'
Data table:
id | case_id
---------------
0  | 10
1  | 10
2  | 20
3  | 20
4  | 30
5  | 30
6  | 30
7  | 40
8  | 40
7  | 40
8  | 40

Creates this:
no of occurrences  | count
of a case_id       |
---------------------------
  2                |  2
  3                |  1
  4                |  1

Thank you!

A: Use an inner query:
SELECT occurences, COUNT(*) cnt
FROM (
    SELECT COUNT(*) occurences FROM mytable GROUP BY case_id
) x
GROUP BY occurences

Demo on DB Fiddle:
| occurences | cnt |
| ---------- | --- |
| 2          | 2   |
| 3          | 1   |
| 4          | 1   |

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can I increase the speed of the results in an mysql select statement? I have a SELECT statement that queries about 115K records.
SELECT *
FROM RC_DATA
WHERE field_19 = '$county'
  AND field_178 = 'Active'
  AND field_1 LIKE '%res%'
ORDER BY field_176
LIMIT 8, 4

It take around 20 seconds to display the results.
I tried specifying the fields (about 20 of them) instead of using * with the same results.
Is there a faster way to do this?

A: Add indexes
Only select the fields you need


text:
Q: Update and insert performance with partial indexes I have different queries for fetching data from a large table (about 100-200M rows). I've created partial indexes for my table with different predicates to fit the query because I know each query.
For example, the table similar to this:
CREATE TABLE public.contacts (
    id int8 NOT NULL DEFAULT ssng_generate_id(8::bigint),
    created timestamp NOT NULL DEFAULT timezone('UTC'::text, now()),
    contact_pool_id int8 NOT NULL,
    project_id int8 NOT NULL,
    state_id int4 NOT NULL DEFAULT 10,
    order_x int4 NOT NULL,
    next_attempt_date timestamp NULL,
    CONSTRAINT contacts_pkey PRIMARY KEY (id)
);

And there are two types of query:
SELECT * FROM contacts WHERE contact_pool_id = X AND state_id = 10 ORDER BY order_x LIMIT 1;

and
SELECT * FROM contacts WHERE contact_pool_id = X AND state_id = 20 AND next_attemp_date <= NOW ORDER BY next_attemp_date LIMIT 1;

For those queries I've created partial indexes:

*

*For state_id = 10 (new contacts)

CREATE INDEX ix_contacts_cpid_orderx_id_for_new ON contacts USING btree (contact_pool_id, order_x, id) WHERE state_id = 10;

*For state_id = 20 (available contacts)

CREATE INDEX ix_contacts_cpid_nextattepmdate_id_for_available ON contacts USING btree (contact_pool_id, next_attempt_date, id) WHERE state_id = 20;

For me, those partial indexes are faster than a single index.
And what about an update and insert performance? If I change a row with state_id = 20, will it affect only index 2 (for available contacts) or both of them will be affected?

A: Partial indexes which are not relevant to the tuple will not get updated.
If PostgreSQL can do a HOT update (if the column being changed is not part of an index, and there is room on the same page for the new tuple), then even the relevant index doesn't need to get updated.

A: Yes, with a partial index you only pay the overhead of modifying the index for rows that meet the WHERE condition, so you will always only need to modify at most one of the indexes at the same time (unless you change state_id from 10 to 20 or vice versa).


text:
Q: Linking with 3rd party library causes segfault in openssl I have a 3rd party library that's using OpenSSL, also I'm using Qt networking classes for accessing a service that's running on https.
What's puzzling is that when I link with my application with a proprietary library then it segfaults during a call to QSslSocket, in code belonging to OpenSSL. All I have to do to get the segfault is to link with it, without calling any functions from the library.
When I don't link with the library then everything works fine.
The segfault looks like this
Program received signal SIGSEGV, Segmentation fault.
__strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:209
209     ../sysdeps/x86_64/multiarch/../strcmp.S: No such file or directory.
(gdb) bt
#0  __strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:209
#1  0x00007ffff72a4a5a in getrn () from /usr/lib64/libs63lib-5.16-dynr.so.10.0
#2  0x00007ffff72a4d90 in lh_insert () from /usr/lib64/libs63lib-5.16-dynr.so.10.0
#3  0x00007ffff72391fc in OBJ_NAME_add () from /usr/lib64/libs63lib-5.16-dynr.so.10.0
#4  0x00007ffff41ddba8 in SSL_library_init () from /lib/x86_64-linux-gnu/libssl.so.1.0.0
#5  0x00007ffff6b14b12 in ?? () from /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4
#6  0x00007ffff6b16de9 in ?? () from /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4
#7  0x00007ffff6b050b9 in QSslCertificate::QSslCertificate(QByteArray const&, QSsl::EncodingFormat) () from /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4
#8  0x00007ffff6b0f429 in ?? () from /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4
#9  0x00007ffff6b1760e in ?? () from /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4
#10 0x00007ffff6b1230f in QSslSocket::QSslSocket(QObject*) () from /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4
#11 0x0000000000404438 in main (argc=1, argv=0x7fffffffdb98) at s63seg.cpp:49

Here are the last lines from strace.
close(4)                                = 0
mprotect(0x7fbab8e95000, 110592, PROT_READ) = 0
munmap(0x7fbabc672000, 215488)          = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=215488, ...}) = 0
mmap(NULL, 215488, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7fbabc672000
close(4)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libssl.so.1.0.0", O_RDONLY|O_CLOEXEC) = 4
read(4, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20.\1\0\0\0\0\0"..., 832) = 832
fstat(4, {st_mode=S_IFREG|0644, st_size=382984, ...}) = 0
mmap(NULL, 2478288, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 4, 0) = 0x7fbab8887000
mprotect(0x7fbab88db000, 2097152, PROT_NONE) = 0
mmap(0x7fbab8adb000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 4, 0x54000) = 0x7fbab8adb000
mmap(0x7fbab8ae4000, 208, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fbab8ae4000
close(4)                                = 0
mprotect(0x7fbab8adb000, 12288, PROT_READ) = 0
munmap(0x7fbabc672000, 215488)          = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0} ---

Any idea what might be causing it or how I could prevent it?
When anything else fails then I could just put the code that uses the proprietary library in a separate executable and call it with system() or something similar, but that wouldn't be a very nice solution.

A: The two uses of OpenSSL are conflicting. You can only have one implementation of CRYPTO_set_locking_callback(), CRYPTO_set_id, and the other callback functions. Two users of OpenSSL in the same process have to cooperate on these things.


text:
Q: Class/Method to check if table exists in SE11 or not? I want to check if a table exists in SE11 or not through ABAP.
Their are some FM's available like "C_TABLE_EXISTENCE"....
But i can't use FM's.
I want to use or have to use Class and its methods in my software.
Please suggest me, how can i check existence of a table without using any FM.
Preferably Class and Method.

A: You can use the class cl_rebf_ddic_tabl
It's exists will return you X if the object (Table, Structure or View) exists i SE11
EG:
CALL METHOD cl_rebf_ddic_tabl=>exists
  EXPORTING
    id_name     = [table name]
    id_tabclass = 'TRANSP'  " For table
*    if_noview   = ABAP_FALSE
  receiving
    rf_exists   = yes
    .

A: The official API to check whether a dictionary data type exists is the function module DDIF_NAMETAB_GET. It features a rather comprehensive documentation. Be aware that it will work for various kinds of tables and data structures and make sure you check the DDOBJTYPE.
If for whatever reason (maybe this is a homework assignment..?) you have to restrict yourself to method calls, you can use the RTTI classes (descendants of CL_ABAP_TYPEDESCR) - but be aware that this is a bit more work because you have to ensure that what you got is actually a table. The RTTI classes will return descriptors of any data type, even the internal ABAP runtime types, while DDIF_NAMETAB_GET is restricted to dictionary types.

A:   CALL METHOD cl_abap_structdescr=>describe_by_name
    EXPORTING
      p_name = tabname
    EXCEPTIONS
      OTHERS = 1.
  IF sy-subrc <> 0.
    WRITE: `Table ` && tabname && ` does not exist`.
    RETURN.
  ENDIF.

To validate results manually, call SE11 (or SE16, table DD02L).

A: You should take a look at the function module DD_OBJECT_EXISTS , it will be helpful.


text:
Q: Adding an array? I found a nice jquery slideshow that I want to implement for a friend/client.  Normally I can figure these things out, but for some reason I'm stumped.
I want to use a specific transition, and the documentation provided tells me it's an array that I have to add, otherwise the script uses all the transitions randomly.
This is the basic code:
$(function(){
  if(!flux.browser.supportsTransitions)
    alert("Flux Slider requires a browser that supports CSS3 transitions");

  window.f = new flux.slider('#slider', {
    pagination : true,
  });
});

I've got it all working, just not the specific transition.  I've searched and can't find anything that looks like my issue.
i know i use 'transitions' and the transition i want is 'bars3d', but I can't seem to figure it out (I'm rusty - my current job is very "basic" when it comes to programming and I haven't worked properly with javascript/jquery in a couple of years)
Any help would be greatly appreciated.

A: When you make the instance of a new flux.slider, just add to the option object parameter the key transitions with, as value, an array with a single element.
The element is a string containing 'bars3d'.
I edited the relevant part of your code
For complete reference see https://github.com/joelambert/Flux-Slider
window.f = new flux.slider('#slider', {
  pagination : true,
  transitions: ['bars3d']
});


text:
Q: RegEx for quantifying and finding a character Considering a string with 12 characters, I want to split the string in three groups of four characters and find a character in group 1 and 3.
For example:
AAAABBBBAAAA  -> B not found (they are in group 2)
ABAABBBBAAAA  -> B found in the first 4 characters (group 1)
AAAABBBBABAA  -> B found in the last 4 characteres (group 2)

I only managed to create group 1 and 3, but I don't know how to find the 'B' on them:
(^.{0,4})|(.{0,4}$)

Thanks

A: Basically, you want to match B's that have 3 or less characters behind them...
(?<=^...|^..|^.|^)B

or B's that have 3 or less characters after them.
B(?=.{0,3}$)

So, this should match all B's that satisfy your conditions:
(?<=^...|^..|^.|^)B|B(?=.{0,3}$)

We are using a positive lookahead and a positive lookbehind here. Those will check your constraints, without being a part of the match. This means that only what you are interested in (the B's) will appear in the match. The reason we don't use the quantifier (e.g.: .{0,3}), on the lookbehind is because quantifiers generally don't work on them. This is why we resort to the "brute force" aproach: ^...|^..|^.|^.
See it live!
On many languages, positive lookbehinds aren't available. If this is the case, you can use lookaheads for both assertions:
B(?=.{8,11}$)|B(?=.{0,3}$)

See it live!

A: You could try this. This finds a 'B' in any group of 4.
Perl version:
^(?:(?=.{0,3}(B))?....)(?:(?=.{0,3}(B))?....)(?:(?=.{0,3}(B))?....)$
PCRE version:
^(?:(?:(?=.{0,3}(B)))?....)(?:(?:(?=.{0,3}(B)))?....)(?:(?:(?=.{0,3}(B)))?....)$
https://regex101.com/r/yV72s2/1
Explained
 ^
 (?:
      (?=
           .{0,3}
           ( B )                         # (1), B in first group of 4
      )?
      . . . .
 )

 (?:
      (?=
           .{0,3}
           ( B )                         # (2), B in second group of 4
      )?
      . . . .
 )

 (?:
      (?=
           .{0,3}
           ( B )                         # (3), B in third group of 4
      )?
      . . . .
 )
 $

If you just want to find out if a 'B' matches in the first or last 4, it would be this
(?:^(?=.{12}$)(?:(?=.{0,3}?(B))....)|(?<=^.{8})(?:(?=.{0,3}?(B))....)$)
https://regex101.com/r/wEdTCU/1
Explained
 (?:
      ^
      (?= .{12} $ )
      (?:
           (?=
                .{0,3}?
                ( B )                         # (1), B in first group of 4
           )
           . . . .
      )
   |
      (?<= ^ .{8} )
      (?:
           (?=
                .{0,3}?
                ( B )                         # (2), B in third group of 4
           )
           . . . .
      )
      $
 )

A: If quantifiers with an infinite width or a predetermined range are are supported in a lookbehind like in for example .NET, Python PyPi regex module or Java you might also use:
(?<=^[AB]{0,3})B|B(?=[AB]{0,3}$)

Regex example in C#
Explanation

*

*(?<=^[AB]{0,3}) Assert what is on the left is start of string, 0-3 times A or B

*B Match literally

*| Or

*B Match literally

*(?=[AB]{0,3}$) Assert what is on the right is 0-3 times A or B, assert end of string


text:
Q: Jackson - reading a JSON array with Robospice using loadDataFromNetwork() method I'm trying to read JSON array, which has the following format: [{"vehicle_id":"76","color":"red"},{"vehicle_id":"7","color":"blue"}], following Robospice's Starter Guide.
Vehicle.java
public class Vehicle {
    @JsonProperty("vehicle_id")
    private int vehicleID;
    @JsonProperty("color")
    private String color;
}

(setters and getters follow)
Class which is giving errors:
VehiclesRequest.class
public class VehiclesRequest extends SpringAndroidSpiceRequest<Vehicle> {

    private static final String METHOD = "systemVehicles";

    public SystemVehiclesRequest() {
        super(Vehicle.class);
    }

    @Override
    public Vehicle[] loadDataFromNetwork() throws Exception {
        return getRestTemplate().getForObject(
                FULL_URL,
                Vehicle[].class);
    }
}

As you can see, I'm overriding loadDataFromNetwork() method and then passing it to the spiceManager.execute() method inside my activity and reading data from the request using custom listener. However I cannot return and array (I've tried with the List<> too) from loadDataFromNetwork(), what would be the best workaround here? I know I could get the data in a different way but I want to still use my listener and be able to make try block that way.

A: I solved the problem by adding Vehicles class:
@JsonIgnoreProperties(ignoreUnknown = true)
public class Vehicles extends ArrayList<Vehicle> {

    public Vehicles() {
    }

}

and changing loadDataFromNetwork() method like that:
public Vehicles loadDataFromNetwork() throws Exception {
    return getRestTemplate().getForObject(
            FULL_URL,
            Vehicles.class);
}

A: Noticed that you should pass array type to super constructor:
public class VehiclesRequest extends SpringAndroidSpiceRequest<Vehicle[]> {

    private static final String METHOD = "systemVehicles";

    public SystemVehiclesRequest() {
        super(Vehicle[].class);
    }

    @Override
    public Vehicle[] loadDataFromNetwork() throws Exception {
        return getRestTemplate().getForObject(
                FULL_URL,
                Vehicle[].class);
    }
}

And I think it looks much reasonable using an array type than creating a new class extending ArrayList<Vehicle> to get things work.


text:
Q: Type Ahead search using Nautilus on Ubuntu 18.04 Before upgrading to Ubuntu 18.04 LTS, I was using Ubuntu 16.04.1 LTS. When I was in the file browser, I was able to access a file just by writing some letters; it just got selected and it was super fast.
After upgrading, when I start typing a search is launched and it's a little bit slow. I prefer the old method.
I tried searching on the internet but didn't know exactly what to type on the search bar.
How can I disable this automatic search?
Thank you

A: Type Ahead search was removed completely from Nautilus, aka GNOME Files, since Artful. Luckily, there is a patch on GitHub that adds this functionality back to Nautilus 3.26.3, the version installed by default in Ubuntu 18.04. Now if you want to apply the patch and build Nautilus from source, go ahead, but there is a guy that did the job for us and provided a PPA to install the patched Nautilus directly:
sudo add-apt-repository ppa:lubomir-brindza/nautilus-typeahead

Then upgrade using sudo apt full-upgrade and kill Files nautilus -q
Please note that this will overwrite the standard version of Nautilus 3.26 in Ubuntu 18.04 with a third-party build. If you're from the paranoid type you're better off using Nemo or Caja instead.
Source: [1]


text:
Q: EXC_BAD_ACCESS crash upon dismissing UIViewController I have two buttons triggering segues to two different UIViewCOntrollers, using this code:
- (IBAction)newTransButton:(UIButton *)sender
{
    [self performSegueWithIdentifier:@"newTransSegue" sender:self];
}

- (IBAction)switchAccountButton:(UIButton *)sender
{
    [self performSegueWithIdentifier:@"selectAccountSegue" sender:self];
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];

    if ([[segue identifier] isEqualToString:@"newTransSegue"])
    {
        UINavigationController *navController = (UINavigationController *)segue.destinationViewController;
        AddTransactionVC *atvc = (AddTransactionVC *)navController.topViewController;
        atvc.delegate = self;

        WMMGTransaction *addedTransaction = (WMMGTransaction *)[WMMGTransaction MR_createInContext:localContext];

        addedTransaction.account = self.currentAccount.name;
        atvc.thisTransaction = addedTransaction;
    }

    else if ([[segue identifier] isEqualToString:@"selectAccountSegue"])
    {
        UINavigationController *navController = (UINavigationController *)segue.destinationViewController;
        AccountSelectVC *acctSelVC = (AccountSelectVC *)navController.topViewController;
        acctSelVC.delegate = self;
    }
}

Activation of either button segues to the appropriate view controller, but causes this warning:
Warning: Attempt to present <UINavigationController: 0x7fb99b4dd430> on <FirstViewController: 0x7fb99b565dd0> whose view is not in the window hierarchy!

I have a Save and a Cancel Navigation bar button on each View controller. Other than as mentioned above, everything works as expected, except for the Cancel button on the View controller at newTransSegue, which dismisses the VC, but crashes the app with this error:
EXC_BAD_ACCESS (code = 1, address = 0x7f87394af29)
Here is the delegate method I use to dismiss that VC:
-(void)addTransactionViewControllerDidCancel
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

I've been at this for a couple of days, and have tried deleting the segues and recreating them in storyboard, as well as doing the same for the navigation controllers. I've gone off the rails somewhere, but can't see exactly where.
I could sure use some guidance. :)

A: OK, I studied the reference kindly provided by @Jay. Turns out I had seen it before, but only Part 1. In Part 2, I discovered a reference to Enable Zombie Objects, which I did. Now, when the app crashed, I was provided with this message: [_UILayoutGuide isDescendantOfView:], which pointed to an issue in the Storyboard.
Upon examining the Storyboard, I discovered that, surprisingly, the representation of the view controller in question was shaped differently than the surrounding view controllers. I wish I'd made a screenshot, but in the heat of the hunt, I didn't.
In any case, further research turned up this question (and its associated comments). My investigation revealed that, while I had Size Classes enabled, for some reason I can't explain, the size of the relevant View Controller under Simulated Metrics had been set to "Freeform." I reset it to "Inferred" and things appear to be operating normally now--no crashes. Wish I could explain it in detail, but I'm happy with the result!


text:
Q: Is there a way to keep permanent access to resources exposed with FileProvider across multiple app launches on Android So basically, my app receives external content:// uris exposed with android FileProvider. As android documentation states:

Permissions granted in an Intent remain in effect while the stack of
  the receiving Activity is active. When the stack finishes, the
  permissions are automatically removed.

If I want shared resource to be available for my users across multiple app launches I have to copy all it's content to my app's own storage, even if its a big amount of data? (Let's say few gigabytes of photos)
Or do I have some other options to hold permanent access on those uris?

A:
If I want shared resource to be available for my users across multiple app launches I have to copy all it's content to my app's own storage, even if its a big amount of data?

Yes.

Or do I have some other options to hold permanent access on those uris?

No. The only thing that gives you semi-permanent access is if you are using ACTION_OPEN_DOCUMENT, then use takePersistableUriPermissions() on a ContentResolver to request long-term access to the content identified by the Uri that you get back.
Alternatively — if you are controlling both sides of this data exchange — do something else for passing the content references. For example, if the content is on external storage, just pass the filesystem path, and ensure that both parties have the appropriate permissions.


text:
Q: I need to restrict Android textInput to only ISO-8859-1 characters I have an input on my android app, the text from this input is sent to my server and then later retrieved by another front end to be displayed. the other front end can only work with ISO-8859-1 character set and will crash if any other characters are encountered(its an old software) so I need to restrict the EditText to only allow ISO-8859-1 characters and I'm not sure how I can achieve this.
[EDIT]
So big thanks to aarnaut for the help, this is what I have ended up with:
public class ISO_8859_1_InputFilter implements InputFilter {
    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
        CharsetEncoder iso_8859_1 = Charset.forName("ISO_8859_1").newEncoder();
        if (source instanceof SpannableStringBuilder) {
            SpannableStringBuilder sourceAsSpannableBuilder = (SpannableStringBuilder) source;
            for (int i = end - 1; i >= start; i--) {
                char currentChar = source.charAt(i);
                if (!iso_8859_1.canEncode(currentChar)) {
                    sourceAsSpannableBuilder.delete(i, i + 1);
                }
            }
            return source;
        } else {
            StringBuilder filteredStringBuilder = new StringBuilder();
            for (int i = start; i < end; i++) {
                char currentChar = source.charAt(i);
                if (iso_8859_1.canEncode(currentChar)) {
                    filteredStringBuilder.append(currentChar);
                }
            }
            return filteredStringBuilder.toString();
        }
    }
}

A: You could simply prevent the user from entering anything other than what is allowed by the ISO-8859-1. You can do this by either applying an android:digits attribute to the EditText e.g
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 "
or by implementing a custom filter whenever a new character is passed into the view. This will ensure that you have ISO-8859-1 characters only.
A class CharsetEncoder within java.nio.charset package provides possibility to check whether a string/character satisfies a specific encoding,
val encoder = Charset.forName("ISO_8859_1").newEncoder()
val canEncode = encoder.canEncode(text)


text:
Q: real link in html-mode emacs emacs has taken my image src text and made it followable. how do I turn that off so I just have plain text.

should be

the first is clickable and opens the image file, the second is the actual text which is what I want to see.
how do I turn this off without turning off html-mode?
edit #1
mlinks-mode is what is doing it, and it was firefox that changed the image paths when I "saved page as"

A: I'm not sure I understand the question.  You appear to be saying that Emacs is displaying src="index_new_menus_files/menu_bg_2.gif" in the buffer, but is saving it as src="images/menu_bg_2.gif".  But I find that hard to believe.
In Firefox, when you Save Page As... "Web page, complete", it changes all the  tags to link to the pagename_files directory.  Once it's done that, there's no way for Emacs to know what the original link looked like.  You'd have to Save Page As... "Web page, HTML only" to prevent Firefox from changing all the links.  That has nothing to do with Emacs.


text:
Q: How to find certain informations in unstructured text i want to implement an application to analyze text. It should check the text for information that I define, e.g. a product announcement, a comment about someone or something, ....
The important text then just needs to be extracted without changing anything.
What should I look at to aquire the knowledge to do that? Can you recoment a method/algorithm to do that?
Thanks for the help
AVL

A: Depends on how smart your analyzer has to be.
The simplest approach would be to search for a keyword, perhaps by regular expressions.
One could also think of using some statistical text analysis like spam filters do (see e. g. http://bogofilter.org/ or http://nasauber.de/opensource/b8/) to distinguish ham from spam. One could create a database with "learned" texts typical for one topic and then calculate the "spamminess", saying the probability that the text is about that topic for each database. This will probably work fine, but it's alot of work to write the code doing it.


text:
Q: Reload page out of iframe I'm using Fancybox and Zend. Hope the following is clear.
On www.example.com/template/edit/id/3 I have jQuery UI Tabs. They are reachable directly via anchors. E.g. www.example.com/template/edit/id/3#tabs-2
On #tabs-2 I have some elements, doesn't matter what it is exactly. You can create or edit them. This elements got a own controller, so for editing them you call /elements/edit/id/44. Currently, I'm doing that in a Layer with Fancybox. I'm using the Iframe functionality of Fancybox for that.
So, if you are on /template/edit and you click on the edit button of an element, a layer opens which includes an iframe which loads /elements/edit.
So, if you change the element now and click on save, i want the layer to automatically close and reload.
Fancybox provides an option to specify what it should do when it gets closed. At the moment i got it like that:
'onClosed'          :  function() {window.location.reload();}

This actually reloads the top window and not the iframe. Also, there's a possibility to close Fancybox via JS. I'm doing that by setting a View Variable which triggers this, e.g:
<?php if($this->close): ?>
    <script type="text/javascript">
    parent.$.fancybox.close();
    </script>
<?php endif ?>

So, if the saving was successfully I set $this->view->close = true and the layer gets clsoed which triggers my JS.
This works fine. My Problem now is to do the reloading with having #tabs-2 in my url.
Of course i could get the urls, clean it up from other anchors the user my typed in etc. and build my url which i set to the window's location, but somehow i think, there must be an easier solution.
E.g. setting the url of the browser to #tabs-2 without reloading, but this also sounds not very nice. The reloading is easy but having the anchor there is quite tricky.

A: window.location.href = "#tabs-2"

Maybe:
<script type="text/javascript">
    parent.$.fancybox.close();
    window.location.href = "#tabs-2" //Add the anchor, won't stack. Will replace existing anchor
    window.location.reload() //Refresh the screen, maintain anchor
</script>


text:
Q: Android 5.0 (Lollipop) startService without import class I need to start from an android widget a service using android > 5.0, but this service is implemented into another project.
If I use a device, with android < 4.4 this code work:
Intent intent = new Intent("com.service.example");
startService(intent);

I read this post:
Service Must be explicit: Intent
and the solution, should be:
Intent serviceIntent = new Intent(context,MyService.class);
context.startService(serviceIntent);

So, how do I start service (using intent) without importing the service class?

A: you need to actually setComponent to start a service in another application. For instance,
Activity in com.xyz.app1:
Intent mServiceIntent = new Intent();
String pkg = "com.xyz.app2";
String cls = "com.xyz.app2.MyService";
mServiceIntent.setComponent(new ComponentName(pkg, cls));
startService(mServiceIntent);

You don't need to set ACTION or CATEGORY if you are specifying a specific component. Make sure that your service is properly defined in the manifest.

A: You can use the component name:
Intent intent = new Intent(YOUR_ACTION_HERE);
intent.setComponent(new ComponentName("your.package.name",
                "your.package.name.YourService"));
statService(intent);


text:
Q: QuickLook/QLPreviewController(QLPreviewItem) change title in iOS8 in iOS7 works fine I'm trying to preview my documents/pictures using QuickLook library.
   Everything was fine when I wanted to open the content in both ios7 & ios8.
   I want to change the name of the item found in the preview.
   Everything is fine on iOS7 but when I run the application on iOS8  there are problems.
This is my code :
-(void)startDownload{
// Download code here - after I set the  QLPreviewController

QLPreviewController* lcontroller= [QLPreviewController new];
self.quickLookUrl      = item.openUrl;
self.quickLookName     = item.name;
lcontroller.dataSource = self;
[self presentViewController:lcontroller animated:NO completion:nil];
}

#pragma mark - Quicklook Delegate
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller{
      return 1;
}

- (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index{
    QLPreviewItemCustom *obj = [[QLPreviewItemCustom alloc] initWithTitle:self.quickLookName url:[NSURL fileURLWithPath:self.quickLookUrl]];
    return obj;
}

QLPreviewItemCustom - QLPreviewItem details :
QLPreviewItemCustom.h
#import <Foundation/Foundation.h>
#import <QuickLook/QuickLook.h>

@interface QLPreviewItemCustom : NSObject <QLPreviewItem>

- (id) initWithTitle:(NSString*)title url:(NSURL*)url;
@end

QLPreviewItemCustom.m - details :
   #import "QLPreviewItemCustom.h"

    @implementation QLPreviewItemCustom
    @synthesize previewItemTitle = _previewItemTitle;
    @synthesize previewItemURL   = _previewItemURL;

    - (id) initWithTitle:(NSString*)title url:(NSURL*)url
    {
        self = [super init];
        if (self != nil) {
            _previewItemTitle = title;
            _previewItemURL   = url;
        }
        return self;
    }
    @end

When I run the project on iOS8 this is the result :

I have read the release notes about iOS8 GM (I was able to open PDF files in the application without any problem) :
 iOS8 GM Release Notes
At this point I do not know if it is still a problem with the new SDK or am I wrong in the development process.
  Can you help me with advice? I have not found other libraries to help me to preview the content of my items (pdf, jpg, excel, doc..).
Thanks in advance for your help !

A: I Think that you forgot to indicate the delegate of your QLPreviewController in code. I run this code on iOS8 and it's work fine :
// MARK: - QLPreviewControllerDelegate
func numberOfPreviewItemsInPreviewController(controller: QLPreviewController! ) -> Int
{
    return 1
}

func previewController(controller: QLPreviewController!, previewItemAtIndex index: Int) -> QLPreviewItem!
{
    // Break the path into it's components (filename and extension)
    // Use the filename (index 0) and the extension (index 1) to get path
    let path = self.filenameToShow
    return NSURL.fileURLWithPath(path!)!
}

func showPrescription(sender: UIButton)
{

    self.previewController = IGQLPreviewController()
    let directory  = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomainMask.UserDomainMask, true)
    var path: String = directory[0] as! String
    let fileName = String(format: "%@_%@.png", arguments: [self.numberTextField.text, self.name.text])
    let imagePath = path.stringByAppendingPathComponent(fileName)

    self.filenameToShow = imagePath

    self.previewController!.dataSource = self
    self.previewController!.delegate = self
    self.previewController!.currentPreviewItemIndex = 0

    self.navigationController?.pushViewController(self.previewController!, animated: true)

}

A: func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {

        //NSURL(fileURLWithPath: self.imageUrl) this will append 'file' string at the end, if you try to load file directly from url.
        // so use below code to load file directly from url.
        let doc = URL(string: fileUrl)
        return doc! as QLPreviewItem

    }


text:
Q: How to clear req.session.array? I am trying to display errorMessages to the user once after they fail registration. If the registration page is visited again the errorMessages array will not be displayed. For some reason req.session.errorMessages is being displayed on every request to the registration page.
module.exports.registration = function(req,res){

    if(Array.isArray(req.session.errorMessages) && req.session.errorMessages.length > 0)
        res.locals.errorMessages = req.session.errorMessages;
    else
        res.locals.errorMessages = [];

    res.render('registration',{

    });

    //This line does not seem to reset the array after the response has been rendered
    req.session.errorMessages = [];

};

A: Move it above the render call. It seems that you can't change req or res anymore after returning data to the user.


text:
Q: Let R be a ring with 1. Show that every principal left ideal is generated by an idempotent iff it is a direct summand of ${}_{R}R$ I think there is a more general statement:
 A left ideal I of R is a direct summand of ${}_{R}R$ $\Leftrightarrow$ I is generated by an idempotent.
the $ \Rightarrow )$ part I got it.
Now suppose $I = Re$ where $e$ is an idempotent element. I don't know how to conclude that I is a direct summand.
Any hint would be nice.

A: Hint: Show that $R=Re \ \oplus \ R(1-e)$


text:
Q: Javascript change for loop variable from within the loop I have a for loop like so
for (var i = 0; i < 100; i += 4) {
    // code with i;
}

I would like to change the value of i to a certain value from within the loop. I am aware you could use continue to change the value of i after evaluating the final-expression, but what if I wanted to change the value of i to something more specific like 40?
Here's one of my attempts
loop:
for (var i = 0; i < 100; i += 4) {
    for (var i = 0; i <= 40; i++) {
        continue loop;
    }
}

Is there a better way of doing this?

A: Just change i directly:
for (var i = 0; i < 100; i += 4) {
    i = 15000;
}

This would exit the loop immediately, but you could do whatever you wanted.
You should read up on function scope to understand how this stuff works. For loops are  bit different from functions in that they're a language construct but the same theory of scope holds true.

A: The scope of increment variable is always available inside the loop block, this allows you  to access increment variable inside the loop block.
for (var i = 0; i < 100; i += 4) {
    if (condition)  i = 40 ;
    /* put any condition to avoid the infinite loop and continue with your rest of code */
}


text:
Q: When submitting record, I get an HTTP forbidden error I'm trying to submit or insert record. But when I click on the submit button, I get the following error:
Forbidden
You don't have permission to access admin/add-member.php< on this server.

Here is the code:
<form id="add" class="form-vertical" action="<?=$_SERVER['PHP_SELF']?><? if(!empty($_GET['id'])){echo '?id='.$_GET['id']; }?>" method="post" enctype="multipart/form-data" >

Where is the issue?

A: Here problem is
<?=

Php is not counting this as tag.So you need to enable the short_open_tag =On in php.ini file and than restart the server

A: Try this:
<form id="add" class="form-vertical" action="<?= $_SERVER['PHP_SELF'] ?><?= (!empty($_GET['id']) ? '?id=' . $_GET['id'] : '') ?>" method="post" enctype="multipart/form-data">

Also, you should do the following to avoid XSS attacks:
<form id="add" class="form-vertical" action="<?= $_SERVER['PHP_SELF'] ?><?= (!empty($_GET['id']) ? '?id=' . htmlentities($_GET['id']) : '') ?>" method="post" enctype="multipart/form-data">

I use htmlentities to escape the user input.

A: Check the permissions set to add-member.php . It must be atleast 644 to handle code. Also the admin folder needs to have proper permissions.


text:
Q: HTTP Status 404 Apache Tomcat I am facing a very strange problem. I made my assignment using JavaEE I run it on my local machine and it works fine, when I deploy it on VM it give me the following error. Nothing is changed in the code.
HTTP Status 404 - /pagescount/start.jsp
type Status report
message /pagescount/start.jsp
description The requested resource is not available
I dont have any issues in my code on local machine.
Anyone knows how to deal with this problem

A: The problem was because of the inclusion of css in my index.jsp file. Nothing else was wrong. So don't include css in jsp make a style.css file and include it in your jsp.
It solved my problem


text:
Q: Isn't it possible to get coordinate without wifi? my code is here:
    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    List<String> providers = lm.getProviders(false);
    Location l = null;

    for (int i=providers.size()-1; i>=0; i--) {
            l = lm.getLastKnownLocation(providers.get(i));
            if (l != null) break;
    }

    double[] gps = new double[2];
    if (l != null) {
            gps[0] = l.getLatitude();
            gps[1] = l.getLongitude();
    }
    return gps;

It only get coordinate when I connected to internet.

A: You can use android GPS service to get Longitute and Latitute too,
add the permission in your AndroidMenifest.xml,
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Initialization,
// saving the context for later use
    private final Context mContext;

    // if GPS is enabled
    boolean isGPSEnabled = false;

    // Location and co-ordinates coordinates
    Location mLocation;
    double mLatitude;
    double mLongitude;

    // Minimum time fluctuation for next update (in milliseconds)
    private static final long TIME = 30000;
    // Minimum distance fluctuation for next update (in meters)
    private static final long DISTANCE = 20;

    // Declaring a Location Manager
    protected LocationManager mLocationManager;

   // This is constructor to get System Location services,
    public GPSService(Context context) {
        this.mContext = context;
        mLocationManager = (LocationManager) mContext
                .getSystemService(LOCATION_SERVICE);

    }

Checking if GPS managed to fetch the data,
try {

            // Getting GPS status
            isGPSEnabled = mLocationManager
                    .isProviderEnabled(LocationManager.GPS_PROVIDER);

            // If GPS enabled, get latitude/longitude using GPS Services
            if (isGPSEnabled) {
                mLocationManager.requestLocationUpdates(
                        LocationManager.GPS_PROVIDER, TIME, DISTANCE, this);
                if (mLocationManager != null) {
                    mLocation = mLocationManager
                            .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                    if (mLocation != null) {
                        mLatitude = mLocation.getLatitude();
                        mLongitude = mLocation.getLongitude();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


text:
Q: .in'ig.status: error: cannot find input file: `Makefile I'm new to GNU and I've been trying to compile a package using Autotools on Mac. After executing the command ./configure, I get the following:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-apple-darwin19.4.0
checking host system type... x86_64-apple-darwin19.4.0
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 196608
checking how to convert x86_64-apple-darwin19.4.0 file names to x86_64-apple-darwin19.4.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin19.4.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin19.4.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for math... no
checking for ANSI C header files... (cached) yes
checking sys/utsname.h usability... yes
checking sys/utsname.h presence... yes
checking for sys/utsname.h... yes
checking for unistd.h... (cached) yes
checking windows.h usability... no
checking windows.h presence... no
checking for windows.h... no
checking gmp.h usability... yes
checking gmp.h presence... yes
checking for gmp.h... yes
checking for stdint.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking whether byte ordering is bigendian... no
checking for long long... yes
checking for uint32_t... yes
checking for uint8_t... yes
checking for random... yes
checking for erf... yes
checking for lgamma... yes
checking for log1p... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
.in'ig.status: error: cannot find input file: `Makefile

After speaking with a teammate working on Windows and using MinGW64, the issue arises on the last line, where the Makefile is supposed to be created like so:
config.status: creating Makefile

Any help will be appreciated.

A: Maybe some files in your system should have been converted from using Windows line endings CRNL to using POSIX line endings NL?  The extra CR character is causing the cursor to go back to the beginning of the line without a newline, and it's causing the name of your file to be MakefileCR (or, Makefile\r) rather than just Makefile.  Obviously the file named Makefile\r.in does not exist.

A: Using @MadScientist's answer, the complete solution for me (using Ubuntu 16.04 on WSL) was -
$autoconf
$./configure --> throws the above error
$ dos2unix configure.ac
$autoconf
$./configure --> No issue now

cat -e <filename> will also show you the line endings to confirm.


text:
Q: Why was the alien released on board the Covenant? Why did

 David, pretending to be Walter

let the Alien out on board the ship?
He already had the crew fooled, so all he had to do was to wait for them to go into hypersleep and then he could conduct as many experiments as he wanted.
Letting the Alien out was very risky: he lost three perfectly good bodies (the one with his cheek burned-out with acid and the couple in the shower) and the alien could also possibly kill all the colonists or even destroy the whole space ship.

A: The way I saw the scene, he didn't know Lope had been impregnated. I'm guessing he assumed the acid burns meant the facehugger had been removed in time.
His plan was that no-one recognise him as an imposter. Daniels only realised his identity when David didn't understand her cabin reference.


text:
Q: How to create a list string display My string is corrected like so:
String mathStatements;

This list stores data for comments made by app users. I would like to display the most recently created comment in a text box on my app and have been doing it like so:
Container(
    child: class.mathStatements == null
     new Text(class.mathStatements),

which works fine. However, I am trying to repeat the process with a list string:
List<String> askedQuestions

but it no longer works and gives me the error message "The argument type 'List' can't be assigned to the parameter type 'String'".
How can I resolve this?

A: [Recommended] If you want to show it as a list view, use ListView.
ListView(
  children: askedQuestions.map((e) {
    return Text(e);
  }).toList(),
)

Or, If you want to show it using one text widget see the below code.
Text(askedQuestions.reduce((value, element) => value + '\n' + element));


text:
Q: Why telegram emoji numbers are not deleted when removing special characters I have a telegram bot and I want to remove all special characters and just returns numbers and A-Z,but the problem is that my regex pattern can remove any emojies except numbers like this :1⃣2⃣3⃣4⃣5⃣6⃣
I want to delete emoji numbers too
So this is my pattern :
text = '1⃣Hi =) 1.This regex removes 2⃣all special 6⃣characters like this !@$#%^&*()_+=~`/\><.⚠4⃣'

text.toUpperCase().match(/[a-z]+|\d+(?:\.\d+)?/gi)
    .map((m) => (isNaN(m) ? m : +m))

//Current output :
// [1,'HI',1,'THIS','REGEX','REMOVES',2,'ALL', 'SPECIAL',6,'CHARACTERS', 'LIKE','THIS']

//What I want :
// ['HI',1,'THIS','REGEX','REMOVES','ALL', 'SPECIAL','CHARACTERS', 'LIKE','THIS']

Also I don't know why it removed the last number emoji from string! (4⃣)

A: These numbers are emojis. To remove them, too, use the following:

text = '1⃣Hi =) 1.This regex removes 2⃣all special 6⃣characters like this !@$#%^&*()_+=~`/\><.⚠4⃣'

console.log(
  text.toUpperCase().match(/[a-z]+|(?!\d\uFE0F\u20E3)\d+(?:\.\d+)?/gi)
    .map((m) => (isNaN(m) ? m : +m))
)

The (?!\d\uFE0F\u20E3) negative lookahead will fail any match of \d+(?:\.\d+)? when the first digit is a part of the numeric emojis.


text:
Q: Failed to request resource on Google Oauth using laravel with artdarek I have searched online for solution to his problem, but i am yet to find a fix. please i need help..
I get this error :
OAuth \ Common \ Http \ Exception \ TokenResponseException
Failed to request resource.
Below is my code, if i am doing anything wrong then please help spot it... I have tried using my Redirect URL manually but it still gives the same error..
public function loginWithGoogle()
{

    $code= Input::get('code');

    $googleService = OAuth::consumer('Google');

    if (!empty($code)){

        $token= $googleService->requestAccessToken($code);
        $result= json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo' ), true);
             if(!empty($result){
                var_dump($result);
             }

    } else {
            // get googleService authorization
            $url = $googleService->getAuthorizationUri();

            // return to google login url
            return Redirect::to( (string)$url );
        }
}


text:
Q: send $_POST to .php file without using CURL Im looking for an alternative to send $_POST data to a .php file without using CURL as it increases loading time of my index.php. Are there any?
I have a file that receives $_POST data and loads file depending on the data received. I've tried using CURL but it greatly increases the loading time of the document. are there any faster alternatives to make 2 php files to communicate with each other without revealing the data sent?

A: I think you are looking for  wget program..It retrieves content from web servers.
Here is the download link


text:
Q: Include HelveticaNeue-Medium in iOS4 iOS5 supports HelveticaNeue-Medium out of the box, and I can just set up everything using xibs.
However, the font is missing in iOS4. I tried adding HelveticaNeue.dfont from my OSX directory, and in plist via UIFonts. I tried (for testing) to add a ttf I found online and nothing worked.
Is there a way to get this working without having to manually set each UILabel programatically?

A: My fault, I was having two conflicting plist files.


text:
Q: Date Calculations (output should be the fixed day of the month) I'm building a LaTeX document that already got the date from other files. The date showed as 23 November 2015 as the example (by \today). Then I need to output another date related to this original date. The resulted date should always the fifteenth day of the next month or this month depending on the original date.
For example, if the original date is 23 November 2015, which is after the 15th day of the month, the resulted date should be 15 December 2015. If the original date is 12 November 2015, the resulted date should be 15 November 2015.
Are there any method to do such calculation with the date output in the file?

A:
\documentclass{article}

\def\zz#1{#1 --- \nextXV{#1}}

\def\nextXV#1{\nextXVx#1\relax}

\def\nextXVx#1 #2 #3\relax{%
  \ifnum#2<16
    #1 15 #3%
  \else
    \csname nextXV#1\endcsname
    \space 15
    \expandafter\ifx\csname nextXV#1\endcsname\nextXVDec
      \the\numexpr#3+1\relax
    \else
      #3%
    \fi
  \fi}

\def\nextXVJan{Feb}
\def\nextXVFeb{Mar}
\def\nextXVMar{Apr}
\def\nextXVApr{May}
\def\nextXVmay{Jun}
\def\nextXVJun{Jul}
\def\nextXVJul{Aug}
\def\nextXVAug{Sep}
\def\nextXVSep{Oct}
\def\nextXVOct{Nov}
\def\nextXVNov{Dec}
\def\nextXVDec{Jan}

\begin{document}

\zz{Nov 12 2015}

\zz{Nov 23 2015}

\zz{Dec 23 2015}

\end{document}

A: With some conditionals on the current day-of-the-month, advdate can be used to retrieve the date you're looking for:

\documentclass{article}

\usepackage{advdate}

\newcommand{\nextfifteenth}[1][\relax]{{%
  \ifx\relax#1\relax\else\SetDate[#1]\fi% If a date was specified
  \today---%
  \ifnum\day<15\else% \day >= 15
    \AdvMonth{1}% Move to next month
  \fi
  \ThisDay{15}% Day will always be 15th
  \today
}}

\begin{document}

\today

\nextfifteenth

\nextfifteenth[15/12/2015]

\nextfifteenth[12/12/2012]

\today

\end{document}

You could also supply the date in a textual format 12 December 2012 (say) using the following:
\documentclass{article}

\usepackage{advdate,xparse}

\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\StrMonthToNum}{ m }
{
  \str_case:nnF { #1 } {
    { January   } {  1 }
    { February  } {  2 }
    { March     } {  3 }
    { April     } {  4 }
    { May       } {  5 }
    { June      } {  6 }
    { July      } {  7 }
    { August    } {  8 }
    { September } {  9 }
    { October   } { 10 }
    { November  } { 11 }
    { December  } { 12 }
  } { 12 } % Wrong month, defaults to December/12
}
\ExplSyntaxOff

\def\formattextdate#1 #2 #3\relax{%
  \ThisDay{#1}% Set day
  \expandafter\ThisMonth\expandafter{\StrMonthToNum{#2}}% Set month
  \ThisYear{#3}% Set year
}

\newcommand{\nextfifteenth}[1][\relax]{{%
  \ifx\relax#1\relax\else
  \expandafter\formattextdate #1\relax%
  \fi% If a date was specified
  \today---%
  \ifnum\day<15\else% \day >= 15
    \AdvMonth{1}% Move to next month
  \fi
  \ThisDay{15}% Day will always be 15th
  \today
}}

\begin{document}

\today

\nextfifteenth

\nextfifteenth[15 December 2015]

\nextfifteenth[12 December 2012]

\today

\end{document}


text:
Q: In C++ is there any portable way of jumping to a computed offset? I'm looking for a portable way of jumping to a computed offset in C++.
I know that GCC has a mechanism for doing this using goto as discussed here:
http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/ec7e52b5-0978-4123-9d29-9dc7d807c6b4
Sadly I don't think other compilers implement this.
Normally I wouldn't have reason to use goto in C++ but I found that it could be useful for optimizing an interpreted language (search for 'threaded interpreter' if you are interested in this).
I know that I can implement this using inline assembly language, but the problem then is I have to implement this for every platform the interpreter runs on.
So does anyone know if there is a portable way of doing this?
The solution might involve goto but I'm open to any other sort of hackery that you can think of ;)
UPDATE: Currently the interpreter uses a switch statement.  I'm looking for techniques that improve on this and make the interpreter run faster.  Specifically I'm trying to figure out a portable way of saying 'goto <next-byte-code-instruction>' where <next-byte-code-instruction> is a computed offset that can be stored in the byte code itself.
UPDATE: I found a related question here.
What opcode dispatch strategies are used in efficient interpreters?

A: *

*switch allows to jump to predefined offsets

*Array of function pointers/function objects

*setjmp/longjmp

A: I think setjmp/longjmp is as close as you can get. Beyond that, the spec calls things like offsets in the instruction stream "implementation details", and you're stuck with platform-specific stuff like intrinsics and inline asm.
The other (really ugly) thing you could try is using a switch statement, which is typically implemented as a jump table of offsets.  Ie,
int ip = 0;

top:
switch( ip )
{
 case 0:
   ip += do_whatever(); // returns an offset
   goto top;
 case 1:
   ip += some_other_function();
   goto top;
 case 2:
   ip += etc();
   goto top;
  // ad infinitum...
}

This is in the spirit of Bell's original article, and the gist is that the body of each case is a single VM "opcode" in the stream. But that seems really icky.

A: Aside from goto's and longjumping and other nonportable tricks, could you consider virtual functions or at least ponters to functions? You can have several singleton objects of types derived from single base class. Array of pointers has all those objects. Virtual function returns index of the next interpreter state. Base object holds all data ever needed by any derived object.
EDIT: Pointers to functions could be a little faster even, but a little messier too. There is a Guru of the Week article that explains it.

A: It looks like it is not possible to implement this in a portable way.
(Although I still welcome alternative answers!)
I found this blog post from someone who has already tried what I wanted to do.  He uses the GCC approach and got a 33% speed improvement (stats are at the end of the post).
The solution is conditionally compiled under Win32 to use inline assembly to compute the address of the labels.  But he reports that using inline assembly in this way is 3 times slower than normal!  Ouch
http://abepralle.wordpress.com/2009/01/25/how-not-to-make-a-virtual-machine-label-based-threading/
Oh well, I didn't want to use inline assembly anyway.

A: I seriously wouldn't use any form of goto. It died a long time ago. If you must, however, perhaps you should just write a macro for this, and use a bunch of ifdefs to make it portable. This shouldn't be too hard, and it is the fastest solution.


text:
Q: Angular add and remove classes triggered by method without jquery I have some code which I want to use with animate.css to add and remove a class in a div.
Here is the code:
app.component.html
<button (click)="toggleMethod()">Toggle Classes</button>

    // Stuff here

app.component.ts

toggle = false;

toggleMethod() {

    if (this.toggle === true) {
        //Do this without JQ $('.myDiv').removeClass('animate__animated animate__fadeInLeft');
    } else if (this.toggle === false) {
      //Do this without JQ $('.myDiv').addClass('animate__animated animate__fadeInLeft');
    }
    this.toggle = !this.toggle;

}

How can I do the above without using jQuery (the Angular way) ?

A: For Angular instead of angularjs, try:
app.component.html
<button (click)="toggleMethod()">Toggle Classes</button>

    // Stuff here

app.component.ts
toggle: boolean = false;

toggleMethod() {
    this.toggle = !this.toggle;
}


text:
Q: Web App GPS Polling So it looks like mobile phones these days are capable of providing gps data ;)
I'm building a django app with a mobile edition that I want to be location aware.
My question is, how does one access GPS data? Is there a standard, or do you have to custom code for android/iphone/other.
Ideally, I'd imagine it being provided in the HTTP request in the same way you get information such as the IP Address and User Agent.

A: There's a really good blog post about this topic, covering a variety of methods @
http://hitching.net/2009/11/10/location-aware-mobile-web-apps-using-google-maps-v3-geolocation/

A: Question is quite old, but still users will be redirected here from google, so update:
As for now, the HTML5 geolocation is a standard
You can read Geolocation API specification on W3C and see the Where am I? app to check your desktop/mobile browser support.
HTML5 geolocation is available for Opera/Opera Mobile, Firefox (both desktop and mobile), IE for desktops (unfortunatelly, not mobile version for Windows Phone 7), Safari (both desktop and mobile), Chrome and Android Browser.

A: Server side API will be common for all platforms (just standard HTTP requests).
GPS access is platform depend and typically You will have to write custom code for all platforms. However you can try use http://www.appcelerator.com/ - framework for crating mobile apps using Web based techniques (there is common appi for GPS access).

A: Your code is going to be used on a mobile client, you know it is going to be a specific kind of phone. Yes you do need to code for a specific device as the API for iPhone is not the same as for Android. Android I don't know yet - for iPhone, you need to use Core Location - the CLLocation class is a good place to start reading in the developer docs once you have Xcode open, and the Locations sample code is a nice starting point that shows how to get a series of position fixes.
Maybe you can get some kind of fix back from the server but I don't think you'll find it at all accurate - that is to say not incorrect but with a very large circle of uncertainty.


text:
Q: How to check if cursor is on an empty line inside textarea? How do I check if the cursor is on an empty line inside a textarea?
I don't care about word wrapping. I care about lines that were created by hitting Enter.
$('textarea').on("change keyup", function() {
  if (cursor is on an empty line or the the line has just spaces) {
    console.log("empty");
  } else {
    console.log("has stuff");
  }
});

For example:

This would log "has stuff"
The line above would log "empty" and this line would log "has stuff"

A: The following should work, but won't in older versions of IE.
// on(..., function() {
if( this.value.substr(0,this.selectionStart).match(/(?:^|\r?\n\s*)$/)
 && this.value.substr(this.selectionStart).match(/^(?:\s*\r?\n|$)/)) {
    console.log("empty");
}

EDIT search now explicitly looks for a newline, with further whitespace optional.

A: Another solution would be:
function is_cursor_on_empty_line(textarea)
{
    // line where cursor is now
    var line_number = textarea.value.substr(0, textarea.selectionStart).split("\n").length;

    // split all lines of the textarea
    var lines = textarea.value.split("\n");

    // current line is empty or not
    return (lines[line_number-1] == '');
}

Example usage with Jquery:
var textarea = $('textarea');

if (is_cursor_on_empty_line(textarea[0]))
{
   // ...
}


text:
Q: Notification receiver failed to catch the GCM message in particular devices When am receiving GCM Notification am getting the below error log.
W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent {act=com.google.android.c2dm.intent.RECEIVE pkg=****** (has extras) }
Condition:
1. At the time my application is not in background and foreground also.
How do i resolve the problem. Please help somebody.


text:
Q: Make internet app available only within VPN? I am not sure if I expressed myself clear enough in the question.
Just managed to set up PPTP on my server and I want to know how can I make a website be accessible only from VPN clients. I have apache and other services installed and I can host a website and access it from all over the world. But I want a specific one like: www.therestrictedone.com to be accessible only by VPN clients.
Is this possible?
Can I make apache work simultaneously on two ports. So port 80 is accessible from Internet and 81 only within VPN?
Probably I am saying lot of things without sense? I am just trying to express whats going through my mind with my own words.

A: Couple different ways to do this. If you have no intentions of hosting any other site except for vpn access the quickest and easiest way would be to use a firewall and only allow from local network. Anyone that connects to vpn will be given a local address such as 192.168.1.x. So using UFW
 sudo ufw allow from 192.168.1.0/24 to any port 80

If you intend to have other sites and are setting this up as a vhost, usually you can throw in an
 Allow from 192.168.1.0/24

Or
 Allow from 192.168.1.*

In the vhost configuration. I forget the exact format for ip range, but it one of the two referenced above. Just look up info on Apache vhosts


text:
Q: Bind Data to .ashx file I am building a SMS Getaway, and I am using SMS Enabler. So this is my example, a person sends a code via SMS. This code is looped in a SQL Server Database and checks if this code exists in this column, let's say on Database TEST, table TAGLE1, column CODES. If this code that this person exists in this column SMS Enabler replies a code that he is the winner, else is the code does not exists it replies "Try Again". I can only do this via .ashx file not .aspx file
This is my code:
public class sms : IHttpHandler {

 // This method is called each time a new SMS message arrives
 public void ProcessRequest(HttpContext context) {
   // form variables (contain all sms message information)
   var sms = context.Request.Form;

   // sender's number
   string senderNumber = sms["sender"];
   // sms message text
   string messageText = sms["text"];
   // SMS center timestamp in UTC. You can consider this
   // as the date and time when the sender sent the message.
   DateTime sentTime = DateTime.ParseExact(sms["scts"],
         "yyyy'-'MM'-'dd HH':'mm':'ss", null);
   // SMS center number (not supported when using SMS Enabler
   // with a Nokia phone)
   string smscNumber = sms["smsc"];
   // Tag value. You can define this in SMS Enabler's settings,
   // and use it to pass additional information.
   string tag = sms["tag"];

   /* TODO:
      WRITE YOUR CODE FOR PROCESSING INCOMING SMS MESSAGES HERE */

   // Sending a reply SMS. If you don't want to send a reply,
   // just comment all the next lines out.
   context.Response.ContentType = "text/plain";

   // Add an X-SMS-To header to set the recipients of the reply.
   // If not set, the reply is sent to the sender of the
   // original SMS message.
   // context.Response.AddHeader("X-SMS-To",
   //      "+97771234567 +15550987654");

   // Write the text of the reply SMS message
   // to the HTTP response output stream.
   context.Response.Write("Reply SMS message");
 }

 public bool IsReusable {
   get {
      return false;
   }
 }
}

The only thing I want is how to bind data on .ashx file, loop through it, check it true or false and then reply.

A: Never mind. I found the solution
SqlConnection con1 = new SqlConnection();
        con1.ConnectionString = ConfigurationManager.ConnectionStrings["NDERMJConnectionString"].ToString();
        string sql1 = "select Count(*) from tablename where name= @name";
        SqlCommand cmd1 = new SqlCommand(sql1, con1);
        cmd1.Parameters.AddWithValue("@name", sms["text"].ToString());
        con1.Open();
        int result = (int)cmd1.ExecuteScalar();
        if (result > 0)
        {
            context.Response.Write("You are the winner");
        }
        else
        {
            context.Response.Write("I'm sorry. Try Again.");
        }


text:
Q: what does this ''(const vector > &A)" segment of code mean? I'm facing some issue in understanding the following segment of code
(const vector<vector<int> > &A). Will it define a 2D array?

A: const vector<vector<int> > &A means that A is a const reference to a vector of vectors of integers.


text:
Q: Is there a way to automate the entry of external testers email info for Testflight? I would like to integrate signup of External Testflight users with an existing website we have that collects interested beta test users. I see that I can export any new signups once and a while and manually upload a CSV of their emails to testflight. This works somewhat well. But this is the digital age :) is there an API or tool like iTMSTransporter that will automate this process for me? Is everyone else just  typing them in as they go or uploading CSV files once and a while?

A: You can launch an instance of boarding on heroku.  It's part of the fastlane toolchain.
https://github.com/fastlane/boarding

A: So the short answer to my question was "no."
But the longer answer is to go use Ruby or something similar and a web test tool such as Capybara ( http://jnicklas.github.io/capybara/ ) to automate what a user would do on the actual iTunes connect website but in a scripting language.


text:
Q: where did my 766 kb in partition go? I used fdisk -l and saw this.
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x580a1fd4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2          206848   417083391   208438272    7  HPFS/NTFS/exFAT
/dev/sda3       417095656  1953523711   768214028    f  W95 Ext'd (LBA)
/dev/sda5       417095658  1871315459   727109901    7  HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.
/dev/sda6      1871316992  1900611583    14647296   83  Linux
/dev/sda7      1900613632  1908424703     3905536   82  Linux swap / Solaris
/dev/sda8      1908426752  1953523711    22548480   83  Linux

This show that my logical partition sda5 ends at 1871315459 and sda6 begins at 1871316992.
Then where did my 1533 sectors ie 766 kb go?

A: It's an alignment thing
For performance reasons you really want your storage to be aligned on all levels. While this is probably just a simple hard drive with a partition table and a file system on it directly, it's still important to not misalign it.
What about alignment?
Suppose your hard drive works with 4 kB sectors (yours appear to work with 512 bytes) and you've aligned the partition to start with just a single byte offset, then updating a single 4 kB file system page will amplify to a two-sector write on your disk. With just 4 kB becoming 8 kB, this is not a great deal, but on larger systems or RAID setups this will become a real problem once the stripe size (block size) becomes hundreds of kilobytes or even megabytes. Once misaligned on this stripe size, this could amplify an unlucky 4 kB filesystem block to a 2x block size (e.g. 2 MB) write to disks, also impacting parity calculations (if any).
SSD and other flash memory based drives are affected even worse. Usually, these drives are using huge page sizes. I've seen 512 kB "sector" sized USB flash drives out there and this is a common size for SSD drives IIRC. A misalignment when using multiple layers on top of it (e.g. dm-crypt, LVM, file system) could result in a huge write amplification (on top of what they already have) you really want to avoid unnecessary wear of the drive.
Why this gap on my drive then?
Most recent utilities just use 1 MB alignment on the disk as a safe default. It is a lowest common denominator for common set ups, avoiding most misalignments while not losing too much space.
Gaining 766 kB on 1 TB is not worth the performance impact it would impose.
Can I fix this?
Yes, you can, you'll have to look into the specification of your drive, the block size of your file system and figure out the proper alignment yourself and then fixing the partition table yourself. It's kinda dangerous to do this, though.
In your case sda5 is probably misaligned (beginning) and I would move the sda5 to proper alignment on an occasion that would suit me (backing up data first!).


text:
Q: How to make option selected necessary in select tag with multiple attribute i want to make a condition that would allow a user to select minimum 3 options from select tag with multiple attribute but the options are coming dynamically from input tag after comma(,) is entered
. for eg if user type hello and then type comma(,) the value hello will be displayed on option tag
.so how can i make my option selected and with minimum of 3 option selected.
here is my code
var skills = document.querySelector('#skills');
var skillhave = document.querySelector('#skill');
var skillshaving = [];

skills.addEventListener('keyup', function(event) {
  if (event.keyCode === 188) {

    if (this.value.length < 2) {
      alert("skill required");
      this.value = "";
    } else {
      var skill = this.value.substring(0, this.value.length - 1);
      skillshaving.push(skill);
      this.value = "";
      //reloadskills();
      addSkills(skill);
    }
  }
});
function addSkills(skill) {
  var opt = document.createElement('option');
  opt.value = skill.toUpperCase();;
  opt.innerHTML = skill.toUpperCase();;
  opt.selected = true;
  skillhave.appendChild(opt);
}
<input type="text" class="form-control" placeholder="Enter skill" name="skills" id="skills"> <!--for entering skills via text -->

<select name="" id="skill" multiple></select>
<!--for diplaying it in option tag -->

A: Use selectedOptions property of element on submit event. See following snippet

function submit() {
  const multiSelect = document.querySelector('#multi-select');
  if (multiSelect.selectedOptions.length > 2) {
    console.log('process submit');
  } else {
    console.log('Please select atleast 3 options');
  }
}
<select id="multi-select" multiple>
  <option>2</option>
  <option>4</option>
  <option>6</option>
  <option>8</option>
</select>
<button onclick="submit()">Submit</button>


text:
Q: How to create a Unix-domain socket with specific access permissions I have a situation in which I intend to communicate with a service through a command interface made available via a UNIX-domain socket on the file system. I am able to successfully send it commands, but for a while sat perplexed as to why I could not receive any response to my queries.
As it turns out, the service did not have sufficient permissions to write to the address I (or the OS) provided for it. However, I realized that if I explicitly bind to an address on the file system then I could adjust the file permissions by leveraging chmod.
Something like:
int mySocket;
struct sockaddr_un local_addr;

mySocket = socket(AF_UNIX, SOCK_DGRAM, 0);
local_addr.sun_family = AF_UNIX;
snprintf(local_addr.sun_path, 108  "/path/to/mySocket");

bind(mySocket, (struct sockaddr *) &local_addr, sizeof(struct sockaddr_un));
chmod("/path/to/mySocket", 777);

That is to say, without the final chmod step, the service is unable to write to mySocket because it does not have the appropriate write permissions. Obviously, this is an even harder problem to spot if one does not explicitly bind to a specific address, since the underlying OS will implicitly generate this socket for the user - but it still exists and still will have the same access problems.
My question, then, is with respect to this final step. Is there a way to allow the OS to implicitly generate the socket for my endpoint (i.e. the address to which the service will respond) but request that it be given certain permissions?

The Explanation
The reason this issue is becoming a problem is due to the requirement that other portions of the program be executed as root. As such, when I, as root, attempt to connect/send to the background service, the OS will implicitly create an address to which replies will be directed. However, this leads to the problem that my socket-file, whether implicit or created with bind, will have permissions like srw- --- ---, so the other endpoint can only reply if they, too, elevate themselves.
Thus, the problem goes away if I first bind and then chmod the permissions as I showed above.

A:
Is there a way to allow the OS to implicitly generate the socket for my endpoint (i.e. the address to which the service will respond) but request that it be given certain permissions?

I solved this very problem once using two calls to umask().
Pseudo code:
current_mask = umask(umask_to_be_used_on_afunix_socket_file_system_entry_creation);
bind afunix socket here
umask(current_umask);

A: [edited] My first guess would be to instead use a fifo, which lets you create file first and set its permissions.  Also, if two users are to communicate through the fifo, it's best to use group-level read/write and have them in the same group.
$ mkfifo -m 660 fifo_name

#include <sys/types.h>
#include <sys/stat.h>
int mkfifo(const char *path, mode_t mode);

As sherrellbc mentions, this is unrelated to unix sockets.  If you are forced into using sockets, why not drop permissions before creating it?  This seems like an important step when running suid anyway.
struct sockaddr_un to_addr;
memset(&to_addr, 0, sizeof(struct sockaddr_un));
strncpy(to_addr.sun_path, "/path/to/socket", sizeof(to_addr.sun_path) - 1);
to_addr.sun_family = AF_UNIX;

/* ------------ change user ------------ */
if(setgid(new_gid) || setuid(new_uid))
    goto error;

handle_conn(&to_addr, sizeof(struct sockaddr_un));

int handle_conn(struct sockaddr *to_addr, socklen_t addrlen) {
    int to_sock;
    int ret;
    pid_t pid;
    if( (to_sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
            goto error;
    }
    if(connect(to_sock, to_addr, addrlen)) {
            close(to_sock);
            goto error;
    }

    ...

    close(to_sock);
}


text:
Q: Связь @ManyToMany 3 таблиц Имеются таблицы dish, kitchen, restaraunt и общая таблица many которая имеет в себе все поля таблиц dish, kitchen, restaraunt, поскольку только начал изучать hibernate , не могу понять как именно связать все три таблицы с many
Вкратце о связи, ресторан имеет блюдо, блюдо могут иметь много ресторанов
Ресторан имеет кухню, кухню имеет много ресторанов
Kitchen model
@Entity
@Table(name = "kitchen")
public class Kitchen {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column(name = "kitchen_name")
    private String name;
    @Column(name = "kitchen_photo")
    private Blob photo;
}

Dish model
@Entity
@Table(name = "dish")
public class Dish {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column(name = "dish_name")
    private String dishName;
    @Column(name = "dish_photo")
    private Blob dishPhoto;

Restaraunt model
 public class Restaraunt {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private long id;
        @Column(name = "res_name")
        private String name;
        @Column(name = "res_rating")
        private double rating;
        @Column(name = "res_address")
        private String address;
        @Column(name = "res_number")
        private String number;
        @Column(name = "res_site")
        private String site;
        @Column(name = "res_price")
        private String price;
        @Column(name = "res_photo")
        private Blob photo;

Ну и общая таблица с которой все нужно связать
Many Model
@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Column(name = "res_id")
    private long res_id;
    @Column(name = "kitchen_id")
    private long kitchen_id;
    @Column(name = "dish_id")
    private long dish_id;
    @Column(name = "many_name")
    private String name;
    @Column(name = "many_rating")
    private double rating;
    @Column(name = "many_address")
    private String address;
    @Column(name = "namy_number")
    private String number;
    @Column(name = "many_site")
    private String site;
    @Column(name = "many_price")
    private String price;
    @Column(name = "many_photo")
    private Blob photo;
    @Column(name = "dish_name")
    private String dishName;
    @Column(name = "kitchen_name")
    private String kitchenName;
    @Column(name = "dish_photo")
    private Blob dishPhoto;
    @Column(name = "kitchen_photo")
    private Blob kitchePhoto;

Понимаю , что нужно связать через @ManyToMany но как прописать если честно - затрудняюсь :(

A: Ну можно в каждом Entity сделать 2 ManyToMany связи
Кухня
@Entity
@Table(name = "kitchen")
public class Kitchen {
    ...

    @ManyToMany
    @JoinTable(
        name = "kitchen_dish",
        joinColumns = { @JoinColumn(name = "kitchen_id") },
        inverseJoinColumns = { @JoinColumn(name = "dish_id") }
    )
    private List<Dish> dishs = new ArrayList<>();

    @ManyToMany
    @JoinTable(
        name = "kitchen_restaurant",
        joinColumns = { @JoinColumn(name = "kitchen_id") },
        inverseJoinColumns = { @JoinColumn(name = "restaurant_id") }
    )
    private List<Restaurant> restaurants = new ArrayList<>();
}

Ресторан
@Entity
@Table(name = "restaurant")
public class Restaurant {
    ...

    @ManyToMany
    @JoinTable(
        name = "restaurant_dish",
        joinColumns = { @JoinColumn(name = "restaurant_id") },
        inverseJoinColumns = { @JoinColumn(name = "dish_id") }
    )
    private List<Dish> dishs = new ArrayList<>();

    @ManyToMany
    @JoinTable(
        name = "kitchen_restaurant",
        joinColumns = { @JoinColumn(name = "restaurant_id") },
        inverseJoinColumns = { @JoinColumn(name = "kitchen_id") }
    )
    private List<Kitchen> kitchens = new ArrayList<>();
}

Блюдо
@Entity
@Table(name = "dish")
public class Dish {
    ...

    @ManyToMany
    @JoinTable(
        name = "restaurant_dish",
        joinColumns = { @JoinColumn(name = "dish_id") },
        inverseJoinColumns = { @JoinColumn(name = "restaurant_id") }
    )
    private List<Restaurant> restaurants = new ArrayList<>();

    @ManyToMany
    @JoinTable(
        name = "kitchen_dish",
        joinColumns = { @JoinColumn(name = "kitchen_id") },
        inverseJoinColumns = { @JoinColumn(name = "dish_id") }
    )
    private List<Kitchen> kitchens = new ArrayList<>();
}


text:
Q: Yaml frontmatter not parsing as documented I have yaml frontmatter installed in a php/Laravel project, but I cannot get it to work as documentend.
I made a testfile test.html:
---
title: Example
---
Lorem ipsum.

Then I try to parse with yaml:
$document = YamlFrontMatter::parse(file_get_contents('test.html'));

dd($document->title);

The result:
Spatie\YamlFrontMatter\Document {#280 ▼
  #matter: []
  #body: "--- title: Example --- Lorem ipsum."
}

While matter should be:
['title' => 'Example']

What am I doing wrong?
Kind regards
Hubert

A: First your test.html file move to resources folder now follow this code
$document = YamlFrontMatter::parseFile(resource_path('test.html'));

dd($document->title);

I hope you this solution is work.

A: In my case the 3 dashes had one space in front ---  and that made the parser to no recognize the properties, when the space was removed all worked back again.


text:
Q: Updating the response body in middleware .NET Core I have a custom middleware in my .NET Core 3.1 application, and trying to set the response StatusCode and Body like this:
public async Task Invoke(HttpContext context)
{
    if ( <some condition on context.Request> )
    {
        context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
        await context.Response.WriteAsync("my custom message");

        // Bad request, do not call next middleware.
        return;
    }

    // Call next middleware.
    await _requestDelegate(context);
}

With the above code, the StatusCode is correctly set, however, the response Body is empty. How can I write my custom message to the Body?
Update1:
Added await, but this won't solve the issue. Thanks @Jonesopolis for mentioning that.
Update 2
So I was testing the response in Swagger (I was also looking at the developer's Network tab). However, when I tested in Postman, I was getting the expected response body.
So the question really is why the response body wasn't showing up in Swagger/network tab?
Thanks!

A: SwaggerUI was setting an accept: text/plain header with the request so ASP.NET Core was ignoring any content that wasn't set as this type.
Change your code:
public async Task Invoke(HttpContext context)
{
    if (xxxx)
    {
        context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
        context.Response.ContentType = "text/plain";   //add this line.....

        await context.Response.WriteAsync("my custom message");
        return;
    }
    await _requestDelegate(context);

}

A: Let me get it straight.
I don't think Swagger is the issue here.
How about specify exactly what the content type is, and more importantly, let response complete its work.
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
   //Unauthorized
   context.Response.Headers.Add("Content-Type", "application/json");
   context.Response.StatusCode = StatusCodes.Status401Unauthorized;
   await context.Response.WriteAsync(JsonConvert.SerializeObject(new
   {
       Msg = msg,
       LoginPath = _options.LoginPath.Value,
   }));
   await context.Response.CompleteAsync();
}

A: It is not necessary to use return keyword in your first block.
you can use else block to call next middleware.
It works
  public class CustomMiddleware
    {
        private readonly RequestDelegate requestDelegate;
        public CustomMiddleware(RequestDelegate requestDelegate)
        {
            this.requestDelegate = requestDelegate;
        }
        public async Task Invoke(HttpContext httpContext)
        {
            if(httpContext.Request.Path.Value=="/Custom")
            {
                httpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                await httpContext.Response.WriteAsync("my custom message");
                return;
            }
            else
            {
                await requestDelegate(httpContext);
            }
        }
    }
    public static class Middlewares
    {
        public static void UseMyCustomMiddleware(this IApplicationBuilder applicationBuilder)
        {
            applicationBuilder.UseMiddleware<CustomMiddleware>();
        }
    }