text:
Q: Ubuntu 13.10 vs 12.04 LTS I am migrating my workflow to ubuntu from windows. I have a macbook pro at home and I really enjoy being able to use the workspaces feature on ubuntu to increase my productivity. As myself being someone that isn't very familiar with doing command line things and hasn't worked with linux a whole lot other than doing basic commands like cd, ls, rm, screen, and sudo. I was wondering what you think would be the best choice for a ubuntu version. I am looking for ease of use as well as stability. I spend most of my time working with eclipse, as well as writing documents.
On a side note, right now I have a pretty high end workstation, but I am using a crappy notebook 2.5 inch 1TB hard drive for my system. Would it be worth it to switch to a top of the line SSD, or would the difference not really be noticeable? How difficult would it be for a newcommer to setup the system with the os and important folders running on a SSD and then other folders for storage running on a HD.

A: If you want stability and support you can use 12.04 LTS as it stands for Long Term Support and it'll be supported untill April 2017 nevertheless Ubuntu 13.10 not, but if you want to experience newer features and possibilities of Ubuntu then you can use 13.10 version but again you may experience some troubles with this version in work as it's not the LTS version and being improved from time to time, the next LTS stable version of Ubuntu is Upcoming in Spring 2014. How to install Ubuntu you can read over here and what partitions you'll be needed to work with over here

A: Regarding the best choice for your ubuntu version, that depends on your processor. Anything after 12.04 is much more resource intensive, but you shouldn't notice on a newer machine. That difference caused problems for me though on a five year old laptop. If your computer can handle it, get 13.10.
With a newer machine, the difference will not be huge with an SSD. SSDs do get better boot time however. Whether or not it is worth it depends on how much money you like to put into your computers (I prefer none, and will always opt for software solutions). Traditionally, no linux distro is very heavy on processing power. Personally, I would not think it worth a hardware upgrade.
It would not be too difficult, though I would do it using Mac's partition editor. NTFS support in linux is still not the best.

A: I am a power user. As a commercial artist and designer I have worked on Mac, Windows and many flavors of Linux. Currently I work with Ubuntu 12.04 and am divorcing the others. Ubu is 1000% better at working with Mac an Windows than they are at working with Linux.
Non-technical background is not a problem. The current versions of Ubu are as user friendly as any OS. It is more flexible, more beautiful, and faster than the others. If you want to do just about anything on your computer just google it and find software suggestions and installation instructions. Power-user software is free except for donating what you feel it is worth.
Problems are easier to resolve because of the communities behind them. Since it is not proprietary there are no secrets that hide solutions from the public and experts. I am considering upgrading from 12.04 to 13.10 because I have upgraded to 64-bit. It is new so 12.04 and Windows 8 are a little quirky on it. Since Ubuntu and other Linux flavors are currently ahead of MS to the point where MS has returned to "borrowing" I totally expect 13.10 to do better.
If it weren't for 64-bit I would stick with 12.04 LTS because adapting to change does slow down production. I am still keeping 12.04 on all my other machines. I hope that answers everyone's questions on upgrading professionally.


text:
Q: Error with packages that cause OSError: [WinError 193] %1 is not a valid Win32 application I'm trying to run the program main file however when installing torch and cuda there seems to be an error that pops up: "OSError: [WinError 193] %1 is not a valid Win32 application"
I have already downgraded torch, torchvision and numpy
runfile('//nsq025vs/u10/aczc973/Desktop/MScProjectConvert/main.py', wdir='//nsq025vs/u10/aczc973/Desktop/MScProjectConvert')
Traceback (most recent call last):

  File "<ipython-input-1-e4181834ff1d>", line 1, in <module>
    runfile('//nsq025vs/u10/aczc973/Desktop/MScProjectConvert/main.py', wdir='//nsq025vs/u10/aczc973/Desktop/MScProjectConvert')

  File "C:\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "//nsq025vs/u10/aczc973/Desktop/MScProjectConvert/main.py", line 4, in <module>
    import torch

  File "C:\Anaconda3\lib\site-packages\torch\__init__.py", line 42, in <module>
    import numpy as _np

  File "\\nsq025ps\p10\aczc973\AppData\Python\Python37\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init

  File "\\nsq025ps\p10\aczc973\AppData\Python\Python37\site-packages\numpy\_distributor_init.py", line 26, in <module>
    WinDLL(os.path.abspath(filename))

  File "C:\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)

OSError: [WinError 193] %1 is not a valid Win32 application

A: There is a mix between differnt python installations: C:\Anaconda3\lib\site-packages and \\nsq025ps\p10\aczc973\AppData\Python\Python37\site-packages which probably have a different 32/64bit setup. Make sure that your PYTHONPATH does not include the reference to \\nsq025ps\p10\aczc973\AppData\Python\Python37\site-packages when you are running stuff with your anaconda distribution and vice versa.
Even safer: Completely uninstall \\nsq025ps\p10\aczc973\AppData\Python\Python37, you should not need a python installation besides your anaconda

redpajama_set_name: RedPajamaStackExchange


text:
Q: Multiple AJAX requests to populate form fields? Let's say my Backbone.js-based web application has a form containing multiple drop downs, each containing a different type of data, populated via API data.
As I am using Backbone.js, my application logic lives entirely on the client side. Thus, I do not want to populate these drop downs via a typical server-side MVC approach of injecting data into the MVC view via the server side; instead, I want Backbone to retrieve data for these dropdowns.
So, my question is: To populate three different dropdowns, will I perform three different AJAX requests to my API? Example:

*

*GET /categories/

*GET /countries/

*GET /vehicle/models

Or does it make sense from a RESTful perspective to combine these into some "meta" API method?

A: I think Backbone is pretty agnostic about this. If you don't mind making three requests, it's certainly okay to do so. If you want to make one call to your API that compiles all three groups of data together and returns them, to be processed on return that is totally legitimate as well.


text:
Q: Wordpress display Catgeory Posts on Page I want to do almost exactly this: http://codex.wordpress.org/Pages#A_Page_of_Posts
But Im confused by the last line:

Save this to pageofposts.php and then assign PageofPosts as the
  Template when creating the action Page:

How do I tell Wordpress to go to index.php, (or anything else) when, for example, it receives an 'events' slug?

A: If you have followed the example in your link then you have created a file 'pageofposts.php' and uploaded it to your theme's directory.
Now when you create a new page in your wordpress admin, on the right side you will see a section for choosing the template - if you have uploaded the 'pageofposts.php' to the correct theme directory then it should appear as an option in the list of templates available for your new page.
That should help with your understanding of that last line that was confusing, however your final question about slugs requires a different answer - if you want to use a specific template for specific slugs then you'll need to look into the template hierarchy which is explained at :
http://codex.wordpress.org/Template_Hierarchy
That page also includes a diagram explaining how the templates are selected - so for example you can rename a template to match a category name or page title and it should be automatically selected when that category or page is selected :
The diagram on the link above is useful but here's another diagram to help clarify :
http://wpcandy.com/files/2008/04/wp-diagram.jpg
Anyway you probably don't need to do this, I only wrote it since you asked specifically about slugs, but you can probably just follow the first part of this answer to specify that your new page uses your new template.


text:
Q: Trouble moving Inline Javascript to the very end of my html file Is it possible to move a remote inline javascript widget to the very end of my html, and then, once the DOM is ready, inject the widget inside a specific element. I see inline javascript as a candidate for poor performance.
Thanks in advance.

A: It will depend entirely on how the widget in question is designed to be used. Looking briefly at the link you gave to TweetMeme, no, it doesn't immediately look like you can do that. But check the docs, they may well have a means of allowing you to do it. If they don't say they do, though, they're probably relying on writing to the document as it's being prepared, in which case you're out of luck.
Edit: They're using document.write, it won't work after-the-fact; see the source.


text:
Q: Is Tukey the best way to test for differences in slopes after a mixed-effect ANCOVA? I have a fairly simple fitted model that looks like:
fm <- lmer(Height~Site*HW+(1|Plot))

where Height and HW are continuous variables and Site and Plot are categorical. Site has 3 levels (A, B, C) I ran a Type II Wald Chi square and it showed that the interaction term was significant, which I am interpreting as that sites differed in their Height vs HW slopes:
> Anova(fm)
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: Height
            Chisq Df Pr(>Chisq)
Site       26.147  2    2.1e-06 ***
HW         91.089  1    < 2e-16 ***
Site:HW    13.775  2    0.00102 **

I'm interested in running a post-hoc to see which sites did and did not significantly differ in slope. I tried the following, but it doesn't look like a good match of what's going on visually when I plot the data. Is this the correct code?
leastsquare = lsmeans(fm,pairwise ~ Site:HW,adjust = "tukey")
leastsquare$contrasts

contrast     estimate     SE     df    t.ratio p.value
A - B        0.00206      0.0113 4.87  0.182   0.9819
A - C       -0.04496      0.0101 4.88 -4.438   0.0163
B - C       -0.04703      0.0113 4.87 -4.154   0.0212

So that's my first question: Is the above the correct way to test for slope differences among 3 levels of my categorical variable?
I am also interested in knowing how the means of the three site levels differ from one another (in addition to the slope question above). Can I just run a post-hoc tukey on Site? Is gives me warnings if I do this. Is there a better way to ask about main effects while taking into account the interaction?
Thank you in advance!

A: That's because the code shown compares means, not slopes. Look at the emtrends (or lstrends) function. Both are documented in the emmeans package.
emt = emtrends(fm, "Site", var = HW)
emt    # estimated slopes
pairs(emt)    # pairwise comparisons


text:
Q: Forecasting in FB Prophet by Minute I'm attempting to do minute forecasting using Prophet.  But I'm getting strange output.  Any suggestions on how to forecast by minute in Prophet or suggestions for improving my code would be very appreciated!
Data is in format for FB Prophet.
df_min.head()
    ds  y
0   2020-01-17 14:21:00     166.380
1   2020-01-17 14:22:00     166.335
2   2020-01-17 14:23:00     166.315
3   2020-01-17 14:24:00     166.320
4   2020-01-17 14:25:00     166.355

There are 100 minutes within the df_min dataframe.  Below, breaking out 30 minutes for the train_df_min dataframe...
prediction_size = 30
train_df_min = df_min[:-prediction_size]

Now attempting the forecast...
q = Prophet(daily_seasonality=True)
q.fit(train_df_min)

future2 = q.make_future_dataframe(periods=60, freq='1min')
forecast2 = q.predict(future2)
forecast2.tail()

And the chart output...

A: Convert your minute data into hour,weekly,monthly,etc.. then compare accuracy, take the frequency which is giving more accurate forecast.


text:
Q: Why test port 0x64 in a bootloader before switching into protected mode? In my MIT OS course (686) I have found some code that I don't understand. I'm trying to understand the instruction inb $0x64, %al in boot/boot.S.
My understanding is that it's reading one byte from data port 0x64 into AL, What is port 0x64? Which device or mechanism is it testing for busy? I'm confused about the comment in the code Busy? What does the comment mean and what does it refer to?
# Enable A20:
#   For fascinating historical reasons (related to the fact that
#   the earliest 8086-based PCs could only address 1MB of physical memory
#   and subsequent 80286-based PCs wanted to retain maximum compatibility),
#   physical address line 20 is tied to low when the machine boots.
#   Obviously this a bit of a drag for us, especially when trying to
#   address memory above 1MB.  This code undoes this.

seta20.1:       inb     $0x64,%al               # Get status
                testb   $0x2,%al                # Busy?
                jnz     seta20.1                # Yes
                movb    $0xd1,%al               # Command: Write
                outb    %al,$0x64               #  output port
seta20.2:       inb     $0x64,%al               # Get status
                testb   $0x2,%al                # Busy?
                jnz     seta20.2                # Yes
                movb    $0xdf,%al               # Enable
                outb    %al,$0x60               #  A20

A:
What is port 0x64?

Port 0x64 is the IO port of the keyboard controller.
Keyboard controller has two ports 0x64 and 0x60.
Port 0x64 (Command Port) is used for sending commands to keyboard controller (PS/2).
Port 0x60 (Data Port) is used for sending data to/from PS/2(Keyboard) controller or the PS/2 device itself.

Which device or mechanism is it testing for busy? I'm confused about
  the comment in the code Busy? What does the comment mean and what does
  it refer to?

The code here makes the CPU poll the PS/2 keyboard controller  to see if it is busy.
inb     $0x64,%al               # Get status

The above instruction reads the Status Register of the PS/2 controller which of 8 bits in length. Specifically it is trying to read the state of the input buffer - bit 1.
testb   $0x2,%al                # Busy?

The byte returned from the previous inb instruction is tested here. Here the status of the input buffer is checked to see if it full or empty - bit 1(0x2).
Status Register - PS/2 Controller
Bit Meaning
0   Output buffer status (0 = empty, 1 = full) (must be set before attempting to read data from IO port 0x60)

1   Input buffer status (0 = empty, 1 = full) (must be clear before attempting to write data to IO port 0x60 or IO port 0x64)

2   System Flag - Meant to be cleared on reset and set by firmware (via. PS/2 Controller Configuration Byte) if the system passes self tests (POST)

3   Command/data (0 = data written to input buffer is data for PS/2 device, 1 = data written to input buffer is data for PS/2 controller command)

4   Unknown (chipset specific) - May be "keyboard lock" (more likely unused on modern systems)

5   Unknown (chipset specific) - May be "receive time-out" or "second PS/2 port output buffer full"

6   Time-out error (0 = no error, 1 = time-out error)

7   Parity error (0 = no error, 1 = parity error)

Syntax of x86 assembly code
The above thread explains in detail about the Port 0x64 and 0x60 referred here.
Also the below link discusses in details on how the IO ports are used.
How are I/O port addresses and data sent?

A: The port 0x64 is the one used by the 8042 keyboard controller in the original IBM PS/2 system. Because 8042 is a general-purpose micro controller that can run programs and has programmable pins, the IBM engineers decided to use the extra pins for unrelated functionalities - one of the pins is used for resetting the CPU, causing it to enter the boot code.
Another function was the A20 gate - as 80286 added 4 bits into the address bus, there were some programs that were written for 8086 and expected the addresses to wrap around to 0 after 1048575 (2^20 - 1). So the IBM engineers figured out a clever solution horrible hack - they used an extra pin from the keyboard controller, that is set to 0 after boot, and added an AND gate to the address line 20 that uses the A20 address line and this line from the keyboard controller as its input - essentially the 20th bit of the CPU address bus going to the memory controller is zeroed, unless the A20 gate enable pin is enabled.
Of course if you want to actually address all of your memory, like any modern operating system would, then you need to re-enable it.
The convention is to ask the controller if it is busy, and when it is no longer busy, to send the commands to it (if you write a command to it when it is busy then all sorts of things might happen including it ignoring the command or being locked in a weird state).


text:
Q: JSONDecodeError while streaming live tweets I am using Twython to get live streaming tweets then append them to a json file. Since the tweets are sequently dumped into the json file, I am trying to separate between every object and format the file to avoid a Multiple JSON root elements error. To do so I am using the following code:
class MyStreamer(TwythonStreamer):
def on_success(self,data):

      with open('fetched_tweets.json','a') as tf:
            json.dump(data, tf)
            tf.write("\n")
            time.sleep(10)

            content = open('fetched_tweets.json', "r").read()
            n = [json.loads(str(item)) for item in content.strip().split('\n')]
            with open ('test.json', 'w') as m:
                json.dump(n,m)
            return True

def on_error(self, status):
    print (status)

My problem:
The code is giving me the following error :
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
What I don't understand:
If I run the following code separately it works fine (reformats the json data dumped into the file 'fetched_tweets.json' to a valid json file 'test.json') but gives me the error when I add it to the main script:
content = open('fetched_tweets.json', "r").read()
            n = [json.loads(str(item)) for item in content.strip().split('\n')]
            with open ('test.json', 'w') as m:
                json.dump(n,m)

What I need:
I need to run everything in the same script without giving me any errors.
NB: I am using Jupyter notebook.
EDIT: The data in the file 'fetched_tweets.json' looks like the API JSON response in this link: https://gist.github.com/hrp/900964. I am using the code below to write every tweet in a single line:
tf.write("\n")

Then using:
content = open('fetched_tweets.json', "r").read()
        n = [json.loads(str(item)) for item in content.strip().split('\n')]
        with open ('test.json', 'w') as m:
            json.dump(n,m)

To reformat the file to a valid JSON file.
Data Sample from 'fetched_tweets.json' file before applying content.strip() code :
{"created_at": "Mon Dec 17 22:38:45 +0000 2018", "id": 1074796067898748929, "id_str": "1074796067898748929", "text": "RT @robreiner: It\u2019s clear. The President is a criminal. He has committed felonies. In the United States of America no one is above the law.\u2026", "source": "Twitter Web Client", "truncated": false, "in_reply_to_status_id": null, "in_reply_to_status_id_str": null, "in_reply_to_user_id": null, "in_reply_to_user_id_str": null, "in_reply_to_screen_name": null, "user": {"id": 817409784777506816, "id_str": "817409784777506816", "name": "UNrealDonaldTrump", "screen_name": "UNreal_Donald_T", "location": "Europe", "url": null, "description": "\ud83c\uddec\ud83c\udde7Old Fernebergian. Follows NASCAR & NFL. Don't make me laugh; it hurts my back\ud83d\ude00. Ex-adman MIPA(retd). Thank gawd for KODI & a VPN.", "translator_type": "none", "protected": false, "verified": false, "followers_count": 367, "friends_count": 103, "listed_count": 12, "favourites_count": 65139, "statuses_count": 51622, "created_at": "Fri Jan 06 16:37:34 +0000 2017", "utc_offset": null, "time_zone": null, "geo_enabled": false, "lang": "en", "contributors_enabled": false, "is_translator": false, "profile_background_color": "000000", "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile": false, "profile_link_color": "000000", "profile_sidebar_border_color": "000000", "profile_sidebar_fill_color": "000000", "profile_text_color": "000000", "profile_use_background_image": false, "profile_image_url": "http://pbs.twimg.com/profile_images/1011365968805875712/Sdu90pe9_normal.jpg", "profile_image_url_https": "https://pbs.twimg.com/profile_images/1011365968805875712/Sdu90pe9_normal.jpg", "profile_banner_url": "https://pbs.twimg.com/profile_banners/817409784777506816/1494141668", "default_profile": false, "default_profile_image": false, "following": null, "follow_request_sent": null, "notifications": null}, "geo": null, "coordinates": null, "place": null, "contributors": null, "retweeted_status": {"created_at": "Mon Dec 17 15:21:01 +0000 2018", "id": 1074685908496961537, "id_str": "1074685908496961537", "text": "It\u2019s clear. The President is a criminal. He has committed felonies. In the United States of America no one is above\u2026 https://t.co/", "source": "Twitter for iPhone", "truncated": true, "in_reply_to_status_id": null, "in_reply_to_status_id_str": null, "in_reply_to_user_id": null, "in_reply_to_user_id_str": null, "in_reply_to_screen_name": null, "user": {"id": 738080573365702657, "id_str": "738080573365702657", "name": "Rob Reiner", "screen_name": "robreiner", "location": "California, USA", "url": null, "description": "Filmmaker, actor, producer, husband, and father.", "translator_type": "none", "protected": false, "verified": true, "followers_count": 539787, "friends_count": 277, "listed_count": 2709, "favourites_count": 67957, "statuses_count": 2313, "created_at": "Wed Jun 01 18:51:36 +0000 2016", "utc_offset": null, "time_zone": null, "geo_enabled": false, "lang": "en", "contributors_enabled": false, "is_translator": false, "profile_background_color": "F5F8FA", "profile_background_image_url": "", "profile_background_image_url_https": "", "profile_background_tile": false, "profile_link_color": "1DA1F2", "profile_sidebar_border_color": "C0DEED", "profile_sidebar_fill_color": "DDEEF6", "profile_text_color": "333333", "profile_use_background_image": true, "profile_image_url": "http://pbs.twimg.com/profile_images/740361916883730432/B44FKZvz_normal.jpg", "profile_image_url_https": "https://pbs.twimg.com/profile_images/740361916883730432/B44FKZvz_normal.jpg", "profile_banner_url": "https://pbs.twimg.com/profile_banners/738080573365702657/1517362906", "default_profile": true, "default_profile_image": false, "following": null, "follow_request_sent": null, "notifications": null}, "geo": null, "coordinates": null, "place": null, "contributors": null, "is_quote_status": false, "extended_tweet": {"full_text": "It\u2019s clear. The President is a criminal. He has committed felonies. In the United States of America no one is above the law. There is nothing in the Constitution that says a President can\u2019t be indicted. Donald Trump must be indicted.", "display_text_range": [0, 233], "entities": {"hashtags": [], "urls": [], "user_mentions": [], "symbols": []}}, "quote_count": 312, "reply_count": 776, "retweet_count": 7790, "favorite_count": 29009, "entities": {"hashtags": [], "urls": [{"url": "https://t.co", "expanded_url": "https://twitter.com/i/web/status/1074685908496961537", "display_url": "twitter.com/i/web/status/1\u2026", "indices": [117, 140]}], "user_mentions": [], "symbols": []}, "favorited": false, "retweeted": false, "filter_level": "low", "lang": "en"}, "is_quote_status": false, "quote_count": 0, "reply_count": 0, "retweet_count": 0, "favorite_count": 0, "entities": {"hashtags": [], "urls": [], "user_mentions": [{"screen_name": "robreiner", "name": "Rob Reiner", "id": 738080573365702657, "id_str": "738080573365702657", "indices": [3, 13]}], "symbols": []}, "favorited": false, "retweeted": false, "filter_level": "low", "lang": "en", "timestamp_ms": "1545086325989"}
{"created_at": "Mon Dec 17 22:38:46 +0000 2018", "id": 1074796068015992832, "id_str": "1074796068015992832", "text": "RT @EdKrassen: BREAKING:  Donald Trump has won the \"Golden Idiot\" award from the Heute-Show, a late-night satirical German television progr\u2026", "source": "Twitter Web Client", "truncated": false, "in_reply_to_status_id": null, "in_reply_to_status_id_str": null, "in_reply_to_user_id": null, "in_reply_to_user_id_str": null, "in_reply_to_screen_name": null, "user": {"id": 23458866, "id_str": "23458866", "name": "Prudence Cain", "screen_name": "iggasuz", "location": "Colorado", "url": null, "description": "Passionate about reading.  Folks should try it.  If salty language offends you, you might not want to follow.  Retired medical professional.  Vet.", "translator_type": "none", "protected": false, "verified": false, "followers_count": 2030, "friends_count": 4328, "listed_count": 9, "favourites_count": 77824, "statuses_count": 38918, "created_at": "Mon Mar 09 16:56:40 +0000 2009", "utc_offset": null, "time_zone": null, "geo_enabled": true, "lang": "en", "contributors_enabled": false, "is_translator": false, "profile_background_color": "642D8B", "profile_background_image_url": "http://abs.twimg.com/images/themes/theme10/bg.gif", "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme10/bg.gif", "profile_background_tile": true, "profile_link_color": "1B95E0", "profile_sidebar_border_color": "DA65AD", "profile_sidebar_fill_color": "7AC3EE", "profile_text_color": "3D1957", "profile_use_background_image": true, "profile_image_url": "http://pbs.twimg.com/profile_images/863044678832111616/E8oRd-1l_normal.jpg", "profile_image_url_https": "https://pbs.twimg.com/profile_images/863044678832111616/E8oRd-1l_normal.jpg", "profile_banner_url": "https://pbs.twimg.com/profile_banners/23458866/1541786436", "default_profile": false, "default_profile_image": false, "following": null, "follow_request_sent": null, "notifications": null}, "geo": null, "coordinates": null, "place": null, "contributors": null, "retweeted_status": {"created_at": "Mon Dec 17 22:20:00 +0000 2018", "id": 1074791346521681920, "id_str": "1074791346521681920", "text": "BREAKING:  Donald Trump has won the \"Golden Idiot\" award from the Heute-Show, a late-night satirical German televis\u2026 https://t.co", "source": "TweetDeck", "truncated": true, "in_reply_to_status_id": null, "in_reply_to_status_id_str": null, "in_reply_to_user_id": null, "in_reply_to_user_id_str": null, "in_reply_to_screen_name": null, "user": {"id": 132339474, "id_str": "132339474", "name": "Ed Krassenstein", "screen_name": "EdKrassen", "location": "Fort Myers, FL", "url": "http://edkrassenstein.com", "description": "Co-founder of @HillReporter, Author \"How the People Trumped Ronald Plump\", ed@hillreporter.com, edkrassen@protonmail.com - Twin of @Krassenstein", "translator_type": "none", "protected": false, "verified": false, "followers_count": 851760, "friends_count": 659436, "listed_count": 6654, "favourites_count": 34890, "statuses_count": 40251, "created_at": "Tue Apr 13 00:00:13 +0000 2010", "utc_offset": null, "time_zone": null, "geo_enabled": false, "lang": "en", "contributors_enabled": false, "is_translator": false, "profile_background_color": "000000", "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", "profile_background_tile": false, "profile_link_color": "229900", "profile_sidebar_border_color": "000000", "profile_sidebar_fill_color": "000000", "profile_text_color": "000000", "profile_use_background_image": false, "profile_image_url": "http://pbs.twimg.com/profile_images/1032612349633486848/t35esAW6_normal.jpg", "profile_image_url_https": "https://pbs.twimg.com/profile_images/1032612349633486848/t35esAW6_normal.jpg", "profile_banner_url": "https://pbs.twimg.com/profile_banners/132339474/1537441493", "default_profile": false, "default_profile_image": false, "following": null, "follow_request_sent": null, "notifications": null}, "geo": null, "coordinates": null, "place": null, "contributors": null, "is_quote_status": false, "extended_tweet": {"full_text": "BREAKING:  Donald Trump has won the \"Golden Idiot\" award from the Heute-Show, a late-night satirical German television program, for the 4th year in a row.\n\nCongratulations Mr. Trump.  You are the mockery of the world, again, and again, and again, and again!", "display_text_range": [0, 257], "entities": {"hashtags": [], "urls": [], "user_mentions": [], "symbols": []}}, "quote_count": 55, "reply_count": 77, "retweet_count": 455, "favorite_count": 1724, "entities": {"hashtags": [], "urls": [{"url": "https://t.co", "expanded_url": "https://twitter.com/i/web/status/1074791346521681920", "display_url": "twitter.com/i/web/status/1\u2026", "indices": [117, 140]}], "user_mentions": [], "symbols": []}, "favorited": false, "retweeted": false, "filter_level": "low", "lang": "en"}, "is_quote_status": false, "quote_count": 0, "reply_count": 0, "retweet_count": 0, "favorite_count": 0, "entities": {"hashtags": [], "urls": [], "user_mentions": [{"screen_name": "EdKrassen", "name": "Ed Krassenstein", "id": 132339474, "id_str": "132339474", "indices": [3, 13]}], "symbols": []}, "favorited": false, "retweeted": false, "filter_level": "low", "lang": "en", "timestamp_ms": "1545086326017"}

A: I was able to modify the script like this:
class MyStreamer(TwythonStreamer):
def on_success(self, data):
    if 'text' in data:

        print(data['text'])
        def on_error(self, status_code, data):
    print(status_code)
    class MyStreamer(TwythonStreamer):
def on_success(self, data):
     with open('fetched_tweets.json','a') as tf:
        json.dump(data, tf)
        tf.write("\n")

    contents = open('fetched_tweets.json', "r").read()
    data = [json.loads(str(item)) for item in contents.strip().split('\n')]
    with open ('test.json', 'w') as m:
        json.dump(data,m)

        return True
def on_error(self, status):
    print (status)
stream = MyStreamer(APP_KEY, APP_SECRET,
                OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
tweet = stream.statuses.filter(track='Keyword')


text:
Q: Excel cell reference isn't returning anything I'm trying to grab a value from a cell on Excel, when the 'value' is returned it's empty.
At first I thought it may be because the cell was a reference to another cell so I copied the cells and pasted as values to try it out but still returns nothing.
This is the code that's running
for(int i = from; i < to; i++)
{
    try
    {
        string cellVal = xlSheet.Cells[$"D{i}"].Value2;
        MessageBox.Show(cellVal, "Program", MessageBoxButtons.OK, MessageBoxIcon.Stop);
    }
    catch
    {
        MessageBox.Show("error", "Program", MessageBoxButtons.OK, MessageBoxIcon.Stop);
    }
}


text:
Q: Why can't persist data into database I am getting:

Can not set java.lang.Integer field com.springboot.Model.departmentModel.id to com.springboot.Model.departmentModel

in my Spring Boot Project trying to persist data into database...
application.properties file:
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.jsp
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost/college_management
spring.datasource.username=root
spring.datasource.password=
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
server.port=8099

departmentModel class:
package com.springboot.Model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "department_master")
public class departmentModel {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    private String depname;
    private String email;
    private String password;

    // getter and setter

}

admindao class:
package com.springboot.Dao;

import com.springboot.Model.departmentModel;

public interface adminDao {
    void insertDepartment(departmentModel dModel);

}

admindaoImpl class:
package com.springboot.Dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.springframework.stereotype.Repository;

import com.springboot.Model.departmentModel;

@Repository
public class adminDaoImpl implements adminDao {

    public void insertDepartment(departmentModel dModel) {
        Configuration con = new Configuration().configure("hibernate.cfg.xml").addAnnotatedClass(departmentModel.class);
        SessionFactory sf = con.buildSessionFactory();
        Session session = sf.openSession();
        Transaction t = session.beginTransaction();
        session.persist(dModel);
        t.commit();
        session.close();
    }

}

adminService class:
package com.springboot.Service;

import com.springboot.Model.departmentModel;

public interface adminService {
    public void insertDepartment(departmentModel dModel);
}

adminServiceImpl class:
package com.springboot.Service;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.springboot.Dao.adminDao;
import com.springboot.Model.departmentModel;

@Service
public class adminServiceImpl implements adminService {
    @Autowired
    private adminDao dao;

    @Override
    @Transactional
    public void insertDepartment(departmentModel dModel) {
        this.dao.insertDepartment(dModel);
    }

}

adminController class:
package com.springboot.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.springboot.Model.departmentModel;
import com.springboot.Service.adminService;

@Controller
public class adminController {
    @Autowired
    private adminService service;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String homepg(Model mdl, @ModelAttribute departmentModel aModel) {
        mdl.addAttribute("adminLogin", aModel);
        return "registration";
    }

    @RequestMapping(value = "/insert", method = RequestMethod.POST, headers = "Accept=application/json")
    public String insertDepartment(Model mdl, @ModelAttribute("dModel") departmentModel dModel) {
        this.service.insertDepartment(dModel);
        //mdl.addAttribute("adminLogin", dModel);
        return "redirect:/";
    }

}

registration.jsp file:
<!DOCTYPE html>

<meta charset="ISO-8859-1">
<title>College Management System</title>
<link
    href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
    rel="stylesheet">
<link th:href="@{../css/style.css}" rel="stylesheet">

REGISTRATION

                        <form th:action="@{/insert}" th:object="${adminLogin}" method="post">

                                DEPARTMENT NAME <input
                                    type="text" th:field="*{depname}" class="form-control">

                                DEPARTMENT EMAIL <input
                                    type="email" th:field="*{email}" class="form-control">

                                DEPARTMENT PASSWORD <input
                                    type="password" th:field="*{password}" class="form-control">

                                    <button type="submit" class="btn btn-outline-primary">REGISTER</button>

                        </form>

error:
Caused by: org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [private java.lang.Integer com.springboot.Model.departmentModel.id] by reflection for persistent property [com.springboot.Model.departmentModel#id] : com.springboot.Model.departmentModel@72fd9d3a
    at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:75)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:230)
    at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:5189)
    at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4889)
    at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:294)
    at org.hibernate.event.internal.EntityState.getEntityState(EntityState.java:59)
    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:95)
    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:55)
    at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:99)
    at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:720)
    at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:706)
    at com.springboot.Dao.adminDaoImpl.insertDepartment(adminDaoImpl.java:18)
    at com.springboot.Dao.adminDaoImpl$$FastClassBySpringCGLIB$$ab6f421.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
    ... 68 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Integer field com.springboot.Model.departmentModel.id to com.springboot.Model.departmentModel
    at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
    at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
    at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
    at java.base/jdk.internal.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)
    at java.base/java.lang.reflect.Field.get(Field.java:419)
    at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:71)
    ... 85 more


text:
Q: Google Cloud Kubernetes not reading application credentials correctly I'm trying to host an application using Google Kubernetes Engine. My docker image works when run locally, but when I put it on Google Cloud and set it up using a kubernetes cluster it fails in a very strange way.
I'm able to connect to the application and it works until I trigger a call of google.cloud.storage.Client(). Then it attempts to read the file I've provided through the GOOGLE_APPLICATION_CREDENTIALS environment variable and something goes wrong. I get this (truncated and redacted) traceback:
self.gcs_client = storage.Client()
  File "/usr/local/lib/python3.6/site-packages/google/cloud/storage/client.py", line 71, in __init__
    _http=_http)
  File "/usr/local/lib/python3.6/site-packages/google/cloud/client.py", line 215, in __init__
    _ClientProjectMixin.__init__(self, project=project)
  File "/usr/local/lib/python3.6/site-packages/google/cloud/client.py", line 169, in __init__
    project = self._determine_default(project)
  File "/usr/local/lib/python3.6/site-packages/google/cloud/client.py", line 182, in _determine_default
    return _determine_default_project(project)
  File "/usr/local/lib/python3.6/site-packages/google/cloud/_helpers.py", line 179, in _determine_default_project
    _, project = google.auth.default()
  File "/usr/local/lib/python3.6/site-packages/google/auth/_default.py", line 294, in default
    credentials, project_id = checker()
  File "/usr/local/lib/python3.6/site-packages/google/auth/_default.py", line 165, in _get_explicit_environ_credentials
    os.environ[environment_vars.CREDENTIALS])
  File "/usr/local/lib/python3.6/site-packages/google/auth/_default.py", line 89, in _load_credentials_from_file
    'File {} was not found.'.format(filename))
google.auth.exceptions.DefaultCredentialsError: File {--redacted--} was not found.

What I've redacted is JSON containing my service account's private key. I've checked the docker container while it's running on the cloud and GOOGLE_APPLICATION_CREDENTIALS is set to a file name as expected. Somehow when my docker container is run on the cloud, instead of using the environment variable as the file name - it uses the contents of the referenced file as the file name. This error also gets reported in the browser console, so anyone that navigates to the app can get my service account credentials.
Does anyone have any guesses about what's going wrong here?
UPDATE:
Looks like I've got it working now. My guess is the error occurred because I set GOOGLE_APPLICATION_CREDENTIALS using valueFrom as in the bokeh.yaml file. This seems to have been setting GOOGLE_APPLICATION_CREDENTIALS equal to the contents of bokeh.yaml. This format seems to work for pandas.io.gbq.read_gbq used in the tutorial code but not for instantiating google.cloud.storage.Client() like I was trying to do. Pointing GOOGLE_APPLICATION_CREDENTIALS to a volume mounted file like DazWilkin suggested and Eric Guan showed worked.

A: I noticed you didn't mention using Kubernetes Secrets. Here's how I did it.

*

*Create a Secret with kubectl on your local machine.

$ kubectl create secret generic gac-keys --from-file=<PATH_TO_SERVICE_ACCOUNT_FILE>

This creates a Secret called gac-keys. It contains your json file found at <PATH_TO_SERVICE_ACCOUNT_FILE>. If you want to rename the json file, you can do
--from-file=new-file-name.json=<PATH_TO_SERVICE_ACCOUNT_FILE>

*Configure your Deployment to use the Secret.

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: my-app
spec:
  template:
    spec:
      volumes:
      - name: google-cloud-keys
        secret:
          secretName: gac-keys
      containers:
      - name: my-app
        image: us.gcr.io/my-app
        volumeMounts:
        - name: google-cloud-keys
          mountPath: /var/secrets/google
          readOnly: true
        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /var/secrets/google/new-file-name.json

You specify a volume with an arbitrary name google-cloud-keys to be referenced later. The volume is linked to the secret. Inside the container spec, you mount the google-cloud-keys volume at path /var/secrets/google. This places your file at the path, so /var/secrets/google/new-file-name.json should exist in the container at runtime. Then you specify an env variable named GOOGLE_APPLICATION_CREDENTIALS which points to the path. Now your client library can authenticate with google.
Docs: https://kubernetes.io/docs/concepts/configuration/secret/


text:
Q: Does SQL Server 2008 express allow remote connections? I have tried to remotely connect to SQL. I put in port 1433, I restarted the service, and I don't have Windows' firewall active. However, I can only use local connection, I can't remotely connect.
I read that SQL Server 2005 Express doesn't allow remote connection, but what about 2008? Does it allow remote connections?

A: You need to setup the server to accept tcp/ip connections.
This is done through the SQL Server Configuration Manager.
Start the manager, navigate to your server node and enable TCP/IP connections on it.


text:
Q: "Invalid numeric literal" error from jq trying to modify JSON with variable I am wanting to pipe values into a bash script that will change values in a json file using jq. I've been working on this for a while now and I can't get past the first set of errors.
Here is my simple json file:
{
    "0000000": {
        "pogo": "AJHVUYKJBOIHKNNLNM"
    },
    "7000000": {
        "pogo": "PPPVUYKJBOIHKNNLNM"
    }
}

Here is my script
#!/bin/bash

#-- pass into script
pgid="${1}"
tpogo="${2}"
file="file.json"

#-- tmp files
tmp_dir="$(mktemp -d -t 'text.XXXXX' || mktemp -d 2>/dev/null)"
tmp_input1="${tmp_dir}/temp_input1.txt"

if [ ! -n "$2" ]; then
   { echo "Check your command as you are missing a variable ..."; echo "Example: script.sh "00000001" "jvkkjbkjbd" ..."; }
   exit 1;
fi

jq -r ".${pgid}.pogo = \"${tpogo}\"" "$file" > "$tmp_input1"
cat "$tmp_input1"
rm -rf "$tmp_dir"

Here are the errors:
jq: error: Invalid numeric literal at EOF at line 1, column 9 (while parsing '.0000000.') at <top-level>, line 1:
.0000000.pogo = "XXXXXXX"
jq: error: syntax error, unexpected IDENT, expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
.0000000.pogo = "XXXXXXX"
jq: 2 compile errors

I have tried so many variations from stack and most of them look similar to what I am doing now.

A: As for the immediate issue: .key works with { "foo": "value" }, but .100 doesn't work with { "100": "value" }; the syntax you're relying is sugar, only available for a limited subset of keys. .["100"] would work, but generating that by expanding shell variables into strings parsed as code is fragile (jq isn't a side-effecting language as of current releases, but in languages that do support I/O operations, such substitutions can be leveraged for injection attacks). To do things the Right Way, pass your variables out-of-band from your code, and use them for lookups in a manner that doesn't rely on what they contain.

The jq equivalent to awk's -v var="$value" is --arg var "$value", used thusly:
jq --arg pgid "$pgid" \
   --arg tpogo "$tpogo" \
   '.[$pgid].pogo = $tpogo'

Testing this with your data:
json='{"0000000":{"pogo":"AJHVUYKJBOIHKNNLNM"},"7000000":{"pogo":"PPPVUYKJBOIHKNNLNM"}}'
pgid="0000000"
tpogo="XXXXXXX"

jq --arg pgid "$pgid" --arg tpogo "$tpogo" \
   '.[$pgid].pogo = $tpogo' <<<"$json"

...emits as output:
{
  "0000000": {
    "pogo": "XXXXXXX"
  },
  "7000000": {
    "pogo": "PPPVUYKJBOIHKNNLNM"
  }
}


text:
Q: Update datatables using relation I try to update two tables using a relation and table adapters generated in dataset designer. But unable to perform child table update, it is not inserted, the problem is that during child table update the identity column value is unknown.
Table "Users" has primary key and identity column UserId. Table "UserInRoles" has column UserId and foreign key to Users.UserId. Here is my code:
usersTableAdapter.Fill(ds.Users);
userInRolesTableAdapter.Fill(this. ds.UserInRoles);
DataRow userRow = ds.Users.NewRow();
userRow["UserName"] = userName; // and fill other userRow fields.
DataRow userRoleRow = ds.UserInRoles.NewRow();
userRoleRow["RoleId"] = selectedRole; // leave unfilled column "UserId", because I thing the relational update should do it.

userRoleRow.SetParentRow(userRow, ds.Relations["FK_UserInRoles_Users"]);
ds.Users.Rows.Add(userRow);
ds.UserInRoles.Rows.Add(userRoleRow);

tableAdapterManager.UpdateAll(ds);
ds.AcceptChanges();
//usersTableAdapter.Update(ds.Users);
//userInRolesTableAdapter.Update(ds.UserInRoles);

I set both relation type, update rule: cascade, delete rule: cascade, accept rule: none. Refresh the datatable option is selected. On database the foreign key is set to cascade update too, and enforce for replication and enforce foreign key to yes.
What I am doing wrong?
I tried Users.GetChanges() after users table update, but don't get any changes. The only way it works now is to fill again users table after update. Tried update table adapters separately, but then get error violating foreign key.

A: you have missed to create a datarelation object
here how to do it:
http://msdn.microsoft.com/en-us/magazine/cc188919.aspx


text:
Q: How can I tell what phase a plugin will run in? I'm using a plugin in my pom that looks like this:
                <plugin>
                    <groupId>org.codehaus.enunciate</groupId>
                    <artifactId>maven-enunciate-plugin</artifactId>
                    <!-- check for the latest version -->
                    <version>1.27</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>docs</goal>
                            </goals>
                            <configuration>
                                <docsDir>${project.build.directory}/docs</docsDir>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

And I'm wondering, if I run package will this plugin run or is it during site or something else?  Is there an easy way to tell by looking at this, or do I have to either

*

*Read the plugin documentation

*Experiment through trial and error

I'm hoping there's an easier way.  I'm using intellij-idea, if that provides a means I'd be happy with that.  Assuming I can't tell without one of these two methods, is it a best practice to always define the phase in the pom so that I can save myself and others time in the future?

A: You can let maven print out informations regarding the plugin using mavens help plugin - for enunciate simply use the following command:
mvn help:describe -Dplugin=org.codehaus.enunciate:maven-enunciate-plugin -Ddetail
It has actually 6 goals bound to different phases - goal docs will be bound to process-sources-phase
To only extract the goal you are interested in you can furthermore use the following command:
mvn help:describe -Dmojo=docs -DgroupId=org.codehaus.enunciate -DartifactId=maven-enunciate-plugin -Ddetail
You could also omit the -Ddetail part, but it won't give you then any information on the phase it is running.


text:
Q: How to download a JAR file from a URL using Groovy? I have a JAR artifact in my nexus repository and I want to download it using Groovy script.
I tired this but it doesn't work:
new File("/dir/to/save/app.jar").withOutputStream { out ->
    new URL('http://server.org.com/nexus/repo/1.11/app.jar').eachByte { b ->
        out.write(b)
    }

But the same scripts works perfectly when I download something from Maven central repository.
What could be the issue? Is there any SSL certificate issue with my nexus that is causing the download to be broken? Because, when I use curl and download it using -k flag it downloads the file perfectly because it makes the connection insecure.
I use curl -k <NEXUS_REPO_PATH_TO_FILE> -O app.jar
If there is any SSL issue then how can I suppress it using Groovy?


text:
Q: Bash Syntax Error Python Help I am trying to learn about new functions and methods of some classes in python, however when I try to use the help() in terminal, I get this error.
morningdew72@saphira:~$ conda activate
(base) morningdew72@saphira:~$ python help(pzybar)
bash: syntax error near unexpected token `('
(base) morningdew72@saphira:~$

Am I using this command wrong?
Thanks

A: You are looking for pydoc, followed by the "thing" name. In your case, pydoc pzybar.
From man pydoc:

pydoc2.7 name  Show text documentation on something.  name may be the
  name of a Python keyword, topic, function, module, or package, or a
         dotted reference to a class or function within a module or module in a package.

You may also use pydoc3 if you have installed packages for Python3.


text:
Q: Extend NHibernate Linq Provider Might anybody provide some example in order to extend Hibernate Linq Provider for asking for whichever field [equals | lt | gt | notEquals ...] some_value. I.e:
this.session.Query<C>.Where(c => c.WhichEverField().Equals(1));

where WhichEverField() would be an extension method.
Any ideas?

A: This is a class I once wrote which allows you to use Convert.ToInt64() in a query:
public class ConvertToInt64HqlGenerator : BaseHqlGeneratorForMethod
{
    public ConvertToInt64HqlGenerator()
        : base()
    {
        this.SupportedMethods = new[] { ReflectionHelper.GetMethodDefinition(() => Convert.ToInt64("")),
                                        ReflectionHelper.GetMethodDefinition(() => Convert.ToInt64(0)),
                                        ReflectionHelper.GetMethodDefinition(() => Convert.ToInt64(0M))};
    }

    public override HqlTreeNode BuildHql(MethodInfo method,
                                            Expression targetObject,
                                            ReadOnlyCollection<Expression> arguments,
                                            HqlTreeBuilder treeBuilder,
                                            IHqlExpressionVisitor visitor)
    {
        return treeBuilder.Cast(visitor.Visit(arguments[0]).AsExpression(),typeof(Int64));
    }
}

To use it you need to create a Registry class:
public class MyLinqToHqlGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry
{
    public MyLinqToHqlGeneratorsRegistry()
        : base()
    {
        this.Merge(new ConvertToInt64HqlGenerator());
    }
}

And add it to your configuration:
Fluently.Configure().Database(msSQLconfig)
                    .ExposeConfiguration(c => c.LinqToHqlGeneratorsRegistry<MyLinqToHqlGeneratorsRegistry>())

A: You may check out among this list if any of those extensions possibilities allows you to meet your goal.
But I doubt this is doable, if I have correctly understood your question. I do not know of any db syntax handling "whichever column" semantic, so I do not see how could it be possible to convert a LINQ extension having such a semantic to a SQL query having it too (which would moreover require a HQL extension since linq-to-nhibernate works by converting the LINQ query to HQL).
If you intend to handle that semantic directly in your LINQ extension by generating a many or comparison criteria inside it, it does not look possible to me either with your proposed c.WhichEverField().Equals(1).
Not only you would then have to use something like AlexDev answer. But also you will have to do type inspection on arguments and non trivial HqlTree building inside the BuildHql method.
And then, it will fail, because at the point  where the BuildHql method would be called for your WhichEverField extension as you have defined it, you will have no idea of which comparison have to be done on your operands.
Maybe with a c.WhichEverField(SomeComparisonTypeEnum.Equal, 1) extension, you could handle that, but that will not be an easy feat anyway.
If this may help, you can find more extension examples (from me) here and by following the other links there, but none of them have the level of complexity of your demand.


text:
Q: how to set range for up and down camera mouvment I am making a game with an orthographic camera, the camera suppose to turn around the player and move up and down on mouse hold. The problem is that I can't find a way to make a range for the up and down movement, it is only supposed to go up and down for just a small angle
this is my code
void LateUpdate () {

if (Input.GetMouseButtonDown(0))
{

    RotateAroundPlayer = true;

}
else if (Input.GetMouseButtonUp(0))
{
    RotateAroundPlayer = false;
}

if (RotateAroundPlayer)
{
    Quaternion camTurnAngle =
        Quaternion.AngleAxis(Input.GetAxis("Mouse X") * RotationsSpeed, Vector3.up);
    Quaternion camUpDown =
        Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * RotationsSpeed, transform.right);

    _cameraOffset = camUpDown * camTurnAngle * _cameraOffset;

}
Vector3 newPos = PlayerTransform.position + _cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPos, SmoothFactor);

if (LookAtPlayer || RotateAroundPlayer)
    transform.LookAt(PlayerTransform);

}
I tried to add the code below but the camera win it reaches the minimum value it goes a way
    _cameraOffset.y = Mathf.Clamp(_cameraOffset.y,  minViewingAngle,maxViewingAngle);


text:
Q: os.path.join not finding file in specified directory I'm working on a game and have a function that checks for valid audio files before attempting to load them. The function looks like this:
def load_sound(name):
    class NoneSound:
        def play(self): pass
    if not pygame.mixer or not pygame.mixer.get_init():
        return NoneSound()
    fullname = os.path.join('data', name)
    try:
        sound = pygame.mixer.Sound(fullname)
    except pygame.error:
        print('Cannot load sound:', fullname)
        raise SystemExit
    return sound

The object being passed into this function is simply:
fire = load_sound("sounds/laser.wav")

The py file is in a folder that also contains a folder called data. Nested in that are several folders, one of which is "sounds". The laser.wav file is in that folder:

The function fails with an error:
Cannot load sound: data\sounds/laser.wav

Why is python adding a \ after data when it should be a /?
When I load files directly, they load fine, such as this:
music = pygame.mixer.music.load("data/music/Zone_66_Theme.ogg")

More specifically, why is the file not found?

A: So it turns out the code is good, it's the WAV file that is the issue. I converted the laser.wav into an OGG file and now the file loads fine.


text:
Q: Gmaps.js route with time I'm trying to output the route time from the location, for some reason the route never goes through.
jQuery(document).ready(function () {
    $.get('api/index.php', function(data) {
        data = JSON.parse(data);
        var map = new GMaps({
            div: '#map',
            lat: 40.715520,
            lng: -74.003409
            zoom: 10
        });
        map.getRoutes({
            origin: [40.715520, -74.003409],
            destination: [data.lat, data.lon],
            callback: function(e) {
                var time = 0;
                for (var i = 0; i < e[0].legs.length; i++) {
                    time += e[0].legs[i].duration.value;
                }
                $('.time').html(time);
            }
        });
    });
});

Am I do anything wrong?
I have tried this before and it worked fine.
Here is the api output:
{"lat":40.9238473,"lng":-73.237647}

A: Missing a comma between lng and zoom property when you create the map:
var map = new GMaps({
    div: '#map',
    lat: 40.715520,
    lng: -74.003409,
    zoom: 10
});

And you need to use the property data.lng insted of data.lon when you call the map.getRoutes method:
map.getRoutes({
            origin: [40.715520, -74.003409],
            destination: [data.lat, data.lng],
            ...
        });


text:
Q: Facing error while retrieving data from mongodb server The server starts successfully and also accepts data but when I retrieve the data I get the following error:

o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context
with path [] threw exception [Request processing failed; nested exception is
org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 2 and error
message 'Field 'locale' is invalid in: { locale: "Tax" }' on server localhost:27017; nested exception is
com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'Field 'locale' is
invalid in: { locale: "Tax" }' on server localhost:27017] with root cause
com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'Field 'locale' is
invalid in: { locale: "Tax" }' on server localhost:27017
at com.mongodb.internal.operation.FindOperation$1.call(FindOperation.java:635) ~[mongodb-driver-
core-
4.0.5.jar:na]
at com.mongodb.internal.operation.FindOperation$1.call(FindOperation.java:625) ~[mongodb-driver-core-4.0.5.jar:na]
at com.mongodb.internal.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:462) ~[mongodb-driver-core-4.0.5.jar:na]
at com.mongodb.internal.operation.FindOperation.execute(FindOperation.java:625) ~[mongodb-driver-core-4.0.5.jar:na]
at com.mongodb.internal.operation.FindOperation.execute(FindOperation.java:77) ~[mongodb-driver-core-4.0.5.jar:na]
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:190) ~[mongodb-driver-sync-4.0.5.jar:na]
at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:135) ~[mongodb-driver-sync-4.0.5.jar:na]
at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92) ~[mongodb-driver-sync-4.0.5.jar:na]
at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:2782) ~[spring-data-mongodb-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:2518) ~[spring-data-mongodb-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:2500) ~[spring-data-mongodb-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:856) ~[spring-data-mongodb-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:383) ~[spring-data-mongodb-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.findAll(SimpleMongoRepository.java:205) ~[spring-data-mongodb-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:549) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at com.sun.proxy.$Proxy58.findAll(Unknown Source) ~[na:na]
at net.example.TaxEngine.Resources.TaxController.getTaxs(TaxController.java:31) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) ~[tomcat-embed-core-9.0.37.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.37.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
at java.base/java.lang.Thread.run(Thread.java:835) ~[na:na]

Tax.java
package net.example.TaxEngine.Model;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(collation = "Tax")
public class Tax {

    @Id
    private String Name;

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        this.Name = name;
    }
}

TaxRepo.java
    package net.example.TaxEngine.Repository;
    import org.springframework.data.mongodb.repository.MongoRepository;
    import net.example.TaxEngine.Model.Tax;

    public interface TaxRepo extends MongoRepository<Tax, String> {
         public Tax findByname(String Name);
    }

Taxcontroller.java
   package net.example.TaxEngine.Resources;

   import java.util.List;

   import org.springframework.beans.factory.annotation.Autowired;
   import org.springframework.web.bind.annotation.GetMapping;
   import org.springframework.web.bind.annotation.PathVariable;
   import org.springframework.web.bind.annotation.PostMapping;
   import org.springframework.web.bind.annotation.RequestBody;
   // import org.springframework.web.bind.annotation.RequestParam;
   import org.springframework.web.bind.annotation.RestController;
   import net.example.TaxEngine.Model.Tax;
   import net.example.TaxEngine.Repository.TaxRepo;

   @RestController
   public class TaxController {

     @Autowired
    private TaxRepo Repo;

     @PostMapping("/addName")
     public String SaveName(@RequestBody Tax name) {
        Repo.save(name);

        return "Added Name:" +name.getName();
     }

     @GetMapping("/AllNames")
     public List<Tax> getTaxs(){
        return Repo.findAll();
     }

     @GetMapping("/message/[name]")
     public String getTax(@PathVariable String name) {
         return "Hello:" +Repo.findById(name);
     }
}

TaxEngineApplication.java
package net.example.TaxEngine;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class TaxEngineApplication {
    public static void main(String[] args) {
        SpringApplication.run(TaxEngineApplication.class, args);
     }
}

ApplicationProperties:
 spring.data.mongodb.uri=mongodb://localhost:27017/test

A: You have a little typo in your code:
@Document(collation = "Tax")
public class Tax {

You are using collation, you should be using collection to refer the data structure in your Mongo db.
@Document(collection = "Tax")
public class Tax {

To read about collation check the mongo official documentation


text:
Q: Passing a class to two navbars I am using two navbars. Both of them share a single class ('navbar-item'). Basically both navbars do the same things.
E.g.
navbar-1

  Services

  Delivery

  Contact

navbar-2

I am looking to add/remove another class name ('current') when clicked. I want to add this new class name ('current') to both navbars. So when "Services" is clicked, in both navbrs only the "Services" should have the class current. When "Delivery" is clicked, in both navbrs only the "Delivery" should have the class current.
I am looking for a pure js solution (no jQuery). This is what I have so far.
This passes the new class name (current) only to the first navbar.
var btns = document.getElementsByClassName("navbar-item");
for (var i = 0; i < btns.length; i++) {
  btns[i].addEventListener("click", function() {
    var current = document.getElementsByClassName("current");
    current[0].className = current[0].className.replace(" current", "");
    this.className += " current";
  });
}

A: Use document.querySelectorAll()

The Document method querySelectorAll() returns a static (not live)
  NodeList representing a list of the document's elements that match the
  specified group of selectors.

document.querySelectorAll('nav.navbar-item')
                .forEach((node) => node.className += ' current')

Here, nav.navbar-item is the selection required, and current is the new class to be appended to the nodes selected by querySelector.
Adding verbose solution:
let classToBeAdded = 'current';//new class to be added
let myNavs = document.querySelectorAll('nav.navbar-item');//Selects all navs with the given class
for(let element of myNavs) {//looping through the elements captured by the above query
    element.classList.add(classToBeAdded);//Appending new class to the element
}

A: Note:- this is the way you can detect selected div using that you can toggle(add/remove) class based on the selected element.

var div1 = document.getElementById("First");
div1.addEventListener("click", function (e) {
  if (event.currentTarget.classList.contains('active')) {
    event.currentTarget.classList.remove('active');
      var element = document.getElementById("Second");
      element.classList.add("active");
  } else {
    event.currentTarget.classList.add('active');
      var element = document.getElementById("Second");
      element.classList.remove("active");
  }
});
var div2 = document.getElementById("Second");
div2.addEventListener("click", function (e) {
  if (event.currentTarget.classList.contains('active')) {
    event.currentTarget.classList.remove('active');
    var element = document.getElementById("First");
      element.classList.add("active");
  } else {
    event.currentTarget.classList.add('active');
    var element = document.getElementById("First");
      element.classList.remove("active");
  }
});
.active{
 color:red;
}

  Delivery

    Delivery2


text:
Q: Deeper reasons why solutions to equations like $\alpha^{ax^2 + bx + c} = \beta^{dx^2 + fx + g}$ form hyperbolas? I am interested if there are any "deeper reasons" why the roots of equations of the form
$$
\alpha^{ax^2 + bx + c} = \beta^{dx^2 + fx + g}
$$
form hyperbolas on the complex plane. I've managed to prove that it is true using algebra, but want to know if there is any reason aside from a purely algebraic one that this must be true. I am comfortable with the possibility that there's no nice explanation for why and that I'm just searching for meaning where there is none, but as I've yet to study university-level mathematics I was wondering if there is some connection between the topics that I'm yet to learn about.
For some context, I recently had to solve $27^{x^2 - 5} = 9^{2x}$ and came up with the general formula for the roots:
$$
x = \frac{2}{3} \pm \frac{\sqrt{49 + \frac{6\pi i n}{\ln 3}}}{3}
$$
for any integer $n$. Out of interest I tried plotting this curve for different values of $n$ and got this shape:

This looks like a hyperbola with the two vertices centered around the two real roots, $3$ and $-5/3$! To prove this, I wrote $x = p + qi$ and then expanded the exponent like so:
$$
\begin{aligned}
27^{x^2 - 5} &= 9^{2x} \\
27^{(p + qi)^2 - 5} &= 9^{2(p + qi)} \\
27^{(p^2 - q^2) + 2pqi - 5} &= 9^{2p + 2qi} \\
e^{\ln(27) ((p^2 - q^2) + 2pqi - 5)} &= e^{\ln(9) (2p + 2qi)} \\
e^{\ln(27) ((p^2 - q^2) + 2pqi - 5) - \ln(9) (2p + 2qi)} &= 1 \\
\ln(27)((p^2 - q^2) + 2pqi - 5) - \ln(9) (2p + 2qi) &= 2\pi i n
\end{aligned}
$$
Equating real and imaginary parts gives:
$$
\ln(27)(p^2 - q^2 - 5) - 2\ln(9)p = 0 \\
2\ln(27)pqi - 2\ln(9)qi = 2\pi i n
$$
This can be further rearranged to show that all the roots lie at the intersection of one hyperbola and an infinite family of additional hyperbolas at right angles to the initial one:
$$
\left(p-\frac{2}{3}\right)^2 - q^2 = \frac{49}{9} \\
\left(p-\frac{2}{3}\right)q = \frac{\pi n}{\ln(27)}
$$
Here is a plot of the above two curves. The red hyperbola represents the first equation and the light green hyperbolas represent the infinite family specified by the second equation:

A similar argument can be made for any equation $\alpha^{ax^2 + bx + c} = \beta^{dx^2 + fx + g}$, and for the case $e^{x^2 - 1} = 1$ then the roots all lie on the unit hyperbola, $x^2 - y^2 = 1$.
Another method of proof is to show that separating the function for the roots in terms of the parameter $n$ into a function for the real and imaginary part of the $x$  satisfies the equation $\frac{(\Re(x) - j)^2}{k} - \frac{\Im(x)^2}{l} = 1$ for some arbitrary constants $j$, $k$ and $l$.
Again, my question is: are there any "deeper reasons" that this is true? Is there a connection between roots to exponential equations like this and conic sections? Or even, is there a geometrical argument that can be made here? Or is it that this algebraic relationship is the connection between the two, and that I'm looking for meaning when there actually is none.
Thanks in advance for any replies.


text:
Q: Email Settings API - How to delete Send-as alias The Google Apps Email Settings API describes creating and retrieving Send-as aliases, but not how to delete them. Is it possible to do this via the API, or is there a workaround?
I'm using the Directory API to add and delete user aliases, which takes care of whether someone can receive at an alias, but I'm stuck on how to remove their Send-as alias.

A: The ability to delete send-as aliases has been added to the API, though I haven't tested it myself  - https://developers.google.com/gmail/api/v1/reference/users/settings/sendAs/delete

A: There is no sendas delete method. Users must manually delete the sendas from the UI.

A: The Directory API has a method to "delete all aliases". Not sure if that includes "sendas" alias but might be worth checking.


text:
Q: Highchart line chart with category do not occupy full width I'm using Highchart to generate a line chart with data labels. Here is an example of what I'm doing:
Highcharts.chart('container', {
    title: {
        text: 'Chart without categories'
    },
    xAxis: {
      categories: ['a','b'],
    },
    series: [{
        data: [1,2]
    }]
});

This code generates the following chart: As you can see, there is a space between the line and and the borders of the chart.

Without using categories, there is no space:

What can I do to remove this spaces?

A: That is a default behavior of category axis type. Please check this example: http://jsfiddle.net/BlackLabel/wuqxb2cy/ with a more visible distribution into categories.
As a solution you can set xAxis.tickmarkPlacement and series.pointPlacement to 'on':
xAxis: {
    categories: [...],
    tickmarkPlacement: 'on'
},
series: [{
    data: [...],
    pointPlacement: 'on'
}]

Live demo: http://jsfiddle.net/BlackLabel/qkezc3mx/
API Refefence:
https://api.highcharts.com/highcharts/xAxis.tickmarkPlacement
https://api.highcharts.com/highcharts/series.line.pointPlacement


text:
Q: Custom headers in WordPress, are there also custom footers? I'm new to WordPress. I saw a custom header file in the inc folder of Twenty Twelve theme. I understand that we can use this custom header in any custom page template instead of header.
I have a doubt now, is there any custom footer that also can be used? Why this custom files should be stored in inc folder?

A: You can take a look at Custom Headers documentation for information about it.
There is no "custom footer" feature, well because WP only has "custom header" theme feature and it isn't named/scoped to handle arbitrary custom-something.

why this custom files should store in "inc" folder?

This is just an implementation detail of specific theme, it's not required or standardized in WordPress. inc is short for includes and is typical name for folder containing PHP files (other common folder names being php and src).


text:
Q: GetCartId() showing up in echo - but not going into database All other information is going into the database
the cart id is coming up in echo (30+ numbers)
but no matter how I configure the query it comes up as 0 in the database
echo GetCartId();

mysqli_query($con,"insert into cart(product,name,image,price,cookieId) values('limited edition','$heading','$art',60,'".GetCartId()."')");


text:
Q: Javascript singleton private function is not accessing object properties when called from another method I have a simple singleton object and am having  problems when a method calls another method that returns an object property.
var Customer = (function () {

var instance;

function init() {

    this.firstName = "";
    this.lastName = "";

    function _myGetFirstName() {
        return this.firstName;
    }

    function _myGetLastName() {
        return this.lastName;
    }

    function _myGetFullName() {
        return _myGetFirstName() + ' ' + _myGetLastName();
    }

    function _mySetFirstName(p) {
        this.firstName = p;
    }

    function _mySetLastName(p) {
        this.lastName = p;
    }

    return {

        setFirstName: _mySetFirstName,
        setLastName: _mySetLastName,
        getFirstName: _myGetFirstName,
        getLastName: _myGetLastName,
        getFullName: _myGetFullName,
    };

};

return {

    getInstance: function () {

        if (!instance) {
            instance = init();
        }

        return instance;
    }

};

})();

I'm using the object like this:
var cust = Customer.getInstance();
cust.setFirstName('FOO');
cust.setLastName('BAR');

console.log(cust.getFirstName());  // displays FOO - OK
console.log(cust.getLastName());   // displays BAR - OK
console.log(cust.getFullName());   // displays nothing

This is a pattern I've seen on the web multiple times, but I just can't get it to work.  What am I doing wrong with the "_myGetFullName" method?  When I get the individual first and last names, it works fine.  Thanks

A: The instance you return is a new Object containing a few methods known to it. The local methods are not within the scope of instance. You should call the instance methods, so:
function _myGetFullName() {
        return this.getFirstName() + ' ' + this.getLastName();
}

or call the function within the context of the current instance
  function _myGetFullName() {
      return _myGetFirstName.call(instance) + ' ' +
             _myGetLastName.call(instance);
  }

or, ofcourse
function _myGetFullName() {
        return this.firstName + ' ' + this.lastName;
}

Anyway, you code is a bit odd. You can only derive one instance of Customer. Didn't you mean something like this?


text:
Q: list iterators not compatible unordered_map I have a fairly large project that implements Dijkstra's algorithm to simulate a network sending packets I've run into an issue I have never seen before;
I have managed to narrow the problem down to this:
//Member function of vertex
unordered_map<Vertex *, int> getEdges()
{
    return _edges; //same data type as return type
}
//Call to member function
Vertex *t = //Arbitrary vertex
unordered_map<Vertex*, int> edges = t->getEdges();

For some reason on the call to this function I receive the error 'list iterators not compatible'. Does anyone understand why this is happening?
EDIT:
removed temporarily
EDIT2:
Turns out I was getting an empty unordered_map back from getEdges() due to a last minute change I made. Apparently this can cause the 'list iterators not compatible'.
For the sake of other people learning from my mistakes i'll upload the code to a more permanent location in a bit.

A: The following code works for me in NetBeans, using C++ 11. Keep in mind the values I'm using are arbitrary, and of course I've hard coded every single Vertex to return arbitrary new edges (which I assume you'd change)..
using namespace std;
struct Vertex{

    //Member function of vertex
    unordered_map<Vertex*, int> getEdges()
    {
        unordered_map<Vertex*, int> v;

        std::pair<Vertex*, int> first (new Vertex(), 0);
        std::pair<Vertex*, int> second (new Vertex(), 1);
        std::pair<Vertex*, int> third (new Vertex(), 2);
        std::pair<Vertex*, int> fourth (new Vertex(), 3);
        v.insert(first);
        v.insert(second);
        v.insert(third);
        v.insert(fourth);
        return v; //same data type as return type
    }
};

int main(int argc, char** argv)
{
    Vertex t;

    //Call to member function
    unordered_map<Vertex*, int> edges = t.getEdges();

    cout << "edges " << edges.size();

    // clean up
    edges.clear();

    return 0;
}

A: Turns out I was getting an empty unordered_map back from getEdges() due to a last minute change I made. Apparently this can cause the 'list iterators not compatible'.


text:
Q: Rails 5: Webpacker can't resolve 'vuelidate' and 'vuelidate/lib/validators' in prod I am trying to use Vuelidate in production with Webpacker for my Rails app.
Usually I just need to run the following commands for my packages.json to get built and deployed into my app:
RAILS_ENV=production bundle exec rake assets:clobber
RAILS_ENV=production bundle exec rake assets:clean
RAILS_ENV=production bundle exec rake assets:precompile

but this isn't working in prod since I added Vuelidate (works fine in dev).
Using /home/my_user/my_app/config/webpacker.yml file for setting up webpack paths
Compiling…
Compilation failed:
Hash: a535894e7898c0a336a3
Version: webpack 3.5.6
Time: 13838ms
                                       Asset       Size  Chunks             Chunk Names
             app-36e1d2de960efd5bf847.js.map    17.4 kB       2  [emitted]  app
           dashboard-9cadea07287686e15eed.js      99 kB       0  [emitted]  dashboard
                 app-36e1d2de960efd5bf847.js    1.65 kB       2  [emitted]  app
    app-4758d50be4328c1ed27fc08a09d9dae2.css  119 bytes       2  [emitted]  app
       dashboard-9cadea07287686e15eed.js.map     808 kB       0  [emitted]  dashboard
     application-06c4c55e7d8c8e2ea0de.js.map     703 kB       1  [emitted]  application
         application-06c4c55e7d8c8e2ea0de.js    83.9 kB       1  [emitted]  application
app-4758d50be4328c1ed27fc08a09d9dae2.css.map  117 bytes       2  [emitted]  app
              app-36e1d2de960efd5bf847.js.gz  843 bytes          [emitted]
      application-06c4c55e7d8c8e2ea0de.js.gz    30.5 kB          [emitted]
        dashboard-9cadea07287686e15eed.js.gz    35.4 kB          [emitted]
                               manifest.json  518 bytes          [emitted]
   [1] (webpack)/buildin/global.js 509 bytes {0} {1} [built]
   [2] ./app/javascript/packs/app.vue + 2 modules 1.65 kB {2} [built]
   [3] ./node_modules/extract-text-webpack-plugin/dist/loader.js?{"omit":1,"remove":true}!./node_modules/vue-style-loader!./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 41 bytes {2} [built]
   [5] ./app/javascript/packs/application.js 1.92 kB {1} [built]
   [6] ./app/javascript/packs/dashboard.js + 1 modules 45.1 kB {0} [built]
   [8] ./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 220 bytes [built]
    + 6 hidden modules

ERROR in ./app/javascript/packs/application.js
Module not found: Error: Can't resolve 'vuelidate' in '/home/my_user/my_app/app/javascript/packs'
 @ ./app/javascript/packs/application.js 13:0-34

ERROR in ./app/javascript/packs/dashboard.js
Module not found: Error: Can't resolve 'vuelidate' in '/home/my_user/my_app/app/javascript/packs'
 @ ./app/javascript/packs/dashboard.js 35:0-34

ERROR in ./app/javascript/packs/application.js
Module not found: Error: Can't resolve 'vuelidate/lib/validators' in '/home/my_user/my_app/app/javascript/packs'
 @ ./app/javascript/packs/application.js 14:0-59

ERROR in ./app/javascript/packs/dashboard.js
Module not found: Error: Can't resolve 'vuelidate/lib/validators' in '/home/my_user/my_app/app/javascript/packs'
 @ ./app/javascript/packs/dashboard.js 36:0-72
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js?minimize!node_modules/vue-loader/lib/style-compiler/index.js?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!node_modules/vue-loader/lib/selector.js?type=styles&index=0!app/javascript/packs/app.vue:
       [0] ./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 220 bytes {0} [built]
        + 1 hidden module

here is my package.json file:
{
  "license": "UNLICENSED",
  "dependencies": {
    "@rails/webpacker": "^3.0.1",
    "vue": "^2.4.3",
    "vue-loader": "^13.0.4",
    "vue-resource": "^1.3.4",
    "vue-template-compiler": "^2.4.3",
    "vuelidate": "^0.5.0"
  },
  "devDependencies": {
    "webpack-dev-server": "^2.8.1"
  }
}

I'm guessing the pack isn't being properly installed to /home/my_user/my_app/app/javascript/packs. Any idea how I'd fix this?
Thanks in advance!


text:
Q: Definition of "succession of central extensions of abelian groups" What is the meaning of the phrase: "A group $G$ can be realized as a succession of central extensions of abelian groups"?

A: A group $G$ is an extension of $K$ by $H$ (where $K$ and $H$ are groups) if and only if there is a normal subgroup $N\triangleleft G$ such that $N\cong K$ and $G/N\cong H$.
We summarize this by writing
$$1 \to K \to G \to H \to 1$$
and saying that the sequence is "exact" (that means that the image of each morphism indicated by an arrow is equal to the kernel of the morphism indicated by the next arrow).
We say that $G$ is a central extension of $K$ by $H$ if and only if there is a central subgroup $N\subseteq Z(G)$ (which is therefore necessarily normal) such that $N\cong K$ and $G/N\cong H$. Necessarily, $K$ must be abelian, but $H$ need not be abelian.
We say that $G$ is a **central extension of abelian groups if $G$ is a central extension of $K$ by $H$, and both $K$ and $H$ are abelian. $G$ may or may not be abelian when it is a central extension of abelian groups. For example, $C_2\otimes C_2$ is a central extension of $C_2$ by $C_2$; and the nonabelian group of order $p^3$ is a central extension of $C_p$ by $C_p\times C_p$ (and is not abelian).
The phrase you suggest is a bit odd, I think; because reading it literally, being a "succession of central extensions of abelian groups" seems to me to be exactly the same as "a central extension of abelian groups". Could you give a citation and context?


text:
Q: Error java.lang.NoClassDefFoundError when starting application in Websphere 8.5 I'm trying to build a Spring application with RAD 9.5 and deploy in Websphere 8.5. When starting application I get this problem :
problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springframework.orm.hibernate3.support.HibernateDaoSupport
Caused by: java.lang.NoClassDefFoundError: org.springframework.orm.hibernate3.support.HibernateDaoSupport
    at java.lang.ClassLoader.defineClassImpl(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:264)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:74)
    at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:853)
    at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:763)
    at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:586)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:650)

I try to find with Ctrl+Shift+T and it's reference to spring-2.0.6.jar. But I don't have any idea to fix this error.


text:
Q: Integrate Facebook messenger (not chat or facebook) I have a problem. I do a lot of collaborative work at university, and the main method of communication (and most convenient) for students use is Facebook. I would love to integrate Facebook messages with Ubuntu.
I know this is almost possible with Pidgin, but this is only really for chat, it doesn't allow me to be offline or see offline messages. It also constantly tells me people are going on and offline as I basically have every person I've ever met on there, and most of they check Facebook on an hourly basis.
I've seen android apps which have this functionality, so there must be an API for it. Is there an Ubuntu app which handles this nicely?

A: Most of these apps are using XMPP for the service, this means that they have to be online to check for new messages, XMPP supports invisible state. Default chat client for ubuntu is empath - use that instead of Pidgin, in empathy you can set your state to invisible and it wont inform you when users go online. (You can also change that in pidgin settings window.)


text:
Q: Presenting indicators and milestone labels for ui slider bar Using HTML & JavaScript
I created a slide bar which successfully responds both ways with a select option.
However i have choosen to 'hide' the select option box.  I was wondering if anyone could give me any tips on creating labels for the slider bar as the user now has no idea what they are selecting.  Examples i have found show perfect indicators, milestone numbers and floating numbers when hovering over yet everything is slide bar related and rather than labels. Help!
My JavaScript Slider Bar Code
        $(function() {
            var select = $( "#logbytes");
            var slider = $( "

").insertAfter(select).slider({
                min: 1,
                max: 6,
                step: 1,
                value: select[0].selectedIndex + 1,
                slide: function(event, ui) {
                    select[0].selectedIndex = ui.value - 1;
                }
            });

            $('#logbytes').after(slider).hide();
        });

A: The basic idea is to wrap your slider inside a wrapper div. Then to add another div inside the wrapper. Its text will be the current value of the slider.
And then the only thing left to do is to move that div around and to update it's text. It's something like:
slide: function(event, ui) {
    $( ".amount" ).text( ui.value );
    $( ".amount" ).css("margin-left",(ui.value-min)/(max-min)*100+"%");
}

Where min and max are the min and max of your slider.
See http://jsfiddle.net/WYdLF/ for an example.


text:
Q: Python3 changes function name <...> I have a pandas df where one column lists a particular func used to get the result in that line of the df.
It appears that Python changes the name of a func. if it is part of a list of functions. So Python takes the func name 'strategy0' and changes it to the less useful '<function strategy0 at 0x0000000009CCA488>' if it is part of a list of functions.
How can I either avoid Python changing the fct name alltogether or use Reg. Ex. to create a new df column 'stratname' with the proper fct. name (changing it back)?
This is my df as it looks now:
                                     Strategy Ticker         ROI
0  <function strategy0 at 0x0000000009CCA488>   nflx  142.976946
1  <function strategy0 at 0x0000000009CCA488>   lnkd   61.710992
2  <function strategy0 at 0x0000000009CCA488>    hsp    8.589611

This is how I would like it to look:
    Strategy Ticker         ROI
0  strategy0   nflx  142.976946
1  strategy0   lnkd   61.710992
2  strategy0    hsp    8.589611

This way the column info could be used directly as input for a new function.
A good friend of mine helped me to the below code. But he is not profficient in pandas, so we're kind of struggling with it.
def format(x):
    m = re.search(r'<function\s+(strategy\d+)\s+.*, x)
    return m.groups(1)

df_max_res['stratname'] = df_max_res['Strategy'].applymap(format)

This seems to look a lot like my problem, but apparantly Python3 handles this differently than P2.
Return function name in python?

A: Another solution if you like map and list
strategies = list(map(lambda x: x.__name__, strategies))

A: Apparantly it accepts f.__name__   but not f.func_name in Python3.
So my function list needs to look like this:
strategies = [strategy0.__name__, strategy1.__name__, strategy2.__name__, strategy3.__name__]

Now it works and I do'nt need to use RegEx. Phew!