text:
Q: Android listview from json array I am new to android and am trying to populate a list view.
When I use the array 'months' the list populates correctly, however when i try to use the 'myFamily' the list is empty.
Why could that be?
The myFamily array is as follows:

[FREE Baby Guinness Shot, 2-4-1 Cocktails , Wine of the Week £21, Unlimited Coffee £5, Single Vodka Redbull £5, Buy One Get One Free (12pm-8pm)]

Full Code:
public class offers extends AppCompatActivity {

    private String jsonResponse;

    private String[] months = { "JAN", "FEB", "MAR", "APR", "MAY", "JUNE", "JULY",
            "AUG", "SEPT", "OCT", "NOV", "DEC" };

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

        final String PREFS_NAME = "userDefaults";
        final ListView myListView = (ListView) findViewById(R.id.listViewOffers);

        SharedPreferences settings_get = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        final String smartCode2 = settings_get.getString("smartCode2", "");

        final ArrayList<String> myFamily = new ArrayList<>();

        RequestQueue queue = Volley.newRequestQueue(offers.this);
        String url = "http://www.barfibrenetwork.co.uk/backend/androidoffers.php?smartcode="+smartCode2;
// Request a string response from the provided URL.

        JsonArrayRequest req = new JsonArrayRequest(url,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                       // Log.d(TAG, response.toString());

                        try {
                            // Parsing json array response
                            // loop through each json object
                            jsonResponse = "";
                            for (int i = 0; i < response.length(); i++) {

                                JSONObject person = (JSONObject) response
                                        .get(i);

                                String name = person.getString("offertitle");

                                Log.i("OFFERTITLE:", name);
                               myFamily.add(name);
                            }

                            Log.i("REPLY:", String.valueOf(myFamily));

                        } catch (JSONException e) {
                            e.printStackTrace();
                            Toast.makeText(getApplicationContext(),
                                    "Error: " + e.getMessage(),
                                    Toast.LENGTH_LONG).show();
                        }

                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.i("Error: ", error.getMessage());
                Toast.makeText(getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_SHORT).show();

            }
        });

// Add the request to the RequestQueue.

        queue.add(req);

        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,
                android.R.layout.activity_list_item, android.R.id.text1, myFamily );

        myListView.setAdapter(arrayAdapter);

    }

A: It's JSON format example
{["example string", "example string 2"]}
You should have similar JSON format. Dont forget shielding special symbols


text:
Q: Renaming downloaded webpages from Chrome without affecting styling, images, etc When I download a webpage with Chrome I am given an HTML file and a folder of files associated with the webpage, which includes styling, images, etc. When I rename the HTML file, the webpage no longer works with styling and images gone. This happens even if I rename the corresponding folder with the exact same name. How can I avoid this issue?

A: You have to edit the downloaded HTML file. It contains "hardcoded" paths to resources in the associated directory. If the directory is renamed, these paths have to be updated accordingly.
HTML files are text files. The Find and replace feature in any competent text editor should do the trick. (Notepad isn't necessarily a competent text editor.)

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to split up a JSON document? I have a JSON file that includes many documents. Each document is data from one Purchase Order. I get file from a web service on a cloud purchase order system. I need to load each of these documents into a separate record in an Oracle database. I have done this for other files of JSON documents using Oracle's external table feature, and it has worked. However, the other files had a crlf between each JSON document.  The file I get from the web service is one document with many POs, with no crlf between the purchase orders.
I found the Q&A here: How to split json into multiple files per document. The code shown as the solution is
import json
in_file_path='path/to/file.json' # Change me!
with open(in_file_path,'r') as in_json_file:
    # Read the file and convert it to a dictionary
    json_obj_list = json.load(in_json_file)
    for json_obj in json_obj_list:
        filename=json_obj['_id']+'.json'
        with open(filename, 'w') as out_json_file:
            # Save each obj to their respective filepath
            # with pretty formatting thanks to `indent=4`
            json.dump(json_obj, out_json_file, indent=4)

but when I try the solution, I get an error as below:
[oracle@localhost gk]$ python36 split.py
Traceback (most recent call last):
  File "split.py", line 11, in <module>
    filename=json_obj['_id']+'.json'
TypeError: string indices must be integers

My JSON file looks like:
{
    "data": [
        {
            "number": "PB510698",
            "uuid": "9cc06f21c1194038b137cec51b02606b"
        },

        etc ...

    ]
}

with multiple docs (sub docs?) that start with {"number":"PB510698","uuid"
Any ideas why the code from the other post is not working?

A: I think this will do what you want. The json_obj_list returned form json.load() is actually a Python dictionary, so you need it iterate the values in json_obj_list['data']. To keep the code sensible with respect to existing variable name(s), I modified it to just retrieve the JSON object list directly from the dictionary returned from json.load() like this:
json_obj_list = json.load(in_json_file)['data']

Here's the complete code:
import json

in_file_path = 'testfile.json'

with open(in_file_path,'r') as in_json_file:

    # Read the file and get the list from the dictionary.
    json_obj_list = json.load(in_json_file)['data']

    for json_obj in json_obj_list:
        filename = json_obj['number']+'.json'  # Changed this, too, per comment by OP.
        print('creating file:', filename)
        with open(filename, 'w') as out_json_file:
            # Save each obj to their respective filepath
            # with pretty formatting thanks to `indent=4`
            json.dump(json_obj, out_json_file, indent=4)


text:
Q: Does the concatenation of two text files, which compile under tex, always compile under tex? In other words, does the set of all text files that compile under tex form a monoid under concatenation?
I have recently dabbled a bit in plain tex and my algebraic spider senses were immediately tingling. I thought I'd google the answer with ease, but so far I have found nothing.

A: First, a plain tex file ends by \bye (and a latex file ends by \end{document}), and everything after this is ignored.  So your statement is trivially correct, since the second file is ignored after concatenation.
If we consider \bye to be a "metacommand", dropped in a concatenation, then your statement is incorrect.
Consider the files
\def\aa{0}
\aa
\bye

and
\def\bb{0}
\bb
\ifx\aa\bb\cc\fi
\bye

Each of them compiles, but the concatenation does not:
\def\aa{0}
\aa
\def\bb{0}
\bb
\ifx\aa\bb\cc\fi
\bye

produces
! Undefined control sequence.
l.5 \ifx\aa\bb\cc
                 \fi
?
! Emergency stop.

The reason is, undefined \aa is undefined in the second file, but is the same as \bb in the concatenated one.

A: In plain TeX a properly formatted file will end in \bye to tell the compiler to stop looking for input.  Therefore the concatenation will only compile the first file then the rest is ignored.. (So no.)  In LaTeX, a compilable file will end in \end{document} again to tell the compiler it is done. So only the first file in the concatenation will compile and the rest is ignored.  Plus the second file will have a preamble now in an location which would cast a compiling error if i was seen. (So no.)
Not discussed are additional impacts of packages, fonts, inputted file, etc.


text:
Q: OpenLDAP - possible to search without specifying base? I am having some issues with OpenLDAP and Spring security, where the latter does a search with the whole path in dn (filter), and an empty base. OpenLDAP does not like this, and the query fails. The problem is that I have no control over the query, so I am thus wondering if it is possible to configure OpenLDAP to allow such queries.

A: An empty base is a special case for retrieving information about the OpenLDAP server that can host several databases (or "namingContexts" or "bases"). E.g.:
ldapsearch -x -LLL -b '' -s base 'objectClass=*' +

There really should be some way of specifying the base to use for searches

A: It's unfortunate that Spring Security won't allow you to set an appropriate search base. Depending on your environment you may be able to get away with setting a default search base to the frontend config.
$ ldapmodify -f <<EOF
dn: olcDatabase={-1}frontend,cn=config
add: olcDefaultSearchBase
olcDefaultSearchBase: dc=example,dc=com


text:
Q: How to set a semi transparent "picture/image" into black and white, without affecting child elements and background color? I know that some say that you should use background rgba(0, 0, 0, 0.5); like that, but that is only for color, not pictures and it also does not remake the picture into black and white.
I am asking for background picture transparency and black and white transformation and I know I could use for example opacity: 0.5; for picture background, but that also makes the text withing the box transparent too and it does not make it black and white either.
I only want the background picture of the div box to be semi transparent and transform into black and white at the same time, maybe it is two different codes for it.
I know of the solution that I could use 2 div boxes inside each other were one has the semi transparent background and another the text that way not effecting the opacity of one box to the other, but I wonder if there is a solution to only use one div box for both background and text without effecting the text when using semi transparency plus color or opacity on the background image.
For example if there was something similar to like:
background-opacity: 0.5;

or
background-image-opacity: 0.5;

Although I know that does not exist in CSS, so some solution to that please?
UPDATE: My CSS used now:
#LinksLayer1
        { position:absolute; left:0px; top:-8px; width:100%; height:100%; z-index:3; }

.TDOnLinks
        { font: 12px Arial, Helvetica, sans-serif; }

.TDLinks
        { background-Color: #EEF4FD; background-repeat: repeat; background-attachment: fixed; background-position: center center; background-image:url('../Pictures/2/P_13.jpg'); }

Works well as #LinksLayer1 is one box (the outer box) that contains .TDOnLinks tables and fonts for it, then the .TDLinks table is with the background. But as you understand and I know, it does not give a transparent background.
Simplified my HTML and JavaScript code:

<form method="Post" action="" name="SeekLoadLink">

Blablabla Head Text

    **,A,B,C,D,E,F,G
    H,I,J,K,L,M,N,O
    P,Q,R,S,T,U,V,W,X,X,Y,Z

Blablabla **,A,B,C,D,E,F,G

Blablabla H,I,J,K,L,M,N,O

Blablabla LINK  <a href="https://www.youtube.com" target="_blank" onmouseover="this.style.backgroundColor='#FFFF00'; javascript: fillitin('6 − points','YouTube.com','https://www.youtube.com','Pros & Cons: \n + Has most videos on the net \n − Little money after 1000 visits \n − Has too many bad rules.','Gives you very little money for sharing your videos. \nSince January 2018, it only gives money if you have over 1000 visitors per 30 days. \nThey also sometime block and delete videos based on fake copyright claims if you have something society contradicting on the video. Censorship is common.');" onmouseout="this.style.backgroundColor='';"> YouTube.com

<nobr><input type="text" name="sitepoints" size="10" class="TEXTLinkPonits" maxlength="255" text value="Ranking" contenteditable="false"><input type="text" name="sitename" size="30" class="TEXTLinkName" maxlength="255" text value="Name" contenteditable="false">URL:<input type="text" name="Dest" class="TEXTLinkPage" size="49" maxlength="255" value="Address" contenteditable="false"></nobr>

<Textarea class="TEXTLinkExtraInfo" name="siteextrinfo" cols="28" rows="4" contenteditable="false">

Extra
Inforomation and Pros / Cons
</Textarea>

<Textarea class="TEXTLinkInfo" name="sitepage" cols="87" rows="4" contenteditable="false">

Page Resume, Information and Comments...
</Textarea>

</form>

NOTE: I need no font codes for the text in the box, as the box uses the font body CSS already working well. The box only has CSS for background and nothing else. Not even size as the size is regulated by other CSS codes that work. I only need to effect the background in the box, nothing else.
I tried this:
div.TDLinks:after
        { background-repeat: repeat; background-attachment: fixed; background-position: center center; background-image:url('../Pictures/2/P_13.jpg'); opacity : 0.5; position: absolute; z-index: -1; }

and
.TDLinks:after
        { background-repeat: repeat; background-attachment: fixed; background-position: center center; background-image:url('../Pictures/2/P_13.jpg'); opacity : 0.5; position: absolute; z-index: -1; }

But it did not work, what did I do wrong? Could my JavaScript be blocking it?
NOTE: I know there are others with similar questions and answers, but it is only similar and not the same question, because nobody has asked of having only one box for this solution with picture background, all the other solutions can be solved by having two div boxes, but I need it all with one div box without effecting the text in that box or they ask of color background and that is a totally different thing.
NOTE:
This is not a repeat question of this "Set opacity of background image without affecting child elements" because that asks of transparent background color, I ask of transparent background PICTURE or IMAGE. Look at the question and its codes plz..
This question does not repeat this one:
Set opacity of background image without affecting child elements

A: Yes, you can use a pseudo element:

div.bg {
  width: 200px;
  height: 200px;
  display: block;
  position: relative;
  text-align:center;
  font-size:20px;
  font-weight:bold;
  text-transform:uppercase;
}

div.bg:after {
  content: "";
  background: url('https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png?v=9c558ec15d8a');
  opacity: 0.5;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  position: absolute;
  z-index: -1;
}

text here


text:
Q: My shift/ctrl and numlock keys stopped working My ctrl and right-shift keys are not responding, though they still work in a VMware window. Numlock doesn't work.  A held-down key does not repeat.  clicking in a field in another window does not make that window active.
Can I clear whatever's making it sick without rebooting?
It started (approximately?) when my full-screen VMWare workstation instance on Desktop 2 was missing and found as a small window on Desktop 4. It moved by itself or I accidentally entered a strange command while working on Desktop 1?

Linux Mint 17.1 Rebeca, standard Cinnamon desktop.

A: I found the answer on this blog post.
First
egrep -i 'rules|layout|model' /var/log/Xorg.0.log

to note the values of interest, and then (in my case)
setxkbmap -rules evdev -layout us -model pc105

to restore them.  If the keyboard/X-console is too hosed to use at all, the original poster used SSH from another machine and prepended DISPLAY=:0 (Though I'm not sure where that goes).  Another commenter plugged in another USB keyboard temporarily.
The blog poster indicates that VMWare is to blame, which makes sense since that's what I'm using too.  Another commenter noted that he has the problem with VNC.
I put this line in an executable file on the desktop, for future need.  I'm assuming that the values don't change unless my hardware changes.


text:
Q: Relative import between main and test files python I have a project with the current structure
src/
  main.py
  frames/
    __init__.py
    base_frame.py
    control_frame.py

This is how my __init__.py file looks like:
from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))

ignore = ['__init__.py']
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not basename(f) in ignore]

My baseframe.py includes a couple of @abstractmethod that needs to be included by my other frames. How I'm currently including my baseframe to the other frames is by doing from frames.base_frame import BaseFrame. This works perfect when including from main.py
Now I want to write a couple of tests and I don't want to have these cluttering the src folder, so I would either want them like
src/
  frames/
  tests/
    test.py

or
src/
  frames/
  ...
tests/
  test.py

but from here I can't really import frames. It just throws ModuleNotFoundError: No module named 'frames'
How can I make my frames module available to other directories?


text:
Q: I messed with my registry, now I need to change it back I was trying to change which programs opened and edited my batch files in Windows 7.  Now I want to change it all back to default, but my computer hasn't made any restore points.
Can someone tell me the registry keys/values for:
HKEY_CLASSES_ROOT\batfile\shell\edit\command
HKEY_CLASSES_ROOT\batfile\shell\open\command

A: Ouch. When tinkering with the registry I'd always back it up first.
However, these are the two entires on my laptop, Windows 7 Professional, 32-Bit.

A: Backup the registry key beofre changing. as there is no restore point. The backed up key can usually be easliy recovered unless the change "bricks' the system
As noted by @tombull89, the keys shown are what I have as well.

A: Here are the entire contents of the HKEY_CLASSES_ROOT\batfile key. Copy-and-Paste to a text file and save as a .REG.
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\batfile]
@="Windows Batch File"
"EditFlags"=hex:30,04,00,00
"FriendlyTypeName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,\
  00,6f,00,6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
  32,00,5c,00,61,00,63,00,70,00,70,00,61,00,67,00,65,00,2e,00,64,00,6c,00,6c,\
  00,2c,00,2d,00,36,00,30,00,30,00,32,00,00,00

[HKEY_CLASSES_ROOT\batfile\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,69,00,6d,00,\
  61,00,67,00,65,00,72,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,36,\
  00,38,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell]

[HKEY_CLASSES_ROOT\batfile\shell\edit]

[HKEY_CLASSES_ROOT\batfile\shell\edit\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
  54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,25,00,31,00,00,\
  00

[HKEY_CLASSES_ROOT\batfile\shell\open]
"EditFlags"=hex:00,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"

[HKEY_CLASSES_ROOT\batfile\shell\print]

[HKEY_CLASSES_ROOT\batfile\shell\print\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
  54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,2f,00,70,00,20,\
  00,25,00,31,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\runas]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\batfile\shell\runas\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6d,00,\
  64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,43,00,20,00,22,00,25,00,31,00,22,\
  00,20,00,25,00,2a,00,00,00

[HKEY_CLASSES_ROOT\batfile\shell\runasuser]
@="@shell32.dll,-50944"
"Extended"=""
"SuppressionPolicyEx"="{F211AA05-D4DF-4370-A2A0-9F19C09756A7}"

[HKEY_CLASSES_ROOT\batfile\shell\runasuser\command]
"DelegateExecute"="{ea72d00e-4960-42fa-ba92-7792a7944c1d}"

[HKEY_CLASSES_ROOT\batfile\ShellEx]

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers]
@="Compatibility"

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers\Compatibility]
@="{1d27f844-3a1f-4410-85ac-14651078412d}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers\OpenGLShExt]
@="{E97DEC16-A50D-49bb-AE24-CF682282E08D}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\PropertySheetHandlers]

[HKEY_CLASSES_ROOT\batfile\ShellEx\PropertySheetHandlers\ShimLayer Property Page]
@="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}"

[HKEY_CLASSES_ROOT\batfile\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"


text:
Q: IPhone App Inside App I have an old post Re-Installing IPhone App From Inside The App
That old post was not so successful in getting what I wanted but now then I though more deeply and came to a conclusion to ask another question. I need to first describe my idea then you tell me if it's possible or not.
Say I have an IPhone app which downloads XCode compiled project from the internet in the phone memory. The compiled binary (not sure if it's really binary) can be opened and if I can read objects and members from the file via reflection, can I show UIView in my app? I mean UIViews is stored in the compiled file and can I extract those views with their functionality as objects to show them in my app as instance of them?
Sounds unrealistic? please do think again as it took me more than 20 hours to find this against my old post.

A: This would never be allowed to happen.

A: See this document.
Specifically:

The creation and use of loadable
  bundles is not supported in iOS.

That includes dynamically loading code of any kind.

A: There is absolutely no way to do this, as was indicated in the answers to your last question. As well, it's unnecessary, your other question has many alternatives that would work perfectly.
If you want to show data, simply download it from the server as text or images, then implement a templating system to present it how you want

A: I've seen people attempting to do this in order to be able to install cracked versions of commercial apps... but... most apps cost CENTS. Do you reaaaally need to pirate them? If you bought the phone then you can surely buy a couple bucks worth of apps! (ok, I'm not saying the OP is in this situation but the post does sound fishy)

A: Stock iOS sandboxes executable code.  There is no way to call or jump into any code that is downloaded.  You can't directly use any downloaded member functions at all.  The sandbox will kill an app if it even tries to do this.
Even if you could decompile methods and functions inside an unencrypted iOS executable, an app would not be allowed to interpret those decompiled results (unless maybe perhaps you could figure out how to decompile some ARM binary function completely into Javascript suitable for running in a UIWebView, and do all that conversion offline).
However, you could use the data from a downloaded app (extracted images, sounds, plists, perhaps even object data extracted from xibs), to modify the current running app.  Apple has a WWDC 2010 video on data driven apps that explains some of how to do this.


text:
Q: How to disable the little touch-keyboard on Windows edit controls In a windows version with tablet support, a small keyboard icon appears when an edit control gets focus. If you touch it the touch keyboard pops up.
Is there a way to disable this? It's rather inconvenient if you have your own touch keyboard.
I want to disable it for certain edit controls in code, ie. I'm not looking for a Windows setting.
Giel

A: Well, I guess a late answer is better than no answer, so here it comes:
You can disable the Windows onscreen-keyboard for your application.
To do so, start Regedit and navigate to the Key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TabletTIP\DisableInPlace]. There you create a new String Value, set its name to the full application Path (e.g. "C:\Progam Files\My App\MyApp.exe") and set its value to "1".
Edit: Recently I had to rethink my solution... By setting the Registry value, you disable the onscreen-keyboard for the whole application. But should you need a keyboard for some seldom used function of your program and just happend to forget including an onscreen-keyboard, you have to control the Windows TextInputPanel via SDK / API. See this link: Disabling the Input Panel Programmatically.
Use the PenInputPanel for handwriting and the TextInputPanel for an onscreen-keyboard.
For all those Delphi programmers out there: import the Type Library "Microsoft PenInputPanel" and FIX A BUG in the imported *_TLB.pas: change the parameter type of the two methods of IPenInputPanel:
function Get_AttachedEditWindow: SYSINT; safecall;
procedure Set_AttachedEditWindow(AttachedEditWindow: SYSINT); safecall;

A: Disable the "Touch Keyboard and Handwriting Panel Service"


text:
Q: Rewriting Pandas script using Python3 standard library Here's the script written in Pandas which I have to rewrite using the standard library:
import pandas as pd
import sys

if __name__ == '__main__':
    if len(sys.argv) != 1 :
        print('usage: python by_continent.py')
        sys.exit(1)

    gap = pd.read_csv('gapminder.tsv', sep='\t')
    means = gap.groupby('continent').mean()
    parts = means[['lifeExp', 'gdpPercap']]
    print( parts )

Input looks like:
country continent   year    lifeExp pop gdpPercap
Zambia  Africa  2002    39.193  10595811    1071.613938
Zambia  Africa  2007    42.384  11746035    1271.211593
Zimbabwe    Africa  1952    48.451  3080907 406.8841148
Zimbabwe    Africa  1957    50.469  3646340 518.7642681
Zimbabwe    Africa  1962    52.358  4277736 527.2721818
Zimbabwe    Africa  1967    53.995  4995432 569.7950712
Zimbabwe    Africa  1972    55.635  5861135 799.3621758
Zimbabwe    Africa  1977    57.674  6642107 685.5876821
Zimbabwe    Africa  1982    60.363  7636524 788.8550411
Zimbabwe    Africa  1987    62.351  9216418 706.1573059
Zimbabwe    Africa  1992    60.377  10704340    693.4207856
Zimbabwe    Africa  1997    46.809  11404948    792.4499603
Zimbabwe    Africa  2002    39.989  11926563    672.0386227
Zimbabwe    Africa  2007    43.487  12311143    469.7092981
Argentina   Americas    1952    62.485  17876956    5911.315053
Argentina   Americas    1957    64.399  19610538    6856.856212
Argentina   Americas    1962    65.142  21283783    7133.166023
Argentina   Americas    1967    65.634  22934225    8052.953021
Argentina   Americas    1972    67.065  24779799    9443.038526
Argentina   Americas    1977    68.481  26983828    10079.02674

Here's what the output should be:
             lifeExp     gdpPercap
continent
Africa     48.865330   2193.754578
Americas   64.658737   7136.110356
Asia       60.064903   7902.150428
Europe     71.903686  14469.475533
Oceania    74.326208  18621.609223

I'm stuck. I can get as far as parsing the code with the csv module but can't get much further. Here's my code:
import sys
import csv

with open('gapminder.tsv', 'r') as gap:
    csv_reader = csv.reader(gap, delimiter="\t")
    lst = list(csv_reader)

    for row in lst:
        if row [1] == 'Africa':
            pop = []
            pop.append(row[4])

A: For the groupby you could just use a dictionary which you fill the keys with programmatically and the values start null and end with a list of 3-tuples; it'd have the column name, the type of calculation and the value that you should be returning for the given combination.
There may be prettier and more elegant ways but this should work.
Edit: wait no they'd be 2-tuples since you've already specified the column (I meant continent) name.  I think I'm still half asleep.
You could also just make an n-dimensional list (matrix) that holds all the relevant values.  That'd be the sensible way to do it.

A: The below should get you started (forgive the lazy variable naming).  The main idea is to leverage the existing groupby from itertools to aggregate by whatever field you want, and then from those groupings pull out the relevant field you want to average by collecting the results into a dictionary.
P.S. - hopefully this isn't your homework, because that's just lazy :)
stuff = """country continent   year    lifeExp pop gdpPercap
Zambia  Africa  2002    39.193  10595811    1071.613938
Zambia  Africa  2007    42.384  11746035    1271.211593
Zimbabwe    Africa  1952    48.451  3080907 406.8841148
Zimbabwe    Africa  1957    50.469  3646340 518.7642681
Zimbabwe    Africa  1962    52.358  4277736 527.2721818
Zimbabwe    Africa  1967    53.995  4995432 569.7950712
Zimbabwe    Africa  1972    55.635  5861135 799.3621758
Zimbabwe    Africa  1977    57.674  6642107 685.5876821
Zimbabwe    Africa  1982    60.363  7636524 788.8550411
Zimbabwe    Africa  1987    62.351  9216418 706.1573059
Zimbabwe    Africa  1992    60.377  10704340    693.4207856
Zimbabwe    Africa  1997    46.809  11404948    792.4499603
Zimbabwe    Africa  2002    39.989  11926563    672.0386227
Zimbabwe    Africa  2007    43.487  12311143    469.7092981
Argentina   Americas    1952    62.485  17876956    5911.315053
Argentina   Americas    1957    64.399  19610538    6856.856212
Argentina   Americas    1962    65.142  21283783    7133.166023
Argentina   Americas    1967    65.634  22934225    8052.953021
Argentina   Americas    1972    67.065  24779799    9443.038526
Argentina   Americas    1977    68.481  26983828    10079.02674""".strip().splitlines()

import itertools
from collections import defaultdict

stuff = [line.split() for line in stuff]
headers, *records = stuff
labeled_records = [dict(zip(headers,line)) for line in records]

#group by continent
grouped = itertools.groupby(labeled_records,lambda x: x['continent'])
results = defaultdict(list)

# for other categories, just change 'lifeExp' to the column you want
for k,v in grouped:
    for d in v:
        results[k].append(float(d['lifeExp']))

# average collected results
for k,v in results.items():
    print(k,'\t',sum(v)/len(v))

A: I don't want to spoil the fun of calculating the solutions but you could convert this to a a list of dictionaries and that would make the data easier to manage. To do so, you need to split all the sublists, the we to zip each sublist with its own list from row 1 those will be our keys, then we can zip those sublist with the keys. After that we use a dict() constructor to create our list of dictionaries.
With this you can do things like for i in res: print(i['country'] etc etc, pull dictionaries from the list that only are of a certain country and so forth.
import csv
import pprint

with open('gapminder.tsv', 'r') as gap:
    csv_reader = csv.reader(gap, delimiter="\t")
    lst = list(csv_reader)

lst = [i[0].split() for i in lst]
prep = zip([lst[0]]*len(lst[1:]), lst[1:])
prep = [(zip(i[0], i[1])) for i in prep]
res = [dict([j for j in i]) for i in prep]
pprint.pprint(res)

[{'continent': 'Africa',
  'country': 'Zambia',
  'gdpPercap': '1071.613938',
  'lifeExp': '39.193',
  'pop': '10595811',
  'year': '2002'},
 {'continent': 'Africa',
  'country': 'Zambia',
  'gdpPercap': '1271.211593',
  'lifeExp': '42.384',
  'pop': '11746035',
  'year': '2007'},
...


text:
Q: Multiple using of % pattern within the same target rule in Makefile Let's say there are a number of rules like this:
prefix/FOO/FOO_suffix/FOO.txt: prefix/FOO/FOO_input.txt
    echo @<
prefix/BAR/BAR_suffix/BAR.txt: prefix/BAR/BAR_input.txt
    echo @<

Instead of that I would like to have a single implicit rule like:
prefix/%/%_suffix/%.txt: prefix/%/%_input.txt
    echo @*

(So, the % represents the same <word>)
Is it possible to achieve that without using foreach/eval/call/define functions and generating explicit rules for each <word>?

A: GNU make's secondary expansion can sometimes be used instead of foreach-eval-call:
.SECONDEXPANSION:

prefix/%.txt: prefix/$$(notdir $$*)/$$(notdir $$*)_input.txt
    @echo '$<'

Demo:
$ make prefix/FOO/FOO_suffix/FOO.txt prefix/BAR/BAR_suffix/BAR.txt
prefix/FOO/FOO_input.txt
prefix/BAR/BAR_input.txt

But if the reason you do not want to use foreach-eval-call is that you find the double expansion difficult to understand and maintain, secondary expansion is maybe not that simpler. Compare:
MY_MACRO = prefix/$1/$1_suffix/$1.txt: prefix/$1/$1_input.txt

$(foreach t,FOO BAR,$(eval $(call MY_MACRO,$t)))

%.txt:
    @echo '$<'

See? Not even a single define or $$...


text:
Q: How do I locate the angularjs error: unknown provider in a minified script? I get an error in console
Uncaught Error: [$injector:unpr] Unknown provider: aProvider <- a <- $httpBackend <- $http <- $compile
http://errors.angularjs.org/1.2.16/$injector/unpr?p0=aProvider%20%3C-%20a%20%3C-%20%24httpBackend%20%3C-%20%24http%20%3C-%20%24compile

The script file is generated by grunt task ngmin followed by uglify
I can understand it could be caused by an incorrect minification. The questions is how do I find out which line in which file is not minified correctly?

A: If you don't uglify file, Haven't the same error?
If you have the error, make sure the dependency is defined and spelled correctly.
Else, you could to download and use the angular minified from the web https://angularjs.org/
or you could use bower to download and specific version, all of them include the minified file.


text:
Q: How can I search and replace by post type? I am trying to use WP-CLI to do a search and replace on about 10,000 posts that were imported from another CMS and it has a great deal of old inline styles and spans and such. I would like to be able to use the search and replace function to remove a lot of chaff using regex. I have no issue creating the regex or limiting my command to just the content column in the wp_posts table, but I do not see a built in way way to limit my post_type to only post, not page or others that are in the wp_posts table. Is there one?
Here is a code example:
wp search-replace '<span^.*>' '' --regex wp_posts --include-columns=post_content


text:
Q: Dealing with C# and VB.net Projects in same solution I am in a c# project, in this project I reference (using a project reference) another class library written in vb.net.
Now, when I right click and view definition on the class. It doesn't take me to the exact source code in the vb.net project, instead it takes me to a dynamically generated c# representation of the vb.net class.
I've tried the experiment in reverse, starting with a vb.net project, and referencing a c# project, this time on a right click view definition, it takes me to the code explorer, so again, not the original code for editing.
If both projects are the same language, everything works like nicely.
Is there an explanation for this? And possibly a solution to allow easy code navigation between projects of different languages?
To reproduce:

*

*Create a blank solution

*Add a c# class library

*Add a vb.net class library

*In the vb.net class library, class1 - create any old method. (optional)

*In the c# class, add a reference to the vb.net class, for example:
VBClassLibrary.VBClass myVBClass = new VBClassLibrary.VBClass();
Now, right click on VBCLass and select "Go To Definition".
Notice where you end up....

A: There is nothing you are doing wrong here.  This is an unfortunte side effect of how Visual Studio is designed.  When you have two projects in different languages a reference between them does not behave like a project reference but instead resembles a file reference.
Project to Project references of the same language share a single language service.  Hence it is in control of all of it's code and can provide special live content benefits.  The primary one being the goto definition and instant intellisense.  There is just no facility in Visual Studio today to allow language services to communicate with each other across the reference boundary like you desire.

A: For "goto definiton" you can use instead "navigate to" (ctrl + commma)


text:
Q: linux hw_breakpoint does not work while accessing memory from userspace I am debugging a ARMv7 board and I want to know whether a kernel symbol is accessed. So I have to use hw_breakpoint in kernel.
For simplicity, I use kernel sample code:data_breakpoint to test, which locates in samples/hw_breakpoint/data_breakpoint.c.
Then I did the following operation:
insmod data_breakpoint.ko ksym=max
cat /proc/kallsyms | grep max
./read_kmem c06fa128

But this did not trigger the callback function.
If I print the value in that address in any kernel module, callback function will be triggered.
I read the cpu manual and it says that the breakpoint register in my cpu support virtual address matching. But I don't know why it doesn't work while accessing memory from userspace. I think that program does read the right value of kernel symbol.
read_kmem.c
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>

#define DEVKMEM         "/dev/kmem"

#define PAGE_SIZE       0x1000
#define PAGE_MASK       (~(PAGE_SIZE-1))

int main(int argc, char* argv[])
{
    int fd;
    char *mbase;
    char read_buf[10];
    unsigned int varAddr;

    varAddr = strtoul(argv[1], 0, 16);

    unsigned int ptr = varAddr & ~(PAGE_MASK);

    fd = open(DEVKMEM, O_RDONLY);
    if (fd == -1) {
        perror("open");
        exit(-1);
    }

    mbase = mmap(0,PAGE_SIZE,PROT_READ,MAP_SHARED,fd, (varAddr & PAGE_MASK));
    if (mbase == MAP_FAILED) {
        printf("map failed %s\n",strerror(errno));
    }

    printf("varAddr = 0x%X \n", varAddr);
    printf("mapbase = 0x%X \n", (unsigned int)mbase);
    printf("value   = 0x%X \n",*(unsigned int*)(mbase+ptr));

    close(fd);
    munmap(mbase,PAGE_SIZE);

    return 0;
}

A: Your userspace does not access address c06fa128, it accesses a different address - one that that mmap() returned (plus offset). Thus no breakpoint hit.
The fact that virtual address being accessed resolves to same physical address as some other virtual address that has a breapoint, does not matter. CPU executing your userspace code has no idea that different mapping exists.


text:
Q: Slider content moving along with slider I have a problem with a slider: slide content should stay fixed to the right bottom corner and preform animation there, but instead it first moves along the slider and then animates back to the position. I would like to make it that when the slide comes in it slides from right to left, and when slides goes away it slides back to position where it is not visible.
Here is my code:

var theSlider = {
  track: document.querySelector('.m-tract-slider-wrapp'),
  // has to match `transition-duration` in CSS:
  duration: 450,
  reset: function() {
    var slides = document.querySelectorAll('.m-tract-slider-wrapp > div');
    for (var i = 0; i < slides.length; i++) {
      slides[i].className = '';
      slides[i].classList.add(i > 1 ? 'after' : (i ? 'current' : 'before'))
    }
  },

  init: function() {
    theSlider.reset();
    theSlider.track.classList.remove('not-loaded')
  },

  next: function() {
    theSlider.track.classList.add('go-right');
    setTimeout(function() {
      var firstSlide = document.querySelector('.m-tract-slider-wrapp > div:first-child');
      theSlider.track.appendChild(firstSlide);
      theSlider.reset();
      theSlider.track.classList.remove('go-right')
    }, theSlider.duration)
  },

  prev: function() {
    theSlider.track.classList.add('go-left');
    setTimeout(function() {
      var lastSlide = document.querySelector('.m-tract-slider-wrapp > div:last-child');
      theSlider.track.insertBefore(lastSlide, theSlider.track.firstChild);
      theSlider.reset();
      theSlider.track.classList.remove('go-left')
    }, theSlider.duration)
  },

  prevButton: document.querySelector('.slide-left'),
  nextButton: document.querySelector('.slide-right')
};

window.addEventListener("load", theSlider.init);
theSlider.prevButton.addEventListener('click', theSlider.prev);
theSlider.nextButton.addEventListener('click', theSlider.next);
.m-tract-slider {
  width: 100%;
  height: 75vh;
  margin: 5em auto;
  position: relative;
  overflow: hidden;
  background-color: #f5f5f5
}

.m-tract-slider-wrapp {
  height: 100%;
  -webkit-transition: all 350ms cubic-bezier(.08, .13, 0, .81);
  -moz-transition: all 350ms cubic-bezier(.08, .13, 0, .81);
  -o-transition: all 350ms cubic-bezier(.08, .13, 0, .81);
  transition: all 350ms cubic-bezier(.08, .13, 0, .81);
  opacity: 1
}

.m-tract-slider-wrapp.not-loaded {
  opacity: 0
}

.m-tract-slider-wrapp>div {
  height: 100%;
  position: absolute;
  background: transparent no-repeat 50% 50%/cover;
  width: 100%
}

.m-tract-slider-wrapp>div.before {
  margin-left: -100%
}

.m-tract-slider-wrapp>div.current+div {
  margin-left: 100%
}

.m-tract-slider-wrapp>div.current .m-tract-slide-content {
  transform: translateX(0);
  -ms-transform: translateX(0);
  -webkit-transform: translateX(0);
  -webkit-transition: transform 350ms ease-in;
  -moz-transition: transform 350ms ease-in;
  -o-transition: transform 350ms ease-in;
  transition: transform 350ms ease-in;
  transition-delay: .6s;
  margin-left: 0
}

.m-tract-slider-wrapp>div.after~div {
  opacity: 0
}

.m-tract-slide-content {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 40%;
  background: #fff;
  padding: 3em;
  margin: 0;
  height: 50vh;
  transform: translateX(100%);
  -ms-transform: translateX(100%);
  -webkit-transform: translateX(100%);
  -webkit-transition: transform 350ms ease-in;
  -moz-transition: transform 350ms ease-in;
  -o-transition: transform 350ms ease-in;
  transition: transform 350ms ease-in;
  transition-delay: .6s
}

.m-tract-slide_title {
  font-size: 32px;
  font-weight: 700;
  color: #212121
}

.m-tract-slide_text {
  font-size: 18px;
  display: block;
  margin-top: 2em;
  color: #ccc;
  font-weight: 300
}

.m-tract-slider-control {
  position: absolute;
  bottom: 0;
  left: 0;
  background: #fff;
  padding: 1em
}

.m-tract-slider-btn {
  display: inline-block;
  cursor: pointer;
  margin-left: 1em
}

.m-tract-slider-btn:first-child {
  margin-left: 0
}

.go-right div {
  transform: translateX(-100%);
  -ms-transform: translateX(-100%);
  -webkit-transform: translateX(-100%)
}

.go-left div {
  transform: translateX(100%);
  -ms-transform: translateX(100%);
  -webkit-transform: translateX(100%)
}

.go-left div,
.go-right div {
  -webkit-transition: transform 450ms cubic-bezier(.4, 0, .2, 1);
  -moz-transition: transform 450ms cubic-bezier(.4, 0, .2, 1);
  -o-transition: transform 450ms cubic-bezier(.4, 0, .2, 1);
  transition: transform 450ms cubic-bezier(.4, 0, .2, 1)
}

        Gde ćeš provesti večnost?

          Lorem ipsum dolor sit amet, consectetur adipisicing elit.
          Voluptatum ea assumenda, nam quia, distinctio omnis. Aspernatur,
          molestias nostrum dolores? Voluptas sequi labore cum ipsum
          necessitatibus possimus, soluta veritatis aut dicta.

        Title 2

          Lorem ipsum dolor sit amet, consectetur adipisicing elit.
          Voluptatum ea assumenda, nam quia, distinctio omnis. Aspernatur,
          molestias nostrum dolores? Voluptas sequi labore cum ipsum
          necessitatibus possimus, soluta veritatis aut dicta.

        Title 3

          Lorem ipsum dolor sit amet, consectetur adipisicing elit.
          Voluptatum ea assumenda, nam quia, distinctio omnis. Aspernatur,
          molestias nostrum dolores? Voluptas sequi labore cum ipsum
          necessitatibus possimus, soluta veritatis aut dicta.

Prev

Next

A: When you deal with properties that affect animations you need to be very careful about your selectors.
The .go-right div and .go-left div selectors are affecting each sibling of .go-right and .go-left, while you probably only want the immediate siblings (the slides) to be affected, so I replaced them with .go-right>div and .go-left>div :

var theSlider = {
  track: document.querySelector('.m-tract-slider-wrapp'),
  // has to match `transition-duration` in CSS:
  duration: 450,
  reset: function() {
    var slides = document.querySelectorAll('.m-tract-slider-wrapp > div');
    for (var i = 0; i < slides.length; i++) {
      slides[i].className = '';
      slides[i].classList.add(i > 1 ? 'after' : (i ? 'current' : 'before'))
    }
  },

  init: function() {
    theSlider.reset();
    theSlider.track.classList.remove('not-loaded')
  },

  next: function() {
    theSlider.track.classList.add('go-right');
    setTimeout(function() {
      var firstSlide = document.querySelector('.m-tract-slider-wrapp > div:first-child');
      theSlider.track.appendChild(firstSlide);
      theSlider.reset();
      theSlider.track.classList.remove('go-right')
    }, theSlider.duration)
  },

  prev: function() {
    theSlider.track.classList.add('go-left');
    setTimeout(function() {
      var lastSlide = document.querySelector('.m-tract-slider-wrapp > div:last-child');
      theSlider.track.insertBefore(lastSlide, theSlider.track.firstChild);
      theSlider.reset();
      theSlider.track.classList.remove('go-left')
    }, theSlider.duration)
  },

  prevButton: document.querySelector('.slide-left'),
  nextButton: document.querySelector('.slide-right')
};

window.addEventListener("load", theSlider.init);
theSlider.prevButton.addEventListener('click', theSlider.prev);
theSlider.nextButton.addEventListener('click', theSlider.next);
.m-tract-slider {
  width: 100%;
  height: 75vh;
  margin: 5em auto;
  position: relative;
  overflow: hidden;
  background-color: #f5f5f5
}

.m-tract-slider-wrapp {
  height: 100%;
  transition: all 350ms cubic-bezier(.08, .13, 0, .81);
  opacity: 1
}

.m-tract-slider-wrapp.not-loaded {
  opacity: 0
}

.m-tract-slider-wrapp>div {
  height: 100%;
  position: absolute;
  background: transparent no-repeat 50% 50%/cover;
  width: 100%
}

.m-tract-slider-wrapp>div.before {
  margin-left: -100%
}

.m-tract-slider-wrapp>div.current+div {
  margin-left: 100%
}

.m-tract-slider-wrapp>div.current .m-tract-slide-content {
  transform: translateX(0);
  margin-left: 0
}

.m-tract-slider-wrapp>div.after~div {
  opacity: 0
}

.m-tract-slide-content {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 40%;
  background: #fff;
  padding: 3em;
  margin: 0;
  height: 50vh;
  transform: translateX(100%);
  transition: transform 350ms ease-in;
  transition-delay: 0s; /* was .6s */
}

.m-tract-slide_title {
  font-size: 32px;
  font-weight: 700;
  color: #212121
}

.m-tract-slide_text {
  font-size: 18px;
  display: block;
  margin-top: 2em;
  color: #999;
  font-weight: 300
}

.m-tract-slider-control {
  position: absolute;
  bottom: 0;
  left: 0;
  background: #fff;
  padding: 1em
}

.m-tract-slider-btn {
  display: inline-block;
  cursor: pointer;
  margin-left: 1em
}

.m-tract-slider-btn:first-child {
  margin-left: 0
}

.go-right > div {
  transform: translateX(-100%);
}

.go-left > div {
  transform: translateX(100%);
}

.go-left > div,
.go-right > div {
  transition: transform 450ms cubic-bezier(.4, 0, .2, 1)
}

        Gde ćeš provesti večnost?

          Lorem ipsum dolor sit amet, consectetur adipisicing elit.
          Voluptatum ea assumenda, nam quia, distinctio omnis. Aspernatur,
          molestias nostrum dolores? Voluptas sequi labore cum ipsum
          necessitatibus possimus, soluta veritatis aut dicta.

        Title 2

          Lorem ipsum dolor sit amet, consectetur adipisicing elit.
          Voluptatum ea assumenda, nam quia, distinctio omnis. Aspernatur,
          molestias nostrum dolores? Voluptas sequi labore cum ipsum
          necessitatibus possimus, soluta veritatis aut dicta.

        Title 3

          Lorem ipsum dolor sit amet, consectetur adipisicing elit.
          Voluptatum ea assumenda, nam quia, distinctio omnis. Aspernatur,
          molestias nostrum dolores? Voluptas sequi labore cum ipsum
          necessitatibus possimus, soluta veritatis aut dicta.

Prev

Next

A few more tips on how to keep developing manageable:

*

*use shorter classnames (you only need one specific longer class or id to apply your CSS to specific elements. So use shorter classnames for its children.

*do not copy/paste transition or transforms over different states of the same element. Just place them on the state that's always active and only override the property that changes. It really improves animation performance and also increases your ability to understand and control it.

*only prefix your properties after you're done developing, as a last step; otherwise, they'll clutter up your "workspace" without adding anything, really;

*when you don't have a reason to use em, use rem. If you want your slider's paddings and margins to be affected by 's font-size use rem. If you want it fixed to whatever you set on slider, use em (and set font-size on your slider).

A quick ran-down of those principles applied to what you have (it's not perfect and can be further streamlined, but I think you'll find it easier to workwith). I also transformed your CSS into SCSS as, again, it's easier to control.
Don't be intimidated by SCSS. You don't have to use variables and mixins (although they are pretty powerful and handy once you learn them). But I'm sure you'll find the simple class nesting handy for starters.
To get the result from the snippet, inspect source and you'll find it transformed into CSS.


text:
Q: How to send a certificate as part of request using api management [![enter image description here][1]][1]Currently I'm reading a client certificate from the external client and then validating in apim using policies which is done using
    <policies>
        <inbound>

Now when the request is valid and must attach the servercertificate along with the request and then send it back to the client.
How must this be done? can you please help.

A: Since you're putting certificate into a header you could simply bin64 encode it. You should be able to do it either by accessing RawData property or calling Export on it.


text:
Q: Mapping a Python dictionary to new attributes in an object I want to map a subset of a dictionary to attributes of a class but with different names. For eg:
D = { "City" : {
                "Name": "Minneapolis",
                "Weather Forecast": "Sunny with chance of rain",
                "Temperature" : 55
               }
      "State": "MN",
      "Area Code": 651,
      "Country": "US"
    }

I want to map the above dictionary to an Object with attributes "Name", "Forecast" and "AreaCode" with values of "Minneapolis", "Sunny with chance of rain" and 651 respectively while ignoring other keys. I also want these attributes to be None if the corresponding keys are not present in the dict. Is there an easy way and direct way to do this without explicitly checking for each specific key?

A: from dataclasses import dataclass

@dataclass
class City:
    name: str
    forecast: str
    area_code: int

    @classmethod
    def from_dict(cls, data):
        name = data.get('City').get('Name')
        forecast = data.get('City').get('Weather Forecast')
        area_code = data.get('Area Code')
        return cls(name, forecast, area_code)

# regular use:
c1 = City('Greensboro', 'Sunny', 336)
print(c1)
City(name='Greensboro', forecast='Sunny', area_code=336)

D = { "City" : {
                "Name": "Minneapolis",
                "Weather Forecast": "Sunny with chance of rain",
                "Temperature" : 55
               },
      "State": "MN",
      "Area Code": 651,
      "Country": "US"
    }

# alternate constructor using a dictionary
c2 = City.from_dict(D)
print(c2)
City(name='Minneapolis', forecast='Sunny with chance of rain', area_code=651)


text:
Q: Is there a way that is more efficient than sitemap to add/force recrawl/remove your website's index entries in google? Pretty much that is the question. Is there a way that is more efficient than the standart sitemap.xml to [add/force recrawl/remove] i.e. manage your website's index entries in google?
I remember a few years ago I was reading an article of an unknown blogger that was saying that when he write news in his website, the url entry of the news will appear immediately in google's search result. I think he was mentioning about something special. I don't remember exactly what.. . some automatic re-crawling system that is offered by google themselves? However, I'm not sure about it. So I ask, do you think that I am blundering myself and there is NO OTHER way to manage index content besides sitemap.xml ? I just need to be sure about this.
Thank you.

A: I don't think you will find that magical "silver bullet" answer you're looking for, but here's some additional information and tips that may help:

*

*Depth of crawl and rate of crawl is directly influenced by PageRank (one of the few things it does influence). So increasing your site's homepage and internal pages back-link count and quality will assist you.

*QDF - this Google algorithm factor, "Query Deserves Freshness", does have a real impact and is one of the core reasons behind the Google Caffeine infrastructure project to allow much faster finding of fresh content. This is one of the main reasons that blogs and sites like SE do well - because the content is "fresh" and matches the query.

*XML sitemaps do help with indexation, but they won't result in better ranking. Use them to assist search bots to find content that is deep in your architecture.

*Pinging, especially by blogs, to services that monitor site changes like ping-o-matic, can really assist in pushing notification of your new content - this can also ensure the search engines become immediately aware of it.

*Crawl Budget - be mindful of wasting a search engine's time on parts of your site that don't change or don't deserve a place in the index - using robots.txt and the robots meta tags can herd the search bots to different parts of your site (use with caution so as to not remove high value content).

Many of these topics are covered online, but there are other intrinsic things like navigational structure, internal linking, site architecture etc that also contribute just as much as any "trick" or "device".

A: Getting many links, from good sites, to your website will make the Google "spiders" reach your site faster.
Also links from social sites like Twitter can help the crawlers visit your site (although the Twitter links do not pass  "link juice" - the spiders still go through them).
One last thing, update your content regularly, think of content as "Google Spider Food". If the spiders will come to your site, and will not find new food, they will not come back again soon, if each time they come, there is new food, they will come a lot. Article directories for example, get indexed several times a day.


text:
Q: How do I avoid immediate loading of associated data in Linq to SQL Say I have an entity that looks as follows
public Order OrderEntity
{
   EntityRef<Customer> CustomerEntity;
   EntitySet<OrderDetail> OrderDetailEntity;
   ...
   ...
}

When I retrieve an OrderEntity, and convert it say to a List, L2S, will also retrieve the entity in CustomerEntity and all the entities in OrderDetailEntity (plus all their child entities etc.). Often times we do not want this behavior. How to tell L2S not to do this?
Thanks - Randy

A: After creating your data context set deferred loading to be enabled.
dataContext.DeferredLoadingEnabled = true;

When the code accesses one of these relationships, null is returned if the relationship is one-to-one, and an empty collection is returned if it is one-to-many. The relationships can still be filled by setting the LoadOptions property.
The main scenario for this property is to enable you to extract a piece of the object model and send it out (for example, to a Web service).

See the other remarks for interaction with object tracking.

A: re: the EntitySet, LINQ-to-SQL will only lazy-load those entities.
To prove this, retrieve our OrderEntity and then dispose of your data context.  You will get an except saying that you can't retrieve more data from a disposed context.
You can force LINQ-to-SQL to load these child entities using the LoadOptions class, but you can't force it not to load them.  By default they are not loaded.
I am not aware if you can remove the reference to the parent entity.

A: Lazy loading of EntityRefs/Sets is the default L2S behavior.
One thing that might make you think otherwise, is that watching your instance in the Visual Studio debugger accesses the ref'd properties, causing them to be loaded. This might make it seem like that they're being eagerly loaded, when in reality it's just VS.
To see exactly what's being loaded and when, set your context's Log property to Console.Out. This will output any executed commands into the Visual Studio output window.


text:
Q: Why this expression does not unbound the variable? Recently I started learning Erlang, coming from an imperative background things are somewhat different...
I was doing fine (learning Erlang) till I came across something I did not understood while working in Eshell, can someone explain me what is happening?
17> One.
1
18> One = 1.
1
19> true andalso f(One).
ok
20> One.
1

Why One is still bound to a value? Since the right side of the expression was indeed evaluated. Now, If I use f() alone, things work as expected
21> f(One).
ok
22> One.
* 1: variable 'One' is unbound

Why?

A: Assuming there are no current variable bindings, the command
1> One = 1.

adds a binding for One by calling erl_eval:add_binding('One',1,[]) where the final argument is a list of current bindings. The bindings are then [{'One',1}].
Next, we run the andalso expression:
2> true andalso f(One).
ok
3> b().
One = 1
ok

What happens for this command is that when true gets evaluated, the bindings are [{One,1}]. Since true makes the left-hand side of the andalso successful, the right-hand side is then evaluated, also with bindings of [{One,1}], and the f(One) command there results in a call to erl_eval:del_binding('One',[{'One',1}]), changing the bindings for only the right-hand side to the empty list []. The result of that part of the expression, ok, becomes the overall result because of the way andalso works. Once that result is available, the bindings for the right-hand side are dropped because all that's needed is the result. The original bindings are still around because of the left-hand side, and those bindings stay in effect. The subsequent b() command to show the bindings therefore still shows One = 1.
A very similar effect happens if you run this:
4> true andalso (Two = 2).
2
5> b().
One = 1
ok

The second part of the andalso, (Two = 2), adds a binding for Two only to the bindings for that part of the evaluation. The result, 2, is kept, but the bindings for that part are dropped, and only the bindings for the left half stay in effect. When we again run b() to see all bindings, we still see only One = 1.


text:
Q: Load a cubemap in a DDS file with DevIL I only get the first face in a cubemap. How do I access/load the other ones?
With DevIL 1.7.8 on Ubuntu Natty:
I use ilLoad or ilLoadImage to load a dds-file with 6 textures, but only the first face gets loaded.
ilGetInteger() give the results:
IL_IMAGE_DEPTH: 1
IL_IMAGE_BYTES_PER_PIXEL:4
IL_NUM_LAYERS: 0
IL_NUM_IMAGES: 0
IL_IMAGE_TYPE: 5121 (= 0x1401, not even an image type according to il.h! )
IL_IMAGE_CUBEFLAGS: 1024
IL_ACTIVE_IMAGE: 0
IL_IMAGE_SIZE_OF_DATA: 65536 (which is 128x128x4 and match the "image size in pixels" times "bytes per pixel".)
If I try to use ilActiveImage with a value other than 0, it returns false.
I have tried Earth.dds and LightCube.dds from the RenderMonkey example textures, as well as saved my own dds-file with GIMP, but only the first face gets loaded for all of them.
Does anyone have any suggestion?
(I have compiled DevIL with ilu and ilut-support, if that would make any difference.)

A: DevIL does not have provisions for DDS Cubemaps. Neither do a surprising number of image loaders.


text:
Q: ludown parse toqna command issue replaces comma with \r\n I am using the following command to parse lu file to json file, which then can be given to QnA Maker service to generate kb. But I found that the command replaces comma with "\r\n". For example:
### ? start
        ```markdown
        Lorem ipsum dolor, Lorem ipsum dolor Lorem ipsum dolor.
        ```

The markdown syntax above is getting converted into the following:
{
    "qnaList": [
        {
          "id": 0,
          "answer": "Lorem ipsum dolor\r\n",
          "source": "custom editorial",
          "questions": [
            "start"
          ],
          "metadata": []
        },
    ]
}

The text is also getting truncated. How do I resolve this issue ?
Thanks

A: I wasn't able to replicate the truncating of text, even with a direct copy/paste of your code. You may need to update ludown with npm i -g ludown. It may also help to ensure you're using the appropriate format, using these resources:

*

*Official format guidelines

*An example .lu file
There's a PR on GitHub that just got merged yesterday that addresses the \r\n issue.
It hasn't been pushed to npm yet. You might be able to pull a nightly build in the next couple of days.
If you'd like to try something more immediate, you can replace the appropriate file in your installed npm package:

*

*Navigate to where NPM installed ludown. On Windows 10, this is %AppData%\Roaming\npm\node_modules\ludown\lib. Other OS locations.

*Copy the contents from the GitHub Repo and replace the contents of parseFileContents.js in your npm install directory.

*Try running the command again

You can see my successful implementation of this:


text:
Q: Vertically wobbly figure in Beamer over slides I have successive slides where one column is text and the other column is just an image. The image stays the same, so I simply kept the exact same code in a new frame. However, at my surprise, when I vary the text of the left column, the vertical alignment of the picture in the right column changes. I would like the picture to stay still from a frame to another.
Here is a MWE which should make it clearer:
\documentclass{beamer}

\begin{document}

\begin{frame}
\begin{columns}

\column{0.5\textwidth}

Sample text

\column{0.5\textwidth}
\begin{figure}

\centering
\def\svgwidth{\textwidth}
\input{fig.pdf_tex}
\caption{Wobbly figure}

\end{figure}

\end{columns}
\end{frame}

\begin{frame}
\begin{columns}

\column{0.5\textwidth}

A much longer sample text which messes up with the vertical alignment of the image in the other column. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

\column{0.5\textwidth}
\begin{figure}

\centering
\def\svgwidth{\textwidth}
\input{fig.pdf_tex}
\caption{Wobbly figure}

\end{figure}

\end{columns}
\end{frame}

\end{document}

A: Yes, it does. Of course, one has to make the usual corrections and I do not have your figure.
\documentclass{beamer}

\begin{document}

\begin{frame}[t]
\begin{columns}[T]

\begin{column}{0.485\textwidth}

Sample text

\end{column}
\begin{column}{0.485\textwidth}
\vspace*{2cm}
\begin{figure}

\centering
\includegraphics[width=0.9\textwidth]{example-image-duck}
\caption{Wobbly figure}

\end{figure}
\end{column}
\end{columns}
\end{frame}

\begin{frame}[t]
\begin{columns}[T]

\begin{column}{0.485\textwidth}

A much longer sample text which messes up with the vertical alignment of the image in the other column. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
\end{column}
\begin{column}{0.485\textwidth}
\vspace*{2cm}
\begin{figure}

\centering
\includegraphics[width=0.9\textwidth]{example-image-duck}
\caption{Wobbly figure}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\end{document}


text:
Q: Getting error Faraday::ClientError: the server responded with status 400 on adding a share to linkedin in rails I am trying to add a share using linkedin-oauth2 gem and getting an error
Faraday::ClientError: the server responded with status 400

I have also tried from irb but still getting same error. I have w_share permissions set for my access token but I don't know why I am getting this error.
Here is a snippet of what m doing in my controller method->
def post_on_linkedin
  user = User.find_by_id(session[:user_id])
  @client = LinkedIn::API.new(user.token)
  @client.add_share(content: "hello")
  redirect_to social_media_linkedin_index_path
end

Please tell me if something is wrong with my syntax or anything else and please provide the syntax for using 'add_share' method with all other options. Thanks


text:
Q: How to customize date colors in ant design datapicker for specific dates? I have an object with a date and color in which the current date should be painted. How to determine the current day with the date in the datepicker in ant design.
When I try to get the current month in the dateRender method, I get all the months that are on this tab.
My code:
import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { DatePicker, Space } from "antd";
import moment from "moment";

const dateFormat = "YYYY-MM-DD";

const data = [{ date: "2021-05-02", color: "green" }];

ReactDOM.render(
  <Space direction="vertical" size={12}>
    <DatePicker
      format={dateFormat}
      dateRender={(current) => {
        let day = moment(data[0].date).format("DD");
        let month = moment(data[0].date).format("MM");
        console.log(current.month()); //instead 5 I get 4,5 and 6
        const style = {};
        if (
          current.date() === Number(day) &&
          current.month() === Number(month)
        ) {

          style.border = "1px solid #1890ff";
          style.borderRadius = "50%";
          style.backgroundColor = data[0].color;
        }
        return (
          <div className="ant-picker-cell-inner" style={style}>
            {current.date()}
          </div>
        );
      }}
    />
  </Space>,
  document.getElementById("container")
);

So how I can get correct current mounth?


text:
Q: Hidden error with cordova build CLI and facebook sdk I added the facebook sdk through cordova add plugin and referenced the Facebook SDK in eclipse on the android project.
On Eclipse I have no error on build but when I try to build in command line with cordova build the build fails with a hidden error.
http://pastebin.com/Z0jf3a6Z
Is there a way to show more context with cordova build or more low level build I could get with ant on a cordova project ? I just need to know what's the error, even if I could replicate it on eclipse ?

A: After a small break and clearing my mind I found the problem and solution.
First, to add more verbosity to the ant build process in CLI you need to edit the build.xml file located in your SDK_PATH/tools/ant/build.xml and look for the property verbosity and set it to true.
This helped me realize the error was actually the warnings themselves since the Werror flag was used in the Facebook SDK compile phase that was failing. So you need to edit the ant.properties of the lib that is failing and remove the Werror flag, be careful as some warnings might be important.
Lastly, the build was failing at the -code-gen phase with a message about an invalid resource directory name, if you have this message you need to close eclipse and run ant clean on the lib/project that is failing and building again without launching eclipse.
I hope this helps.


text:
Q: AWS Lambda module initialization error: [Errno 30] Read-only file system I have the following snippet in my python code to download AWS IoT topic certificates and keys which are stored in an S3 bucket.
 # download certs and keys
    certification_path = organisation + '/' + uuid + '/'

    client.download_file(BUCKET, certification_path + cert_file, cert_file)  # copy file to local storage
    client.download_file(BUCKET, certification_path + key_file, key_file)
    client.download_file(BUCKET, certification_path + root_file, root_file)

The code runs perfectly in my AWS Cloud9 environment, but if I try to run the code as an AWS Lambda function, I get the error module initialization error: [Errno 30] Read-only file system: '-certificate.pem.crt.4aBBF198'
How can I get past this error in order to obtain the correct certificates and publish messages to the IoT topic.

A: Lambda only allows you to save into the /tmp directory.  I'd change to:
client.download_file(BUCKET, certification_path + cert_file, "/tmp/" + cert_file)

and so on.  Of course, whatever read these files now needs to know about the new path.
EDIT
If this is the Python IoT library there is a specific call to handle this.  You'd want to do something like:
client.download_file(BUCKET, certification_path + cert_file, '/tmp/' + cert_file)
client.download_file(BUCKET, certification_path + key_file, '/tmp/' + key_file)
client.download_file(BUCKET, certification_path + root_file, '/tmp/' + root_file)

iot_client.configureCredentials( '/tmp/' + root_file, '/tmp/' + key_file, '/tmp/' + cert_file)

before you tried to call anything else.


text:
Q: How to parse triplets in a single line of input in C I'm doing an assignment where I get input like this:
(x y z)

where x, y and z are integers, lets call it a triplet.
I need to get a lot of these, but in one line only. The input should be like this:
1 2 3 3 2 1 3 1 3 4 2 1 8 2 1

And I need to transform this input in triples, like (1, 2, 3) (3, 2, 1), (3, 1, 3) and so on.
My problem is, how do I read an entire (undefined size) line of numbers and store these?

A: If you are getting input from standard input, you can use scanf to accomplish this, the following should be a good start, you should add more validation to complete the code:
#include <stdio.h>

int main(void)
{
    int x,y,z;

    while(scanf("%d %d %d ",&x,&y,&z)==3) {
        printf("[%d, %d, %d]\n",x,y,z);
    }
}

Using test.txt with the values you have provided, breaking them into multiple lines would work as well, as long as they are in sets of 3 and separate by space:
cat > test.txt << EOF
1 2 3 3 2 1 3 1 3 4 2 1 8 2 1
EOF

Running the example:
./a.out < test.txt
[1, 2, 3]
[3, 2, 1]
[3, 1, 3]
[4, 2, 1]
[8, 2, 1]


text:
Q: Continuity of inductively constructed lift to covering space I am following through the proof of lemma "(c)" of proposition 1.7 in Hatcher's AT, which says that if we have a covering space $\tilde X \xrightarrow{p} X$, an $F:Y \times I \rightarrow X$ and an "initial lift" $\tilde F_0: Y \times \{ 0 \} \rightarrow \tilde X$, then we can construct a (unique) lift $\tilde F$ of $F$ to $\tilde X$ which extends $\tilde F_0$.
I understand the inductive construction of $\tilde F$ around $\{ y_0 \} \times I$ for an $y_0 \in Y$. We find a neighborhood $N$ of $y_0$ and a partition of $I = [0,1]$, $0=t_0 < \ldots < t_m=1$, and an $\tilde F$ which is continuous on every $N \times [t_i, t_{i+1}]$, and their definitions agree on overlaps ($\tilde F|_{N \times [t_i, t_{i+1}]} := p_{\tilde{U_i}}^{-1}( F|_{N \times [t_i, t_{i+1}]} )$ for $U_i \simeq \tilde U_i$ through $p$ and $U_i$ a neighborhood of $F(N,[t_i,t_{i+1}])$).
What don't get is why $\tilde F$ constructed as such is continuous on $N \times I$. I'm thinking that if $Y$ is a locally compact Hausdorff space, then, since $N$ is open, we can find an open (precompact) neighborhood of $y_0$, say $M$, such that $\overline M \subseteq N$. Then $\tilde F|_{\overline{M} \times [t_i, t_{i+1}]}$ are all continuous too and we can apply the glueing lemma for the closed sets $\overline{M}\times [t_i, t_{i+1}]$, obtaining that $\tilde F|_{M \times I}$ is continuous, and this is fine because we only care about $\tilde F$ on a neighborhood of $\{ y_0 \} \times I$. But is $\tilde F_{N \times I}$ constructed as such continuous for an arbitrary $Y$?


text:
Q: jquery webcam plugin picture i am trying to use the jquery webcam plugin and i believe i have placed every thing right but still i have a problem .
thought the #webcam div is working fine and show frames from the cam but on clicking capture no image is taken
i get the following error on the chrome console :
Uncaught TypeError: Object # has no method 'capture'
there are similar questions here but none seems to solve my problem
i have placed the callbacks too .
jQuery("#webcam").webcam({

    width: 320,
height: 240,
mode: "callback",
swffile: "../jcam/jscam_canvas_only.swf",

onTick: function(remain) {
},

onSave: function(data) {...
    }
},
onCapture: function () {....
},

debug: function (type, string) {
},
onLoad: function () {.......
    }
}
});

A: Try this
$(function(){
jQuery("#webcam").webcam({

    width: 320,

    height: 240,

    mode: "callback",

    swffile: "../jcam/jscam_canvas_only.swf",

    onTick: function(remain) {
    },

    onSave: function(data) {...
        }
    },
    onCapture: function () {....
    },

    debug: function (type, string) {
    },
    onLoad: function () {.......
        }
    }
});

});


text:
Q: Can you explain tides in our water bodies with respect to Theory of General Relativity and spacetime curvature? We read everywhere that Moon's "gravitational pull" causes tidal waves. Is there any explanation of this "gravitational pull" in terms of General Relativity and curvature of spacetime? And how does this work? Or Newtonian gravity is the only way to explain this phenomenon?

A: Either set of tools can be used to get an accurate picture of tidal dynamics. Here is the key point in either case:
If you trace out the gravitational field lines emanating from a compact, massive object, you will find that the field lines diverge as you move away from the object and converge as you get closer to it.
Now imagine that you are distant from that object, and you spread your arms out and drop a golf ball from each hand towards the massive object. Each ball will follow its own field line as it falls, and since those lines converge on the center of mass of the massive object, the golf balls will move toward each other as they get closer to the object.
Imagine further that you now drop another pair of golf balls from your hands, but this time you turn sideways so the two balls will follow the same field line, but one starts closer to the object and the other starts farther from it. Both balls will fall toward the object, but the one that started closer to it will experience a stronger pull and the one behind it a lesser pull. This means that as they approach the object, the distance between them will increase.
If you had an arrangement by which you could drop all four of these balls at the same instant, you would then observe the side-by-side balls moving towards each other and the fore-and-aft balls moving away from each other, as they got progressively closer to the object.
The shift in the positions of the falling balls is what is meant by tidal effects and to an observer, it looks as if there is a force stretching the fore-and-aft balls apart and squeezing the side-by-side balls together. And if you yourself were falling instead of the balls, you would feel that stretch and squeeze.
Since both general relativity and newtonian gravity feature field lines that possess
divergence in three-dimensional space, both will accurately predict tidal effects as long as the field strengths are not large and the speeds with which the objects fall are not really big. In the cases of huge masses and high speeds, newtonian gravity will yield the wrong answers and general relativity will give the right ones.

A: Tidal forces find a very natural expression in the language of spacetime curvature, via the concept of geodesic deviation.  Here's how:
First, we need the concept of a geodesic.  This is the equivalent of a "straight line" on a plane;  effectively, it is a path in your space (or your spacetime) that is "locally straight".  An example would be a great-circle path on a sphere.  One of the fundamental postulates of general relativity is that freely falling objects follow geodesics in a curved spacetime.
Now, an important property of curved spaces (or curved spacetimes) is that nearby geodesics may converge or diverge.  Suppose I'm on a flat plane with a friend, who is standing the COVID-required 2 meters away from me.  At a given time, we both start off walking in the same direction, and we walk at the same speed along a geodesic (a straight line) thereafter.  As we walk, we will continue to be exactly 2 meters apart at all times.
But now let's suppose that we go to the equator of the Earth, each get in identical planes that are 2 km apart, and we each take off heading due North.  Even if we start off going in the same direction, and even if we travel at the same speed, the distance between us will change with time.  We're both travelling along lines of longitude, but all lines of longitude meet at the North Pole.  So as we travel north, the distance between us will decrease from 2 km to (eventually) 0.  The fact that we both travelled along straight lines and yet didn't remain the same distance apart is due to the fact that the Earth is curved.
The analogue of this phenomenon in curved spacetime is tidal effects.  Suppose my friend and I are now in space, freely falling towards the Earth.  We both follow our own geodesics through the curved spacetime around the Earth.  But because the spacetime is curved, the distance between our "nearby" geodesics will change.  Depending on where my friend is relative to me and the Earth, it will look like there is a force pushing them towards me or pulling them away from me as we both freely fall.  In other words, I see my friend undergo a "tidal acceleration" relative to me.  If we replace my friend & me with the Earth and its oceans, and think of both of them as freely falling towards the Moon (or the Sun), we would say that the oceans are experiencing tidal forces that pull them away from the Earth at some points and push them towards the Earth at other points.
Of course, my friend isn't really experiencing any forces, any more than they were actively steering their plane towards me back when we did that experiment.  It is the curvature of the spacetime that causes the distance between us to change as we both freely fall.

A: It's non-Relativistic, but I suggest you read about Amphidromic
points. https://en.wikipedia.org/wiki/Amphidromic_point . It deals with the water-sloshing-around stuff, not gravitational gradient stuff.
As someone who lives on the shore a few miles away from truly impressive tidal events https://www.youtube.com/watch?v=QEfUblSDzww , its hard to believe tides were caused by the Moon. OK. not true. I believe it's caused by the Moon.
The High school physics explanation of diurnal tides is so simplistic, it is useless.


text:
Q: Setting an optional parameter explicitly when calling a PHP function I defined the function f in PHP:
function f($r, $o1="1", $o2="2") { echo($r . $o1 . $o2 . "\n"); }

Now I can call f (1) without the optional parameters, (2) with the first or (3) with both optional parameters:
f(0);           // 012
f(0, "a");      // 0a2
f(0, "a", "b"); // 0ab

Is it also possible to call f only with the second parameter? e.g.
f(0, $o2="X");  // 01X

I'm using 5.5.12-2ubuntu4.1.

A: You can define your function as this:
function f($r, $o1=null, $o2=null) {
  if(is_null($o1)) $o1 = "1";
  if(is_null($o2)) $o1 = "2";
  echo($r . $o1 . $o2 . "\n");
}

Now you know that you can always pass null to use default value, and you can later change the default values without changing the callers.

A: You could make all parameters optional:
function f($r = null, $o1 = "1", $o2 = "2")
{
    $r = $r ? : 0;
    echo($r . $o1 . $o2 . "\n");
}

This gives you:
f(0);           // 012
f(null, "a");   // 0a2
f(1, "a");      // 1a2

A: Since PHP 5.6, you can use "..." before a parameter to tell the interpreter that your function accepts a random number fo arguments.
Before PHP 5.6, you can pass an array instead of a list of params.
You can also use func-get-arg() or func-get-args() and check whether the second parameter is "disabled" (ie: == null)


text:
Q: Strange behaviour in biblatex @online without year \documentclass[12pt,english,a4paper]{report}

\usepackage[backend=biber,
%           natbib=true
        style=ieee,
        sorting=none,
        doi=false,
        isbn=false,
        url=true,
        urldate=long,
        ]{biblatex} % best for bibliography

\usepackage{filecontents}

\begin{filecontents}{references.bib}
@Online{stack,
title     = {stackexchange},
url       = {http://tex.stackexchange.com/},
urldate   = {2016-08-30},
}
    \end{filecontents}

\DefineBibliographyStrings{english}{urlseen = {Last accessed:},}

\addbibresource{references.bib}

\begin{document}
\cite{stack}
\printbibliography
\end{document}

gives

*

*starting (). should be removed.

\AtEveryBibitem{%
    \ifentrytype{Online}{%
        \clearfield{labelyear}%
    }{%
}%
} not working

*Available: => Available at:

*(Last accessed: ) => without bracket

Please don't change filecontents.

A: Since date/year is a mandatory field biblatex-ieee expects there to be one and does not check if the year is missing to avoid empty brackets. We can do that - the check is inserted using the xpatch package to avoid rewriting the driver -
\usepackage{xpatch}
\xpatchbibdriver{online}
  {\printtext[parens]{\usebibmacro{date}}}
  {\iffieldundef{year}{}{\printtext[parens]{\usebibmacro{date}}}}
  {}{}

Item 2 should be dealt with with
\DefineBibliographyStrings{english}{url = [Online]\adddot\addspace Available at,}

Finally, there is
\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}

for the third point.
MWE
\documentclass[12pt,english,a4paper]{report}

\usepackage[backend=biber,
%           natbib=true
        style=ieee,
        sorting=none,
        doi=false,
        isbn=false,
        url=true,
        urldate=long,
        ]{biblatex} % best for bibliography

\usepackage{filecontents}

\begin{filecontents}{references.bib}
@Online{stack,
title     = {stackexchange},
url       = {https://tex.stackexchange.com/},
urldate   = {2016-08-30},
}
    \end{filecontents}

\DefineBibliographyStrings{english}{urlseen = {Last accessed:},}

\addbibresource{references.bib}

\usepackage{xpatch}
\xpatchbibdriver{online}
  {\printtext[parens]{\usebibmacro{date}}}
  {\iffieldundef{year}{}{\printtext[parens]{\usebibmacro{date}}}}
  {}{}

\DefineBibliographyStrings{english}{url = [Online]\adddot\addspace Available at,}
\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}

\begin{document}
\cite{stack}
\printbibliography
\end{document}

[1] Stackexchange, [Online]. Available at: https://tex.stackexchange.com/ Last accessed: Aug. 30, 2016.


text:
Q: SQL retrieving columns which aren't in a Aggregate or Group By Ok I am representing a matrix with three columns in a table. For simplicity sake: Columns A,B and Value. A and B represent the X and Y "coordinates" of the matrix.
Could someone please help me work out the following:
For each column in the matrix (X), I wish to retrieve the smallest Value AND the Y coordinate field, which represented this smallest Value in column X.
This is for each column/X in the matrix.
I have been struggling because I couldnt include Y in a group by or aggregate function, so it wouldnt let me return it in the same query as calculating the minimum value (X was GROUP BY'd).
EDIT If there are two or more rows, the minimum Y value should be returned.
Just to be clear, my table is therefore:
Y | X | Value
0 | 0 | 0.38
1 | 0 | 0.72
2 | 0 | 0.13
3 | 0 | 0.45
0 | 1 | 0.52
1 | 1 | 0.23
2 | 1 | 0.84
3 | 1 | 0.15
0 | 2 | 0.52
1 | 2 | 0.04
2 | 2 | 0.04
3 | 2 | 0.15
With the above test data, it should return:
X | Y | Value
0 | 2 | 0.13
1 | 3 | 0.15
2 | 1 | 0.04
Please note on the Y=2, row 1 was the smallest Y, even though row 2 also had the minimum value.

A: SELECT x
     , y
     , value
FROM
  ( SELECT x
         , y
         , ROW_NUMBER() OVER (PARTITION BY x ORDER BY Value, y) AS rn
         , Value
    FROM tableX
  ) AS tmp
WHERE rn = 1 ;

You can test it at: SQL-Fiddle
(corrected to reflect the changed data in the question: test-2)
An index on (x, value, y) will be useful for performance.

A: SELECT  y ,
        ( SELECT    MIN(x)
          FROM      user997112 i
          WHERE     i.Y = o.y
                    AND i.VALUE = o.VALUE
        ) AS x ,
        value
FROM    ( SELECT    y ,
                    MIN(VALUE) AS value
          FROM      dbo.user997112
          GROUP BY  y
        ) AS o

Here is the schema I used
CREATE TABLE [dbo].[user997112](
    [x] [int] NULL,
    [y] [int] NULL,
    [VALUE] [decimal](5, 2) NULL
)
GO
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (0, 0, CAST(0.38 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (1, 0, CAST(0.72 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (2, 0, CAST(0.13 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (3, 0, CAST(0.45 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (0, 1, CAST(0.52 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (1, 1, CAST(0.23 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (2, 1, CAST(0.84 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (3, 1, CAST(0.15 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (0, 2, CAST(0.52 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (1, 2, CAST(0.04 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (2, 2, CAST(0.04 AS Decimal(5, 2)))
INSERT [dbo].[user997112] ([x], [y], [VALUE]) VALUES (3, 2, CAST(0.15 AS Decimal(5, 2)))

A: Here's one way to do it, but it's ungainly:
SELECT X, MIN(Y), Value
FROM your_table fullTable
WHERE Value <= ALL (SELECT Value FROM your_table WHERE X = fullTable.X)
GROUP BY X, Value

This will probably be more performant if you have no index on Value.  Otherwise you will probably get better performance from
SELECT X, MIN(Y), Value
FROM your_table fullTable
WHERE Value = (SELECT MIN(Value) FROM your_table WHERE X = fullTable.X)
GROUP BY X, Value

A: Something like
SELECT Test.X, Test.Y, MAX(Test.Value) AS Value FROM Test
INNER JOIN (
SELECT DISTINCT X, MIN(Y) AS Y FROM Test
GROUP BY X) t
ON Test.X = t.X AND Test.Y = t.Y
GROUP BY Test.X, Test.Y

Basicly: first do a subquery to get the combinations of X with  minimum Y, then join that to the original table, to get the corresponding value

A: I hope im right on time!
Select t1.A,
    min(t1.B),
    t1.value
from `table` t1,
 (SELECT MIN( value ) AS value, a
  FROM  `table`
  GROUP BY (A)) `t2`
where t1.A = t2.A
group by (t1.a)

Giving you  first the smallest value for A and then, grouping by B


text:
Q: Warning:  is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements I'm trying to automatically create React Elements from strings corresponding to the react-icons library. But I am getting the following errors in the console:

*

*Warning: <RiHeartPulseFill /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.

*Warning: The tag <RiHeartPulseFill> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.

Currently I have a data file that consists of a name and iconName (see below)
const categoriesData = [
    {
        name: 'Vitals',
        iconName: 'RiHeartPulseFill',
    },
    {
        name: 'Body',
        iconName: 'RiBodyScanFill',
    },
    {
        name: 'Sleep',
        iconName: 'RiHotelBedFill',
    },
    {
        name: 'Metabolism',
        iconName: 'RiLungsFill',
    },
    {
        name: 'Stress',
        iconName: 'RiMentalHealthFill',
    },
    {
        name: 'Strength & Training',
        iconName: 'RiRunFill',
    },
    {
        name: 'Lifestyle',
        iconName: 'RiCellphoneFill',
    },
]

export default categoriesData

I want to dynamically render React elements with the exact name as the iconName in the above datafile as React-icons require specific elements with those names.
Then I try to create a list of navigation links (using the React Router <Link> syntax and adding a React-icon + Name. See the code below:
const menuCategories = categoriesData.map((category) => {
        const IconElement = category.iconName

        return (
            <Link
                to={`/data/${category.name.toLowerCase()}`}
                key={category.name}
                className="flex flex-row items-center gap-2"
            >
                <IconElement />
                {category.name}
            </Link>
        )
    })

The issue I run into is the following error: Warning: <RiHeartPulseFill /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
I does not seems to be incorrect as it actually IS PascalCase. However when I check dev tools I see the following: <riheartpulsefill></riheartpulsefill>
I have no Idea why this happens. Any solutions?
Extra: Does anyone know how I can also import those icon names based on the initial data files. I'm thinking about creating an icon selection tool, so only the selected icons should be imported from the react-icons lib.

A: If you want to dynamically render these icon components then you'll typically need to import and specify them in the config instead of strings corresponding to their names.
Example:
import {
  RiHeartPulseFill,
  RiBodyScanFill,
  RiHotelBedFill,
  RiLungsFill,
  RiMentalHealthFill,
  RiRunFill,
  RiCellphoneFill,
} from "react-icons/ri";

const categoriesData = [
  {
    name: 'Vitals',
    iconName: RiHeartPulseFill,
  },
  {
    name: 'Body',
    iconName: RiBodyScanFill,
  },
  {
    name: 'Sleep',
    iconName: RiHotelBedFill,
  },
  {
    name: 'Metabolism',
    iconName: RiLungsFill,
  },
  {
    name: 'Stress',
    iconName: RiMentalHealthFill,
  },
  {
    name: 'Strength & Training',
    iconName: RiRunFill,
  },
  {
    name: 'Lifestyle',
    iconName: RiCellphoneFill,
  },
];

export default categoriesData;

const menuCategories = categoriesData.map((category) => {
  const IconElement = category.iconName;

  return (
    <Link
      to={`/data/${category.name.toLowerCase()}`}
      key={category.name}
      className="flex flex-row items-center gap-2"
    >
      <IconElement />
      {category.name}
    </Link>
  );
});

An alternative is to create and export a lookup object for the icon components.
import {
  RiHeartPulseFill,
  RiBodyScanFill,
  RiHotelBedFill,
  RiLungsFill,
  RiMentalHealthFill,
  RiRunFill,
  RiCellphoneFill,
} from "react-icons/ri";

export const iconMap = {
  RiHeartPulseFill,
  RiBodyScanFill,
  RiHotelBedFill,
  RiLungsFill,
  RiMentalHealthFill,
  RiRunFill,
  RiCellphoneFill,
};

const categoriesData = [
  {
    name: 'Vitals',
    iconName: 'RiHeartPulseFill',
  },
  {
    name: 'Body',
    iconName: 'RiBodyScanFill',
  },
  {
    name: 'Sleep',
    iconName: 'RiHotelBedFill',
  },
  {
    name: 'Metabolism',
    iconName: 'RiLungsFill',
  },
  {
    name: 'Stress',
    iconName: 'RiMentalHealthFill',
  },
  {
    name: 'Strength & Training',
    iconName: 'RiRunFill',
  },
  {
    name: 'Lifestyle',
    iconName: 'RiCellphoneFill',
  },
];

export default categoriesData;

const menuCategories = categoriesData.map((category) => {
  const IconElement = iconMap[category.iconName];

  return (
    <Link
      to={`/data/${category.name.toLowerCase()}`}
      key={category.name}
      className="flex flex-row items-center gap-2"
    >
      <IconElement />
      {category.name}
    </Link>
  );
});

To allow for any react-icons/ri icon then in the UI component import all of react-icons/ri and conditionally render the icon component if it exists.
import { Link } from 'react-router-dom';
import * as ReactRiIcons from "react-icons/ri"; // <-- all RI icons
import * as ReactRxIcons from "react-icons/rx"; // <-- all RX icons

const ReactIcons = { // <-- all merged icons set
  ...ReactRiIcons,
  ...ReactRxIcons
};

...

const menuCategories = categoriesData.map((category) => {
  const IconElement = ReactIcons[category.iconName];

  return (
    <Link
      to={`/data/${category.name.toLowerCase()}`}
      key={category.name}
      className="flex flex-row items-center gap-2"
    >
      {IconElement && <IconElement />} // <-- handle possible undefined icon
      {category.name}
    </Link>
  );
});

...

A: Use React.createElement. Take a look here to see how: Create react component dynamically
Heres my recursive example:
const demoData = [
{
    tagName: 'MyButtonComponent',
    children: [
        {
            tagName: 'MyChildComponent'
        }
    ]
},
{
    tagName: 'MyOtherComponent'
},
]

function recursivelyRenderChildren(elements) {
    if(elements.length) {
        return elements.map((element, index) => {
            return React.createElement(elementData.tagName, {
                key: element.fieldType+'-'+index,
                children: recursivelyRenderChildren(element.children)
            });
        })
    }
}

const arrayOfElements = recursivelyRenderChildren(demoData)


text:
Q: java.lang.NullPointerException warning after setting image resource After defining a rescource for the my imageview, a warning is then returned. What can be done to get rid of this warning?
    imageView.setImage(ImageSource.resource(R.drawable.map));

Method invocation 'imageView.setImage(ImageSource.resource(R.drawable.map))' may produce 'jave.lang.NullPointerException'

A: It's just a warning, so you can ignore it if you have no reason to think that the variables are null, but you can just assert that the variable isn't null like so to get rid of it.
assert imageView != null;
imageView.setImage(ImageSource.resource(R.drawable.map));

A: A null pointer exception on a line of the form A.B.C means that something on the left-hand side of a dot is null. In this example :
either A is null;
or A.B is null.
There can be no other reason.
From this
Also You can check this


text:
Q: Emoji Unicode in regular expression with variable number of groups I am aware that this is a corner case, but I have come across a code that uses regular expression with variable number of groups
According to docs this is legal:

The captured input associated with a
  group is always the subsequence that
  the group most recently matched. If a
  group is evaluated a second time
  because of quantification then its
  previously-captured value, if any,
  will be retained if the second
  evaluation fails. Matching the string
  "aba" against the expression (a(b)?)+,
  for example, leaves group two set to
  "b". All captured input is discarded
  at the beginning of each match.

However, when I try to use that with the unicode sign 'GRINNING FACE WITH SMILING EYES' (U+1F601) I get StringIndexOutOfBoundsException.
Is that expected according to the spec or a bug?
Here is the test code:
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestEmoji {
    public static void main(String[] args)  {
        Pattern pattern = Pattern.compile("(A.)* EEE");

        testGroups(pattern, "ACAB EEE");
        testGroups(pattern,  "ABACA\uD83D\uDE01");

    }

    public static void testGroups(Pattern pattern, String s) {
        Matcher matcher = pattern.matcher(s);
        if (matcher.matches()) {
            System.out.println("matches");
            System.out.println(matcher.groupCount());
            for (int i = 1; i <= matcher.groupCount(); ++i) {
                System.out.println(matcher.group(i));
            }
        }
    }
}

and the exception:
matches
1
AB
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -2
        at java.lang.String.charAt(String.java:658)
        at java.util.regex.Pattern$Slice.match(Pattern.java:3867)
        at java.util.regex.Pattern$GroupCurly.match0(Pattern.java:4382)
        at java.util.regex.Pattern$GroupCurly.match0(Pattern.java:4354)
        at java.util.regex.Pattern$GroupCurly.match(Pattern.java:4304)
        at java.util.regex.Matcher.match(Matcher.java:1221)
        at java.util.regex.Matcher.matches(Matcher.java:559)
        at TestEmoji.testGroups(TestEmoji.java:19)
        at TestEmoji.main(TestEmoji.java:12)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

A: After some digging in Java Bugs database, I found it:
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8007395
JDK-8007395 : StringIndexOutofBoundsException in Match.find() when input String contains surrogate UTF-16 characters