I've found the remains of a doomsday-cult mass suicide. Can I do anything with their Poisoned Wine?

Question: Just south of Boston Common, I found the remains of the Boylston Social Club, hangout for Boston's wealthy and powerful. It looks like, when the bombs hit, they raised one last toast and drank themselves to death with Poisoned Wine, a half a dozen bottles of which were still left lying around the club, 200 years later, for me to, well, procure.
The stat-line in the pip boy doesn't make this Poisoned Wine seem like it's anything different from regular Wine - it has an identical statistical effect - but it does sell to a vendor for substantially more.
That's boring though. Is there anything more interesting I can do with the Poisoned Wine? If I plant it on someone, will they drink it and die? Or am I overthinking some quick caps?
Comment: Have you tried drinking it yet?
Comment: Is it still a doomsday cult if doomsday actually arrives?
Comment: You can plant live mines and it'll blow people up, so why not poisoned wine and poison people?
Comment: @Paralytic Yeah. At least on my own character, it has no effect above and beyond that of, just, y'know, Wine.
Answer: Unfortunately according to the Fallout Wiki it says:

Despite the name, the only adverse affects of drinking it is a penalty
  to Intelligence.

Reference:
http://fallout.wikia.com/wiki/Poisoned_wine
Now, I personally haven't tried this myself, but you could potentially use this in conjunction with the Junk Jet. Who said launching poison wine followed by a teddy bear can't be fun? Even though the wiki says:

All ammunition has the same damage, as even soft teddy bears do the
  same damage as items that would normally have deadly effects, like
  deathclaw hands.

I wouldn't see why you couldn't at least make some use out of it other than losing a bit of intelligence!
Comment: So the people had 1 INT and then drank it to lose that last point and their brains died.
Comment: Its a Junk Jet in fallout 4


Python Selenium: Changing from three loops to one loop repeat the same information

Question: I am extracting google reviews of a resturant. I am interested in extracting reviewer name, rating given by reviewer, and text of the review. I used following code for the extraction:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains
import time

driver = webdriver.Chrome('')
base_url = 'https://www.google.com/search?tbs=lf:1,lf_ui:9&tbm=lcl&sxsrf=AOaemvJFjYToqQmQGGnZUovsXC1CObNK1g:1633336974491&q=10+famous+restaurants+in+Dunedin&rflfq=1&num=10&sa=X&ved=2ahUKEwiTsqaxrrDzAhXe4zgGHZPODcoQjGp6BAgKEGo&biw=1280&bih=557&dpr=2#lrd=0xa82eac0dc8bdbb4b:0x4fc9070ad0f2ac70,1,,,&rlfi=hd:;si:5749134142351780976,l,CiAxMCBmYW1vdXMgcmVzdGF1cmFudHMgaW4gRHVuZWRpbiJDUjEvZ2VvL3R5cGUvZXN0YWJsaXNobWVudF9wb2kvcG9wdWxhcl93aXRoX3RvdXJpc3Rz2gENCgcI5Q8QChgFEgIIFkiDlJ7y7YCAgAhaMhAAEAEQAhgCGAQiIDEwIGZhbW91cyByZXN0YXVyYW50cyBpbiBkdW5lZGluKgQIAxACkgESaXRhbGlhbl9yZXN0YXVyYW50mgEkQ2hkRFNVaE5NRzluUzBWSlEwRm5TVU56ZW5WaFVsOUJSUkFCqgEMEAEqCCIEZm9vZCgA,y,2qOYUvKQ1C8;mv:[[-45.8349553,170.6616387],[-45.9156414,170.4803685]]'
driver.get(base_url)
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//div[./span[text()='Newest']]"))).click()

total_reviews_text =driver.find_element_by_xpath("//div[@class='review-score-container']//div//div//span//span[@class='z5jxId']").text
num_reviews = int (total_reviews_text.split()[0])

all_reviews = WebDriverWait(driver, 20).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, 'div.gws-localreviews__google-review')))
time.sleep(2)
total_reviews = len(all_reviews)

 while total_reviews < num_reviews:
        driver.execute_script('arguments[0].scrollIntoView(true);', all_reviews[-1])
        WebDriverWait(driver, 5, 0.25).until_not(EC.presence_of_element_located((By.CSS_SELECTOR, 'div[class$="activityIndicator"]')))
        #all_reviews = driver.find_elements_by_css_selector('div.gws-localreviews__google-review')
        time.sleep(5)
        all_reviews = WebDriverWait(driver, 5).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, 'div.gws-localreviews__google-review')))
        print(total_reviews)
        total_reviews +=5

person_info = driver.find_elements_by_xpath("//div[@id='reviewSort']//div[contains(@class,'google-review')]")
rating_info = driver.find_elements_by_xpath("//div[@class='PuaHbe']")
review_text = driver.find_elements_by_xpath("//div[@class='Jtu6Td']")

for person in person_info:
    name = person.find_element_by_xpath("./div/div/div/a").text
    print(name)

for rating in rating_info:
    rating_txt = person.find_element_by_xpath("./g-review-stars/span").get_attribute('aria-label')
    print(rating_txt)

for text in review_text:
    texts = text.find_element_by_xpath("./span").text
    print(texts)

The above code worked as per expectations. I want to make slight change in above code. Instead of using three loops to display name, rating, and review_text. I wanted to extract the same information using one loop. So I made following changes in the above code:
reviews_info = driver.find_elements_by_xpath("//div[@class='jxjCjc']")
for review_info in reviews_info:
    name = review_info.find_element_by_xpath("./div/div/a").text
    rating = review_info.find_element_by_xpath("//div[@class='PuaHbe']//g-review-stars//span").get_attribute('aria-label')
    text = review_info.find_element_by_xpath("//div[@class='Jtu6Td']//span").text
    print(name)
    print(rating)
    print(text)
    print()

The problem with a change in code is that it displays the same information (i.e. rating and text) for all reviewers names. I am not sure where am I making the mistake. Any help to fix the issue would be really appreciated.
Comment: Hi! Could you find a way to rephrase your problem with a [mre]? Some people might have very insightful answers for you, but they'll be put off by all the `webdriver`-related things so they won't answer. Could you find a way to rephrase the problem by focusing more on the issue (how to loop) and less on all the webdriver stuff?
Comment: You forgot current context `.` in `rating` and `text` xpath.
Answer: from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

driver = webdriver.Chrome()
base_url = 'https://www.google.com/search?tbs=lf:1,lf_ui:9&tbm=lcl&sxsrf=AOaemvJFjYToqQmQGGnZUovsXC1CObNK1g:1633336974491&q=10+famous+restaurants+in+Dunedin&rflfq=1&num=10&sa=X&ved=2ahUKEwiTsqaxrrDzAhXe4zgGHZPODcoQjGp6BAgKEGo&biw=1280&bih=557&dpr=2#lrd=0xa82eac0dc8bdbb4b:0x4fc9070ad0f2ac70,1,,,&rlfi=hd:;si:5749134142351780976,l,CiAxMCBmYW1vdXMgcmVzdGF1cmFudHMgaW4gRHVuZWRpbiJDUjEvZ2VvL3R5cGUvZXN0YWJsaXNobWVudF9wb2kvcG9wdWxhcl93aXRoX3RvdXJpc3Rz2gENCgcI5Q8QChgFEgIIFkiDlJ7y7YCAgAhaMhAAEAEQAhgCGAQiIDEwIGZhbW91cyByZXN0YXVyYW50cyBpbiBkdW5lZGluKgQIAxACkgESaXRhbGlhbl9yZXN0YXVyYW50mgEkQ2hkRFNVaE5NRzluUzBWSlEwRm5TVU56ZW5WaFVsOUJSUkFCqgEMEAEqCCIEZm9vZCgA,y,2qOYUvKQ1C8;mv:[[-45.8349553,170.6616387],[-45.9156414,170.4803685]]'
driver.get(base_url)
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//div[./span[text()='Newest']]"))).click()

total_reviews_text =driver.find_element_by_xpath("//div[@class='review-score-container']//div//div//span//span[@class='z5jxId']").text
num_reviews = int (total_reviews_text.split()[0])
print("NUm reviews=", num_reviews)

all_reviews = WebDriverWait(driver, 20).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, 'div.gws-localreviews__google-review')))
time.sleep(2)
total_reviews = len(all_reviews)
print("Total reviews=", total_reviews)
s = "(//div[@id='reviewSort']//div[contains(@class,'google-review')])[0]"
b = '0'
a = 1  # Index of Review button

for i in range(10):
    c = str(a)
    s = s.replace(b, c)  # Updating Xpath's index in every loop so that it can focus on new review everytime.
    b = str(a)
    a = a + 1
    WebDriverWait(driver, 5, 0.25).until_not(EC.presence_of_element_located((By.CSS_SELECTOR, 'div[class$="activityIndicator"]')))
    time.sleep(5)
    all_reviews = WebDriverWait(driver, 5).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, 'div.gws-localreviews__google-review')))
    total_reviews +=1
    Info = driver.find_element_by_xpath(s).text
    print(Info)
    print("<------------------------------------------------------>\n\n")

Output:-
Click Here to See Program Output
Comment: Add some description to your answer, as it's written it is difficult to read.


No route matches {:action=>"show", :controller=>"scoo.....missing required keys: [:id]

Question: I have a partial form for create and update...for the new it render the partial but when going for the edit one I keep getting this error
ActionController::UrlGenerationError in Scoopes#edit
no route matches {:action=>"show", :controller=>"scoopes", :id=>nil, :user_name=>#<Scoope id: 11, name: "asdsada", user_id: 3, created_at: "2016-08-07 20:37:52", updated_at: "2016-08-07 20:37:52">} missing required keys: [:id]

I search for an answer from old questions but no one solved my problem...the form is for creating scoopes....
the assosiaction between scoope and users is :
scoope belong_to user
and user has_many scoopes

here is my scoope controller:
class ScoopesController < ApplicationController
  before_action :authenticate_user!, except: [:show]
  before_action :set_scoope, only: [:show, :edit, :update, :destroy, :index]
  before_action :owned_scoope, only: [:edit, :update, :destroy]

  def index
    @scoopes = @user.scoopes.all
  end

  def show
    @scoope = @user.scoopes.find(params[:id])
  end

  def new
    @scoope = current_user.scoopes.build
  end

  def create
    @scoope = current_user.scoopes.build(scoope_params)
    if @scoope.save
        redirect_to scoope_path(current_user.user_name, @scoope)
    else
        render 'new'
    end
  end

  def edit
    @scoope = @user.scoopes.find(params[:id])
  end

  def update
    @scoope = @user.scoopes.find(params[:id])
    if @scoope.update(scoope_params)
        redirect_to scoope_path(@user, @scoope)
    else
        render 'edit'
    end
  end

  def destroy
    @scoope = @user.scoopes.find(params[:id])
    @scoope.destroy
    redirect_to scoopes_path
  end

  private

  def scoope_params
    params.require(:scoope).permit(:name)
  end

  def set_scoope
    @user = User.find_by(user_name: params[:user_name])
  end
  def owned_scoope
    unless @user == current_user
        flash[:danger] = "this scope dont belong to you"
        redirect_to root_path
    end
  end
end

here is my partial form(I think maybe the problem somehow related to the edit path because when I try yo replace scoope with edit_scoope_path then it render the form under the edit page..but it will not solve my whale problem because it is a partial):

    <%= render 'shared/errors', obj: @scoope %>

      <%= form_for @scoope do |f| %>

          <%= f.label :name %>

          <%= f.text_area :name, rows: 6, class: 'form-control' %>

          <%= f.submit class: 'btn btn-primary'  %> <%= link_to "Back", :back, class: "btn btn-danger" unless current_page?(scoopes_path) %>

      <% end %>

here is my routes for scoopes:
               scoopes GET    /:user_name/scoopes(.:format)               scoopes#index
                     POST   /:user_name/scoopes(.:format)               scoopes#create
          new_scoope GET    /:user_name/scoopes/new(.:format)           scoopes#new
         edit_scoope GET    /:user_name/scoopes/:id/edit(.:format)      scoopes#edit
              scoope GET    /:user_name/scoopes/:id(.:format)           scoopes#show
                     PATCH  /:user_name/scoopes/:id(.:format)           scoopes#update
                     PUT    /:user_name/scoopes/:id(.:format)           scoopes#update
                     DELETE /:user_name/scoopes/:id(.:format)           scoopes#destroy

my scoope table:
create_table "scoopes", force: :cascade do |t|
  t.string   "name"
  t.integer  "user_id"
  t.datetime "created_at", null: false
  t.datetime "updated_at", null: false
end

Routes:
devise_for :users, :controllers => { :registrations => "user/registrations" }
root "posts#index"
scope '/:user_name' do
 resources :scoopes
end
get ':user_name', to: 'profiles#show', as: :profile
get ':user_name/edit', to: 'profiles#edit', as: :edit_profile
patch ':user_name/edit', to: 'profiles#update', as: :update_profile
................

Comment: please post routes.rb
Comment: Does your console log show that an `id` is being passed when you make the edit call?
Comment: @Deepak I add routes you can see it now
Comment: @MarsAtomic If you talking about this here it is.. Parameters:

{"user_name"=>"Sam Abunu",
 "id"=>"11"}   that The id that display before the error in the log
Comment: @Tobias Thank u for the the improvment
Answer: Your call is failing because you're working with a nested route, as defined by the scoope belongs to user relationship.
In routes.rb, you can set up ReSTful routing between user and scoope like so:
resources :users do
  resources :scoopes
end

This notation should give you the nested route you need:
edit_user_scoope_path

To organize the nested object under user_name, try:
scope "/:user_name" do
  resources :posts
end

This should give you a route like this:
edit_scoope GET /:user_name/scoopes/:id/edit(.:format) scoopes#edit

Comment: ok but I want user_name instead of user_id in the routes and here it gave user_id instead
Comment: also I dont want user/:user_name/scoopes/:id...If you notice my url in routes is :user_name/scoopes/:id because the scoopes is related to user profile url ...
so for example my profile url is localhost:3000/Sam%20Abunu and if I want to check the the related scoopes I pass localhost:3000/Sam%20Abunu/scoopes but in your example it will change all my plan...!!
Comment: still this method not working...I found another method that work well without changing my routes.. I add this <%= form_for @scoope, :url => @scoope.persisted? ? scoope_path(@scoope.user.user_name, @scoope) : scoopes_path(current_user.user_name)  do |f| %>, anyway thank you for trying to help...you method give me some new things that I was not aware before...so thanks again
Comment: The second example should give you exactly what you want, so what do you mean by "this method not working?"
Comment: not worked for me and the form did not work also it gives me this two thing in the routes, 1-  user_scoopes GET    /users/:user_id/scoopes ..... 2- scoopes GET    /:user_name/scoopes ... as well as it gives me a new user routes with id which i dont want....all what I want is stay with only scope "/:user_name" do
  resources :posts
end without adding any routes and to fix the form
Comment: I see. Well, I'm glad you found something that worked for you. I would ask, however, that you clearly state all of your requirements in your questions rather than relying on readers to infer your meaning based on routes. Clarity would save everyone some time in the future.
Comment: I thought my question was clear but will ensure that it will be clearer in the fututre, T,Y ;)
Answer: Problem lies with your routes.rb file. You can add nested routes like below:
resources :users do
  resources :scoopes
end

that will output urls like below.From this output you can clearly see that the path will be user_scoope_path(current_user, @scoope) .
                                                                                scoopes#index
                                                            POST     /users/:user_id/scoopes(.:format)                                          scoopes#create
                                            new_user_scoope GET      /users/:user_id/scoopes/new(.:format)                                      scoopes#new
                                           edit_user_scoope GET      /users/:user_id/scoopes/:id/edit(.:format)                                 scoopes#edit
                                                user_scoope GET      /users/:user_id/scoopes/:id(.:format)                                      scoopes#show
                                                            PATCH    /users/:user_id/scoopes/:id(.:format)                                      scoopes#update
                                                            PUT      /users/:user_id/scoopes/:id(.:format)                                      scoopes#update
                                                            DELETE   /users/:user_id/scoopes/:id(.:format)                                      scoopes#destroy

Hope that helps.
Comment: ok but I want user_name instead of user_id in the routes and here it gave user_id instead
Comment: Ohh my bad, you can change your `routes.rb` like below:
   ` resources :users, :key => :user_name do
      resources :scoopes
    end `
and then call like `user_scoope_path(current_user.user_name, @scoope)`
Comment: I didn't test it but should work fine.Remember that in your show action you should use `@scoope = @user.scoopes.find(params[:user_name])`
Comment: still have user_id but also that not what I want...I dont want user/:user_name/scoopes/:id...If you notice my url in routes is :user_name/scoopes/:id because the scoopes is related to user profile url
Comment: so for example my profile url is http://localhost:3000/Sam%20Abunu and if I want to check the the related scoopes I pass http://localhost:3000/Sam%20Abunu/scoopes/ but in your example it will change all my plan...!!
Comment: still this method not working...I found another method that work well without changing my routes.. I add this <%= form_for @scoope, :url => @scoope.persisted? ? scoope_path(@scoope.user.user_name, @scoope) : scoopes_path(current_user.user_name)  do |f| %>, anyway thank you for trying to help...you method give me some new things that I was not aware before...so thanks again


Using angular7 how to get dataBase updated value after component call using server API

Question: After login success, I am getting data in database showing dashboard, but the scenario is I have to get updated data from the database without component reload
Comment: You need to use mechanism of web socket for example you can use Socket.io.
Comment: Do a `get` request that takes the updated value from the database, then `subscribe` to it and update your data with the data recieved from the db. Also, this question is going to be downvoted, so please attach some usefull code, thank you.
Comment: Already its working get request, but scenario is if someone update database, instantly I have to get data updated
Comment: That's not *natively* possible. You should implement some kind of websocket that keep listening for changes. Or, the worst way possible, add a setTimeout of 5 seconds that check the data and update your client data if needed.
Comment: ok than you so much
Answer: this.pollingData = Observable.interval(5000).switchMap(() => http.post('ur URL/GetMethod')).map((data) => data.json()).subscribe((data) => { this.data = data });
Comment: Hello to all, i got the solution for get updated value from database for this you have to install rxjs-compat or you can manually add your component rxjs. and alos unsubscrube this subsciption other wise it will be run on when your component close


How to check the power capabilities of a house?

Question: I'm planning a wedding, and the current plan is to have it at my fiancée's aunt's house, which has a large avocado orchard in the back.  We love the space, but it just occurred to me: I'm not entirely sure her house can handle the power drain of the DJ, lights, decorations, rented bathrooms, etc.
I have basically zero experience with this sort of thing, but I find myself needing to check the power capabilities of this house.  I have a vague notion that the information I need will be near the breaker box, but what specifically should I be looking for?  And what information (wattage, voltage, etc) will I need to get from my DJ and such, to total up and compare to the house's capability?
Comment: There's probably a main breaker in the electrical panel, on the handle there should be a number printed. That number is the maximum load in amperes that can be drawn.  Wattage = Volts x Amperes. Don't forget, you'll still have to power everything in the house, as well as all the party stuff. The DJ, lights, etc. might not require all that much power, but getting the power from the house to the party could be a challenge in itself. Which is why a generator might be a handy thing to have.
Comment: You might want to consider renting a generator, or asking the DJ if they have one that can be used.
Answer: Go to the main breaker box and find the main breaker, or "Service Disconnect". It will be separated from the other breakers, and perhaps even in a different box.

The number on the breaker, eg "100" is the max number of amps that your box is wired for (Of course, you would need to distribute your load appropriately.
Have you looked into renting a large generator for the day?
Comment: If you are in the US, Amps = Watts / 120
Comment: I would suggest asking about wattage. That would be more common for that kind of equipment.
Comment: @Nerrolken most DJs would know what they need in both watts and amps.  If not there are simple calculators online.  Its just Watts=Volts*Amps
Comment: I haven't looked into generators, but I'm beginning to suspect that I need to.  So the maximum load is measured in amps?  Is that something I can ask people, like my DJ, how much they need, or is that a less common unit than watts, etc?
Comment: Given that the **main** breaker capacity is being considered for at least part of this question, watts/240 also applies (unless it's more complicated by being 3-phase.) A 100 amp main (single phase, 240V) supplies 24000 watts.
Answer: The main breaker shows the total Amps allowable. It is usually outside by the meter or in the house inside the main panel.
Things to Consider
Under normal conditions an average home will consume between 20 - 30 amps continuously. Without physically testing with an Amp probe, there is no definite certainty of knowing what the average Amp load is.
Hypothetical
If you have 5 empty breaker spaces in the main panel you could pull 5 dedicated circuits.  3 for the DJ/band, and two for lights and other miscellaneous needs.  Each circuit would be protected by a dedicated GFCI 20 Amp breaker.
Materials

500+ feet of SJ cord #12/3 $650
5 GFCI breakers $280
Weather rated receptacles and covers $90
Labor: installation and removal. $1600
Grand Total $2680
Alternative
5 20 Amp circuits is roughly 10kW of power
As this is just a one time event, the cost of renting a 10kW generator might be the smart approach financially as well as safety is concerned. The generator should come equipped with GFCI protection too but double check before the rental is finalized.
Even with a generator, the SJ cord would still require the proper weather rated male/female terminations on each end and there is always the noise concern of the generator too.
Using #12 wire I would be hesitant of running it over 200 feet.  Each 100' interval might require a larger wire size.  For example, 300' might require #8, 400' might require #6.  I say might because basic lighting loads are not as critical/sensitive as other loads like the DJ/Band equipment were voltage quality is a concern.
Comment: Depending on how far from the building the equipment is, voltage drop on the cord could be a problem.  If power quality is a concern, you could end up needing #6 cord instead of #12.  That's the advantage of the generator, it can be closer to the party.  The disadvantage would be noise.
Comment: @Tester101 true.  In my experience with this, #12 offers pretty decent voltage quality at distances up to 200' or less.  I would be hesitant to use it on longer distances.


How to replace PostSharp Aspect with fake aspect for unit testing

Question: I have a class like the following:
[Log]
public class SomeClass
{  }

With the LogAttribute being an OnMethodBoundaryAspect from PostSharp. I would like to have all instances of LogAttribute to be swapped out for some faked/mocked version of the aspect that does nothing so that I can unit test SomeClass independently of the aspect code running. I will leave the aspect functioning normally during my integration tests.
Does anyone know how to achieve something similar to this?
Note that this project is using Moq for the unit testing and Ninject for DI outside of the unit test project.
Thanks!
Comment: possible duplicate of [How do you disable PostSharp when running unit tests?](http://stackoverflow.com/questions/14691554/how-do-you-disable-postsharp-when-running-unit-tests)
Answer: See this question How do you disable PostSharp when running unit tests?
You can tell PostSharp not to compile in the aspect for your unit-tests.
Comment: I disable PostSharp in my UnitTest project, but the project it is testing has to have it enabled. I am still getting the PostSharp aspect code running inside the project being tested, should disabling PostSharp in my UnitTest project also disable it in the project being tested?
Comment: With this approach you need to build your project under test with a special build configuration for unit testing. You can use the standard Debug configuration or create your own. You need to disable PostSharp only for this build configuration, and leave it enabled for the Release build.
Answer: If your logging aspect somewhat follows the PostSharp tutorials, then it should be writing to System.Diagnostics.Trace.
Assuming that is true, you just need to configure your DI framework to not register a TextWriter (or System Logging, or similar...) in Trace when running your tests; this lets the aspects fire and behave as they normally would at runtime, and they still write to Trace, you just don't have all the disk IO going on (because you didn't register a Stream Writer in System.Diagnostics.Trace).
I have used that successfully with my live logging aspect and not had issues with my SUTs or mocks. I also added a couple stubs with a couple simple methods, some decorated with aspects, some not. I then verified that the live aspect behaved as expected (Assert.Throws<MyWrappedException> for example). These stubs allowed me to isolate down so that the Aspect was the SUT everything else was mocked, and I could assert the aspect behaved as I expected. That was a while ago, I probably could have used Moq instead of the fakes, but there has been no reason to change that code; they help verify my aspect was thread-safe.

As another option, you can add a stub or fake that inherits from OnMethodBoundaryAspect, and have your CI register it as your Aspect at test runtime instead of your live aspect. This lets you leave the guts empty or near-empty if your live aspect isn't writing to Trace, or if you cannot exclude registering the System Logging or a TextWriter in Trace at test time. You then control the guts of the stubbed methods and decide what should be recorded in memory for later retrieval / assertion and what should just simply be ignored.
Because those methods are #protected, Moq isn't going to be happy about it; To a pure Moq'ist this can feel painful or ugly, but, in this case you're talking about only one fake class, and it will coexist nicely with your Moqs. Additionally, it lets you isolate your tests to your SUTs ignoring the aspects, so it helps narrow your tests down to the class and behavior you care about.
Store that stubbed or fake class in the same project as your tests, and then configure your DI to instantiate your stub at test runtime instead of your real aspect. PostSharp will still properly inject into your SUTs at compile-time, and asserts should still succeed if you code the stub
Comment: I am not actually trying to replace the [Log] aspect, just any PostSharp aspects in general. So I am attempting to have my DI bind my own "empty" aspect for any `OnMethodBoundary` aspects. I  need the PostSharp aspect to ideally not run any code, but if possible at least not call the RuntimeInitialize function. By injecting my overridden `OnMethodBoundaryAspect` class, the live PostSharp aspects are still running their RuntimeInitialize functions. Should injecting my `OnMethodBoundaryAspect` be forcing my empty RuntimeInitialize implementation to be getting ran?
Comment: Let me hack on it a bit over the weekend and I'll have some code snippets for you; I thought I had some already in some demo code, but no. The issue I think you're hitting is at compile-time, your live Log aspect is being used (and thus woven into your source), so runtime, it will still fire the `RuntimeInitializations` on it, not your FakeLog. Let me know if I'm off on that.
Comment: Sounds right to me, so short of getting PostSharp to be disabled, there needs to be some way to have the FakeLog woven in at compile time...
Comment: yah exactly; then you can do whatever you want with FakeLog. I've done something similar in the past, I just need to play around with it a bit to get a demo. Outside of that, you could use a mocking framework that allows runtime intercepts, like TypeMock, but I hate going to that extreme... but that would let you intercept any call to RuntimeInitialize and tell it to do nothing.
Comment: TypeMock might not be an option for the client this is for, but I will definitely look in to it.
Comment: If you want to use DI at run-time to enable/disable the aspect, then you need to create your own `OnMethodBoundaryAspect` that only delegates all calls to the real aspect provided by the DI container. This should be pretty straightforward - the methods like OnEntry, OnSuccess, etc. will just ask the container for the required instance and invoke corresponding method. More about using aspects with DI: http://doc.postsharp.net/content/consuming-dependencies


How to retrieve .length of numerous elements with a particular class using jQuery?

Question: Yo guys,
The problem is as follows: on the website I'm currently working there are numerous boxes, each of which has some little area in the corner that is supposed to count users when the website goes live. Thus, just for the test I've used a  with an id in my markup for accommodating the number:
612

with the following lines of simple jQuery:
var users = $('#usercount').text().length;

if (users >= 4) {
    $('#usercount').css('font-size','12px');
    $('#usercount').css('margin-left','7px');
}

As you see, if a number has 4 or more symbols it gets smaller and aligned properly inside this area.
But since there should be numerous boxes on the website, I've changed id="usercount" to a class="usercount" and it's not working any longer. I understand that there should be some loop for retrieving the same piece of data from every element with the class of "usercount" but I can't figure out how to put it down competently with a proper syntax. I realize it's a simple operation, but I'm new to JS and would appreciate your assistance.
Thanks a lot!
Comment: check the *.each* function of a jquery collation
Comment: Hmm. Are you looking for the number inside `usercount`, or the length of the text?
Comment: Actually, the length of the text inside that span.
Answer: You can use the filter method:
$('.usercount').filter(function() {
   return $(this).text().length >= 4;
}).css({
    'font-size': '12px',
    'margin-left': '7px'
});


Clone lttng via http

Question: I am trying to clone lttng by running the command
git clone git://git.lttng.org/lttng-modules.git

and what i get is
$ git clone git://git.lttng.org/lttng-modules.git
Cloning into 'lttng-modules'...
fatal: unable to connect to git.lttng.org:
git.lttng.org[0: 126.96.36.199]: errno=No such file or directory

I have tried to replace git:// with http:// and a username and password is requested. Could you please help me with this issue?
Thanks,
Bogdan.
Comment: It worked fine for me with `git://`. Try again or investigate why your computer cannot connect to `git.ttng.org`. It is a network issue.
Comment: i am behind a firewall which i cannot modify.
Answer: Maybe the Default-Port for the git Protocol is closed on your firewall. Try use https instead of the git protocol
git clone https://git.lttng.org/lttng-modules.git

This has given the following result to me:
$ git clone https://git.lttng.org/lttng-modules.git
Cloning into 'lttng-modules'...
remote: Counting objects: 8044, done.
remote: Compressing objects: 100% (2616/2616), done.
remote: Total 8044 (delta 5855), reused 7474 (delta 5330)
Receiving objects: 100% (8044/8044), 1.79 MiB | 0 bytes/s, done.
Resolving deltas: 100% (5855/5855), done.
Checking connectivity... done.

If still not works you have eventually a too old git version. A good idea is to use a newer portable version of git (for Windows Users for example https://sourceforge.net/projects/gitportable/)
Comment: i used http and i have to give a username and password which i dont know.
Comment: I've cloned this repository right now with this command. Everything worked. My Log:

$ git clone http://git.lttng.org/lttng-modules.git
Cloning into 'lttng-modules'...
remote: Counting objects: 8044, done.
remote: Compressing objects: 100% (2616/2616), done.
remote: Total 8044 (delta 5855), reused 7474 (delta 5330)
Receiving objects: 100% (8044/8044), 1.79 MiB | 0 bytes/s, done.
Resolving deltas: 100% (5855/5855), done.
Checking connectivity... done.
Comment: This is what i get

$ git clone http://git.lttng.org/lttng-modules.git
Cloning into 'lttng-modules'...
Username for 'http://git.lttng.org':
Comment: specify the http protocol like me in the code snippet
Comment: I did exactly like you and I have to put a username and password. I have git 1.9.5 if this helps. I cannot get Another version.
Comment: same ...

$ git clone https://git.lttng.org/lttng-modules.git
Cloning into 'lttng-modules'...
fatal: unable to access 'https://git.lttng.org/lttng-modules.git/': Failed connect to git.lttng.org:443; No error
Comment: I'm sure you find a newer, portable Version of git on the internet. check with that.

Clone lttng via http


SVG: getting rid of shape outlines using feBlend multiply blending

Question: I have an SVG where I'm using filters to blend white shapes on top of black backgrounds using multiply blending. Since I'm using multiply, I would expect the white shape not to show up at all, but this is not the case. In this example I'm drawing a square in its own filter, then a smaller circle (also in its own filter):
http://jsfiddle.net/mugwhump/SwcjL/2/
However, there is a faint, pixel-wide white outline surrounding the circle. The color and opacity of this outline depends on the color and opacity used to draw the circle.
It disappears if I move the circle into the same filter group as the square, but unfortunately that's not an option.
Any idea how to get rid of that outline? This happens in basically all browsers/renderers.
Here's the code for the svg:
<svg contentScriptType="text/ecmascript" width="530"
 xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify"
 contentStyleType="text/css" viewBox="0 0 530 530" height="530"
 preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg"
 version="1.1">

<defs id="defs">

    <filter color-interpolation-filters="sRGB" x="-1.0" y="-1.0" width="3.0"
        xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
        xlink:actuate="onLoad" height="3.0"
        xlink:show="other" id="blend-square-multiply">
        <feFlood result="blackness" flood-color="black"/>
        <feComposite result="blackness clip" in="blackness" in2="SourceGraphic" operator="in"/>
        <feColorMatrix in="SourceGraphic" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0" type="matrix" result="color-trans"/>
        <feBlend mode="multiply" in="blackness clip" in2="color-trans"/>
    </filter>
</defs>

<g filter="url(#blend-square-multiply)">
    <g fill="white" >
        <rect  x="200" width="100" y="200" height="100" />
    </g>
</g>

<g filter="url(#blend-square-multiply)">
    <g fill="white" opacity="1">
        <circle stroke-width="0" cx="250" cy="250" r="50"/>
    </g>
</g>

Answer: I think the enable-background attribute may be the answer to your problem.
http://www.w3.org/TR/SVG/filters.html#EnableBackgroundProperty
Answer: Remember that source graphics are rasterized before they're handed to the filter pipeline and hence shed their vectorish nature when they enter the threshold of filterdom.
You are getting that effect because the circle element has an edge of anti-aliasing aka semi-opaque pixels around its edges. When those are multiplied with black, you get grey.
Use shape-rendering="crispEdges" to avoid this. Or use an feMorphology erode filter to clip the edges of the antialiasing. Or use an feFuncA filter to dial those edges up to full opacity first. On second thought -- that first idea.
<circle shape-rendering="crispEdges" stroke-width="0" cx="250" cy="250" r="50"/>


How to set the width and height of a dcjs Heatmap based on the filtered group?

Question: In the sample of my code below, I want to set the width and height based on the number of values in the filtered group. Is there a best way to do this? Should I be tracking a count in the group add/remove functions?
    myHeatMap
        .width(45 * 20)
        .height(45 * 30)
        .dimension(heatDim)
        .group(heatGroup)
        .title(function (d) {
            return "Value: " + d.value;
        })
        .keyAccessor(function (d) { return d.key[0]; })
        .valueAccessor(function (d) { return d.key[1]; })
        .colorAccessor(function (d) { return d.value; })
        .colors(["#ffffd9", "#edf8b1", "#c7e9b4", "#7fcdbb", "#41b6c4", "#1d91c0", "#225ea8", "#253494", "#081d58"])
        .calculateColorDomain();

Answer: This is an interesting question. In the general case, one would want the heatmap to change size when the number of rows or columns changes.
If you're not concerned with that, I think doing a count of of the elements is about the best you can do, with d3.set one easy way to get this:
var data = heatGroup.all();
var ncols = d3.set(data.map(function(x) { return x.key[0]; })).size();
var nrows = d3.set(data.map(function(x) { return x.key[1]; })).size();

myHeatMap.width(ncols*45).height(nrows*45)

Feel free to file a feature request, or better yet, a PR, if you'd like to see the more general case. The heatmap is already doing something like this internally, although it doesn't have to compute the unique set since it relies on the ordinal scale for that.
Comment: Thanks Gordon, I may look into submitting a PR if I get some time!
Comment: Gordon, I need heatmap to be resized when the underlying data changes (e.g. filters being applied). How do I do that?
Comment: Hi @GregaKešpret, please dig into [the code](https://github.com/dc-js/dc.js/blob/develop/src/heatmap.js) and find out! I don't have time to implement this feature right now, but I'll be glad to help out if you start on it. Just go ahead and fork the repo, and if you get stuck, file an issue with your work so far, and preferably with a working example.
Comment: I figured it out already, for posterity: just put the code from this answer into ```.on('preRedraw', function(chart) { ... }``` block.
Comment: Nice, that's a lot simpler than I was expecting. Thanks for sharing!


SAML 1x vs SAML 2.0

Question: I have theoretically learned how SAML 2.0 works both in IdP initiated & SP initiated model. Can some one point me how SAML 1x works? I am not seeing any proper material about SAML 101.
And i have some basic question. What is SAML 101, SAML 1.0 & SAML 1.1? Is there any difference between these version?
Comment: http://saml.xml.org/differences-between-saml-2-0-and-1-1
Answer:
What is SAML 101, SAML 1.0 & SAML 1.1?

SAML 101 is a way of referring to introductory information about SAML. There is no actual version of SAML that is "101".
SAML 1.0 is the original SAML spec which was fairly quickly superseded by SAML 1.1. Over these two versions, input from other related standards (Shibboleth and Liberty ID-FF) were fed in so that by the time SAML 2.0 arrived on the scene it was the convergence of federation standards at the time - with the exception of WS-Federation.

Is there any difference between these versions?

Yes, there are a number of differences, here are the biggest:

SAML 101 isn't a standard :-)
SAML 1.0 is significantly less mature than SAML 1.1 or SAML 2.0
SAML 1.1 lacks a robust solution for federated single logout
SAML 2.0 is the king of the pile, most widely adopted and most complete
Answer: Maybe you can check this official tech overview document and Chapter 6 give a detail introduction about the different between SAML1 & SAML2
Comment: http://saml.xml.org/saml-2-0-enhancements

SAML 1x vs SAML 2.0


Why doesn't the author subtract everything by two first before applying modulus?

Question: This is from a youtube video on the Chinese Remainder Theorem  - https://www.youtube.com/watch?v=ru7mWZJlRQg

What the author has done thus far is basically
1.Make sure that the mods, 3, 4, 5 are relatively pairwise prime by showing that gcd(3,4) = 1, gcd(3,5) = 1 and gcd(4,5) = 1.
2.Set up a table with mod 3, mod 4, mod 5 as the columns. He multiplied one column by the other two so that when applied it's modulus, say for mod 3, mod 4 and mod 5 column values will be set to zero.
3.Here's the part that I have a question about. The author states that the first linear congruence x $\equiv$ 2(mod 3) must be satisfied and to do so, he mods all the values by 3. The only non zero value will be the value in column 1(because of the last step).

My question is by the definition of  a is congruent to b modulo m(below)

Shouldn't the author have to subtract all the values by 2 first and then mod 3, that way he get 18 mod 3, 13 mod 3, and 9 mod 3, or 0, 1, and 0? Is there a reason he doesn't have to do this? To me, this isn't consistent with the definition of congruency
Comment: Are you saying that $x=20mod3$ is the set of solutions to all three equations?
Comment: ${\rm mod}\ 3\!:\ 15\equiv 0 \equiv 12\,\Rightarrow\, n+15+12\equiv n\,$ by the Congruence Sum Rule. The point is, that by construction, all the other columns are $\equiv 0\pmod 3.\ $
Comment: Not me, its the video. What he first did to satisfy the first congruence, x ≡ 2 mod( 3) , was to apply mod 3 to all three columns. He was left with 20, 0, 0, meaning x = 20 mod (3) or x$\equiv$ 20 mod(3) which is equivalent to x $\equiv$ 2 mod (3)
Comment: @BillDubuque At the bottom of that snippet, shouldn't it be  x≡ 20 mod(3), not  x = 20 mod (3)? I don't think by definition, they mean the same thing?
Comment: $\,x\equiv 20\equiv 2\pmod3\,$ so it is a solution of the first congruence, as claimed.
Comment: @BillDubuque I get that but notation wise, the author uses x= 20 mod 3, not x$\equiv$ 20 mod (3)? The first is just a modular expression and the second would be a congruence?
Comment: @committedandroider through an abuse of notation, people often use $=$ and $\equiv$ interchangeably in casual contexts.  It is a bad habit, but so long as it is understood from context, its forgivable.
Comment: @JMoravitz Oh ok thanks for clarifying that.
Comment: @BillDubuque Because all of the numbers have the same congruence (mod 3), is that why the Congruence Sum Rule works? So 20(mod3) +15(mod3) + 12(mod3) = 2(mod3) + 0 + 0 = 2(mod 3)?
Comment: @com Your photo doesn't show $\, x = 20\ {\rm mod}\ 3.\,$ It shows $\,x\equiv 20\pmod{3},\,$ i.e. $\,3\mid x-20,\,$  To apply the Congruence Sum Rule to multiple summands you can either do one summand at a time, or prove the n-ary extension of the Sum Rule.
Answer: First that's not the only definition there is of congruence. For example you may define it as :

Two integers $a$ and $b$ are said to be congruents modulo m if the remainders of the division of $a$ and $b$ by $m$ are equal.

Which is equivalent to your definition, and for some more intuitive.
Second, notice that congruence is an equivalence relation  and also we may sum and multiply through congruence.
Third you may represent a residue class by
$$ \overline {a} = \{x \in \mathbb Z ; x \equiv a \mod m\} $$
and the basic properties of arithmetic you are used to with the integers is also valid here. With this in mind we may "apply" congruence modulo $3$ to obtain
$$\overline{x} = \overline {20 + 15 + 12} = \overline {20} + \overline {15} + \overline {12} = \overline {2} + \overline {0} + \overline {0}$$
Because according to definition we gave here $$20 = 6 \cdot 3 + \color{#f05}2\ ,\  15 = 5 \cdot 3 + \color{#f05}0\ ,\  12 = 4 \cdot 3 + \color{#f05}0\ \ \text{and}\ \  2 = 0 \cdot 3 + \color{#f05}2$$
In order words, $$ x \equiv 20 \equiv 2 \mod 3$$
Also you may notice that, of course,
$$(20 -2)  \equiv 0 \mod 3$$
Because $$18 = 6 \cdot 3 + \color{#f05} 0$$
Comment: Feel free to ask if you have any questions.
Comment: Is a residue class the same as a set? I noticed that you used set builder notation.
Comment: Yes it is, think of $\mathbb Z_2 = \{\overline{0}, \overline{1}\}$. The subset $\overline{1}$ for instance, is the one that contains all odd numbers.
Comment: SO because congruence is an equivalence relation, you are basically summing $\equiv$20mod(3) + $\equiv$15mod(3) + $\equiv$12mod(3) and getting $\equiv$2mod(3) as the final answer?
Comment: That's right!..


multi tab menu in a page using jquery

Question: I have a tab-menu and trying to use this tab-menu 2 times or more in a page.
But the tab-menu is not working well when multi use.
what do I need to fix the jquery ?
please help...

 $(document).ready(function(){

     $('ul.tabs li').click(function(){
      var tab_id = $(this).attr('data-tab');

      $('ul.tabs li').removeClass('current');
      $('.tab-content').removeClass('current');

      $(this).addClass('current');
      $("#"+tab_id).addClass('current');
     })

    })
      ul.tabs li{ padding:3px; display:inline-block }
      ul.tabs li.current{ background: #ededed; color: #222; }
      .tab-content{ display: none;    }
      .tab-content.current{ display: inherit; }

Tab One

Tab Two

 1111

 2222

Tab One

Tab Two

33

4

Comment: What is it about your provided code that isn't working correctly? What are your expected results?
Answer: The way you are using it is supposed to be one tab only because the code you shared hide all other tabs on the page when one tab is selected.
There is one way to solve it by recognizing the parent before showing or hiding tab content:

$(document).ready(function(){
  $('ul.tabs li').click(function(){
    var tab_id = $(this).attr('data-tab');
    var parent = $(this).closest('div');

    $(parent).find('li').removeClass('current');
    $(parent).find('.tab-content').removeClass('current');

    $(this).addClass('current');
    $(parent).find("#"+tab_id).addClass('current');
  })
})
ul.tabs li {
  padding: 3px;
  display: inline-block;
}

ul.tabs li.current {
  background: #ededed;
  color: #222;
}

.tab-content {
  display: none;
}

.tab-content.current {
  display: inherit;
}

Tab One

Tab Two

 1111

 2222

Tab One

Tab Two

33

4

Explanation
I added a div wrapper on each tab section. This div will be the guide for the code to act.
Once you click in a tab:

it locates the closest parent that is a div and uses it as starting point
it uses the show/hide logic only inside this div, not affecting other tabs on the page

multi tab menu in a page using jquery


Are there any advantage to having a high galactic readiness rating in multiplayer?

Question: In Singleplayer, the rating affects the outcome of the ending of the game.
However, does it make any difference in multiplayer?
Comment: In single player, it does not affect the outcome of the game at all.
Comment: @Hugo. It does. The "best" ending can only be seen when choosing the renegade option and having 5500+ effective military strength. If you don't play multiplayer at all or use none of the smartphone apps, you can only reach 4000 or something of effective military strength, as far as I'm aware (I myself played a 100% ME1 and ME2 character, completed pretty much everything of ME3 and was at about 4000).
Comment: You are wrong. I got slightly over 5500 military strengh, using a character imported from ME1->ME2. I got all three "choices" at the ending.  My guess is that you need to complete all side-quests. But I finished the single player mode a week after the game came out, and only started playing multiplayer yesterday, so rest assured, MP did *not* affect my galactic readiness.  I was actually surprised most people got only two "choices" at the end, since this was the only run I did of ME3.
Answer: Galactic Readiness has no effect on Multiplayer.
That doesn't quite cover it though; there is no Galactic Readiness in multiplayer (you earn it, but it doesn't change anything). Galactic Readiness exists solely within Single Player.
But, if you've maxed Glactic Readiness, you get an XP bonus at the end of a match instead of a readiness boost.
Answer: If you are interested in playing multiplayer it is better to keep your readiness at 100%. Because in doing so you get an extra 5% experience from every match played. But other than the bonus experience you get, it is only useful for solo play.


Disable networking driver/modules when booting from live USB

Question: I want to disable all networking related drivers and modules before I boot off a live Ubuntu USB in try mode. This includes Ethernet, WiFi, and Bluetooth.
How can this be achieved?
Comment: Short answer: It can't.
Answer: To disable networking drivers and modules before booting into live Ubuntu, you can use the "nomodprobe" and "blacklist" options when starting the live USB. The nomodprobe option prevents any kernel modules from being loaded, while the blacklist option allows you to specify specific drivers or modules that you want to prevent from loading.
Here is an example of how you can use these options when booting from a live USB:

Plug in your live Ubuntu USB and restart your computer.
When the boot menu appears, press the "e" key to edit the boot options.
Use the arrow keys to navigate to the line that starts with "linux" and add the "nomodprobe" and "blacklist" options to the end of this line, like this:

linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper nomodprobe blacklist=<DRIVER1>,<DRIVER2>,<MODULE1>,<MODULE2>

Replace <DRIVER1>, <DRIVER2>, <MODULE1>, and <MODULE2> with the names of the drivers and modules that you want to disable. For example, if you want to disable the Ethernet, WiFi, and Bluetooth drivers, you can use the following:

linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper nomodprobe blacklist=ethernet,wifi,bluetooth

Press the "Ctrl + X" keys to boot the live USB with the modified options. This will prevent the specified drivers and modules from being loaded, disabling networking on the live Ubuntu system.

Please note that the above instructions are just an example and may vary depending on your specific system and configuration. If you are not familiar with modifying boot options or are unsure about how to proceed, it is recommended to seek assistance from a more experienced user or a professional. Modifying boot options can have unintended consequences if not done properly, so proceed with caution.
Comment: This answer is WRONG and potentially harmful, as I was not able to shutdown normally and had to resort to cutting power. Unfortunately, I can't downvote or undo my upvote.


iPhone Attributed String

Question: Any ideas on how to get the functionality of an attributed string on an iPhone.
Specifically, I am writing out chemical compounds and want to properly display subscripts:  for example:
H2O   (the 2 should be a subscript)
Thanks for any suggestions
Answer: You may find it more convenient to use the Unicode characters set up for subscripts:
SUBSCRIPT TWO is U+2082: H₂0
Answer: You can use a UIWebView and HTML, or draw it yourself using the NSString + UIKit additions, or CoreGraphics.
Answer: Just posting this to help others trying to make the scientific notation work. Works for 3.2 and higher (maybe lower, just give it a shot ;))
// Property to show
NSString *formula = cellData.formula;

// Setup font
UIFont *font = [UIFont fontWithName:@"Dax-Bold" size:5];

// Draw property
UIGraphicsPushContext(context);
[formula drawAtPoint:CGPointMake(cellData.rect.origin.x + 2, cellData.rect.origin.y + 15) withFont:font];
UIGraphicsPopContext();

The drawAtPoint: uses the current context so make sure you use this method in you drawRect: method.
I had to wrap the drawAtPoint: method with two UIGraphics methods to make sure my text got rendered in a multi thread application.
Make sure that your font supports the unicode characters. If it doesn't the default font will be used. You can add missing font glyphs with a tool called FontLab.

iPhone Attributed String


Accessing Ubuntu terminal of a system outside LAN, but connected to internet

Question: I know how to access remote terminal of an Ubuntu machine from a Windows machine using PuTTY when both the machines are part of same LAN.
Is it possible to use the same method for two machines connected over the Internet?
I searched the Internet for an answer, but had less luck finding what I need.
It will be useful if someone could answer or point-out a link.
Answer: You will need to set port-forwarding on the router that connects you to the internet.
for example (choose a port number yourself):
port 10022 on the router, forwarded to port 22 of your ubuntu ip.
(I would use a port > 10000 because some providers block standard ports, and 10022 reminds me it's ssh.)
Then find out your 'internet ip', with  http://whatismyip.com
From somewhere else on the internet, then you can putty or ssh to that 'internet ip' on port 10022. What will be forwarded by your router to port 22 of your ubuntu ip.
So you will need to figure out how to configure that on your router. And have a good password, or not always leave that open ... for security reasons.
(Here port 22 is used to forward directly, what might not work or isn't advised to do so)
Comment: Depending on how complicated the network/LAN is. On a simple home network, ... this should be sufficient.
Comment: This helped.Thanks. I hope apart from router settings, other things remains the same as that of connecting machines inside the same LAN.


Is it possible to add an event listener to the small buttons in a number input box?

Question: If for example i had an input box in a shopping basket which is asking for the quantity of the product, I would like to add an event listener to the small buttons to the right of the number in the <input type=number> field which change the number accordingly and will update the price.
If this is possible an example would be great.
Thanks.
EDITED
I would also like to stay clear of jQuery please if possible
Comment: you could just use the change/input event
Comment: If your browser supports Shadow DOM, you might be able to get at the buttons. But most browsers don't. Why isn't the input's *change* event enough for you?
Comment: Honestly I hadn't heard of the change event before, but now I have learned it, it is the most suitable solution, thank you everyone!
Answer: You can use Javascript change event:
document.getElementById("product").addEventListener("change", function( event ) {
    console.log(event.target.value);
  }, false);

DEMO
Updating price which changing value of product:
document.getElementById("product").addEventListener("change", function( event ) {
    var product = parseInt(event.target.value);
    document.getElementById("price").value = product *2;
  }, false);

DEMO
Comment: +1 for this solution.
May I add that the little buttons depend only on the browser, because it's yet an HTML5 reference.
Many browsers won't show any little button whatsoever, until a potential new version that will support it.
Comment: @AlexPierstoval `input type="number"` is supported in most all modern browser. And If HTML 5 Input Types are not supported on a browser, they will behave as regular text fields. Then change event will not work, so you can use `keyup` event then.


Hot do I create a Web Site Project in Visual Studio 2015

Question: How do I create a Web Site using Visual Studio 2015? I don't see Web Site in the list of project templates.
My intention is to create a User Control that can be dynamically added to a Content Management System
Answer: There seem to be at least a couple of ways of doing this.
If you already have a project and you wish to add a website to it you can right click on the solution  in the Solution Explorer pane to bring up the context menu, then Add > New Web Site...
If you wish to create a new project and add a Web Site to it, it seems that you can create a project of most any type and add a Web Site to it using the instructions I've just provided.


Is there a way to set up a Ghost-type with Synchronize for SOS chaining?

Question: I want to SOS chain a Beldum for a shiny, but Take Down is an issue. So naturally, I want a Ghost-type so it doesn't knock itself out. The issue is that I also need it to have Synchronize so that it's likely to be Adamant on my chaining Pokémon. I don't have access to Pokémon Bank, so that's a limitation, but if it's possible to do this through Pokémon Bank, I might get it.
Answer: Yes, there is. Use the following method:

Get an Adamant Smeargle, preferably a high-level one.
Get a Staryu with Reflect Type, get a wild Smeargle to copy it, and copy it off of the Smeargle with your one.
Teach it Sketch again at the move relearner.
Get a Sylveon with Skill Swap and get a wild Smeargle to copy it, and copy it off of the Smeargle with your one.
Teach Smeargle False Swipe and a good powerful move against Beldum with the above method. Single target only, no Normal or Fighting-types.
Breed a male Reuniclus line Pokemon with Skill Swap with a female Ralts line Pokemon so you have a Ralts with Skill Swap and Synchronize, which you train up.
Get a Pokemon with Trick-or-Treat, Gourgeist probably.

Now we chain:

Trick-or-Treat Beldum with Gourgeist.
Skill Swap it Synchronize with Gardevoir.
Then you send in Smeargle who Reflects Type to become a Ghost-type then Skill Swaps to grab Synchronize.
Get Beldum to call a friend with Adrenaline Orb.
KO the Ghost-type Beldum, then chain with False swipe, switching Beldum after 15 turns each so it doesn't struggle after the 20th move

This works with Jangmo-o, Bewear and Riolu too, but they have different lengths of turns. The call rate is also different, and after a 255 long chain, there is only a 18% chance of a shiny throughout the whole thing. This is a long process, so get a lot of Leppa Berries. Synchronize still works despite swapping, but this is after 3 tests, of which an Adamant Smeargle has drawn 2 shiny Adamant Riolu.
Comment: No. The allies summoned can continue the chain. The chain ends when all opposition is gone or the pokemon can no longer call for allies.
Comment: To avoid the need to trick or treat, you can use the first move slot as a powerful ghost type move (which is good for ko'ing beldums anyway), then use conversion instead of reflect type. Then you get false swipe and skill swap. If you don't have a better item, you can even z-conversion for a power boost.
Comment: This doesn't really solve the problem of the beldums struggling after their Take Down PP runs out. Doesn't that break the chain?
Comment: I don't think a Skill Swapped Synchronize works.
Comment: Beginning testing now, a total of 5 experiments, will report back number of times an Adamant nature occours
Comment: Just a note: Ralts and Pumpkaboo can't be found in Sun/Moon, and since OP doesn't have access to Pokebank he needs to obtain them in GTS or similar.
Comment: As an aside, any friendly group online would help trade people these easy to obtain pokemon. I have these pokemon now, and the method works exceptionally well.
Answer: An easier way that would solve your problem is to just use Heal Pulse instead. The Ralts line can learn Heal Pulse and have Synchronise.
There are other ways to solve this problem involving Magic Guard, Skill Swap, and Role Play, but if your goal is to stop the wild Beldum from knocking themselves out with Take Down or Struggle recoil while keeping Synchronise on your own Pokémon, simply using Heal Pulse is your best bet.
If you also want to prevent them from struggling, bring along a Pokémon with a leppa berry, recycle, and fling. Munchlax and the elemental monkeys can learn recycle and fling by level up. Then you can just keep flinging leppa berries at the beldum to restore their PP.
Comment: Wouldn't Fling kill them?
Comment: @DanmakuGrazer True, I forgot it did damage, though it would only be 10 base power with a berry.
Comment: 0+ Atk Ralts (level 50) Fling (10 BP) vs. 0 HP / 0 Def Beldum (level 25):   10-12 (16.1 - 19.3%) -- possible 6HKO
Comment: Unfortunately Recycle doesn't work with Bestow, otherwise that would be the better option.
Answer: It's only possible through Pokebank if you have a Pokemon meeting the criteria you want in another game (compatible with PB) or in the bank itself.  You can't send yourself what you don't have.
Also I don't think Ghost types can have the Synchronize ability, and from checking online that seems to be the case.  You might be able to hack a ghost type to have that ability, but I don't have any experience of that. The only ones listed are:

Abra
Kadabra
Alakazam
Mew
Natu
Xatu
Espeon
Umbreon
Ralts
Kirlia
Gardevoir
Munna
Musharna
Elgyem
Beheeyem

Source: Bulbapedia Synchronize Ability
Comment: @Taacoo That will force the beldum to struggle and thus KO itself even faster.
Comment: Yes, but I was thinking along the lines of using something like camouflage to change types to ghost on syncronize pokemon or using ability moving tricks to change a ghost's ability to synchronize
Comment: @ThatOneRandomScrub The move "Trick or Treat" adds ghost typing. but only Puckaboo gets that move. Something that might be a lot easier is using Disable


How to create an "impact grenade" in Minecraft 1.13?

Question: I am trying to make an "impact grenade" command in Minecraft 1.13. I am trying to get it to work so that when an egg hits blocks or entities, a creeper will be summoned. I originally used the following command set up in 1.12 and tried to update it to current, 1.13:

Always active, repeat: /execute at @e[type=egg] run kill
  @e[tag=tracker,distance=2]
Chain unconditional: /execute at @e[tag=tracker] run summon creeper ~
  ~ ~ {Silent:1b,Invulnerable:1b,CustomNameVisible:0b,Fuse:1,ignited:1b}
Chain unconditional: /kill @e[tag=tracker]
Chain unconditional: /execute at @e[type=egg] run summon
  area_effect_cloud ~ ~ ~
  {Particle:"ambient_entity_effect",Duration:2,Tags:["tracker"]}

Instead, all that happens is the creepers are summoned constantly at the egg. Any help on this subject would be great!
Answer: You're in luck, because I have a function that does exactly this. I'll explain what it does then give you the commands. I'm not sure eggs are a good idea, though, because there is a chance a baby chicken could spawn.
First, a scoreboard objective is created that tracks players who have thrown eggs. Players who have thrown an egg and have held an egg (determined by tag commands at the end of the function) summons an armor stand at the closest egg without a certain tag, then tags the egg so it doesn't happen again. The armor stand is constantly teleported to the closest egg, but when it does not detect a nearby egg then it is tagged. You can then execute all armor stands who have that tag to summon creepers or whatever you want to happen, then kill the armor stand.
This is the function. I converted it into 1.13 because it was originally in 1.12, and I changed it from snowballs to eggs (named "Grenade"). Because of lack of time I haven't tested it, but I see no reason why it shouldn't work. If it doesn't work, just let me know.
<code>scoreboard objectives add grenade minecraft.used:minecraft.egg
execute as @a[scores={grenade=1..},tag=grenade] at @e[sort=nearest,limit=1,type=egg,tag=!grenade] run summon armor_stand ~ ~ ~ {Small:1b,NoGravity:1b,CustomName:"\"grenade\"",Marker:1b,Invisible:1b}
execute as @e[type=egg,tag=grenade] at @s run tp @e[type=armor_stand,name=grenade,limit=1,sort=nearest,distance=..2] @s
tag @e[type=armor_stand,name=grenade] add boom
execute as @e[type=egg,tag=grenade] at @s run tag @e[type=armor_stand,name=grenade,limit=1,sort=nearest] remove boom
execute as @e[type=armor_stand,tag=boom] at @s run summon creeper ~ ~ ~ {Fuse:0.0b,CustomName:"\"a grenade\""}
kill @e[type=armor_stand,tag=boom]
scoreboard players reset @a grenade
tag @a remove grenade
tag @a[nbt={SelectedItem:{id:"minecraft:egg",tag:{display:{Name:"\"Grenade\""}}}}] add grenade
</code>
Comment: I typed the first command (scoreboard objectives add grenade minecraft.used:minecraft.egg) in chat, then I put the second command, (execute as @a[scores={grenade=1..},tag=grenade] at @e[sort=nearest,limit=1,type=egg,tag=!grenade] run summon armor_stand ~ ~ ~ {Small:1b,NoGravity:1b,CustomName:"\"grenade\"",Marker:1b,Invisible:1b}) in a repeating, always active command block. The remaining commands I put in chain, always active, unconditional command blocks connecting to the repeating one. For some reason, nothing happened when I threw an egg.
Comment: @user212269 Is the egg named "Grenade"? To make the grenades work with any eggs, replace the last command with: tag @a[nbt={SelectedItem:{id:"minecraft:egg"}}] add grenade
Comment: Ok, well I fixed that issue. However, a single creeper spawns as soon as the egg is thrown.
Comment: Could we replace the creeper with a TNT?


Player and Monster miss together in my game

Question: In my C# game TextQuest, The fighting system is in progress now and I ran into a problem.
If the player misses the Monster misses too (always at the same time). Here is the used code:
private void button1_Click(object sender, EventArgs e)
    {
        Monster_Class mc = new Monster_Class();
        Account_Class ac = new Account_Class();
        if (hitOrMiss())
        {
            int hit = -1;
            hit = mc.hitAmount(ac.getAtk(Properties.Settings.Default.CurrentUser), mc.getDef(monster));
            mhealth -= hit;
            if (hit == -1)
            {
                setText("You missed.");
            }
            else
            {
                setText("You hit " + hit + ".");
            }
            monsterHit();
            update();
        }
        else
        {
            setText("You missed.");
            monsterHit();
        }
    }

private void monsterHit()
{
    Monster_Class mc = new Monster_Class();
    Account_Class ac = new Account_Class();
    if (hitOrMiss())
    {
        int hit = -1;
        hit = mc.hitAmount(mc.getAtk(monster), ac.getDef(Properties.Settings.Default.CurrentUser));
        phealth -= hit;
        if (hit == -1)
        {
            addText(monster + " missed.");
        }
        else
        {
            addText(monster + " hit " + hit + ".");
        }
    }
    else
    {
        addText(monster + " missed.");
    }
}

private bool hitOrMiss()
{
    bool hit = true;
    Random rand = new Random();
    if (rand.Next(101) < 15)
    {
        hit = false;
    }
    return hit;
}

public int hitAmount(int Atk, int Def)
{
    int hit = -1;
    Random rand = new Random();
    int deturm = rand.Next(6);
    try
    {
        hit = ((Atk + deturm * 3) / Def + 1) / 2;
        if (hit == 0)
        {
            hit = 1;
        }
    }
    catch { }
    return hit;
}

Also if you have a better Idea for the amount of damage done please let me know. since I just kinda threw numbers and symbols together
Comment: They always miss at the same time. If the player misses the monster shouldn't always miss too. and if the player hits the monster should still be able to miss
Comment: Kind of unrelated to the question but... that `try` block is bad. The only exception that can come out of that is a divide by zero error, and you can check that with an `if` statement (`if (Def == 0) return -1;`) - *if* you didn't mean for the `+1` to be applied before the `/` (and assuming `Def` is >= 0). If that you did, you need brackets around it.
Comment: I had it there because I was changing the math around trying to find something that worked and I plan on changing it some more later so I left it there for now
Answer: You don't want to create a new Random object every time you need a random number. Otherwise I suspect you will get always the same number! Define a global Random object once and use it in every request for random numbers.
Comment: Thank you very much I didn't even think of trying that.
Answer: Just as a side hint I would change the design a little bit, something like:
bool hitOrMiss(Entity attacker, Entity defender)
{
  // do your calcs
}

int doAttack(Entity attacker, Entity defender)
{
  if (hitOrMiss(attacker, defender)) {
    // calculate damage
    return dmg;
  }
  else
    return 0;
}

private void attachPhase(object sender, EventArgs e)
{
  Player player = ...
  Monster monster = ...

  int playerDmg = doAttack(player, monster);
  int monsterDmg = doAttack(monster, player);

  if (playerDmg > 0) {

  }

  if (monsterDmg > 0) {

  }
}


Puzzle: Cumulative Sum Divisible by 10

Question: If we sum the first $4$ positive integers, we get $4 + 3 + 2 + 1 = 10$, which I think is pretty cool.
I'm interested in seeing solutions to the following puzzle:  If we take the cumulative sum of the first $N$ positive integers, how many times along the way will the sum be divisible by $10$?
In other words, define:
$$f(N) = \left|\left\{n \leq N \;:\; \sum_{i=1}^n i = \frac{n(n+1)}{2} \text{ is divisible by $10$}\right\} \right|$$
Is there a nice expression for $f(N)$?
Comment: I think this is a great question!
Answer: You need $20$ to divide $n(n+1)$. Note $n$ and $n+1$ are of opposite parity. Hence, $4$ divides either $n$ or $n+1$. $5$ divides either $n$ or $n+1$ since $5$ is a prime.
Hence, we have $4$ cases which gives us as discussed below.
$1$. $4|n$ and $5|n$. This case is trivial. Since $(4,5)=1$, we get that $20|n$ and hence $n \equiv 0\bmod 20$.
$2$. $4|n$ and $5|(n+1)$. This means that $n = 4k_4$ and $n+1 = 5k_5$. Hence, we get that $5k_5 - 4k_4 = 1$.
Solving such general congruence fall under the Chinese remainder theorem, as TMM points out in the comments, and is certainly something which you should look at. In this case, we solve it as follows. Clearly, $(k_4,k_5) = (1,1)$ is a solution. In general, if $ax+by$ has integer solutions and $(x_0,y_0)$ is one such integer solution, then all integer solutions are given by $$(x,y) = \displaystyle \left( x_0 + k \frac{\text{lcm}[\lvert a \rvert,\lvert b \rvert]}{a}, y_0 - k \frac{\text{lcm}[\lvert a \rvert,\lvert b \rvert]}{b} \right)$$ where $k \in \mathbb{Z}$. Hence, we get that $(k_4,k_5) = (1+5k,1+4k)$. This gives us that $n = 20k+4$ i.e. $n \equiv 4 \bmod 20$.
$3$. $4|(n+1)$ and $5|n$. This means that $n = 5k_5$ and $n+1 = 4k_4$. Hence, we get that $4k_4 - 5k_4 = 1$. Clearly, $(k_4,k_5) = (4,3)$ is a solution. Hence, we get that $(k_4,k_5) = (4+5k,3+4k)$. This gives us that $n=20k+15$ i.e. $n \equiv 15 \bmod 20$.
$4$. $4|(n+1)$ and $5|(n+1)$. This case is again trivial. Since $(4,5) = 1$, we get that $20|(n+1)$ and hence $n \equiv 19 \bmod 20$.
To summarize, the solutions are given by
\begin{cases}
n \equiv 0\bmod 20 &(\text{ if }4 \text{ divides }n \text{ and }5 \text{ divides }n)\\
n \equiv 4\bmod 20 & (\text{ if }4 \text{ divides }n \text{ and }5 \text{ divides }n+1)\\
n \equiv 15\bmod 20 & (\text{ if }4 \text{ divides }n+1 \text{ and }5 \text{ divides }n)\\
n \equiv 19\bmod 20 & (\text{ if }4 \text{ divides }n+1 \text{ and }5 \text{ divides }n+1)
\end{cases}
Comment: (+1) although I think mentioning the Chinese Remainder Theorem would have been nice
Answer: Write $n$ in the form $20k+j$ where $0≤j<20$.
Then you have $n(n+1) = (20k+j)(20k+j+1) = 400k^2 + 40kj + 20k + j^2 + j$ which is obviously a multiple of 20 if and only if $j^2+j$ is.  So the problem has been reduced to finding $0≤j<20$ where $j(j+1)$ is a multiple of 20; this occurs for $j=0,4,15,19$, so the solutions all have the form $n=20k+\{0,4,15,19\}$ for some integer $k$.

Where did I get the inspiration to write $n$ in the form $20k+j$?  I guessed that it would repeat with period 10 or 20, and I looked at the list of triangular numbers in OEIS and saw that multiples of 10 did indeed appear at $n=4,15,19,20,24$, so 20 seemed to be the way to go.
Why did I guess that it would repeat with period 10 or 20? The main reason is that questions about when an polynomial $P(n)$ is divisible by $q$ usually does something like that, because if you calculate $P(n+q) - P(n)$ the constant term cancels, as do all the terms that are pure in $n$, and leaves you with some higher-order terms that are all divisible by $q$.
I knew that was the thing to try because I have seen a lot of problems of that type.
Addendum: How many solutions lie between 1 and $N$?  Write $N=20k+j$ as before, and the answer is $4k$ plus a fudge factor.  The fudge factor is 0 if $j<4$, 1 if $4≤j<15$, 2 if $15≤j<19$, and 3 if $j=19$.
Comment: @uncleZeiv: The difference is that while $n$ can be any number, $j$ must be less than 20.
Comment: I can't see why your substitution is useful, given that the conclusion is the same as the premise: n(n + 1) must be a multiple of 20, j(j + 1) must be a multiple of 20. Am I missing something?
Answer: Hint $ $ If $\rm\:m,n,i\in \mathbb Z\:$ and $\rm\:(n,i) = 1\:$ with $\rm\:m,\:\!m\!+\!i\:$ powers of distinct primes, then
$\rm\quad\phantom{m\!|\:\!\rm n\!+\!i,}\:\ m(m\!+\!i)\:|\:n(n\!+\!i)\ $ iff one of the four following cases holds
$\quad\begin{eqnarray}
\rm &&&\rm m(m\!+\!i)\!\!\! &|&\rm n &\ \iff\ &\rm n\equiv\:\ \ 0&\rm\pmod{\:m(m\!+\!i)} \\
\rm &&&\rm m(m\!+\!i)\!\!\!&|&\rm n\!+\!i &\ \iff\ &\rm n\equiv -i&\rm\pmod{\:m(m\!+\!i)} \\
\rm m\!&|\:&\rm n,\!\!\!\!&\rm \phantom{m(}m\!+\!i\:&|&\rm n\!+\!i &\ \iff\ &\rm n\equiv\ m&\rm\pmod{\:m(m\!+\!i)} \\
\rm m\!&|&\:\!\rm n\!+\!i,\!\!\!\! &\rm \phantom{m(}m\!+\!i\!\!\!\!\!\!\:&|&\rm n &\ \iff\ &\rm n\equiv -m\!-\!i\!\!\!\!\:&\rm\pmod{\:m(m\!+\!i)}
\end{eqnarray}$
Put $\rm\ m=4,\ i=1\:$ to solve your problem.
Hint for the proof: for prime powers $\rm\:p^k\:|\:n(n\!+\!i)\!\iff\! p^k\:|\:n\:$ or $\rm\:p^k\:|\:n\!+\!i\:$ by $\rm\:n,n\!+\!i\:$ coprime, by $\rm (n,n\!+\!i)=(n,i) = 1.$
Answer: Only the ones digit matters when figuring multiples of ten.  Also, a multiple of ten plus a multiple of ten is a multiple of ten.  Thus, we can find the applicable patterns that we need to consider:
First pattern to get to a multiple of ten (starting with 1):
1+2+3+4 = 10

Second pattern (starting from 5, since we counted 4 last in the previous pattern):
5+6+7+8+9+0+1+2+3+4+5 = 50

Third pattern (starting from 6):
6+7+8+9 = 30

Fourth pattern (starting from 5):
0

Repeat back to pattern 1

Now we have the 4 sequential patterns that we need to consider, which consist of 20 total numbers.  I'm more of a programmer than a mathematician, so here's one way to represent the solution programmatically (in this case using JavaScript), with a working fiddle to see it in action:
function getMultiplesOfTenWhileCountingTo(finalCount){
    //There are 4 multiples every 20 numbers
    var multiples = Math.floor(finalCount/20) * 4;

    //Add the additional multiples based on the remainder
    var remainder = finalCount % 20;
    if(remainder >= 4){
        multiples++;
    }
    if(remainder >= 15){
        multiples++;
    }
    if(remainder >= 19){
        multiples++;
    }
    return multiples;
}

Answer: Given the expression
$$f(N)=\#\left\{n\le N:\sum_{i=1}^n i=n(n+1)2 \text{ is divisible by 10}\right\},$$
each time when the $n=4,64,1024$, etc., take the root (e.g. in $2^2$, $2^6$, $2^{10}$),     therefore, you can form your function in following two ways:

$\text{power}\,\%\,4=2$;
An arithmetic progression with first term 2 and $d=4$, will give you the powers of two.

Apologies for bad formatting.

Puzzle: Cumulative Sum Divisible by 10


Reuse nail holes when replacing oak trim

Question: I removed some trim boards and I used the technique of pulling the nail through the wood to avoid splintering the finished face (instead of pounding the nails back out).
This resulted in the heads of the nails enlarging the holes slightly.
Since the oak is old, it is as hard as cast iron.  Driving nails into it results in bent nails.   I could predrill holes but that is extra work!
Are there any tricks to reuse the existing holes?
Comment: Have you tried it? What problem did you encounter? If they pull through the obvious answer would be slightly larger nails.
Comment: I haven't tried it yet...weeks away.  That is an option..but the old nails are already pretty large.  Maybe it's not really going to be an issue.
Answer: Just two quick things.

Given that your nail heads were covered, I would have just bent them back and broke them off.   But if they came out and you have holes on the other side that's fine.   Honestly every trim/nail-type might have a best method so there isn't anything that someone can categorically say.

To go into existing holes... Get a better quality trim nail and use a gun.   Up the pressure on the gun.   When nailing into existing hole you want to hit the hole at an angle  - maybe 30 degrees - so that your head doesn't shoot straight through.
Comment: I like the angle idea, that could/should give the head a larger surface area and make new holes in the underlying surface.
Answer: Consider that the old nail holes have saved you the step of drilling pilot holes. If you are installing hardwood trim with a hammer and nail set it is easy to split the piece -- especially on seasoned wood. Since there are already nail holes in the trim, the chances of splitting the wood is very low. Here are some other suggestions:

If the opening is too large in that the new nail head won't get a purchase on the wood, use the next penny size up.

If you think the wood may split, blunt the pointed end of the nail by tapping it with your hammer. This allows the nail, when driven, to crush the wood fibers rather than chiseling (and expanding) them which is what causes wood split.

If you can't get the nail to bite into the wall stud or nailer in the wall, re-angle the nail in the pilot hole so it is driven in a different direction.

Drive nails until just the head is above the wood surface and then use the nail set to sink it 1/16-1/8 inch below.

If the nail is driven on a location that prevents hammering without doing damage, use the other (wider) end of the nail set to drive the nail head to just above surface and then use the pointed end to sink it.

Sometimes it is easier to chuck the finish nail in a drill so that the chuck tightens on the nail shank below the head. Slowly easing the nail into the wood allows the nail to bore through the wood grain to prevent splits. Stop short of the chuck's jaws hitting the wood and finish with hammer and nail set.

Finally, when pulling nails through trim, first clip the nail head off and then pry it through from the back. It will leave a smaller opening.


Copy image from Google Sheets to Google Docs using Google Apps Script

Question: I was working on generating a report as Google Docs document using data from spreadsheets. Some parts of the sheets contain a step-by-step screenshot walkthrough (That is, text, image, text, image vertically). That needs to be copied to the doc.
I have read through Google Apps Script reference and found that OverGridImage represent the image in the file. However, there was no method that allows exporting as a blob, or even a URL. (Since the image pasted on the sheets come directly from clipboard, there is no URL of the image in the first place, so getUrl() does not work.)
Is there any workaround that is possible?
Answer: I'm afraid what you're trying to do is currently not possible.
The class OverGridImage was released fairly recently (October 2018) and, as you said, there is no way to retrieve the Blob for such images. There is actually an open Feature Request in Issue Tracker regarding this.
Since there is no BlobSource interface related to this class, there is no way to get a reference of that image, if you have no URL. And the image cannot be retrieved by Sheets API either.
Reference:

OverGridImage
Feature Request: Update OverGridImage to support BlobSource interface
Comment: Thank you very much for the confirmation. Sadly, there is no way to implement this. I will continue trying to find a workaround.
Comment: @Bearfinn You're welcome. The workarounds I can think of are related to adding the image from an URL or from Drive. If you just upload it from your device, I'm afraid there is nothing that can be done. Also, remember that you can [accept](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) answers that you consider helpful. This is useful because this community relies on it to share knowledge to other users.
Comment: Sorry for the late response. The thing is that the client would like it to be easy to paste the images, such as pasting them directly in the sheet. I think they would have to do the upload and copy the link themselves. Also, thank you for your suggestion. I have accepted your answer!
Comment: Have you checked out this library: https://github.com/tanaikech/DocsServiceApp?
Although the library has some issues but it is able to retrieve overgridimages as well as in-cell-images. How does it manage to do that?


C# WinFormApp DataGridView cannot show object inside of List

Question: UPD: I have found this article: http://www.developer-corner.com/blog/2007/07/19/datagridview-how-to-bind-nested-objects/ , but it is pretty old, posted in 2007.
I have C# win forms app and I want to show list of items in datagridView:
here is the List: `
public static List<Item> ItemsList { get; set; } = new List<Item>()
        {
            new Item()
            {
                Id = 1,
               ItemName = "Ice Tea",
               ItemCategory   = new Category(){
                    Name = "Drinks"
                },
                Price = 4000.00,
        },...}`

as  you can see I have another object ItemCategory inside Item.
Here is the code to connect to dataGrid:
dataGridAllProducts.DataSource = Item.ItemsList;

The problem is that I cannot get the Name from ItemsList and show in rows, here is what it shows in output:
As you can see instead of Drinks it shows another thing.
Also i tried to loop through my list using foreach and rows to datagrid but it throwed some errors .
Answer: On class Category add this code:
public override string ToString(){
    return this.Name;
}

When you call the object on need a string, the object Category show Name property.
Answer: The column binding for the data grid view might not be right.
Please try the following in the design view:
1. Right click on your data grid view and select "Edit Columns"
2. Select the column for which the data is not coming right.
3. In the "DataPropertyName" under "Data" mention "Name" i.e. the property name of your Item class.


Adding to Nested Array in MongoDB

Question: Suppose I had three arrays nested in a document as follows and I knew all the indices. How would I add another element to the third array, in this case "array3"? I wouldn't be able to use the positional operator but is there a way to update/push when you know the indices?
<code>"name1": "foo1",
"array1": [
      {
        name2: "foo2",
        "array2" : [
          {
            "name3" : "foo3",
            "array3": [
              {
                data : "ImData"
              }
            ]
          }

        ]

]
</code>
Answer: Well. I figured it out. I somehow missed just directly referencing it via its index. I figured it possible but just about every example showed positional references and I couldn't find the syntax to do it directly. It's quite simple. To add to array 3 above when knowing the index you'd:
<code>db.collection('productlist').update({name1:'foo1'},{'$push': { "array1.0.array2.0.array3": {"data": "yay"}}}
</code>

Adding to Nested Array in MongoDB


Can Cloud Firestore onSnapshot() only trigger on changes, and not get the initial state?

Question: The documentation says:

You can listen to a document with the onSnapshot() method. An initial call using the callback you provide creates a document snapshot immediately with the current contents of the single document. Then, each time the contents change, another call updates the document snapshot.

I just want my listener to fire when the data changes. I don't want it to fire when the app loads, to get the initial state of the data. Any suggestions?
Comment: I would love this feature!
Answer: Firestore listeners don't work that way.  You will always be delivered the document(s) relevant to the fetch or query, then updates after that for as long as the listener remains added.  There is no mode to receive deltas only.
If you want to receive only certain data, you might want to figure out how to query for it, for example, by adding a timestamp field and having the client only query for documents that have changed since some prior time.
Comment: It would be great if the ability to ignore the initial state was there. In my apps, I am syncing data with Firebase and I am storing it in CoreData for further use by my app. It is quite annoying that upon the app's launch I get all the data from the listener, even the one I already have stored. I now need to find a way to ignore this first launch. Are we guaranteed that there will always be 1 response with all local data (initial state) which will NOT contain any new info from the server?  If so, I could ignore exactly one response from the listener to achieve the functionality which I want.
Comment: You can't ignore data.  You could instead construct a query that only returns the data you want.  If you can't construct such a query, then you're out of luck.
Comment: Thanks for your official support on SO, Mr. Doug. I have a question regarding your statement "Firestore listeners don't work that way"... The documentation states that this implicit behavior is designed for the convenience of populating the UI using the initial state. In that case, the user ought to be given an option whether to receive the initial state or not, right? A field such as `ListenerOptions.getInitialState()` and `ListenerOptions.ignoreInitialState()` would make the `onSnapshot()` method more flexible, just like 'SetOptions.merge()'! Is this a reasonable request, Firebaser?  :D
Comment: @arcety Hi there. I think I did file one back then... but I'm not sure what happened because there is no request tracker or feedback ID... Just in case, I've sent the same feature request again today, thanks for letting me know. Look forward to this handy feature!  :)
Comment: It would be nice to get an Etag along with a read, then next time you read the same collection, you can provide your Etag as "this is what I have already" and if there's a newer Etag in Firestore, it sends only the deltas in the next query.
Comment: @varun Sure, you are always free to file a feature request with Firebase support. https://support.google.com/firebase/contact/support
Comment: @DougStevenson Oh, alright. I'll file it some time soon!  :)
Comment: @varun Did you eventually a feature request for this feature?
Comment: @varun Ha, great, thanks! Hope they take it into consideration. Would be a nice addition.
Comment: thank you for your response. Subscribing to updates after timestamp is not feasible in my case. Maybe my setup is wrong and you could advise me how to correct it. I have a theory test app and I want to store user's progress. When they take a test, I wish to store the test log so that I can then reconstruct their actual progress. We could instead store one file with the overall statistics, but I am concerned about the bandwidth. Also, I am worried that a single file with up to date progress would go over the field size limit.
Comment: nevermind - there is a property "isFromCache" which allows me to easily ignore any reads coming from local cache regardless of whether it is the first launch or not. It is exactly what I need.
Comment: @AndriyGordiychuk https://firebase.google.com/docs/firestore/query-data/get-data#source_options
Answer: After reading the first and second solution, I have made a solution that seems to work.
First you initialize a variable to true and inside the onSnapshot() method you check if this variable is true, if it is, you change it to false, and on else you write your retrieving data algorithm. Something like this:
var initState = true;

let observer = records.onSnapshot(docSnapshot => {

    console.log(`Received doc snapshot`);

    if (initState) {
        initState = false;
    } else {
        if (!docSnapshot.docChanges().empty) {
            docSnapshot.docChanges().forEach(function (change) {
               //Write here wahtever you want

            });
        }
    }

}, err => {
    console.log(`Encountered error: ${err}`);
});

Comment: Note: This solution is very very superficial, all it is doing is ignoring the first fetch of data using an (if...else) statement. The only solution to the OP's question is to wait for the firestore team to give us an API which can make the initial snapshot optional.
Comment: 3 years later. do we have this already ?
Answer: No. Whenever you use onSnapshot, an initial call is made to get the data immediately and after that changes are listened.
But you can handle the logic within it to detect wether it was an initial call or updates trigger using the following properties provided by the firebase.
  db
  .collection("pets")
    .doc(petId)
    .onSnapshot(
      snapshot => {
        let data = snapshot.data()
          // either edit, update or delete
          if (snapshot.metadata.hasPendingWrites) {
            if (snapshot.exists) {
              // edit or create logic
            }
            else{
             // delete logic
            }
        }

      },
      err => {
        console.log(err)
      }
    )

Answer: Firestore listeners loads by their own order and the "onSnapshot" event must always execute first on initial state. But, you can handle that behavior adding a initial state variable like:
var initState = true;
db.collection('col').doc('id').onSnapshot(....

Then you could validate inside the function the code you dont want to run when your application starts.
var initState = true;
db.collection('col').doc('id').onSnapshot(....
if(!initState){ // if is not initial state
   //your code
}

and after the application starts up you must change initState to false and add a sleep/timeout function (cause it may have an unexpcted asyncronous load)
var initState = true;
db.collection('col').doc('id').onSnapshot(....
if(!initState){ // if is not initial state
   //your code
}

setTimeout(function () { // cause onSnapShot executes first
   initState = false;
}, 2000);

Answer: What also worked for me was to check for the document.readystate and then choose to act on the snapshot changes. Like this -
db.collection("collectionName").onSnapshot( (snapshot) => {
    console.log(snapshot.docChanges())
    if( ["loaded","interactive", "complete"].indexOf(document.readyState) >=0 ){
        <-----Your code to act on the snapshot changes---->

}

Based on the readystate property documentation here -
https://www.w3schools.com/jsref/prop_doc_readystate.asp
Comment: You reference link relates to HTML documents not Firestore documents.


Prove that $ f(x) = e^x + \ln x $ attains every real number as its value exactly once

Question:
Prove that the function $$ f(x) = e^x + \ln x $$ attains every real number as its value exactly once.

First, I thought to prove that this function is a monotonic continuous function.
But then I wasn't sure if that is how to prove the result, and if it is, I wasn't sure of how exactly to prove it that way.
Comment: It's a function defined on $\langle0,\infty\rangle$, continuous, so having intermediate value property. And its derivative is positive, so it's monomtone increasing. Unbounded both above and below, that does it.
Answer: Clearly, $f$ is continuous and differentiable over the set of positive numbers.
$$f'(x)=e^x+\frac{1}{x}$$
 If $x>0, f'(x)>0$, hence it is monotonic  continuous function.
Also, note that $$\lim_{x \rightarrow 0^+}f(x)=-\infty$$ and $$\lim_{x \rightarrow \infty}f(x)=\infty$$
Hence, it attains every real number exactly once.
Comment: attain every real number (surjective) and exactly once (injective).
Comment: My comment is beside the point, but I was wondering if you would tell me what it means for a function to attain every real number exactly once? Is this synonymous with an injective function?
Comment: Dear SiongThyeGoh.. I'm aorry fir this comment..Can you look my simple problem? Can you show me mistakes in my solution? Please, Thank you so much..!!
 https://math.stackexchange.com/q/2678602/456510
Comment: Jack's solution seems awesome isn't it?
Comment: I did not receive a notification because you didn't tagg my name.)..Yes Jack is high reputation and skilled user. But, I edited my question and fixed my mistakes..
Answer: You can prove it by noting three things:

The function $f \colon (0,\infty) \rightarrow \mathbb{R}$ is continuous and strictly monotonic as
$$ f'(x) = e^x + \frac{1}{x} > 0 \,\,\, \forall x \in (0,\infty). $$
When $x \to 0^{+}$, we have
$$ \lim_{x \to 0^{+}} f(x) = -\infty. $$
When $x \to \infty$ we have
$$ \lim_{x \to \infty} f(x) = +\infty. $$

By using $(2)$ and $(3)$, given $y \in \mathbb{R}$ we can find $x_0 < x_1$ such that $f(x_0) < y - \frac{1}{2}$ and $f(x_1) > y + \frac{1}{2}$. By continuity on $[x_0,x_1]$, $f$ must assume all values between $f(x_0)$ and $f(x_1)$ and in particular $y$. By strict monotonicity, it will assume $y$ only once.

Without proving $(2)$ and $(3)$, the function could miss some values if it has an asymptote at infinity or at $0$. For example, $f(x) = \arctan(x)$ is monotonic on $(0,\infty)$ but its image is $(0,\frac{\pi}{2})$.