text:
Q: IndexOutOfBoundsException for MapView in RecyclerView I'm getting IndexOutOfBoundsException exception when I try to update the adapter containing the MapView.
I'm using example LiteListDemoActivity. Once it's static everything is fine, but when I want to submit an update to the adapter to show a different type of data not map related, then in some rare cases the app crashes.
The beginning of the stack trace is:
java.lang.IndexOutOfBoundsException:
  at java.util.ArrayList.get (ArrayList.java:437)
  at com.google.maps.api.android.lib6.lite.u.a (u.java:4)
  at com.google.maps.api.android.lib6.lite.x.a (x.java:15)
  at com.google.maps.api.android.lib6.lite.j.onDraw (j.java:48)
  at android.view.View.draw (View.java:21860)
  at android.view.View.buildDrawingCacheImpl (View.java:21129)
  at android.view.View.buildDrawingCache (View.java:20989)
  at android.view.View.updateDisplayListIfDirty (View.java:20705)
  at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4535)
  at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4507)
  at android.view.View.updateDisplayListIfDirty (View.java:20688)
  at android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4535)
  at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4507)
  at android.view.View.updateDisplayListIfDirty (View.java:20688)
  at android.view.View.draw (View.java:21586)
  at android.view.ViewGroup.drawChild (ViewGroup.java:4551)
  at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4326)
  at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw (ConstraintLayout.java:2023)
  at android.view.View.updateDisplayListIfDirty (View.java:20719)
  at android.view.View.draw (View.java:21586)
  at android.view.ViewGroup.drawChild (ViewGroup.java:4551)
  at androidx.recyclerview.widget.RecyclerView.drawChild (RecyclerView.java:4820)
  at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4326)
  at android.view.View.draw (View.java:21863)
  at androidx.recyclerview.widget.RecyclerView.draw (RecyclerView.java:4219)

Is it something related to the RecyclerView implementation? I am sharing the adapter from my code. You can find the full implementation in the link above that I shared.
/**
 * Adapter that displays a title and {@link com.google.android.gms.maps.MapView} for each item.
 * The layout is defined in lite_list_demo_row.xml. It contains a MapView
 * that is programatically initialised in
 * {@link #(int, android.view.View, android.view.ViewGroup)}
 */
private class MapAdapter extends RecyclerView.Adapter<MapAdapter.ViewHolder> {

    private NamedLocation[] namedLocations;

    private MapAdapter(NamedLocation[] locations) {
        super();
        namedLocations = locations;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext())
                .inflate(R.layout.lite_list_demo_row, parent, false));
    }

    /**
     * This function is called when the user scrolls through the screen and a new item needs
     * to be shown. So we will need to bind the holder with the details of the next item.
     */
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        if (holder == null) {
            return;
        }
        holder.bindView(position);
    }

    @Override
    public int getItemCount() {
        return namedLocations.length;
    }

    /**
     * Holder for Views used in the {@link LiteListDemoActivity.MapAdapter}.
     * Once the  the map field is set, otherwise it is null.
     * When the {@link #onMapReady(com.google.android.gms.maps.GoogleMap)} callback is received and
     * the {@link com.google.android.gms.maps.GoogleMap} is ready, it stored in the {@link #map}
     * field. The map is then initialised with the NamedLocation that is stored as the tag of the
     * MapView. This ensures that the map is initialised with the latest data that it should
     * display.
     */
    class ViewHolder extends RecyclerView.ViewHolder implements OnMapReadyCallback {

        MapView mapView;
        TextView title;
        GoogleMap map;
        View layout;

        private ViewHolder(View itemView) {
            super(itemView);
            layout = itemView;
            mapView = layout.findViewById(R.id.lite_listrow_map);
            title = layout.findViewById(R.id.lite_listrow_text);
            if (mapView != null) {
                // Initialise the MapView
                mapView.onCreate(null);
                // Set the map ready callback to receive the GoogleMap object
                mapView.getMapAsync(this);
            }
        }

        @Override
        public void onMapReady(GoogleMap googleMap) {
            MapsInitializer.initialize(getApplicationContext());
            map = googleMap;
            setMapLocation();
        }

        /**
         * Displays a {@link LiteListDemoActivity.NamedLocation} on a
         * {@link com.google.android.gms.maps.GoogleMap}.
         * Adds a marker and centers the camera on the NamedLocation with the normal map type.
         */
        private void setMapLocation() {
            if (map == null) return;

            NamedLocation data = (NamedLocation) mapView.getTag();
            if (data == null) return;

            // Add a marker for this item and set the camera
            map.moveCamera(CameraUpdateFactory.newLatLngZoom(data.location, 13f));
            map.addMarker(new MarkerOptions().position(data.location));

            // Set the map type back to normal.
            map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        }

        private void bindView(int pos) {
            NamedLocation item = namedLocations[pos];
            // Store a reference of the ViewHolder object in the layout.
            layout.setTag(this);
            // Store a reference to the item in the mapView's tag. We use it to get the
            // coordinate of a location, when setting the map location.
            mapView.setTag(item);
            setMapLocation();
            title.setText(item.name);
        }
    }
}

A: I don't see any update strategy in your adapter that you have shared on Github. The adapter takes a fixed-length array in the constructor and thus gets the size of the fixed array from the getItemCount function.
I would like to suggest modifying the adapter like the following.
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * This shows to include a map in lite mode in a ListView.
 * Note the use of the view holder pattern with the
 * {@link com.google.android.gms.maps.OnMapReadyCallback}.
 */
public class LiteListDemoActivity extends AppCompatActivity {

    private RecyclerView mRecyclerView;

    private LinearLayoutManager mLinearLayoutManager;
    private GridLayoutManager mGridLayoutManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.lite_list_demo);

        mGridLayoutManager = new GridLayoutManager(this, 2);
        mLinearLayoutManager = new LinearLayoutManager(this);

        // Set up the RecyclerView
        mRecyclerView = findViewById(R.id.recycler_view);
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setLayoutManager(mLinearLayoutManager);

        // Pass the ArrayList instead of the array
        mRecyclerView.setAdapter(new MapAdapter(getInitialLocations(LIST_LOCATIONS)));
        mRecyclerView.setRecyclerListener(mRecycleListener);
    }

    /**
     * Create a menu to switch between Linear and Grid LayoutManager.
     */
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.lite_list_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.layout_linear:
                mRecyclerView.setLayoutManager(mLinearLayoutManager);
                break;
            case R.id.layout_grid:
                mRecyclerView.setLayoutManager(mGridLayoutManager);
                break;
        }
        return true;
    }

    /**
     * Adapter that displays a title and {@link com.google.android.gms.maps.MapView} for each item.
     * The layout is defined in lite_list_demo_row.xml. It contains a MapView
     * that is programatically initialised in
     * {@link #(int, android.view.View, android.view.ViewGroup)}
     */
    private class MapAdapter extends RecyclerView.Adapter<MapAdapter.ViewHolder> {

        // Take an ArrayList instead of array. Its easier to implement the add and clear functionality here
        private ArrayList<NamedLocation> namedLocations;

        private MapAdapter(ArrayList<NamedLocation> locations) {
            super();
            namedLocations = locations;
        }

        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new ViewHolder(LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.lite_list_demo_row, parent, false));
        }

        /**
         * This function is called when the user scrolls through the screen and a new item needs
         * to be shown. So we will need to bind the holder with the details of the next item.
         */
        @Override
        public void onBindViewHolder(ViewHolder holder, int position) {
            if (holder == null) {
                return;
            }
            holder.bindView(position);
        }

        @Override
        public int getItemCount() {
            return namedLocations.size();
        }

        public void updateLocationList(ArrayList<NamedLocation> newLocations) {

            // Clear the old locations
            this.namedLocations.clear();

            // Add the new locations passed by calling this function to the list associated with this adapter.
            for (NamedLocation location : newLocations) this.namedLocations.add(location);

            // Call notifyDataSetChanged so that the RecyclerView takes the new ArrayList to be populated in the RecyclerView
            notifyDataSetChanged();
        }

        /**
         * Holder for Views used in the {@link LiteListDemoActivity.MapAdapter}.
         * Once the  the map field is set, otherwise it is null.
         * When the {@link #onMapReady(com.google.android.gms.maps.GoogleMap)} callback is received and
         * the {@link com.google.android.gms.maps.GoogleMap} is ready, it stored in the {@link #map}
         * field. The map is then initialised with the NamedLocation that is stored as the tag of the
         * MapView. This ensures that the map is initialised with the latest data that it should
         * display.
         */
        class ViewHolder extends RecyclerView.ViewHolder implements OnMapReadyCallback {

            MapView mapView;
            TextView title;
            GoogleMap map;
            View layout;

            private ViewHolder(View itemView) {
                super(itemView);
                layout = itemView;
                mapView = layout.findViewById(R.id.lite_listrow_map);
                title = layout.findViewById(R.id.lite_listrow_text);
                if (mapView != null) {
                    // Initialise the MapView
                    mapView.onCreate(null);
                    // Set the map ready callback to receive the GoogleMap object
                    mapView.getMapAsync(this);
                }
            }

            @Override
            public void onMapReady(GoogleMap googleMap) {
                MapsInitializer.initialize(getApplicationContext());
                map = googleMap;
                setMapLocation();
            }

            /**
             * Displays a {@link LiteListDemoActivity.NamedLocation} on a
             * {@link com.google.android.gms.maps.GoogleMap}.
             * Adds a marker and centers the camera on the NamedLocation with the normal map type.
             */
            private void setMapLocation() {
                if (map == null) return;

                NamedLocation data = (NamedLocation) mapView.getTag();
                if (data == null) return;

                // Add a marker for this item and set the camera
                map.moveCamera(CameraUpdateFactory.newLatLngZoom(data.location, 13f));
                map.addMarker(new MarkerOptions().position(data.location));

                // Set the map type back to normal.
                map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
            }

            private void bindView(int pos) {
                NamedLocation item = namedLocations.get(pos);
                // Store a reference of the ViewHolder object in the layout.
                layout.setTag(this);
                // Store a reference to the item in the mapView's tag. We use it to get the
                // coordinate of a location, when setting the map location.
                mapView.setTag(item);
                setMapLocation();
                title.setText(item.name);
            }
        }
    }

    /**
     * RecycleListener that completely clears the {@link com.google.android.gms.maps.GoogleMap}
     * attached to a row in the RecyclerView.
     * Sets the map type to {@link com.google.android.gms.maps.GoogleMap#MAP_TYPE_NONE} and clears
     * the map.
     */
    private RecyclerView.RecyclerListener mRecycleListener = new RecyclerView.RecyclerListener() {

        @Override
        public void onViewRecycled(RecyclerView.ViewHolder holder) {
            MapAdapter.ViewHolder mapHolder = (MapAdapter.ViewHolder) holder;
            if (mapHolder != null && mapHolder.map != null) {
                // Clear the map and free up resources by changing the map type to none.
                // Also reset the map when it gets reattached to layout, so the previous map would
                // not be displayed.
                mapHolder.map.clear();
                mapHolder.map.setMapType(GoogleMap.MAP_TYPE_NONE);
            }
        }
    };

    /**
     * Location represented by a position ({@link com.google.android.gms.maps.model.LatLng} and a
     * name ({@link java.lang.String}).
     */
    private static class NamedLocation {

        public final String name;
        public final LatLng location;

        NamedLocation(String name, LatLng location) {
            this.name = name;
            this.location = location;
        }
    }

    private ArrayList<NamedLocation> getInitialLocations(NamedLocation[] locationsArray) {
        ArrayList<NamedLocation> locationArrayList = new ArrayList<>();

        for (NamedLocation location : locationsArray)
            locationArrayList.add(location);

        return locationArrayList;
    }

    /**
     * A list of locations to show in this ListView.
     */
    private static final NamedLocation[] LIST_LOCATIONS = new NamedLocation[]{
            new NamedLocation("Cape Town", new LatLng(-33.920455, 18.466941)),
            new NamedLocation("Beijing", new LatLng(39.937795, 116.387224)),
            new NamedLocation("Bern", new LatLng(46.948020, 7.448206)),
            new NamedLocation("Breda", new LatLng(51.589256, 4.774396)),
            new NamedLocation("Brussels", new LatLng(50.854509, 4.376678)),
            new NamedLocation("Copenhagen", new LatLng(55.679423, 12.577114)),
            new NamedLocation("Hannover", new LatLng(52.372026, 9.735672)),
            new NamedLocation("Helsinki", new LatLng(60.169653, 24.939480)),
            new NamedLocation("Hong Kong", new LatLng(22.325862, 114.165532)),
            new NamedLocation("Istanbul", new LatLng(41.034435, 28.977556)),
            new NamedLocation("Johannesburg", new LatLng(-26.202886, 28.039753)),
            new NamedLocation("Lisbon", new LatLng(38.707163, -9.135517)),
            new NamedLocation("London", new LatLng(51.500208, -0.126729)),
            new NamedLocation("Madrid", new LatLng(40.420006, -3.709924)),
            new NamedLocation("Mexico City", new LatLng(19.427050, -99.127571)),
            new NamedLocation("Moscow", new LatLng(55.750449, 37.621136)),
            new NamedLocation("New York", new LatLng(40.750580, -73.993584)),
            new NamedLocation("Oslo", new LatLng(59.910761, 10.749092)),
            new NamedLocation("Paris", new LatLng(48.859972, 2.340260)),
            new NamedLocation("Prague", new LatLng(50.087811, 14.420460)),
            new NamedLocation("Rio de Janeiro", new LatLng(-22.90187, -43.232437)),
            new NamedLocation("Rome", new LatLng(41.889998, 12.500162)),
            new NamedLocation("Sao Paolo", new LatLng(-22.863878, -43.244097)),
            new NamedLocation("Seoul", new LatLng(37.560908, 126.987705)),
            new NamedLocation("Stockholm", new LatLng(59.330650, 18.067360)),
            new NamedLocation("Sydney", new LatLng(-33.873651, 151.2068896)),
            new NamedLocation("Taipei", new LatLng(25.022112, 121.478019)),
            new NamedLocation("Tokyo", new LatLng(35.670267, 139.769955)),
            new NamedLocation("Tulsa Oklahoma", new LatLng(36.149777, -95.993398)),
            new NamedLocation("Vaduz", new LatLng(47.141076, 9.521482)),
            new NamedLocation("Vienna", new LatLng(48.209206, 16.372778)),
            new NamedLocation("Warsaw", new LatLng(52.235474, 21.004057)),
            new NamedLocation("Wellington", new LatLng(-41.286480, 174.776217)),
            new NamedLocation("Winnipeg", new LatLng(49.875832, -97.150726))
    };
}

Now you have the updateLocationList function in your adapter and when you need to change the location list, just use this function to pass your updated location list in your adapter.
Please note that I have not tested this code. So, it might have some compilation error as I have changed the array implementation to a list. Please modify as per your need.
Hope that helps!


text:
Q: CMD.exe closes immediately - unusual line in AutoRun registry entry I've noticed that my command line didn't start anymore, it just immediately minimized and closed itself upon running. I suspect this is due to a virus or at least some kind of malicious program having been executed. I found the following code inside my registry. It seems legible but my knowledge of batch / the command line is limited. Can anyone tell me what it does?
@mode 20,5 & tasklist /FI "IMAGENAME eq SoundModule.exe" 2>NUL | find /I /N "SoundModule.exe">NUL && exit & if exist "C:\Users\Leon\AppData\Roaming\Microsoft\SoundModule\SoundModule.exe" ( start /MIN "" "C:\Users\Leon\AppData\Roaming\Microsoft\SoundModule\SoundModule.exe" & tasklist /FI "IMAGENAME eq explorer.exe" 2>NUL | find /I /N "explorer.exe">NUL && exit & explorer.exe & exit ) else ( tasklist /FI "IMAGENAME eq explorer.exe" 2>NUL | find /I /N "explorer.exe">NUL && exit & explorer.exe & exit )

A: According to this reddit thread, it's a "vmprotected cryptocurrency miner".
You most likely got it if you installed anything you downloaded from the torrent network, for example a popular game released in the past few weeks :^)
The following SO thread contains part of the solution: CMD.exe closes immediately after calling (Win7 64)
The malicious party added an AutoRun directive via registry to the Windows Command Processor (cmd.exe usually), which you need to remove from any of the following locations it's present in:

*

*Computer\HKEY_CURRENT_USER\Software\Microsoft\Command Processor

*Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
What the directive does is to execute SoundModule.exe and then explorer.exe (if not already started).
According to the other reply in this thread, they set %comspec% to run at startup, via Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon.
So on startup, it's running %comspec% (instead of the default Windows Explorer), which itself on start first runs SoundModule.exe and then explorer.exe. Not sure why they did it this way, anyone who makes use of cmd.exe was bound to figure it out and spread the word.
There are at least two confirmed VirusTotal records for this file: [1], [2]

A: I had the same program on my computer, check Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon for the shell value which is most likely "%comspec%" (which makes sense why it was just cmd running on startup since %comspec% is cmd.exe) and change it to "explorer.exe"

A: Run regedit
Go to HKLM\Software\Microsoft\Command Processor\ or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\ or HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\
For some reason there was AUTORUN key with "EXIT" inside.
Remove the AutoRun key and cmd will work fine.
Then check Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon for the shell value which is most likely "%comspec%" (which makes sense why it was just cmd running on startup since %comspec% is cmd.exe) and change it to "explorer.exe" as the user above said.
Edit: I also found that it was a cryptocurrency mining virus located at %appdata%\Microsoft\SoundModule or SoundMixer on my case.
You should probably delete this file too.

A: For reference, I will add that I was able to verify that my issue was the Autorun registry key by using Win-R to bring up the "Run" dialog, and typing cmd /d (which disables any autorun per the windows docs [https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd] .  This successfully opened a command prompt window.
Inspecting the registry, my HKEY_CURRENT_USER\Software\Microsoft\Command Processor had Autorun as Type=REG_SZ and Data=if exist.  I made a restore point, then renamed that key to AutorunOld ... and then I was able to open a command prompt without issue.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Checking for existance of data from a parameter list I'm currently working on a project that has me stumped since I haven't done much stored procedure design. I have a task where when entering a user, they can be associated with one or more groups. I am passing the list of groups as a parameter when calling the stored proc as @GroupList = "'Group1','Group2','Group3'". There can be any number of groups. The call for adding a new user should fail if one of the groups doesn't exist. I am attempting to use the following code to check if it exists before populating a temp table with the ID's of the existing groups. My issue is that it keeps failing. I've tried everything I can think of so I am turning to people more skilled than I. Thanks in advance. It is the if exists statement that is failing on me.
Declare @GroupList varchar(100), @return int, @sql varchar(1000)
if @GroupList is not null
begin
if (object_id ('tempdb..#TempGroupList') is not null) drop table #TempGroupList
Create Table #TempGroupList
(
GroupID int,
PlayerID int
)
if exists (select * from Group_new where GroupName in (' + @GroupList + '))
    begin
    --lets populate our temp table
        set @SQL = 'insert into #TempGroupList (GroupID) select GroupID from Group_New where GroupName in (' + @GroupList + ')'
        exec(@sql)
    end
else
set @return = 1
select @return
print 'Stop, one of the Group names you entered does not exist'
Return
end

A: I would break in input apart, do the check, and then insert:
create procedure . . . (
    Declare @GroupList varchar(100),
    @return int, @sql varchar(1000)
) as
begin
    declare table @groups (grp varchar(255));

    insert @groups (grp)
        select ltrim(rtrim(value))
        from string_split(@grouplist, ',');

    if not exists (select 1
                   from @groups g
                   where not exists (select 1 group_new gn where gn.groupname = g.groupname)
                  )
    begin
        . . .  whatever you want to do here
    end;
    else begin
        print 'Stop, one of the Group names you entered does not
    end;
end;

Populating the temporary table defined in the stored procedure doesn't do much, because the temporary table is deleted when the stored procedure returns.  But you can put whatever logic you want in the then part after the if.


text:
Q: Vue Spa show  tag content as description text in search engine. ex.Google search I have a landing page build using Vue 2 with vue router and vue pwa.
When public to production, everything run okay but when i search my web in Google, results show only title page, content in noscript tag as description and when view cached version of my page Google show totally empty page.
But my web on production still run normal, full function and i definitely don't disable Js in browser. I also tried use Google Search Console to request re-index my page but nothing change.

A: Disable prefetch and preload in vue.config.js resolved my problem.
chainWebpack: config => {
  config.plugins.delete('preload')
  config.plugins.delete('prefetch')
},

A: Everything turned on in the server? Just had that happen today anyway what code you using to add the title and description. Looks like something may not be executing when the page loads.


text:
Q: Error: redeclaration differs in 'constexpr' Clang accepts this code, but GCC rejects it:
class Foo {
 public:
  static constexpr double kVal = 0.25f;
};

const double Foo::kVal;

(Using clang 3.0 and g++ 4.6.3)
~$ clang++ foo.cc -std=c++11 -c
[ok]
~$ g++ foo.cc -std=c++0x -c
foo.cc:6:19: error: redeclaration 'Foo::kVal' differs in 'constexpr'
foo.cc:3:34: error: from previous declaration 'Foo::kVal'
foo.cc:6:19: error: declaration of 'constexpr const double Foo::kVal' outside of class is not definition [-fpermissive]

Which interpretation is correct?

A: clang is correct.  It looks like somebody on the gcc team misread or misimplemented:
7.1.5/1:

If any declaration of a function or function template has constexpr specifier, then all its declarations shall contain the constexpr specifier.

Foo::kVal is obviously not a function or function template.  I don't see anything else in the Standard requiring use of constexpr to be consistent from one declaration to the next.

A: You don't need to declare twice.
class Foo {
  public:
   static constexpr double kVal = 0.25f;
};

Is all that is needed.


text:
Q: I have an error in python with tkinter and need help(school project) I have to create a little text adventure for school in python.
To detect keyboard inputs I decided to use tkinter and disable the window.
All is working fine but if I try to calculate with a variable after a key was pressed, I get the following error...This is the error message
This is the script I am using(I don't have much experience with python...)
import os
import sys
import tkinter

menueeintraege = ["Start", "Steuerung", "Credits", "Beenden"]
index = 0

def menueaufbauen():
    os.system("cls")
    print("Menue")
    print("")
    print("")
    for i in range(4):
        if i == index:
            print(menueeintraege[i] + "<")
        else:
            print(menueeintraege[i])

menueaufbauen()

def startgame():
    os.system("game.py");

def steuerung():
    os.system("cls")
    print("Steuerung")
    print("")
    print("Norden = Pfeiltaste Hoch")
    print("Sueden = Pfeiltaste Runter")
    print("Osten = Pfeiltaste Rechts")
    print("Westen = Pfeiltaste Links")
    print("Bestaetigen = Enter")

def credits():
    os.system("cls")
    print("Credits")
    print("")
    print("Jannik Nickel")
    print("Thomas Kraus")
    print("")

def exitgame():
    sys.exit()

def menueauswahl(taste):
    print(taste)
    if taste == "Up":
        if index > 0:
            index -= 1
            print(index)

    elif taste == "Down":
        if index < 3:
            index += 1

    menueaufbau()

def tasteneingabe(event):
    tastenname = event.keysym
    menueauswahl(tastenname)

fenster = tkinter.Tk()
fenster.bind_all('<Key>', tasteneingabe)
fenster.withdraw()
fenster.mainloop()

I think the mistake have to be in the last part of the script, I hope someone here knows a solution because it's really important for school.
Thanks for any help
(I'm using Visual Studio 2015)

A: Okay so I caught a couple of errors. The first is that you are referencing a global variable (index) inside of a function. To do that, you need to tell python that you are using a global variable.
def menueauswahl(taste):
    global index
    print(taste)

And also you need to change the function name in line 61 to menuaufbauen().


text:
Q: libXp.so.6 missing for ubuntu 17.04 mc@mc:~$ sudo apt-get install libXp.so.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libXp.so.6
E: Couldn't find any package by glob 'libXp.so.6'
E: Couldn't find any package by regex 'libXp.so.6'
mc@mc:~$

and there is no package related to libxp6 for ubuntu 17.04

A: I had this issue when trying to run an old app on Ubuntu 18.04. The workaround that I used was to create a symbolic link named libXp.so.6 pointing to file libXpm.so.4.11.0
Search for the package containing the file pattern libXpm
sudo dpkg -S libXpm
libxpm4:amd64: /usr/lib/x86_64-linux-gnu/libXpm.so.4
libxpm4:amd64: /usr/lib/x86_64-linux-gnu/libXpm.so.4.11.0

Then install the found package - libxpm4 (if not already installed)
sudo apt-get install libxpm4

Create the symbolic link:
cd /usr/lib/x86_64-linux-gnu

ls -l libXp*
lrwxrwxrwx 1 root root    16 Dec 22  2016 libXpm.so.4 -> libXpm.so.4.11.0
-rw-r--r-- 1 root root 72520 Dec 22  2016 libXpm.so.4.11.0

sudo ln -s libXpm.so.4.11.0 libXp.so.6

ls -l libXp*
lrwxrwxrwx 1 root root    16 Dec 22  2016 libXpm.so.4 -> libXpm.so.4.11.0
-rw-r--r-- 1 root root 72520 Dec 22  2016 libXpm.so.4.11.0
lrwxrwxrwx 1 root root    16 Nov  7 18:25 libXp.so.6 -> libXpm.so.4.11.0

If it's still worth for anybody...

A: Open the software sources config in a text editor with root permission, for example
sudo vim /etc/apt/sources.list

Append this line:
deb http://security.ubuntu.com/ubuntu precise-security main

Then run
sudo apt update
sudo apt install libxp6

A: I haven't found any library that would support this package for Ubuntu 17.04. However there is a temporal solution that works OK for me:
Download libxp6 package from earlier Ubuntu version:
https://packages.ubuntu.com/trusty/libxp6
Then install it manually using
sudo dpkg -i ./libxp6_1.0.2-1ubuntu1_amd64.deb
sudo apt-get install -f

It seems the package is compatible (enough) with 17.04.

A: A working solution for installing libXp.so.6:

*

*First provide multiarch support by
wget http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/multiarch-support_2.27-3ubuntu1.2_amd64.deb
sudo dpkg -i multiarch-support_2.27-3ubuntu1.2_amd64.deb

*Proceed to install libXp.so.6
wget ftp.us.debian.org/debian/pool/main/libx/libxp/libxp6_1.0.2-2_amd64.deb
sudo dpkg -i libxp6_1.0.2-2_amd64.deb

Cheers.


text:
Q: What does the .size on number mean in ruby? Why is my ruby giving incorrect size of number?  It doesn't matter what's the number. The output is always 4 for the size. What does that mean? I always thought it should give the number of digits.
number = 14
print number
print "\n"
print number.size

output:
14
4

ruby version
ruby 2.1.8p440 (2015-12-16 revision 53160) [i386-mingw32]

A: I always suggest to check the method you're not sure about using the following scheme:

*

*Check where the method comes from (using Object#method):
number.method(:size)
#=> #<Method: Fixnum#size>

*Open docs and learn what it does for Fixnum#size and how it works.
2.1 If you're using IRB, you can run help 'Fixnum#size' to get the docs right in your console
2.2 If you're using pry, you can go with show-doc Fixnum#size (install pry-doc gem first)

In Ruby 2.1.8 method was defined in Fixnum#size.
Starting from Ruby 2.4 it's defined in
Integer#size:

Returns the number of bytes in the machine representation of int.

A: You are confusing the two methods String#size:

Returns the character length of str.

and Fixnum#size:

Returns the number of bytes in the machine representation of fix.

14 is an object of class Fixnum, so when you call size on it you are getting the number of bytes in the machine representation of the number.
If you would like to know how many digits there are in a number, you can simply convert it to a string first and then call size on that:
14.to_s
# => "14"
14.to_s.size
#=> 2
12345.to_s.size
#=> 5


text:
Q: Flutter press suffixIcon without entring the text form field I have a TextFormField of a password and I want to put a suffixIcon so when the user press the icon the obsecure getting change and it's working but it's also entering me to the textform field and open the keyboard and I dont want that, Someone know how to do that?
this is my code:
import 'package:flutter/material.dart'

class trying extends StatefulWidget {
  const trying({Key? key}) : super(key: key);

  @override
  _tryingState createState() => _tryingState();
}

class _tryingState extends State<trying> {

  bool _secureText = true;

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;

    void secureText() {
      setState(() {
        _secureText = !_secureText;
      });
    }

    return Container(
      child: TextFormField(
        style: TextStyle(
          fontSize: size.width * .040,
        ),
        decoration: InputDecoration(
          hintText: 'Password',
          suffixIcon: IconButton(
            onPressed: () {
              secureText();
            },
            icon: Icon(
              _secureText ? Icons.visibility_off : Icons.visibility,
            ),
          ),
        ),
        obscureText: _secureText,
      ),
    );
  }
}

A: Maybe you can try to unfocus keyboard when u click the icon like
onPressed: () {
    secureText();
    FocusScope.of(context).unfocus();
}

A: Made small change,also don't put your _secureText() function under the Widget,also try use different names for function,it helps to identify fast using same name create confusion
class _MyHomePageState extends State<MyHomePage> {

  bool _secureText = false;

   void _togglevisibility() {
    setState(() {
      _secureText = !_secureText;
    });
  }
  @override
  Widget build(BuildContext context) {
 Size size = MediaQuery.of(context).size;
  return TextFormField(
    style: TextStyle(
      fontSize: size.width * .040,
    ),
    decoration: InputDecoration(
      hintText: 'Password',
      suffixIcon: IconButton(
        onPressed: () {
         _togglevisibility();
        },
        icon: Icon(
          _secureText ? Icons.visibility_off : Icons.visibility,
        ),
      ),
    ),
    obscureText: !_secureText,
  );
  }
}


text:
Q: AngularJS - $event passed in for function and in UI but is 'undefined'? I've created a function similar to many others I've done before, where I've passed in $event via the controller where it's placed, and also in the element's function call in the HTML for an ng-change event, but the console is saying that $event is undefined in all browsers.
HTML:
<select data-ng-change="determineAbsenceInputs($event)"

JS:
$scope.determineAbsenceInputs = function($event) {
    console.log($event.target);
}

Also returning the same in JSFiddle: http://jsfiddle.net/ADukg/16190/.
Written like every other function I've made where I've used it to reference the event target and it's attributes, but cannot figure out why this is happening only for this function.

A: From issue

ng-change is not a directive for handling the change event (I realize
  that this is confusing given the name), but is actually instead
  notified when ngModelController.$setViewValue() is called and the
  value changes (because ng-change adds a listener to the
  $viewChangeListeners collection). So this is as expected.

You should use ng-model instead
  <select data-ng-change="determineAbsenceInputs(selectedAbsenceType)" data-ng-model="selectedAbsenceType" id="absenceTypeSelect" name="absenceTypeSelect" material-select watch class="validate" required>

WORKING DEMO


text:
Q: storing values in an array using react usestate hook I have the following formik based example where I'm using primereact fileupload.
Everytime user uploads a file, the value of selectedAssetCategoryId is different. If a user is uploading multiple file at once then the value will remain the same. For example,
if a user is uploading 3 files together, the value of selectedAssetCategoryId will be 1.
So I want to store value 1 three times in uploadedFileCategory array.
Is   setUploadedFileCategory(uploadedFileCategory =>[...uploadedFileCategory,selectedAssetCategoryId]); a correct way of pusing items in the array? When I'm hovering over the variable uploadedFileCategory on this line  const [uploadedFileCategory , setUploadedFileCategory] = useState([]), visual studio code editor is telling me that uploadedFileCategory is declared but its value is never read.ts(6133)
const DataRequestForm = (props) => {
    const user = JSON.parse(sessionStorage.loggedInUser)
    const {values, setFieldValue, touched, errors, isSubmitting, handleReset, handleChange} = props;
    const growl = React.createRef()

     const [uploadedFileCategory , setUploadedFileCategory] = useState([])

    // fileUpload function testing using new service
    const fileUpload = (e) => {

         //Store the values in an array.
         setUploadedFileCategory(uploadedFileCategory =>[...uploadedFileCategory,selectedAssetCategoryId]);

        const personnelId = JSON.parse(sessionStorage.loggedInUser).id
        let formData = new FormData();
        e.files.forEach((file, i) => formData.append(`files`, file))

        axios.post('upms/uploadAndCreateAssociations?personnelId=' + personnelId +'&assetCategoryId='+selectedAssetCategoryId, formData,{
            headers: {
                "Content-Type": "multipart/form-data"
            }
        }).then((response) => {

            }).catch(err => console.log(err));

        }).catch((response) => {
            growlComp.show({severity: 'error', summary: 'File Upload unsuccessful', detail: 'File Upload was unsuccessful'})
            console.log('Could not upload files.....')
        })

    }

    return (

                <Growl ref={growl}/>
                <Form className="form-column-3">

                     Document Upload

                                <FileUpload
                                    name="files"
                                    mode='advanced'
                                    uploadHandler={fileUpload}
                                    customUpload={true}
                                    chooseLabel="Attach Files"
                                    maxFileSize="2058722381"
                                    ref={fileUploadRef}
                                    id="researcherAttachFileButton"
                                    disabled={disableButton}
                                    multiple={true}/>

                </Form>

    )

};

export const DataRequestEnhancedForm = withFormik(

    {

    mapPropsToValues: props => {

        return {

            uploadedFileCategory: uploadedFileCategory

        }
    },
    validationSchema:validationSchema,
    handleSubmit(values, {props, resetForm, setErrors, setSubmitting}) {

        props.handleSubmit(values)

        setSubmitting(false)
    },
    setFieldValue(field, value, shouldVal) {
        console.log('In setFieldValue')
    },

    displayName: 'Data Request Form',
})(DataRequestForm)

A: Let me answer this:
Question 1:
Is   setUploadedFileCategory(uploadedFileCategory =>[...uploadedFileCategory,selectedAssetCategoryId]); a correct way of pusing items in the array?
Answer
It works and here is the example code:
import "./styles.css";
import { useState } from "react";

export default function App() {
  const [array, setArray] = useState([]);
  const changeArray = () => {
    console.log(array);
    setArray((b) => [...array, 1]);
  };
  return (

Open console to see the logs

      <button onClick={() => changeArray()}>Example</button>

  );
}

The link is currently live at: https://byy0g5.csb.app/
Look at the console to see the logs.
Question 2
When I'm hovering over the variable uploadedFileCategory on this line  const [uploadedFileCategory , setUploadedFileCategory] = useState([]), visual studio code editor is telling me that uploadedFileCategory is declared but its value is never read.ts(6133)
Answer
It simply means that uploadedFileCategory is not being used anywhere in the code.
Even if the value is correctly set, you need to properly place this in the code to see the changes of value.
Try console.log(uploadedFileCategory) to see the output of the code.


text:
Q: Eliminate $x,y,z$ from equations Eliminate $x,y,z$ from equations
$$\frac{x}{y}+\frac{y}{z}+\frac{z}{x}=a$$
 $$\frac{x}{z}+\frac{y}{x}+\frac{z}{y}=b$$
 $$\left(\frac{x}{y}+\frac{y}{z}\right)\left(\frac{y}{z}+\frac{z}{x}\right)\left(\frac{z}{x}+\frac{x}{y}\right) =c$$
I try this problem with this method.
$$ab=\left(\frac{x}{y}+\frac{y}{z}+\frac{z}{x}\right)\left(\frac{x}{z}+\frac{y}{x}+\frac{z}{y}\right)$$
$\implies$$$ab=3+\sum_{cyclic}\frac{x^2}{yz}+\sum_{cyclic}\frac{xy}{z^2}$$
$$c=\left(\frac{x}{y}+\frac{y}{z}\right)\left(\frac{y}{z}+\frac{z}{x}\right)\left(\frac{z}{x}+\frac{x}{y}\right)=2+\sum_{cyclic}\frac{xy}{z^2}+\sum_{cyclic}\frac{x^2}{yz} $$
from above two equations I get,
$ab-3=c-2$
$ab=c+1$.
Is it correct ?or not correct ?
is there exists another way to do it? i want to know solution

A: Following is an alternate way to derive $c = ab - 1$.
Let $\lambda_1 = \frac{x}{y}$, $\lambda_2 = \frac{y}{z}$ and $\lambda_3 = \frac{z}{x}$. It is trivial to see $\lambda_1\lambda_2\lambda_3 = 1$.
In terms of $\lambda_1,\lambda_2,\lambda_3$, we have
$$\begin{align}
a &= \frac{x}{y} + \frac{y}{z} + \frac{z}{x} = \lambda_1 + \lambda_2 + \lambda_3\\
b &= \frac{y}{x} + \frac{z}{y} + \frac{x}{z} = \frac{1}{\lambda_1} + \frac{1}{\lambda_2} + \frac{1}{\lambda_3} = \lambda_2\lambda_3 + \lambda_3\lambda_1 + \lambda_1\lambda_2
\end{align}$$
Using Vieta's formula, we obtain
$$(\lambda-\lambda_1)(\lambda-\lambda_2)(\lambda-\lambda_3) = \lambda^3 - a\lambda^2 + b\lambda - 1$$
Notice the three factors in $c$ are simply $a - \lambda_i$ for $i = 1,2,3$. As a result,
$$c = (a-\lambda_1)(a-\lambda_2)(a-\lambda_3) = a^3 - a a^2 + b a - 1 = ba - 1$$


text:
Q: I am unable to not run php file from codeigniter asset folder? My directory structure is
project_name
--application
--assets
--user_data

I have added test.php file in asset directory.
and i entered url: http://domain.com/assets/test.php
It gives me 404 error.
Thanks


text:
Q: How to Detect if Firebase Listeners finished fetching Data? I'm using Firebase ValueEventlistener in an Android app to retreive some data from the database to initialize my UI, but my Problem is that I never know when data fetching is done and it depends on the speed of the user's internet connection, I'm making a delay of 5 seconds for the Listeners to finish fetching data but sometimes it's not enough and data is still null giving a null pointer exception. I want to know when the Firebase Listeners finish fetching data to be able to update my UI .
This is one Method where I fetch Data :
      public void GetRequests(){

         Retrieve.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
     Iterable<DataSnapshot> Games = dataSnapshot.getChildren();

            for(com.google.firebase.database.DataSnapshot game : Games ){

                String Game_Key = game.child("GameKey").getValue(String.class);
                String Game_Location = game.child("Location").getValue(String.class);
                String UserID_Sender = game.child("UserID").getValue(String.class);
                Adapter_Game_Key.add(Game_Key);
                Adapter_UserID_Sender.add(UserID_Sender);
           }
        }
        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}

Here I try to get the data from the Firebase Listeners in an ArrayList to be able to initialize the UI by passing the ArrayLists to an Adapter of a ListView.
Anyone has a solution for this please ?

A: Do all the UI updates inside the onDataChanged() method as follows:
    ArrayList<Ad> adArrayList_1 = new ArrayList<>();
    DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("ads");

    ListView listView_1 = (ListView) findViewById(R.id.market_list_view_1);

    MarketArrayAdapter marketArrayAdapter = new MarketArrayAdapter(
            this,
            adArrayList_1
    );

    listView_1.setAdapter(marketArrayAdapter);

            ref.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    adArrayList_1.clear();
                    for(DataSnapshot snapshot : dataSnapshot.getChildren()){
                        Ad ad = snapshot.getValue(Ad.class);
                        adArrayList_1.add(ad);

                    }
                    marketArrayAdapter.notifyDataSetChanged();
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });

My adapter class is below
public MarketArrayAdapter(Context context, ArrayList<Ad> list) {
    super(context, 0, list);
}

@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    final Ad ad = getItem(position);
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.ad_item, parent, false);
    }
    ImageView imageView = (ImageView) convertView.findViewById(R.id.ads_profile_pic);
    TextView title = (TextView) convertView.findViewById(R.id.ads_title);
    TextView price = (TextView) convertView.findViewById(R.id.ads_price);
    TextView description = (TextView) convertView.findViewById(R.id.ads_short_description);

    byte[] imageAsBytes = Base64.decode(ad.getaPictureUri().getBytes(), Base64.DEFAULT);
    imageView.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length));
    title.setText(ad.getaTitle());
    price.setText(String.valueOf(ad.getaPrice()));
    description.setText(ad.getaDescription());

    parent.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MarketActivity.this, ViewAdActivity.class);
            in.putExtra("key", ad.getaId());
            startActivity(in);
        }
    });
    return convertView;
}

}
Please dont forget to put this line marketArrayAdapter.notifyDataSetChanged();


text:
Q: Bootstrap 4 scroll to the bottom of long sticky sidebar I'm trying to achieve Facebook like right side navigation. When the sidebar content is taller than the viewport, If you scroll down the sidebar should be scrolled to the very bottom before it's stick to the screen.
JSFiddle

                Header

              Main Content

                Sidebar Content

                      Content

                Footer

A: I've come up with a solution to the problem using jQuery to make the sidebar sticky to a negative position based on the viewport and the sidebar's height (fiddle here):

function setPosition() {
  $(".sidebar-right").css({
    'position': 'sticky',
    'top': window.innerHeight - $(".sidebar-right").innerHeight()
  });
}

// Set initial positioin
setPosition();

// Adjust position when window is resized
$(window).resize(setPosition);
.header {
  width: 100%;
  background-color: green;
  text-align: center;
  padding: 15px 20px;
  color: #fff;
}

.sidebar-left {
  background-color: purple;
  color: #fff;
  padding: 15px;
  height: 500px;
}

.sidebar-right {
  background-color: purple;
  color: #fff;
  padding: 15px;
  height: 500px;
}

.main-content {
  background-color: red;
  height: 900px;
  color: #fff;
  padding: 15px;
}

.footer {
  width: 100%;
  background-color: green;
  text-align: center;
  padding: 15px 20px;
  color: #fff;
}

.content-bottom {
  position: absolute;
  bottom: 0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

        Header

        Main Content

        Sidebar Content

          Content

        Footer

If you don't want to use jQuery, you can add the sticky-top class to the element at bottom of your sidebar (it won't look quite right). Fiddle here (resize the window so the text at the sidebar is longer than the window height).

.header {
  width: 100%;
  background-color: green;
  text-align: center;
  padding: 15px 20px;
  color: #fff;
}

.sidebar-left {
  background-color: purple;
  color: #fff;
  padding: 15px;
  height: 500px;
}

.sidebar-right {
  background-color: purple;
  color: #fff;
  padding: 15px;
  height: 100%;
}

.main-content {
  background-color: red;
  height: 900px;
  color: #fff;
  padding: 15px;
}

.footer {
  width: 100%;
  background-color: green;
  text-align: center;
  padding: 15px 20px;
  color: #fff;
}

.content-bottom {
  position: absolute;
  bottom: 0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>

        Header

        Main Content

        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer quis turpis enim. Sed non lacinia lacus.

          Curabitur lorem lorem, efficitur sit amet ex non, viverra porttitor odio.

        Footer


text:
Q: Can I get a NSURL from an XCAssets bundle? I'm in a situation where I am listing attachments from a message.  Each attachment has a NSURL associated with it that represents a path to the attachment data.  In the case of non-image attachments I want to load pre-generated icon thumbnails in the place of a preview (i.e. excel documents, PDF, word, etc).
I currently have these images in my project, within an XCAssets bundle.  I can get at them using [UIImage imageNamed:@"someName"].  I cannot seem to get at them via NSBundle's various resource lookup methods.  Does the XCAssets bundle somehow change the filenames of the icon images I'm looking for?
Here's the code I'm currently working with.  Path is nil every time.  Do I need to not use XCAssets in this case?
+ (NSURL *)mediaURLWithMessage:(SRMediaMessage*)message
{
  NSURL *url = message.mediaURL;

  // if this is an image URL or non-existant, there is no work left to do, return it.
  if (!url || (message.secureFile.secureFileMimeType & SRSecureFileMimeTypeImage))
    return url;

  NSString *filename = @"unknown";

  switch (message.secureFile.secureFileMimeType)
  {
    case SRSecureFileMimeTypeDOC:
      filename = @"doc";
      break;

    case SRSecureFileMimeTypePPT:
      filename = @"ppt";
      break;

    case SRSecureFileMimeTypePDF:
      filename = @"pdf";
      break;

    case SRSecureFileMimeTypeXLS:
      filename = @"exl";
      break;

    case SRSecureFileMimeTypeCSV:
      filename = @"csv";
      break;

    case SRSecureFileMimeTypeTXT:
      filename = @"txt";
      break;

    case SRSecureFileMimeTypeRTX:
      filename = @"rtf";
      break;

    default:
    case SRSecureFileMimeTypeMP4:
      // unknown icon for now.
      break;

      // unused but available:
//      @"ilife"

  }

  NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:nil];
  if (path)
    url = [NSURL fileURLWithPath:path];

  return url;
}

A: Swift 3 and Swift 2.3 versions of the answer by @tadija:
Swift 3:
import UIKit

class AssetExtractor {

    static func createLocalUrl(forImageNamed name: String) -> URL? {

        let fileManager = FileManager.default
        let cacheDirectory = fileManager.urls(for: .cachesDirectory, in: .userDomainMask)[0]
        let url = cacheDirectory.appendingPathComponent("\(name).png")
        let path = url.path

        guard fileManager.fileExists(atPath: path) else {
            guard
                let image = UIImage(named: name),
                let data = UIImagePNGRepresentation(image)
                else { return nil }

            fileManager.createFile(atPath: path, contents: data, attributes: nil)
            return url
        }

        return url
    }

}

Swift 2.3:
import UIKit

class AssetExtractor {

    static func createLocalUrl(forImageNamed name: String) -> NSURL? {

        let fileManager = NSFileManager.defaultManager()
        let cacheDirectory = fileManager.URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask)[0]
        guard
            let url = cacheDirectory.URLByAppendingPathComponent("\(name).png"),
            let path = url.path
            else { return nil }

        guard fileManager.fileExistsAtPath(path) else {
            guard
                let image = UIImage(named: name),
                let data = UIImagePNGRepresentation(image)
                else { return nil }

            fileManager.createFileAtPath(path, contents: data, attributes: nil)
            return url
        }

        return url
    }

}

A: I wanted to access some vector assets for creating UNNotificationAttachment with local resources so I came up with this helper class. It basically just gets image from assets, saves its data to disk and return file URL. I hope that helps someone.
import UIKit

class AssetExtractor {

    static func createLocalUrl(forImageNamed name: String) -> URL? {

        let fileManager = FileManager.default
        let cacheDirectory = fileManager.urls(for: .cachesDirectory, in: .userDomainMask)[0]
        let url = cacheDirectory.appendingPathComponent("\(name).png")

        guard fileManager.fileExists(atPath: url.path) else {
            guard
                let image = UIImage(named: name),
                let data = UIImagePNGRepresentation(image)
            else { return nil }

            fileManager.createFile(atPath: url.path, contents: data, attributes: nil)
            return url
        }

        return url
    }

}

A: If you're targeting iOS 7+, Xcode 5 now puts the assets into a new file format. 1 file for all of the assets. This means you can not get access to the file directly.
If you need to access the file directly, you can include it as an normal image outside of an asset catalog.

A: Swift 5
And it made a bit more sense to me as a URL extension.
extension URL {
    static func localURLForXCAsset(name: String) -> URL? {
        let fileManager = FileManager.default
        guard let cacheDirectory = fileManager.urls(for: .cachesDirectory, in: .userDomainMask).first else {return nil}
        let url = cacheDirectory.appendingPathComponent("\(name).png")
        let path = url.path
        if !fileManager.fileExists(atPath: path) {
            guard let image = UIImage(named: name), let data = image.pngData() else {return nil}
            fileManager.createFile(atPath: path, contents: data, attributes: nil)
        }
        return url
    }
}

Usage:
if let url = URL.localURLForXCAsset(name: "MyIcon") {
  // code
}

A: Swift 3.x
static func createLocalUrl(forImageNamed name: String) -> URL? {

    let fileManager = FileManager.default
    let cacheDirectory = fileManager.urls(for: .cachesDirectory, in: .userDomainMask)[0]
    let url = cacheDirectory.appendingPathComponent("\(name).png")
    let path = url.path

    guard fileManager.fileExists(atPath: path) else {
        guard
            let image = UIImage(named: name),
            let data = UIImagePNGRepresentation(image)
            else { return nil }

        fileManager.createFile(atPath: path, contents: data, attributes: nil)
        return url
    }

    return url
}


text:
Q: OPENQUERY update on linked server I want to execute the following statement through from a linked server (openquery):
UPDATE SAP_PLANT
SET (OWNER, OWNER_COUNTRY) = (SELECT import.AFNAME, import.COUNTRY
                                FROM SAP_IMPORT_CUSTOMERS import, SAP_PLANT plant
                                WHERE plant.SAP_FL = import.SAP_NO
                                AND import.role ='OWNER')

I've tried to form it into the following syntax, without success :(
update openquery('my_linked_server, 'select column_1, column_2 from table_schema.table_name where pk = pk_value')
set column_1 = 'my_value1′, column_2 = 'my_value2′

I hope for you this is no problem?

A: I guess this is not really a query you want to open, rather an SQL statement you want to execute. So instead of openquery, you shoud use execute. See example G here: http://msdn.microsoft.com/en-us/library/ms188332.aspx
So your script shoul look like
execute ('your sql command here') at my_linked_server

A: Are you getting syntax error?  Your server parameter in the update openquery is missing a trailing quote.  Change ```my_linked_servertomy_linked_server'`.


text:
Q: Style different GeoJSON geometries differently in OpenLayers I got this GeoJSON from Geoserver, having 2 different types of geometry type i.e. Polygon & LineString which I want to style differently i.e polygon with different colour & line with different colour.
The GeoJSON from Geoserver URL is as follows
{"type":"FeatureCollection","features":[{"type":"Feature","id":"INDIA_DIST_717_GCS.fid-7165b83f_17ec626fcae_2492","geometry":{"type":"Polygon","coordinates":[[[77.19886222,28.68648361],[77.20063225,28.68325992],[77.2070568,28.68135635],[77.21419518,28.6815943],[77.21966794,28.68516349],[77.22109562,28.69135009],[77.21909473,28.69985388],[77.22091961,28.70479139],[77.22077629,28.70609661],[77.22299919,28.71466881],[77.22157151,28.718238],[77.21966794,28.72156925],[77.21490902,28.72299692],[77.2101501,28.72537638],[77.20348761,28.72680406],[77.20063225,28.72537638],[77.19563538,28.72347281],[77.1946836,28.72585227],[77.1915903,28.72704201],[77.18825905,28.73132504],[77.18302424,28.73537012],[77.17826532,28.73774958],[77.17802737,28.74274645],[77.18064478,28.74441207],[77.18564165,28.74512591],[77.18516576,28.74750537],[77.18326219,28.75036072],[77.17985384,28.75697345],[77.18263439,28.76589371],[77.18934396,28.7660118],[77.21052226,28.78512337],[77.21291649,28.7826737],[77.214344,28.78212268],[77.21329286,28.77891617],[77.21487985,28.77467261],[77.21535579,28.7700811],[77.22309772,28.75740185],[77.23118146,28.74604219],[77.24602265,28.73249849],[77.24447918,28.70125628],[77.24341252,28.69893773],[77.242228,28.66835722],[77.24683587,28.66219308],[77.25020969,28.66126535],[77.25066034,28.66105188],[77.25057487,28.66160025],[77.25510434,28.66167805],[77.25702548,28.65827558],[77.25821521,28.65589612],[77.25988083,28.65256488],[77.26083262,28.65137515],[77.26273618,28.6511372],[77.26559154,28.64947158],[77.26773305,28.64709212],[77.267971,28.64447471],[77.26844689,28.64114346],[77.26701921,28.63662249],[77.2648777,28.63043589],[77.26041763,28.62146749],[77.25705349,28.62129086],[77.24232154,28.63056745],[77.23747368,28.63081229],[77.2321803,28.63433555],[77.22051222,28.63971957],[77.20081329,28.63773235],[77.19679132,28.63437549],[77.19053547,28.63097923],[77.1876979,28.62468523],[77.1867211,28.62425017],[77.18691352,28.62459838],[77.18639978,28.6250822],[77.18395439,28.62583001],[77.18780029,28.63030264],[77.18976021,28.63271484],[77.19368004,28.63497628],[77.19453912,28.63688009],[77.19329285,28.63826603],[77.19150826,28.64254906],[77.19008058,28.64576133],[77.18825011,28.6496708],[77.18707341,28.65227906],[77.18587936,28.65646007],[77.18585946,28.65652975],[77.17283954,28.65564257],[77.17130498,28.65758713],[77.16749833,28.66113447],[77.17072312,28.66677811],[77.17093248,28.66693439],[77.17658537,28.67115381],[77.1782239,28.68104105],[77.18253744,28.68801789],[77.18702255,28.68743972],[77.19223781,28.68753146],[77.19886222,28.68648361]]]},"geometry_name":"geometry","properties":{"fid":138,"state_name":"Delhi","state_id":"7","district_name":"CENTRAL-DELHI","district_id":95}},{"type":"Feature","id":"INDIA_DIST_717_GCS.fid-7165b83f_17ec626fcae_2493","geometry":{"type":"Polygon","coordinates":[[[76.96584863,28.81351167],[76.96771995,28.80494727],[76.96879071,28.79887965],[76.97164606,28.79316894],[76.97557217,28.79102743],[76.9798552,28.78959975],[76.98342439,28.78852899],[76.98806434,28.7867444],[76.99270429,28.7831752],[76.99805808,28.78067677],[77.00733797,28.77996293],[77.01447636,28.7774645],[77.01483328,28.76854152],[77.01483328,28.76211697],[77.01590403,28.75676319],[77.02018706,28.75212324],[77.02589777,28.74855405],[77.03517767,28.74569869],[77.03838994,28.74498485],[77.04445757,28.74320026],[77.04838368,28.74070182],[77.05195287,28.74034491],[77.05659282,28.73963107],[77.0655158,28.73713263],[77.07158342,28.73249268],[77.07443877,28.72963733],[77.08193408,28.72499738],[77.08586019,28.72606814],[77.09014322,28.73177885],[77.09656776,28.73356344],[77.09978003,28.73499112],[77.10441998,28.73499112],[77.10834609,28.73356344],[77.11298604,28.72785274],[77.1158414,28.72428354],[77.11869675,28.71714516],[77.12012443,28.71286213],[77.12405054,28.70429607],[77.12690589,28.70286839],[77.13297352,28.70536683],[77.13547195,28.70893602],[77.13582887,28.71107754],[77.14082574,28.71678824],[77.14582261,28.71964359],[77.14796412,28.72285587],[77.15117639,28.72356971],[77.15617326,28.72428354],[77.15974245,28.72749582],[77.16509624,28.72749582],[77.16652392,28.72071435],[77.16581008,28.717859],[77.16581008,28.71357597],[77.166167,28.70893602],[77.16473932,28.70358223],[77.16581008,28.69822845],[77.17294846,28.69680077],[77.17758841,28.69680077],[77.18080068,28.69680077],[77.1829422,28.69537309],[77.18758215,28.69287466],[77.19223781,28.68753146],[77.18702255,28.68743972],[77.18253744,28.68801789],[77.1782239,28.68104105],[77.17658537,28.67115381],[77.17093248,28.66693439],[77.16688622,28.67163931],[77.15494464,28.67241291],[77.15265711,28.67467244],[77.11951433,28.67374964],[77.11127409,28.67557252],[77.09835667,28.68618258],[77.08622567,28.67906097],[77.07976212,28.68452934],[77.07606028,28.6834758],[77.07152833,28.68602168],[77.06379885,28.68193647],[77.05812586,28.68544683],[77.04471569,28.68519933],[77.02600405,28.68846683],[77.01090496,28.68095556],[76.99863665,28.67973969],[76.97816297,28.69414135],[76.96372127,28.69341223],[76.96409474,28.69397837],[76.96450443,28.69882057],[76.96085908,28.70321867],[76.95117244,28.71049658],[76.96060605,28.72992596],[76.95915313,28.73496173],[76.96026542,28.74011966],[76.95739735,28.74460099],[76.94816892,28.75310703],[76.95658062,28.7675122],[76.95397162,28.772012],[76.95234458,28.78124495],[76.95311925,28.78860196],[76.9475061,28.7969928],[76.94740075,28.80264981],[76.95237135,28.81417721],[76.95828556,28.81115307],[76.96584863,28.81351167]]]},"geometry_name":"geometry","properties":{"fid":143,"state_name":"Delhi","state_id":"7","district_name":"NORTH-WEST-DELHI","district_id":90}},{"type":"Feature","id":"INDIA_DIST_717_GCS.fid-7165b83f_17ec626fcae_2494","geometry":{"type":"Polygon","coordinates":[[[77.19453912,28.63688009],[77.19368004,28.63497628],[77.18976021,28.63271484],[77.18780029,28.63030264],[77.18395439,28.62583001],[77.17830225,28.62755845],[77.17330538,28.62934305],[77.16723775,28.63077073],[77.16259781,28.633983],[77.15867169,28.63648143],[77.15438866,28.63683835],[77.14739397,28.63885969],[77.14425572,28.63669442],[77.13837858,28.63308379],[77.13047552,28.63118924],[77.12016851,28.61873449],[77.11303701,28.61217887],[77.10776942,28.61091501],[77.09173502,28.61705058],[77.08577819,28.61694196],[77.07585016,28.61676043],[77.06064105,28.61589689],[77.05478117,28.61169905],[77.03823525,28.61139295],[77.03685589,28.61370442],[77.03408309,28.6189113],[77.02867642,28.62348484],[77.02531102,28.6257592],[77.01995973,28.62799643],[77.01200264,28.62843198],[77.00793269,28.63244553],[77.0038484,28.63704293],[76.99700294,28.64626223],[76.98828351,28.65077193],[76.97891558,28.65468463],[76.968828,28.66092003],[76.96282635,28.6625587],[76.95757245,28.66070603],[76.95218979,28.66410878],[76.95208088,28.66854839],[76.95238879,28.66856472],[76.95710296,28.67061319],[76.95579604,28.67693196],[76.95824479,28.68144158],[76.9598786,28.68758687],[76.96372127,28.69341223],[76.97816297,28.69414135],[76.99863665,28.67973969],[77.01090496,28.68095556],[77.02600405,28.68846683],[77.04471569,28.68519933],[77.05812586,28.68544683],[77.06379885,28.68193647],[77.07152833,28.68602168],[77.07606028,28.6834758],[77.07976212,28.68452934],[77.08622567,28.67906097],[77.09835667,28.68618258],[77.11127409,28.67557252],[77.11951433,28.67374964],[77.15265711,28.67467244],[77.15494464,28.67241291],[77.16688622,28.67163931],[77.17093248,28.66693439],[77.17072312,28.66677811],[77.16749833,28.66113447],[77.17130498,28.65758713],[77.17283954,28.65564257],[77.18585946,28.65652975],[77.18587936,28.65646007],[77.18707341,28.65227906],[77.18825011,28.6496708],[77.19008058,28.64576133],[77.19150826,28.64254906],[77.19329285,28.63826603],[77.19453912,28.63688009]]]},"geometry_name":"geometry","properties":{"fid":148,"state_name":"Delhi","state_id":"7","district_name":"WEST-DELHI\n","district_id":96}},{"type":"Feature","id":"INDIA_DIST_717_GCS.fid-7165b83f_17ec626fcae_2495","geometry":{"type":"Polygon","coordinates":[[[76.91889812,28.82120806],[76.92440642,28.8200071],[76.93378263,28.82285602],[76.9440744,28.8198429],[76.95237135,28.81417721],[76.94740075,28.80264981],[76.9475061,28.7969928],[76.95311925,28.78860196],[76.95234458,28.78124495],[76.95397162,28.772012],[76.95658062,28.7675122],[76.94816892,28.75310703],[76.95739735,28.74460099],[76.96026542,28.74011966],[76.95915313,28.73496173],[76.96060605,28.72992596],[76.95117244,28.71049658],[76.96085908,28.70321867],[76.96450443,28.69882057],[76.96409474,28.69397837],[76.96372127,28.69341223],[76.9598786,28.68758687],[76.95824479,28.68144158],[76.95579604,28.67693196],[76.95710296,28.67061319],[76.95238879,28.66856472],[76.95208088,28.66854839],[76.93955322,28.66788359],[76.93291729,28.66268772],[76.92727592,28.65073561],[76.92798056,28.64674004],[76.94367249,28.63110087],[76.93572361,28.62270985],[76.93340652,28.62211032],[76.92009986,28.63129934],[76.9137507,28.63141526],[76.90700963,28.62628019],[76.90341271,28.62623339],[76.8876576,28.63113361],[76.87055847,28.59601798],[76.86444686,28.58585593],[76.85985871,28.58363249],[76.84464047,28.58492883],[76.84251436,28.57603269],[76.84717142,28.55050676],[76.86630759,28.54131346],[76.86877346,28.53541595],[76.88586107,28.52187185],[76.88899489,28.51746424],[76.88332862,28.50786549],[76.88889065,28.50251882],[76.88049592,28.49767485],[76.86410045,28.49808744],[76.82931936,28.50198334],[76.8255144,28.50147635],[76.82304234,28.49922018],[76.8133123,28.47462081],[76.79492848,28.46573164],[76.78924846,28.46589265],[76.7785889,28.47155082],[76.77662944,28.47342],[76.77222182,28.47396404],[76.76860207,28.47206452],[76.7634922,28.46386679],[76.76057854,28.46149042],[76.75225626,28.46152299],[76.74429027,28.46361804],[76.73919065,28.46848318],[76.73137486,28.4813452],[76.72111046,28.48762243],[76.70954791,28.48971975],[76.70767103,28.47938461],[76.71077926,28.46465089],[76.71036753,28.45704542],[76.71357031,28.45464538],[76.713625,28.45257382],[76.71291691,28.44608201],[76.7184433,28.43660951],[76.71619516,28.43293589],[76.71368153,28.42822036],[76.71016052,28.41726556],[76.70809094,28.40685869],[76.7088136,28.4016915],[76.71095271,28.39836728],[76.7142427,28.39584408],[76.72312431,28.39239948],[76.72972375,28.38657553],[76.73426591,28.38096823],[76.73528695,28.37554774],[76.73400612,28.36852531],[76.7303559,28.36249065],[76.72577324,28.35850966],[76.719652,28.3573472],[76.71318344,28.35825033],[76.70819925,28.35840651],[76.69762466,28.3594832],[76.69787627,28.36104316],[76.69837951,28.36416307],[76.69862427,28.36598199],[76.69708474,28.3688004],[76.6822512,28.37574745],[76.6740577,28.37861882],[76.66656742,28.37673328],[76.6671559,28.37940125],[76.66453378,28.38779042],[76.6596291,28.39438312],[76.65190373,28.39969113],[76.64563675,28.40825549],[76.63788813,28.41696724],[76.62997865,28.42285296],[76.6218452,28.42672816],[76.61514196,28.42753121],[76.61399342,28.42576306],[76.60945498,28.41875107],[76.60451029,28.40247869],[76.59678427,28.40100465],[76.59333153,28.40093086],[76.5898788,28.40085699],[76.57746578,28.39997988],[76.57062763,28.39738909],[76.56736011,28.39059839],[76.56267834,28.38499892],[76.55927666,28.38309263],[76.55228774,28.38599627],[76.55210184,28.39271264],[76.54644245,28.39747758],[76.53882975,28.39792331],[76.52505338,28.39640153],[76.51868518,28.40176096],[76.51842917,28.41091937],[76.51900031,28.41520834],[76.51527387,28.42490163],[76.4971104,28.43183438],[76.48738886,28.43345314],[76.48326182,28.43275121],[76.46896471,28.42510405],[76.44959132,28.42589543],[76.44390906,28.43126702],[76.44231834,28.4385625],[76.44214388,28.44466769],[76.43514877,28.44756592],[76.43830578,28.45802178],[76.43201819,28.46032474],[76.42303707,28.46012346],[76.41063692,28.45862294],[76.40907912,28.46469679],[76.40558948,28.46583993],[76.39868065,28.465684],[76.39311822,28.46678003],[76.38491623,28.46353977],[76.38504034,28.4592663],[76.38861854,28.45507111],[76.39350736,28.45334909],[76.39361348,28.44968606],[76.39719112,28.44549061],[76.39936937,28.44187436],[76.39262109,28.43622351],[76.38234903,28.43293605],[76.37561977,28.42667387],[76.36515291,28.43010105],[76.3589368,28.42995914],[76.3498148,28.43463788],[76.34830806,28.43887983],[76.34890927,28.44194821],[76.34812899,28.44498492],[76.34585959,28.45165296],[76.3463533,28.45838426],[76.34277357,28.46257848],[76.34004604,28.46129408],[76.33949881,28.45639428],[76.33891572,28.45271543],[76.33478888,28.45200968],[76.33280641,28.44890952],[76.33298623,28.44280448],[76.33376687,28.43976783],[76.33456544,28.43612065],[76.33463734,28.4336786],[76.3312738,28.43054655],[76.32507572,28.4297928],[76.31880551,28.43148088],[76.31795234,28.43695954],[76.31513529,28.43872721],[76.31169977,28.43803681],[76.30904549,28.43430979],[76.30491943,28.43360324],[76.30017529,28.4304385],[76.2996842,28.42370677],[76.29066556,28.4239164],[76.29076532,28.43340859],[76.29092576,28.43388654],[76.29076113,28.4339782],[76.29179421,28.43935004],[76.29157684,28.44760966],[76.29157684,28.45282627],[76.29201157,28.45869494],[76.2924463,28.46369419],[76.29375049,28.46651985],[76.29353313,28.46891079],[76.28940319,28.47173645],[76.28766427,28.47369268],[76.28527325,28.47695305],[76.28440379,28.47890928],[76.28440379,28.48130022],[76.28741215,28.48836965],[76.28779391,28.48851497],[76.29027265,28.49347229],[76.2930984,28.49651531],[76.29896726,28.4976021],[76.30505349,28.49760211],[76.31331337,28.4976021],[76.31787804,28.49542852],[76.31961696,28.49282022],[76.32070379,28.4923855],[76.32274612,28.49219984],[76.32679001,28.49368965],[76.33026786,28.49999305],[76.33526726,28.51694701],[76.33678882,28.52607606],[76.33694558,28.53438444],[76.34296338,28.54678002],[76.34333396,28.56986413],[76.34336715,28.57193248],[76.34346158,28.58089419],[76.3436686,28.60056835],[76.3499907,28.60154953],[76.3575387,28.60272058],[76.36027891,28.60187029],[76.37516695,28.5972494],[76.37565756,28.59705955],[76.39241265,28.59057478],[76.40124388,28.5871956],[76.4077777,28.55826559],[76.40916434,28.55212373],[76.41054206,28.54602066],[76.42617457,28.54453633],[76.43772211,28.59131718],[76.44748368,28.5917183],[76.45504248,28.59280392],[76.46466872,28.59797226],[76.46629967,28.60277962],[76.46231151,28.60782382],[76.45367879,28.61874028],[76.4520432,28.62503483],[76.45308743,28.63100207],[76.4549311,28.64153684],[76.45579909,28.64649614],[76.45267724,28.65199472],[76.45240385,28.65247613],[76.41829683,28.65658871],[76.41002109,28.6576762],[76.40913384,28.66485264],[76.40716985,28.68073226],[76.407013,28.68082426],[76.41780608,28.69005297],[76.42054546,28.70556649],[76.41850767,28.7209726],[76.42957518,28.72402958],[76.45314414,28.73579165],[76.4706251,28.73758323],[76.50092857,28.73684486],[76.52641398,28.73740074],[76.53573601,28.7460307],[76.54859678,28.74209509],[76.5759087,28.73425483],[76.59008988,28.74017641],[76.59603804,28.75575362],[76.59713083,28.77403595],[76.60137083,28.78157663],[76.61332554,28.78716294],[76.62950805,28.78572728],[76.63674237,28.79180474],[76.64524197,28.80087084],[76.64781934,28.80507239],[76.63541172,28.81606924],[76.63385801,28.82373885],[76.64168707,28.83279052],[76.64698714,28.83586405],[76.65179075,28.83240984],[76.66234049,28.81544842],[76.67188147,28.81090729],[76.67221504,28.79847184],[76.67509479,28.79142165],[76.69007476,28.78462228],[76.71160268,28.78447389],[76.71076049,28.76549592],[76.7291116,28.75816948],[76.74191291,28.75724582],[76.75377866,28.76637511],[76.76526716,28.76423784],[76.76946968,28.75780502],[76.76701257,28.74886729],[76.77863759,28.74139892],[76.7853579,28.7415342],[76.79647679,28.7536082],[76.80354964,28.76619283],[76.82261805,28.78316317],[76.81293267,28.79363542],[76.79452007,28.80333977],[76.79895164,28.81409314],[76.8216625,28.82047068],[76.82717854,28.81524798],[76.83073737,28.80761637],[76.84556024,28.8067244],[76.86414777,28.81656944],[76.86668796,28.82254384],[76.87789663,28.83164978],[76.88659494,28.83359662],[76.90287551,28.86067475],[76.90881169,28.85879026],[76.91074529,28.85582403],[76.91160403,28.84560561],[76.91373572,28.8388554],[76.91715516,28.83246004],[76.91889812,28.82120806]]]},"geometry_name":"geometry","properties":{"fid":191,"state_name":"Haryana","state_id":"6","district_name":"JHAJJAR","district_id":83}},{"type":"Feature","id":"INDIA_DIST_717_GCS.fid-7165b83f_17ec626fcae_2496","geometry":{"type":"Polygon","coordinates":[[[76.55426298,29.08410688],[76.56694148,29.06534095],[76.57185573,29.06181081],[76.58999201,29.06301353],[76.61176752,29.05900096],[76.63309774,29.05902855],[76.63907545,29.05718273],[76.63932184,29.05449362],[76.65088697,29.05766037],[76.65688637,29.06161766],[76.66641499,29.06411529],[76.6787036,29.06130466],[76.69296049,29.05010306],[76.70094951,29.04490265],[76.70634309,29.03888206],[76.72237872,29.02618116],[76.72870275,29.0178793],[76.73245183,29.00799167],[76.73263375,29.00109705],[76.7329167,28.99037192],[76.73151766,28.97731275],[76.72973806,28.96636247],[76.74365233,28.95845426],[76.7577015,28.96219626],[76.76642689,28.95669657],[76.77741968,28.94436457],[76.77884987,28.94309124],[76.77560304,28.93945419],[76.78371401,28.92590336],[76.79121627,28.92432072],[76.8129163,28.92687694],[76.81882914,28.92689362],[76.82751913,28.91931265],[76.82555441,28.91218506],[76.82720354,28.90212109],[76.81949351,28.88953277],[76.82017653,28.88392926],[76.81222546,28.86315936],[76.81933219,28.857743],[76.84582768,28.85974856],[76.85886897,28.85966116],[76.86434815,28.8605252],[76.86821319,28.86487003],[76.87991402,28.86796908],[76.89192887,28.86656585],[76.90287551,28.86067475],[76.88659494,28.83359662],[76.87789663,28.83164978],[76.86668796,28.82254384],[76.86414777,28.81656944],[76.84556024,28.8067244],[76.83073737,28.80761637],[76.82717854,28.81524798],[76.8216625,28.82047068],[76.79895164,28.81409314],[76.79452007,28.80333977],[76.81293267,28.79363542],[76.82261805,28.78316317],[76.80354964,28.76619283],[76.79647679,28.7536082],[76.7853579,28.7415342],[76.77863759,28.74139892],[76.76701257,28.74886729],[76.76946968,28.75780502],[76.76526716,28.76423784],[76.75377866,28.76637511],[76.74191291,28.75724582],[76.7291116,28.75816948],[76.71076049,28.76549592],[76.71160268,28.78447389],[76.69007476,28.78462228],[76.67509479,28.79142165],[76.67221504,28.79847184],[76.67188147,28.81090729],[76.66234049,28.81544842],[76.65179075,28.83240984],[76.64698714,28.83586405],[76.64168707,28.83279052],[76.63385801,28.82373885],[76.63541172,28.81606924],[76.64781934,28.80507239],[76.64524197,28.80087084],[76.63674237,28.79180474],[76.62950805,28.78572728],[76.61332554,28.78716294],[76.60137083,28.78157663],[76.59713083,28.77403595],[76.59603804,28.75575362],[76.59008988,28.74017641],[76.5759087,28.73425483],[76.54859678,28.74209509],[76.53573601,28.7460307],[76.52641398,28.73740074],[76.50092857,28.73684486],[76.4706251,28.73758323],[76.45314414,28.73579165],[76.42957518,28.72402958],[76.41850767,28.7209726],[76.42054546,28.70556649],[76.41780608,28.69005297],[76.407013,28.68082426],[76.40587907,28.67985451],[76.39828791,28.68612872],[76.39795474,28.6864041],[76.39795471,28.68640416],[76.38396291,28.6979657],[76.38080313,28.70221522],[76.38053412,28.70769527],[76.38680194,28.71734145],[76.38774518,28.72158735],[76.39365874,28.72761509],[76.4007592,28.73177036],[76.40577712,28.75007449],[76.39083028,28.76954167],[76.38752309,28.77170082],[76.35009116,28.79612822],[76.33258112,28.80412734],[76.33223189,28.80743956],[76.33187766,28.81942021],[76.33694684,28.82506957],[76.34295439,28.8344289],[76.3457956,28.84463771],[76.35183188,28.85307487],[76.35988152,28.86432388],[76.35861815,28.87167215],[76.32865414,28.89288096],[76.30019628,28.9031581],[76.29184702,28.87450556],[76.29037092,28.87382118],[76.28633088,28.89436264],[76.27673449,28.89808352],[76.25645892,28.89990349],[76.23707164,28.89990756],[76.23277999,28.90393374],[76.22983077,28.93578011],[76.21547553,28.95176562],[76.21343592,28.9569707],[76.21163003,28.96157904],[76.21256509,28.96359096],[76.21994812,28.97947447],[76.23980453,28.99534763],[76.23888101,29.01201515],[76.23456627,29.0509757],[76.24101679,29.05259287],[76.25393454,29.0558306],[76.2737435,29.05995978],[76.28056206,29.06740323],[76.28249397,29.06767111],[76.28718807,29.06832195],[76.29063868,29.07272486],[76.29194655,29.07697267],[76.30151197,29.08538569],[76.33233088,29.08604763],[76.34085034,29.0844956],[76.35140297,29.08531825],[76.3810348,29.07169138],[76.39068826,29.07298166],[76.3962567,29.07656346],[76.40484609,29.07947012],[76.4120518,29.07782072],[76.42417778,29.07015166],[76.43070335,29.06392029],[76.44012009,29.05973783],[76.44647196,29.05850805],[76.45547535,29.06098113],[76.46123394,29.06507382],[76.47260129,29.08194651],[76.47911289,29.0949388],[76.48731857,29.08986535],[76.49868936,29.08145927],[76.50550669,29.07938008],[76.51242116,29.07912258],[76.52000927,29.08367443],[76.52684175,29.09090028],[76.54011072,29.10288993],[76.54595841,29.09741897],[76.55060844,29.0909823],[76.55426298,29.08410688]]]},"geometry_name":"geometry","properties":{"fid":202,"state_name":"Haryana","state_id":"6","district_name":"ROHTAK","district_id":82}},{"type":"Feature","id":"railway_shapefile.fid-7165b83f_17ec626fcae_2497","geometry":{"type":"LineString","coordinates":[[77.20053514,28.66707104],[77.1701275,28.66873684],[77.15085908,28.67444862],[77.13878007,28.67955302],[77.12705661,28.68104114],[77.1204191,28.68188335],[77.11622764,28.68213757],[77.0901064,28.68371911],[77.06815655,28.68377646],[77.05898208,28.68493942],[77.04817328,28.68630883],[77.03529025,28.68793999],[77.00832211,28.68899674],[76.97997949,28.69094027],[76.95918629,28.6946738],[76.93536721,28.69871347],[76.93172285,28.69926543],[76.92092428,28.70090065],[76.91709217,28.70148075],[76.88916945,28.7113967],[76.86895242,28.7209085],[76.84617795,28.73266039],[76.83243396,28.74110246],[76.81470688,28.75056477],[76.78576887,28.76677079],[76.76348877,28.77888719],[76.7406599,28.79190625],[76.73298861,28.79459302],[76.71327862,28.80363609],[76.68943335,28.81534268],[76.66953166,28.82740278],[76.64881555,28.83861788],[76.63331398,28.84714196],[76.62403646,28.85224227],[76.59900611,28.86599748],[76.58526596,28.87313335],[76.58494311,28.87337671]]},"geometry_name":"geometry","properties":{"fid":10,"DESCRIPTIO":"RAILWAY BROAD GAUGE DOUBLE LINE","RAILWAY_BR":null,"ELECTRIFIE":"YES","DIVISION":"DELHI","ZONE_":"NORTHERN RAILWAY","GAUGE":"BROAD GAUGE","SHAPE_LENG":64741.9298417,"FROM":"DELHI","TO":"ROHTAK"}}],"totalFeatures":6,"numberMatched":6,"numberReturned":6,"timeStamp":"2022-02-04T20:28:10.729Z","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::4326"}}}

Style defined in JS is as:
var style = new ol.style.Style({
  fill: new ol.style.Fill({
    color: 'rgba(255, 255, 255, 0.0)'
  }),
  stroke: new ol.style.Stroke({
    color: '#f21602',
    width: 12
  }),

  image: new ol.style.Circle({
    radius: 7,
    fill: new ol.style.Fill({
      color: '#ffcc33'
    })
  })
});

geojson = new ol.layer.Vector({
  source: new ol.source.Vector({
    URL: "https://raw.githubusercontent.com/abhilashsinghimd/AASD_Geojson/main/features.json",
    format: new ol.format.GeoJSON()
  }),
  style: style,
  visible: true,

});

The output now is like this

but it should be like this.

How to define the style for 2 different types of geometries?

A: Instead of fixed style you can use style function, where first parameter is feature. Here you can check feature geometry type with .getGeometry().getType() methods and return desired style.
Code could the look something like this:
var defaultStyle = new ol.style.Style({
  fill: new ol.style.Fill({
    color: 'rgba(255, 255, 255, 0.0)'
  }),
  stroke: new ol.style.Stroke({
    color: '#0000ff',
    width: 4
  })
});

var lineStyle = new ol.style.Style({
  stroke: new ol.style.Stroke({
    color: '#f21602',
    width: 12
  })
});

function style(feature, resolution) {
  if (feature.getGeometry().getType() == 'LineString')
    return(lineStyle);
  else {
    return(defaultStyle);
  }
}

var vectorLayer = new ol.layer.Vector({
  source: new ol.source.Vector({
    url: "https://raw.githubusercontent.com/abhilashsinghimd/AASD_Geojson/main/features.json",
    format: new ol.format.GeoJSON({
      dataProjection: 'EPSG:4326',
      featureProjection: 'EPSG:3857'
    })
  }),
  style: style,
  visible: true
});

var osmLayer = new ol.layer.Tile({
  source: new ol.source.OSM(),
});

var view = new ol.View({
  center: ol.proj.transform([77.21966794,28.68516349], 'EPSG:4326', 'EPSG:3857'),
  zoom: 8,
});

var map = new ol.Map({
  target: 'map',
  layers: [
    osmLayer,
    vectorLayer
  ],
  view: view
});

This is the result:


text:
Q: Numbering in subequation and align environments I use the subequations and align environments as follows:
 \begin{subequations}
 \begin{align}
   \sum_{a \in \delta^+_G(v)} f^k_a -  \sum_{a \in \delta^-_G(v)} f^k_a  &= d^k_v, & \forall v \in V, k \in K \\
    \sum_{k \in K} f^k_a  &\le \sum_{m \in M}c^m x^m_a, & \forall a \in A   & \quad \texttt{Directed}\\
    \max \left\{\sum_{k \in K} \{f^k_{e+},f^k_{e-}\}  \right\}&\le \sum_{m \in M}c^m x^m_a, & \forall e \in E   & \quad \texttt{Bidirected}\\
    \sum_{k \in K} (f^k_{e+}+f^k_{e-})&\le \sum_{m \in M}c^m x^m_e, & \forall e \in E   & \quad \texttt{Undirected}
 \end{align}
 \end{subequations}

which shows the equations numbered as
1.a
1.b
1.c
1.d
However, I'd like the numbering to be displayed as
1
2.a
2.b
2.c

A: I would like to suggest that you (a) embed all four statements in a gather environment and (b) embed the three inequalities in combined subequations and alignat environments. I would also recommend using \smashoperator directives in order to typeset the summation expressions in the first row more compactly.

\documentclass{article}
\usepackage{mathtools} % for \smashoperator macro

\begin{document}
\begin{gather}
   \smashoperator{\sum_{a \in \delta^+_G(v)}} f^k_a -
   \smashoperator{\sum_{a \in \delta^-_G(v)}} f^k_a  =
   d^k_v, \quad \forall v \in V,\ k \in K
\\[\jot]
\begin{subequations}
\begin{alignat}{3}
  \sum_{k \in K} f^k_a
  &\le \sum_{m \in M}c^m x^m_a,
  &\qquad& \forall a \in A
  & \quad& \texttt{Directed} \\
  \max \biggl\{\sum_{k \in K} \{f^k_{e+},f^k_{e-}\}  \biggr\}
  &\le \sum_{m \in M}c^m x^m_a,
  && \forall e \in E
  && \texttt{Bidirected} \\
  \sum_{k \in K} (f^k_{e+}+f^k_{e-})
  &\le \sum_{m \in M}c^m x^m_e,
  && \forall e \in E
  &&  \texttt{Undirected}
\end{alignat}
\end{subequations}
\end{gather}
\end{document}

A: Mico just posted his answer as I was writing this, and you should consider that, but to directly answer the question with align I'd probably not use subequations and simply tag the later equations so

\documentclass{article}

\usepackage{amsmath}

\begin{document}

 \begin{align}
   \sum_{a \in \delta^+_G(v)} f^k_a -  \sum_{a \in \delta^-_G(v)} f^k_a  &= d^k_v, & \forall v \in V, k \in K \\
    \sum_{k \in K} f^k_a  &\le \sum_{m \in M}c^m x^m_a, & \forall a \in A   & \quad \texttt{Directed} \refstepcounter{equation}\tag{\theequation a}\\
    \max \left\{\sum_{k \in K} \{f^k_{e+},f^k_{e-}\}  \right\}&\le \sum_{m \in M}c^m x^m_a, & \forall e \in E   & \quad \texttt{Bidirected} \tag{\theequation b}\\
    \sum_{k \in K} (f^k_{e+}+f^k_{e-})&\le \sum_{m \in M}c^m x^m_e, & \forall e \in E   & \quad \texttt{Undirected}  \tag{\theequation c}
 \end{align}
\end{document}

A: You can define a new specialsubequations environment in which the first item is treated specially with the help of \specialequation.
\documentclass{article}
\usepackage{amsmath}
%\usepackage{hyperref} % not mandatory

\usepackage{lipsum} % for mock text, don't load it in your document

\makeatletter
\newcounter{specialsubequations}
\newenvironment{specialsubequations}
 {%
  \stepcounter{specialsubequations}%
  \stepcounter{equation}%
  \let\@currentlabel\theequation
  \label{@@@fake\thespecialsubequations @@@}%
  \subequations
 }
 {\endsubequations}
\@ifpackageloaded{hyperref}{%
  \newcommand{\specialequation}{\tag{\ref*{@@@fake\thespecialsubequations @@@}}}%
}{%
  \newcommand{\specialequation}{\tag{\ref{@@@fake\thespecialsubequations @@@}}}%
}
\makeatother

\begin{document}

\lipsum[1][1-3]
\begin{specialsubequations}
\begin{align}
  \sum_{a \in \delta^+_G(v)} f^k_a -  \sum_{a \in \delta^-_G(v)} f^k_a
  &= d^k_v, & \forall v \in V, k \in K \specialequation\label{1}
  \\
  \sum_{k \in K} f^k_a  &\le \sum_{m \in M}c^m x^m_a,
  & \forall a \in A   & \quad \texttt{Directed}
  \\
  \max \left\{\sum_{k \in K} \{f^k_{e+},f^k_{e-}\}  \right\}
  &\le \sum_{m \in M}c^m x^m_a, & \forall e \in E   & \quad \texttt{Bidirected}
  \\
  \sum_{k \in K} (f^k_{e+}+f^k_{e-})&\le \sum_{m \in M}c^m x^m_e,
  & \forall e \in E   & \quad \texttt{Undirected}
\end{align}
\end{specialsubequations}
\lipsum[2][1-3]

\end{document}

You can add a \label to the special equation; links will work when hyperref is loaded.

However I'd recommend not changing the number.
\documentclass{article}
\usepackage{amsmath}
%\usepackage{hyperref} % not mandatory; use `\ref*` if hyperref is loaded

\usepackage{lipsum} % for mock text

\begin{document}

\lipsum[1][1-3]
\begin{subequations}\label{main}
\begin{align}
  \sum_{a \in \delta^+_G(v)} f^k_a -  \sum_{a \in \delta^-_G(v)} f^k_a
  &= d^k_v, & \forall v \in V, k \in K \tag{\ref{main}}
  \\
  \sum_{k \in K} f^k_a  &\le \sum_{m \in M}c^m x^m_a,
  & \forall a \in A   & \quad \texttt{Directed}
  \\
  \max \left\{\sum_{k \in K} \{f^k_{e+},f^k_{e-}\}  \right\}
  &\le \sum_{m \in M}c^m x^m_a, & \forall e \in E   & \quad \texttt{Bidirected}
  \\
  \sum_{k \in K} (f^k_{e+}+f^k_{e-})&\le \sum_{m \in M}c^m x^m_e,
  & \forall e \in E   & \quad \texttt{Undirected}
\end{align}
\end{subequations}
\lipsum[2][1-3]

\end{document}


text:
Q: How do I create a .desktop file for a .jar file? My problem is, that I do want to create a .desktop file for Technic Launcher, which is an alternative launcher for Minecraft. It comes in the form of a .jar file and I want to create a menu entry for it. How would I write such a .desktop file?
My attempt was the following:
[Desktop Entry]
Type=Application
Name=Technic Launcher
Comment=Minecraft Launcher for Technic Pack, Tekkit, Hack/Mine and Yogbox
Exec=/home/benjamin/Applications/Minecraft/TechnicLauchner/technic-launcher-latest.jar
Icon=/home/benjamin/Applications/Minecraft/TechnicLauchner/icon.png
Terminal=false
Categories=Game;ActionGame;AdventureGame;RolePlaying;

This didn't work, hence my question. What did I do wrong? Is it even possible to point to a .jar file?

A: You just messed up a part of the Desktop file. This is what it should look like (sorry for the thread resurrection):
[Desktop Entry]
Type=Application
Name=Technic Launcher
Comment=Minecraft Launcher for Technic Pack, Tekkit, Hack/Mine and Yogbox
Exec=java -jar /home/benjamin/Applications/Minecraft/TechnicLauchner/technic-launcher-latest.jar
Icon=/home/benjamin/Applications/Minecraft/TechnicLauchner/icon.png
Terminal=false
Categories=Game;ActionGame;AdventureGame;RolePlaying;

Then just type
sudo chmod +x "/home/(username)/Desktop/Technic Launcher.desktop"

A: On a Xubuntu I just gave the the absolute path of the jar file and mad it executable using the chmod +x on jar file.
On the permissions tab just clicked over run file as an program.

Or you may want to associate the .jar extension with the java application.
With Xubuntu you can do this via Configuration manager Dialog and choosing the
System -> MIME Editor by editing the entry at application/java-x-archive to the preferred Java Virtual Machine.

A: You can make it manualy, or using Alacarte. Here's the way:
1: Install Alacarte
It will install some Gnome dependencies. Nothing to worry about.
2: Create a new entry
In the command entry, click browse and select your .jar file.

*

*You may need to add /usr/bin/java -jar  to the start of the Command, so that it looks like /usr/bin/java -jar /home/angel/minecraft.jar.

3: Make the file executable
Go where you have your .jar file. Right click, properties, permissions, check the 'Allow run as a program' option.
4: Look for it in the Dash
There you should have it. Just click and enjoy!

Extra: Here's the icon

A: .jar files are not executable, so you have to open them with something (java):
Exec=java -jar /home/benjamin/Applications/Minecraft/TechnicLauchner/technic-launcher-latest.jar

Anyway, I wouldn't recommend creating those files manually from scratch.


text:
Q: Invertible 4x4 matrix $$
    \begin{pmatrix}
    5 & 6 & 6 & 8 \\
    2 & 2 & 2 & 8 \\
    6 & 6 & 2 & 8 \\
    2 & 3 & 6 & 7 \\
    \end{pmatrix}
$$
Is this matrix invertible? I would like to show that it is invertible but first I should find the det(Matrix) which should not be equal to zero. To find the determinant, maybe the best idea is to use row operations and find an upper triangular of zeroes and then multiply the numbers on the diagonal to get the determinant. I have been doing some row operations and get this:
$$
    \begin{pmatrix}
    5 & 6 & 6 & 8 \\
    0 & -1 & -4 & 1 \\
    0 & 0 & 2 & 6 \\
    -1 & 0 & 0 & -12 \\
    \end{pmatrix}
$$
I just need to get rid of the -1 on the last row. But I am stuck. Thank you for your assistance.

A: A combination of Gaussian elimination and a well-known trick readily gives the answer.
$$\det
    \begin{pmatrix}
    5 & 6 & 6 & 8 \\
    2 & 2 & 2 & 8 \\
    6 & 6 & 2 & 8 \\
    2 & 3 & 6 & 7 \\
    \end{pmatrix}
=\det\begin{pmatrix}
    5 & 6 & 6 & 2 \\
    2 & 2 & 2 & 6 \\
    6 & 6 & 2 & 2 \\
    2 & 3 & 6 & 4 \\
    \end{pmatrix}
=4\det\begin{pmatrix}
    5 & 6 & 6 & 2 \\
    1 & 1 & 1 & 3 \\
    3 & 3 & 1 & 1 \\
    2 & 3 & 6 & 4 \\
    \end{pmatrix}
\\[0.5cm]=4\det\begin{pmatrix}
    5 & 6 & 6 & 2 \\
    1 & 1 & 1 & 3 \\
    2 & 2 & 0 & -2 \\
    2 & 3 & 6 & 4 \\
    \end{pmatrix}=8\det\begin{pmatrix}
    5 & 6 & 6 & 2 \\
    1 & 1 & 1 & 3 \\
    1 & 1 & 0 & -1 \\
    2 & 3 & 6 & 4 \\
    \end{pmatrix}
$$
and the last determinant is an odd integer, hence the original matrix is invertible.
$$ \det\begin{pmatrix}
    5 & 6 & 6 & 2 \\
    1 & 1 & 1 & 3 \\
    1 & 1 & 0 & -1 \\
    2 & 3 & 6 & 4 \\
    \end{pmatrix}\equiv
\det\begin{pmatrix}
    1 & 0 & 0 & 0 \\
    1 & 1 & 1 & 1 \\
    1 & 1 & 0 & 1 \\
    0 & 1 & 0 & 0 \\
    \end{pmatrix}\equiv 1\pmod{2}.$$

A: We have $\det(A)=-8$ and
$$
A^{-1}=\frac{1}{4}\begin{pmatrix} -68 & -36 & 48 & 64\cr
68 & 35& -47 & -64 \cr -16 & -9 & 11 & 16 \cr 4 & 3 & -3 &-4 \end{pmatrix}
$$
Testing $AA^{-1}=I_4$ shows that $A$ is indeed invertible. So the question "Is this matrix invertible?" is answered, but of course there are many ways to obtain this result.

A: Just go on converting to zero the three first elements of the last row. Removing the first one you lose the zeros and second and third position and get nasty fractions instead, but it doesn't matter. Just go on.
Alternatively, you can compute the determinant this way
$$5\begin{vmatrix}-1&-4&1\\0&2&6\\0&0&-12\end{vmatrix}-(-1)\begin{vmatrix}6&6&8\\-1&-4&1\\0&2&6\end{vmatrix}$$

A: Proof only by determinant
We have $$\begin{vmatrix}
    5 & 6 & 6 & 8 \\
    2 & 2 & 2 & 8 \\
    6 & 6 & 2 & 8 \\
    2 & 3 & 6 & 7 \\
    \end{vmatrix}=A-B+C-D$$ where $$A=5\begin{vmatrix}
    2 & 2 & 8 \\
    6 & 2 & 8 \\
    3 & 6 & 7 \\
    \end{vmatrix}=5\left(2\begin{vmatrix}
    2 & 8 \\
    6 & 7 \\
    \end{vmatrix}-2\begin{vmatrix}
    6 & 8 \\
    3 & 7 \\
    \end{vmatrix}+8\begin{vmatrix}
    6 & 2 \\
    3 & 6 \\
    \end{vmatrix}\right)=5(-68-36+240)=680,$$ $$B=6\begin{vmatrix}
    2 & 2 & 8 \\
    6 & 2 & 8 \\
    2 & 6 & 7 \\
    \end{vmatrix}=6\left(2\begin{vmatrix}
    2 & 8 \\
    6 & 7 \\
    \end{vmatrix}-2\begin{vmatrix}
    6 & 8 \\
    2 & 7 \\
    \end{vmatrix}+8\begin{vmatrix}
    6 & 2 \\
    2 & 6 \\
    \end{vmatrix}\right)=6(-68-52+256)=816,$$ $$C=6\begin{vmatrix}
    2 & 2 & 8 \\
    6 & 6 & 8 \\
    2 & 3 & 7 \\
    \end{vmatrix}=6\left(2\begin{vmatrix}
    6 & 8 \\
    3 & 7 \\
    \end{vmatrix}-2\begin{vmatrix}
    6 & 8 \\
    2 & 7 \\
    \end{vmatrix}+8\begin{vmatrix}
    6 & 6 \\
    2 & 3 \\
    \end{vmatrix}\right)=6(36-52+48)=192$$ and $$D=8\begin{vmatrix}
    2 & 2 & 2 \\
    6 & 6 & 2 \\
    2 & 3 & 6 \\
    \end{vmatrix}=8\left(2\begin{vmatrix}
    6 & 2 \\
    3 & 6 \\
    \end{vmatrix}-2\begin{vmatrix}
    6 & 2 \\
    2 & 6 \\
    \end{vmatrix}+2\begin{vmatrix}
    6 & 6 \\
    2 & 3 \\
    \end{vmatrix}\right)=8(60-64+12)=64$$ Thus $$\begin{vmatrix}
    5 & 6 & 6 & 8 \\
    2 & 2 & 2 & 8 \\
    6 & 6 & 2 & 8 \\
    2 & 3 & 6 & 7 \\
    \end{vmatrix}=680-816+192-64=-8\neq0$$ so your matrix has an inverse.

A: You may find interesting to use Hamilton-Caley Formula, for $4x4$ matrices:
$$\text{det}\mathsf{A} = \frac{1}{24}\left\{(\text{tr}\mathsf{A}^4 - 6\text{tr}(\mathsf{A}^2)(\text{tr}\mathsf{A})^2 + 3(\text{tr}\mathsf{A})^2 + 8\text{tr}(\mathsf{A}^3)\text{tr}\mathsf{A} - 6\text{tr}(\mathsf{A}^4)\right\}$$


text:
Q: web submission automation: simulate onclick event on a title element to load form A resume-service I use requires that for each listed activity on the resume, there is an hours-per-week field and total hours field. However, the total hours field does not update itself automatically no matter how many weeks pass. My goal is to write a script that does this.
The idea behind the script is:
Log in to website -> go to a certain page -> submit a form** on that page updating the total hours
**unfortunately, for the form to open, you need to click an "edit" title element first which causes it to show up. I've taken a look at the html of the webpage but cannot find the form or input tags corresponding to the form I wish to submit, only that the form is generated with what I think is a javascript function call from the element's onclick field.
I believe the relevant html snippet is:
Edit

but just in case there is a much larger code snippet later in this post (check the 2nd pastebin link at the bottom)
THE QUESTION: Is there a specific language/library/way (preferably in python, although I can work with Java) to simulate an onclick event and that would result in a form loading?
I've worked on this problem a bit, starting with python's mechanize library. I wrote two functions,
def login(br,url):...
def navigate(br,baseurl,url):...

which would satisfy the first two parts of my script's plan, but the third is where the trouble starts. When I print all the forms on the page using
for form in br.forms():
    print form

I get http://pastebin.com/Gxy2tc1A
The website's html can be found on http://pastebin.com/PySri5cb
Later I tried to work with Selenium (the firefox IDE plugin) and then exporting code into python, where I would edit it to satisfy my specific needs, but that was a no-go either due to some awkward errors.

A: Have you looked into GreaseMonkey? You should be able to use that to extract the hours per week, do the math and populate the total hours field. You could probably do the entire thing. Anything that can be done on the page in JavaScript could be done within GreaseMonkey.
EDIT: The code for that site is awful. I especially like the inline call to loadResume() that is made BEFORE the element it writes to (#build-wrap).


text:
Q: Looking for a proper solution for a case which requires: Service, Timer, GPS, Notification, Activity In my Android application I have this scenario:
An activity starts a service.
The service needs to run in foreground.
That's why I've created a notification.
When the service starts, will start a GPS class.
At each second, the service will retrieve data from the GPS class and update the notification text. And also broadcast to the activity that data.
To check at every second, I need a task repeater.
The current code fails probably because of the performance.
The last message I got was !!! FAILED BINDER TRANSACTION !!!
This service can work up to 5-8 hours.
Most of the time the app fails after 15-40 minutes, so is quite slow to debug it.
Is there any proper solution for this case?

A: The story is long, but I'll try to simplify the answer.
Just for future reading.
I solved the problem.
I've used a simple Service, a foreground sticky Notification, a Handler, a BroadcastReceiver, a TimerTask, and of course a GPS class.
The issue I had was caused by the fact that the service was updating the notification every second and the app was using too many resources for that.


text:
Q: Copy function not working i am trying to copy a image from one folder to another folder but m getting now where with it
  if (!file_exists("user/$username"))
    {
      mkdir("user/$username",0755); //making a directory

      $srcfile="/user/display_pic.jpg";
     $dstfile="/user/$username/display_pic.jpg";

      copy($srcfile, $dstfile);
    }

so there is a picture located inside the folder named user and i am trying to copy that picture inside the folder $username (i.e the directory that is been created) the folder  $username is located inside /user/$username' and the folderuser is located inside /user/

A: i was able to fix this
$srcfile="user/display_pic.jpg";
$dstfile="user/$username/display_pic.jpg";
copy($srcfile, $dstfile);

my error was that i was using the / in the start