text:
Q: Sizes Not Showing In Category- Category.sizes: nill I have a Category Model. When you create a Category you must select the sizes that category will have. A Shirt Category will have XS, S, M, L, XL, XXL.
I created all sizes of clothes using enum sizes: which is in my Category model.
For some reason when I run Category.last it shows sizes.nill. How do I make this work?
2.2.1 :003 > Category.last
  Category Load (0.4ms)  SELECT  "categories".* FROM "categories"  ORDER BY "categories"."id" DESC LIMIT 1
 => #<Category id: 25, name: "test", ancestry: "20", created_at: "2015-09-03 11:27:40", updated_at: "2015-09-03 11:27:40", sizes: nil>

Category Controller
class CategoriesController < ApplicationController
  before_action :set_category,   only: [:show]
  before_action :admin_user,     only: [:destroy, :index, :edit]

  def index
    @categories = Category.all
  end

  def show
    @tags = Item.where(category_id: @category.id).tag_counts_on(:tags)
    if params[:tag]
      @items = Item.tagged_with(params[:tag])
    else
      @items = Item.where(category_id: @category.id).order("created_at DESC")
    end
  end

  def new
    @category = Category.new
  end

  def edit
    @category = Category.find(params[:id])
  end

  def create
    @category = Category.new(category_params)
    if @category.save
      redirect_to @category
      flash[:success] = "You have created a new category"
    else
      flash[:danger] = "Your category didn't save"
      render "new"
    end
  end

  def update
    @Cateogry = Category.find(params[:id])
    if @Cateogry.update(category_params)
       redirect_to @Cateogry
       flash[:success] = 'Category was successfully updated.'
    else
      render "edit"
    end
  end

  def destroy
    Category.find(params[:id]).destroy
    flash[:success] = "Category deleted"
    redirect_to categories_path
  end

  private

    def set_category
      @category = Category.find(params[:id])
    end

    def category_params
      params.require(:category).permit(:name, :sizes, :parent_id)
    end

    # Confirms an admin user.
    def admin_user
      redirect_to(root_url) unless current_user.try(:admin?)
    end

end

Category Model
class Category < ActiveRecord::Base
    has_ancestry
    has_many :items
    validates :name, presence: true, length: { maximum: 20 }
    enum sizes: [:XSmall, :Small, :Medium, :Large, :XLarge, :XXLarge,
                             :'1', :'2', :'3', :'4', :'5', :'6', :'7', :'8', :'9', :'10',
                             :'11', :'12', :'13', :'14', :'15', :'16', :'17', :'18', :'19', :'20',
                             :'21', :'22', :'23', :'24', :'25', :'26', :'27', :'28', :'29', :'30',
                             :'31', :'32', :'33', :'34', :'35', :'36', :'37', :'38', :'39', :'40',
                            ]
end

Category Create View

                    <%= simple_form_for(@category) do |f| %>

                        <%= f.input :name %>

                            <%= f.input :sizes, collection: Category.sizes.keys, as: :check_boxes, input_html: { multiple: true }, label:"Select Size" %>

                        <%= f.collection_select :parent_id, Category.order(:name), :id, :name, {prompt: "Select Parrent ID If Applicable"},include_blank: true %>

                        <%= f.button :submit %>

                    <% end %>

My migration for sizes in category.
class AddSizesToCategories < ActiveRecord::Migration
  def change
    add_column :categories, :sizes, :integer, array: true
  end
end

Schema
  create_table "categories", force: :cascade do |t|
    t.string   "name"
    t.string   "ancestry"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.integer  "sizes"
  end

A: The enum column name should be singularized, and the list of all available values you can get with a pluralized name of your enum column.
In your example the column should be called size, and the list off all sizes will be accessible with Category.sizes then

A: I think there is a misunderstanding:
An enum is not a set. An enum can hold one of a set of given values.
So if you want to handle multiple sizes per category you either need an asscociation (has_many :sizes, with a different model Size) or use  serialisation.
The reason that your sizes is empty:
The form returns an array with name sizes and the selected choices.
Your category_params only permit a scalar :sizes, so strong parameters rejects the array of values. But if you would permit sizes: [] then assignment to the integer would fail.


text:
Q: launchArguments in UITesting in Xcode 7.3 not working I've been writing UI tests in Xcode 7.3 and recently wanted to add a launch argument to enable some test code inside the app. I initially tried setting XCUIApplication().launchArguments as several people have done in various posts, but they would not work.
Digging around it appears that both launchArguments and launchEnvironment cannot be setup within a UI test, even though the API documentation says they can.
Further when I attempted to set launch arguments and environment variables in the UI Testing scheme, they also where not passed through to the app, where as when unit testing or running the app, they are.
Here's a copy of a quick tests I did to prove this, all these tests fail.
import XCTest

class LaunchDebugUITests: XCTestCase {

    func testLaunchArgumentsSetting() {
        XCUIApplication().launchArguments = ["abc"]
        print("Arguments \(XCUIApplication().launchArguments)")
        XCTAssertTrue(XCUIApplication().launchArguments.contains("abc"))
    }

    func testLaunchArgumentsAppending() {
        XCUIApplication().launchArguments.append("abc")
        print("Arguments \(XCUIApplication().launchArguments)")
        XCTAssertTrue(XCUIApplication().launchArguments.contains("abc"))
    }

    func testLaunchEnvironmentSetting() {
        XCUIApplication().launchEnvironment = ["abc":"def"]
        print("Environment \(XCUIApplication().launchEnvironment)")
        XCTAssertEqual("def", XCUIApplication().launchEnvironment["abc"])
    }

    func testLaunchEnvironmentAppending() {
        XCUIApplication().launchEnvironment["abc"] = "def"
        print("Environment \(XCUIApplication().launchEnvironment)")
        XCTAssertEqual("def", XCUIApplication().launchEnvironment["abc"])
    }

}

Has anyone else encountered this? Do you have a work around?

A: You need to also, then, launch you app and check in the app for the argument. Here's how I do it...
func testFooBar() {
    // given
    app.launchArguments = ["shouldDoBar", "shouldDoFoo"]

    // when
    app.launch()

    // then
}

Then in your app
int main(int argc, char *argv[]) {
    NSArray *arguments = [[NSProcessInfo processInfo] arguments];

    if ([arguments containsObject:@"shouldDoBar"]) {
       doBar();
    }

    if ([arguments containsObject:@"shouldDoFoo"]) {
       doFoo();
    }
    ...
}

You might want the arguments checks somewhere more appropriate to your use (and perhaps also wrapped in a #ifdef DEBUG ... #endif to avoid shipping it).

A: Apple got back to me and told me I was using XCUIApplication() incorrectly.
You should not invoke XCUIApplication() multiple times.
Many of the blogs I read did this call multiple times and is most circumstances it doesn't matter. In fact many blog posts treat the function like it's accessing a singleton. I had a feeling this was incorrect as it looked wrong, but I figured other people would have got it right.
But it isn't. It's not accessing a singleton and actually creates a new XCUIApplication instance each time it's called. Hence my code was failing because I was setting launch arguments on one instance, then creating another one to launch.
So my tests should have actually looked like this:
func testLaunchArgumentsSetting() {
    let app = XCUIApplication()
    app.launchArguments = ["abc"]
    print("Arguments \(app.launchArguments)")
    XCTAssertTrue(app.launchArguments.contains("abc"))
    app.launch()
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: MOSFET Always On despite of Pull-Down I'm currently trying to get the hang of using a MOSFET as a switch.
My schematic looks something like this (it's the first schematic I've ever drawn, so please don't be too hard on me).

simulate this circuit – Schematic created using CircuitLab
The problem is that the MOSFET is always-on, no matter the gate voltage (or even any gate voltage present at all).
I'm using a 12V DC LED without fixed polarity (so no real flow direction, which is why I drew it as a lamp) which I don't know the resistance of, which is why I put 100 Ohm. I'm almost certain that it does not matter.
Anyhow, the 12V are coming out of a laboratory power supply and I'm only using the positive and negative terminals there. It does not matter if the gate voltage is connected or left out at all, the LED just lights up no matter what.
I've been told (when first trying on a Raspberry Pi, see my last questions if interested) that it could be "stray voltage" and the GPIO pin being floating turning the FET on. I was told to put a pull-down resistor to prevent this.
I've since changed from using the RPI to using the second supply available to me to just provide +3.3v as a replacement for a GPIO Output to make building the circuit easier and more fool-proof (I think I'm one of the bigger fools in electronics for not getting this to run)
From what I have understood I'm supposed to use source as a voltage input, gate as a switch (on/off signal coming in there with a logic level MOSFET like the IRLZ34N) and Drain to connect to the circuit. So that the MOSFET switches (lowers the resistance, becomes conductive, closes the connection) between Drain and Source. Am I wrong in this most basic understanding?

A: If you are sure about your hook-up, you are simply using the MOSFET the wrong way. In this I assume you have the negative of the 12V connected to the same ground that your sometimes present 3.3V has its negative.
The N-MOSFET looks, on the inside, more like this:

simulate this circuit – Schematic created using CircuitLab
So your set-up turns on the LED through the diode inside the MOSFET, because you connected the positive terminal entirely on the wrong side. It's called diode-conduction and that needs no gate voltage at all.
For your first experiments with MOSFETs, using them as switches, you need to make sure the Source of an N-MOSFET is always at the 0V potential, for a P-MOST (not yours!) the source should always be at the supply voltage.
So your schematic should look like this:

simulate this circuit
Later you can progress to circuits that use MOSFETs that do not connect their sources to the correct voltage points, once you start understanding what's going on. For now, stick to the rule above.


text:
Q: java set double value format I have a simple calculate code that count about box volume (long * width * height):
ActionListener volListener = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        try{
            String L = long.getText();
            String W = width.getText();
            String H = height.getText();
            double parseL = Double.parseDouble(L);
            double parseW = Double.parseDouble(W);
            double parseH = Double.parseDouble(H);
            double volResult = parseL*parseW*parseH;
            txtAreaOut.append("Volume : " + volResult + "\n");
            long.setText("");
            width.setText("");
            height.setText("");
        }catch(NumberFormatException nfe){
            String fault = nfe.getMessage();
            infoBox(fault,  " " + nfe.getClass());
        }
    }
};

If "volResult" return large number, for example 9.0408284742E7,
and i want the result like this 9.040.828.474...
How the code?..

A: Use string.format and define number of decimal places. Here I defineded two decimal places.
txtAreaOut.append("Volume : " + String.format( "%.2f",volResult ) + "\n");


text:
Q: Clean Architecture: should i have a use case for each Http End point? Suppose i must create a web page where user:

*

*Search products

*Click on specific product and show details

*Change some details and click Save.

I excpect my web app will have a ProductController with three actions: one for list, one for detail, one for save changes.
Should i have three distinct user cases (then three classes) or is sufficient to have a single class (e.g. ProductInteractor) with three methods ?
I'm afraid that having a use case for each entry point would generate a lot of boiler code..
Thanks for any help!

A: You have already designed three controller actions, what difference would it make if you design three interactors?
After all, you do have three different use cases, so my advice to you is to follow SRP (single responsibility principle) and let each use case have its own interactor.
That would give you more flexibility in a sense that it would be easy, for example, to replace an existing implementation of products search with a new one - independently from the other interactors.


text: Q: Offer similar tags when dialog to create new tag opens I think it will be a lot more useful if the prompt on new tag creation shows similarly sound alternatives whenever a user attempts to create a new tag.


text:
Q: How to plot a streamplot in python for a streamline flow arround a cylinder? I have written a program where it takes a radius range(R to 5) and theta range(0 to 2pi). It converts the polar coordinates to Cartesian coordinates. Then I have plotted the scatter graph of the x,y Cartesian coordinates.
I have a free stream velocity u(x-direction)=1 and v-velocity(y-direction)= 0. I want to plot a stream plot for the points I have obtained above. I know I have to use  meshgrid function. But after trying a lot, I cannot map the Mesh grid points to the velocity values.
I want to get a plot like below picture.

The Code is given below:
import math
import numpy as np
from matplotlib import pyplot

R=1.15;  # Radius of circle
Nr=75;    # No of radial points
Ntheta=75; # No of theta points
x_start,x_end=-5,5;
y_start,y_end=-5,5;
theta=np.linspace(0,2*np.pi,Ntheta); # Array of theta points
radial=np.linspace(R,5,Nr);          # Array of radius points
xc=-0.15; # Center of circle.
yc=0.0;   # Center of circle.

X,Y=np.meshgrid(r,theta);   # Meshgrid for stream plot

x=np.zeros((Nr*Ntheta,1),dtype=np.float64);   # To store x cordinates
y=np.zeros((Nr*Ntheta,1),dtype=np.float64);   # to store y cordinates

# Z-Plane Computation
cnt=0;
for i in range(Nr):
    for j in range(Ntheta):
        x[cnt,0]=radial[i]*np.cos(theta[j])+xc;    # Calculation of Cartesian Cordinates
        y[cnt,0]=radial[i]*np.sin(theta[j])+yc;    # Calculation of Cartesian Cordinates
        cnt+=1;

# Plot
fig=pyplot.figure(figsize=(10,10));
pyplot.scatter(x[:,0],y[:,0],s=1,color='k');
pyplot.xlim(-6,6);
pyplot.ylim(-6,6);
pyplot.scatter(xc,yc,s=80,color='g',marker='o');
pyplot.title('Z-Plane',fontsize=20);
pyplot.xlabel('x',fontsize=15);
pyplot.ylabel('y',fontsize=15);
pyplot.grid(color='k',which='both',axis='both',linestyle='--',linewidth=0.5);

# StreamLine Velocity
u_inf=1;
u_freestream= u_inf*np.ones((Nr,Ntheta),dtype=np.float64);
v_freestream= np.zeros((Nr,Ntheta),dtype=np.float64);

#plotting
pyplot.figure()
pyplot.streamplot(X,Y,u_freestream,v_freestream);

The error is
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-59df08985fbe> in <module>()
     46 #plotting
     47 pyplot.figure()
---> 48 pyplot.streamplot(X,Y,u_freestream,v_freestream);
     49
     50

3 frames
/usr/local/lib/python3.6/dist-packages/matplotlib/streamplot.py in __init__(self, x, y)
    342
    343         if not np.allclose(np.diff(x), self.width / (self.nx - 1)):
--> 344             raise ValueError("'x' values must be equally spaced")
    345         if not np.allclose(np.diff(y), self.height / (self.ny - 1)):
    346             raise ValueError("'y' values must be equally spaced")

ValueError: 'x' values must be equally spaced

A: I am spending a lot of time with streamplots, and I thought of taking a shot at your problem. Here is what I got so far.
import numpy as np
import matplotlib.pyplot as plt

I agree with @swag2198's comment, so I started with a cartesian grid. Then I found the corresponding polar grid.
# init cartesian grid
Y, X = np.mgrid[-5:5:101j, -5:5:101j]

# get corresponding polar grid
R, T = np.sqrt(X**2 + Y**2), np.arctan(Y/X)

Then I realized that the question is missing vector field equations. So I did some googling and found the Wikipedia page for the problem. The following formula gives the vector field $$ V $$:  where $$ \psi $$ is .
# stream function
U = 1 # velocity(?) constant
R_disc = 1.15 # radius of the disc
S_polar = U * (R - (R_disc**2)/R) * np.sin(T)

Then I headed to Mathematica figured out $$ \del \psi $$ . Then I wrote it in python.
# substitute and differentiate
denom = np.power(X*X + Y*Y, 3/2) * (np.sqrt(1 + ((Y*Y)/(X*X))))
Sx = 2 * (R_disc**2) * U * Y / denom
Sy = U * (R_disc**2 * (Y*Y - X*X) + (X*X + Y*Y)**2) * (1 / (X*denom))

Then, I removed the disc and the outer region from the vector fields using the fact that streamplot doesn't plot NaN values.
# remove regions
Sx[R<R_disc]=np.nan
Sy[R<R_disc]=np.nan
Sx[R>5]=np.nan
Sy[R>5]=np.nan

Finally, the last part of plotting.
# plot the figure
fig = plt.figure(figsize=(5,5))
ax = plt.subplot()
ax.streamplot(X, Y, Sy, -Sx)
disc = plt.Circle((0,0), radius=R_disc, fc='k')
plt.gca().add_patch(disc)
plt.show()

Here is the final product:

Though the vectors in $$ x < 0 $$ half point in the opposite direction, I could not figure out why this is the case. Perhaps, I made some mistake in coordinate transforms or the function.
Here is the full code for easy copy-paste:
import numpy as np
import matplotlib.pyplot as plt

# init cartesian grid
Y, X = np.mgrid[-5:5:101j, -5:5:101j]

# get corresponding polar grid
R, T = np.sqrt(X**2 + Y**2), np.arctan(Y/X)

# stream function
U = 1 # velocity(?) constant
R_disc = 1.15 # radius of the disc
S_polar = U * (R - (R_disc**2)/R) * np.sin(T)

# substitute and differentiate
denom = np.power(X*X + Y*Y, 3/2) * (np.sqrt(1 + ((Y*Y)/(X*X))))
Sx = 2 * (R_disc**2) * U * Y / denom
Sy = U * (R_disc**2 * (Y*Y - X*X) + (X*X + Y*Y)**2) * (1 / (X*denom))

# remove regions
Sx[R<R_disc]=np.nan
Sy[R<R_disc]=np.nan
Sx[R>5]=np.nan
Sy[R>5]=np.nan

# plot the figure
fig = plt.figure(figsize=(5,5))
ax = plt.subplot()
ax.streamplot(X, Y, Sy, -Sx)
disc = plt.Circle((0,0), radius=R_disc, fc='k')
plt.gca().add_patch(disc)
plt.show()


text:
Q: How can i play a video in vimeo player using videoId? Is there any option in vimeo javascript api to play a video using videoId? Player is already loaded. I've got that option in youtube and dailymotion.
here is the functions( youtube and dailymotion api).
function onYouTubePlayerReady() {
    ytplayer = document.getElementById("player");
    ytplayer.addEventListener("onError", "onPlayerError");
}

//play a video by Id

this.PlayVideo = function (videoID) {
        ytplayer.loadVideoById(videoID);
    }

function onDailymotionPlayerReady(playerId) {
    dmplayer = document.getElementById("player");
    dmplayer.addEventListener("onError", "onPlayerError");
}

//play a video by Id

 this.PlayVideo = function (videoID) {
        dmplayer.loadVideoById(videoID);
    }

In vimeo api I've got the player using below function
function vimeo_player_loaded() {
    vimeoplayer = document.getElementById("player");
}

vimeoplayer.api_play() will play the current video. But I want to load another video using videoId with out reloading the player.
Please help me if anyone know an option to play a video using videoId.
thanks in advance!!


text:
Q: Replace SObject list view with custom Lightning page You can use a Lightning record page to replace the view for a single SObject in the Lightning Record Page option in setup.
How do I do that for the list view?

A: You can't override the list view separately in Lightning because it's fused with the object home page, the Tab, which is overrideable.
From the Lightning Components Developer Guide:

Lightning Experience and the Salesforce mobile app combine the Tab and List actions into one action, Object Home. However, Object Home is reached via the Tab action in Lightning Experience, and the List action in the Salesforce mobile app. Finally, the Salesforce mobile app has a unique Search action (reached via Tab). (Yes, it's a bit awkward and complicated.)

A: The List View is displayed on a Lightning Application Tab.

A: Yes, it is possible to override the listview in the lightning record home page.
The trick is to override the listview. You can currently only override the listview with a visualforce page. The override will apply in both classic and lightning. You can use Lightning Out in the VF page if you want to render a lightning component.
The ListOverride Visualforce page:
<apex:page standardController="Case" recordSetVar="X" >
My Test
</apex:page>
The setup:

It looks like this:


text:
Q: C++ : Segmentation fault (core dumped) issue Implementation of Sieve of eratosthenes in C++ :
When i Run my C++ program i get

"Segmentation fault      (core dumped)"

It compiles without any error.
In this program , i am trying to print all prime numbers between two numbers a and b.
#include <iostream>
#include <string.h>
#define MAX 1000000

using namespace std;

// Print all primes s.t. a <= prime <= b
int main()
{
    int t; // no of test cases
    cin>>t;

    bool prime[MAX + 1];    // a[i] = true for i = prime
    long int count_primes_lte_me[MAX + 1]; // a[i] = Count ( primes ) <= i
    long int counter_of_visited_primes;

    prime[0] = prime[1] = false;
    for(int i = 2 ; i <= MAX ; i++)
    {
        if(prime[i] == true)
            count_primes_lte_me[i] = ++counter_of_visited_primes;

        for(int j = i*i ; j <= MAX ; j += i)  // sieve of eratosthenes
            prime[j] = false;
    }

    long int a , b;
    while(t--)
    {
        cin>>a>>b;
        cout<<count_primes_lte_me[b] - count_primes_lte_me[a - 1]<<endl;
    }

    return 0;
}

A: Try with a smaller value for MAX. Allocating such huge arrays on the stack produces the (initial) problem. Then replace with dynamic allocation:
bool *prime = new bool[MAX+1];
if (prime==nullptr) // error

...

delete [] prime;

You may also use static allocation (define your variables as global).
Best may be to use some appropriate container, for example bitset.
Beware that i*i may overflow, so other problem may arise...

A: i * i will overflow in your inner loop for i <= MAX. This might cause a segfault due to negative j. Use a larger integer type: long long j = (long long)i * i.
For correctness, you need to initialize the prime array to true and the count array to 0 values.

A: You've a Max of a million... I tried to reduce it and no error but still nothing works... try this
/************************************
***Array names as pointers***********
************************************/
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    const int MAX = 10000;
    long prime[MAX] = { 2, 3, 5 };
    long trial = 5;
    int count = 3;
    int found = 0;

    do
    {
        trial += 2;
        found = 0;
        for (int i = 0; i < count; i++)
        {
            found = (trial % *(prime + i)/* prime[i] */) == 0;

            if (found)
                break;
        }
        if (found == 0)
            *(prime + count++)/* prime[count++] */ = trial;
    } while (count < MAX);

    for (int i = 0; i < MAX; i++)
    {
        if (i % 5 == 0)
            cout << endl;
        cout << setw(10) << *(prime + i)/* prime[i] */;
    }
    cout << endl;
    return 0;
}


text:
Q: How to add error handling using SQL in snowflake I've written below stored procedure code using SQL in snowflake which truncates a table and load new data into that table by first copying the data from a source, applying a bit of processing on it and loading into the target table which we truncated.
I've added nested Begin and End statements in order to try to add error handling functionality along with If Else statements but none of them worked. I want to first test if copy data was successful if yes than code should run second insert statements which basically brings data to staging where we refine the data where I want to add second check which checks if the rows were added successfully. Lastly we copy into the target table after all the checks are passed.
CREATE OR REPLACE PROCEDURE DEV_NMC_ITEM_AND_PSYCHOMETRIC_DM.STAGE2B."SP_N_1Test"("STAGE_S3" VARCHAR(16777216), "STAGE_OUTPUT" VARCHAR(16777216))
RETURNS VARCHAR(16777216)
LANGUAGE SQL
EXECUTE AS CALLER
AS '
DECLARE
Stage_nm_s3 STRING;

begin

truncate table "STAGE2A"."T001_IRF_STUDENT_FORM_S3";

execute immediate ''COPY INTO "STAGE2A"."T001_IRF_STUDENT_FORM_S3"
FROM ( select

a bunch of columns

from @stage2a.''||:STAGE_S3||'')
pattern= ''''.*_IRF_.*\\\\.csv''''
file_format = (type=csv, skip_header=1 )'';

begin
Insert into "STAGE2B"."T011_IRF_STUDENT_FORM_V001" (

a bunch of columns

SELECT

   a bunch of columns

from  "STAGE2A"."V001_IRF_STUDENT_FORM_T001";

    begin
execute immediate ''copy into @stage2a.''||:STAGE_OUTPUT||''/T001_IRF_STUDENT_FORM_S3
from (SELECT

a bunch of columns

 from "STAGE2B"."T011_IRF_STUDENT_FORM_V001")
    file_format = ( format_name = F_CSV type=csv compression = none)
header = True
SINGLE = FALSE
OVERWRITE = TRUE
max_file_size=524288000 '';

return ''Load process completed for IRF_STUDENT_FORM_S3'';
end;
end;
end;
';```

A: I'm afraid you will need to wrap up your SQL statements into Javascript-syntax stored procedure to use Try/Catch block.
Here's some more explanation on that topic: Error handling for stored procedures


text:
Q: Why does my rails app not deploy (H10 code error) and rails server not start? I am at the very start of a rails app with just a "hello world" page and the basic skeleton. i am trying to deploy to heroku before i start working on it. however, on both production and local server i can not get the app to start. I did have it start once on local host 3000 but now i changed something and it doesn work. the only things i changed were putting the sqlite gem into devlopment and pg gem into production since herku doesnt work with sqlite. please see following errors:
when trying to start the local server:
C:\Sites\nutri>rails s
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.5-x86-mingw32/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.5-x86-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.5-x86-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:91:in `require'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:86:in `each'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:86:in `block in require'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:75:in `each'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:75:in `require'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler.rb:107:in `require'
        from C:/Sites/nutri/config/application.rb:7:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:88:in `require'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:88:in `block in server'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `tap'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `server'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

when opening th eapp in production i get an H10 error, unfortunately herko suppor tpage doesnt go into any detail about how to fix this error and just states what the code means which i do not understand.
the heroku logs:
C:\Sites\nutri>heroku logs
This is the legacy Heroku CLI. Please install the new CLI from https://cli.heroku.com
2017-12-10T05:44:26.046591+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2017-12-10T05:44:26.046604+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
2017-12-10T05:44:26.046616+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/server.rb:84:in `app'
2017-12-10T05:44:26.046628+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
2017-12-10T05:44:26.046639+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:283:in `start'
2017-12-10T05:44:26.046649+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/server.rb:104:in `start'
2017-12-10T05:44:26.046660+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:90:in `block in server'
2017-12-10T05:44:26.046670+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `tap'
2017-12-10T05:44:26.046680+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `server'
2017-12-10T05:44:26.046690+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
2017-12-10T05:44:26.046701+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
2017-12-10T05:44:26.046712+00:00 app[web.1]:    from bin/rails:4:in `require'
2017-12-10T05:44:26.046723+00:00 app[web.1]:    from bin/rails:4:in `<main>'
2017-12-10T05:44:26.239147+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-10T05:44:32.729566+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=murmuring-woodland-44138.herokuapp.com request_id=49085526-9dfc-4fe7-abba-b11be446f965 fwd="82.102.17.248" dyno= connect= service= status=503 bytes= protocol=https
2017-12-10T05:45:15.010455+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=murmuring-woodland-44138.herokuapp.com request_id=e090f107-9036-4e55-9d70-8f450c4aa7a2 fwd="82.102.17.248" dyno= connect= service= status=503 bytes= protocol=https
2017-12-10T06:09:54.415945+00:00 heroku[web.1]: State changed from crashed to starting
2017-12-10T06:09:56.992085+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 59932 -e production`
2017-12-10T06:10:00.485332+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-10T06:10:00.375617+00:00 app[web.1]: => Booting Puma
2017-12-10T06:10:00.375631+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:59932
2017-12-10T06:10:00.375632+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-12-10T06:10:00.375633+00:00 app[web.1]: Exiting
2017-12-10T06:10:00.375723+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/connection_specification.rb:176:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
2017-12-10T06:10:00.375747+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/connection_specification.rb:173:in `spec'
2017-12-10T06:10:00.375748+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_handling.rb:53:in `establish_connection'
2017-12-10T06:10:00.375751+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/railtie.rb:125:in `block (2 levels) in <class:Railtie>'
2017-12-10T06:10:00.375752+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
2017-12-10T06:10:00.375754+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
2017-12-10T06:10:00.375775+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
2017-12-10T06:10:00.375776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
2017-12-10T06:10:00.375779+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
2017-12-10T06:10:00.469714+00:00 heroku[web.1]: Process exited with status 1
2017-12-10T06:10:00.375780+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:49:in `each'
2017-12-10T06:10:00.375782+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
2017-12-10T06:10:00.375783+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/base.rb:324:in `<module:ActiveRecord>'
2017-12-10T06:10:00.375826+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/base.rb:24:in `<top (required)>'
2017-12-10T06:10:00.375827+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
2017-12-10T06:10:00.375828+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `block in require'
2017-12-10T06:10:00.375829+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:259:in `load_dependency'
2017-12-10T06:10:00.375830+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
2017-12-10T06:10:00.375831+00:00 app[web.1]:    from /app/app/models/application_record.rb:1:in `<top (required)>'
2017-12-10T06:10:00.375832+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
2017-12-10T06:10:00.375832+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `block in require'
2017-12-10T06:10:00.375833+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:259:in `load_dependency'
2017-12-10T06:10:00.375835+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
2017-12-10T06:10:00.375836+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:380:in `block in require_or_load'
2017-12-10T06:10:00.375837+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:37:in `block in load_interlock'
2017-12-10T06:10:00.375838+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
2017-12-10T06:10:00.375839+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
2017-12-10T06:10:00.375840+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies/interlock.rb:11:in `loading'
2017-12-10T06:10:00.375842+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:37:in `load_interlock'
2017-12-10T06:10:00.375865+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:358:in `require_or_load'
2017-12-10T06:10:00.375866+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:336:in `depend_on'
2017-12-10T06:10:00.375868+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:252:in `require_dependency'
2017-12-10T06:10:00.375869+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
2017-12-10T06:10:00.375871+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/engine.rb:475:in `each'
2017-12-10T06:10:00.375873+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/engine.rb:475:in `block in eager_load!'
2017-12-10T06:10:00.375891+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/engine.rb:473:in `each'
2017-12-10T06:10:00.375892+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/engine.rb:473:in `eager_load!'
2017-12-10T06:10:00.375893+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/engine.rb:354:in `eager_load!'
2017-12-10T06:10:00.375897+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
2017-12-10T06:10:00.375896+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/application/finisher.rb:59:in `each'
2017-12-10T06:10:00.375901+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/initializable.rb:30:in `run'
2017-12-10T06:10:00.375899+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/initializable.rb:30:in `instance_exec'
2017-12-10T06:10:00.375920+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
2017-12-10T06:10:00.375920+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
2017-12-10T06:10:00.375919+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/initializable.rb:55:in `block in run_initializers'
2017-12-10T06:10:00.375922+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
2017-12-10T06:10:00.375923+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
2017-12-10T06:10:00.375925+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each'
2017-12-10T06:10:00.375943+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `call'
2017-12-10T06:10:00.375944+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
2017-12-10T06:10:00.375945+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
2017-12-10T06:10:00.375947+00:00 app[web.1]:    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
2017-12-10T06:10:00.375948+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/initializable.rb:54:in `run_initializers'
2017-12-10T06:10:00.375965+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/application.rb:352:in `initialize!'
2017-12-10T06:10:00.375966+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2017-12-10T06:10:00.375968+00:00 app[web.1]:    from /app/config.ru:3:in `require_relative'
2017-12-10T06:10:00.375980+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'
2017-12-10T06:10:00.375982+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
2017-12-10T06:10:00.375983+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
2017-12-10T06:10:00.375990+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2017-12-10T06:10:00.375984+00:00 app[web.1]:    from /app/config.ru:in `new'
2017-12-10T06:10:00.375988+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file'
2017-12-10T06:10:00.375985+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2017-12-10T06:10:00.375987+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string'
2017-12-10T06:10:00.375985+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval'
2017-12-10T06:10:00.375992+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
2017-12-10T06:10:00.376005+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
2017-12-10T06:10:00.376005+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/server.rb:84:in `app'
2017-12-10T06:10:00.376008+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/server.rb:104:in `start'
2017-12-10T06:10:00.376010+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:90:in `block in server'
2017-12-10T06:10:00.376006+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:283:in `start'
2017-12-10T06:10:00.376019+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `server'
2017-12-10T06:10:00.376012+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `tap'
2017-12-10T06:10:00.376021+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
2017-12-10T06:10:00.376027+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
2017-12-10T06:10:00.376048+00:00 app[web.1]:    from bin/rails:4:in `<main>'
2017-12-10T06:10:00.376047+00:00 app[web.1]:    from bin/rails:4:in `require'
2017-12-10T06:27:43.466729+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=murmuring-woodland-44138.herokuapp.com request_id=b7646d82-6d59-45b2-8040-e16cf89d513a fwd="82.102.17.248" dyno= connect= service= status=503 bytes= protocol=https

C:\Sites\nutri>

notice particularly the last line:
2017-12-10T06:27:43.466729+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=murmuring-woodland-44138.herokuapp.com request_id=b7646d82-6d59-45b2-8040-e16cf89d513a fwd="82.102.17.248" dyno= connect= service= status=503 bytes= protocol=https

I have searched and read many similar questions on here, but none seem to have an answer to my particular case. any help much appreciated.
EDIT: added gem file:
source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.6'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3' #commented out see below
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'sqlite3' #, '1.3.5'#added here because didnt deploy to heroku, as advised on https://gist.github.com/JennDudley/2493288
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'

end

group :production do
  gem 'pg'
  #gem 'rails_12factor'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

EDIT 2, database.yml:
# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

EDIT 3: new config/datbase.yml file
EDIT 4: new config/datbase.yml file (i accidentally added the wrong database yml file from another project, below is my database yml file)
# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: postgresql #sqlite3
  pool: 5
  timeout: 5000

# development:
#   <<: *default
#   database: db/development.sqlite3
development:
  <<: *default
  database: nutri_development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
# test:
#   <<: *default
#   database: db/test.postgresql #sqlite3

test:
  <<: *default
  database: nutri_test

# production:
#   <<: *default
#   database: db/production.postgresql #sqlite3
production:
  <<: *default
  database: nutri_production
  prepared_statements: false
  encoding: unicode

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
# default: &default
#   adapter: sqlite3
#   pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
#   timeout: 5000
# default: &default
#   adapter: postgresql
#   pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
#   timeout: 5000

# development:
#   <<: *default
#   database: db/development.sqlite3
# development:
#   <<: *default
# database: rails-tutorial_development #http://guides.rubyonrails.org/configuring.html#configuring-a-database

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.

# test:
#   <<: *default
#   database: db/test.sqlite3
# test:
#   <<: *default
#   database: rails-tutorial_development

# production:
#   <<: *default
#   database: db/production.sqlite3

# production:
#   <<: *default
#   adapter: postgresql
#   prepared_statements: false
#   encoding: unicode
#   database: rails-tutorial_development

is this the correct configuration to use postgresql?

A: See how in our default, you specify sqlite3 as the adapter?
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

Then, in your production, you use the defaults plus specify the sqlite3 database.
production:
  <<: *default
  database: db/production.sqlite3

Instead, it should look something like:
production:
  <<: *default
  adapter: postgresql
  encoding: unicode

Again, you really should set up postgresql on your development machine to avoid syntax differences between sqlite3 and postgresql.
To provision a database, go onto the Resources tab of your application on Heroku. Under 'Add-ons', search for 'Postgres'. Heroku will walk you through from there.
Once you're set up, in your terminal you'll need to run:
> heroku run rake db:migrate --app your_app_name

Or, if you'd rather load from your schema (which is the basically the result of all your migrations mashed into one file), you do something like:
> heroku run rake db:schema:load

REPLY
Here's what my database.yml looks like for one of my apps (naturally, I've substituted 'app_name' in for my actual app name):
default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: 5

...

production:
  <<: *default
  database: app_name_production
  username: app_name_admin
  password: <%= ENV['APP_NAME_DATABASE_PASSWORD'] %>

As you can see, I in fact have database: and username: in my production section. username: may not be required, I'm not sure. According to SQLite on Heroku, you should include database: .... But, as stated in the guide, it should be a custom name, not:
database: db/production.sqlite3

The encoding and pool bits come from section 3.15.3 (Configuring a PostreSQL Database) of the Rails Guide on Configuring a Database. You'll note that the Heroku guide does not specify encoding but the Rails guide does. I prioritize the Rails guide over the Heroku guide and so include it in all my database.yml files.
You already include pool and timeout in our default, so you don't need to reconfigure those in production.
"Set up postgreSQL on your development machine" means installing a postgreSQL server on your local machine. Simply including the pg gem does not install a server. You will ONLY need to do this if you decide to use postgreSQL in development (instead of sqlite). This has nothing to do with deploying to Heroku.
To learn more about installing postgresql on your machine, see the Local setup section of the Heroku Postgres guide.
You might also want to read the Dev/prod parity section of the Twelve-Factor App.
If you decide to continue developing with sqlite and deploying with postgresql, then you can completely ignore my comment about setting up postgresql on your development machine. However, as I said previously, sqlite and postgres have some subtle sytactic differences (the one I recall of the top of my head is how each of the databases implement LIKE functionality). What that means is that you could possibly have code that works flawlessly in development on sqlite but breaks in production on postgres. If you run into that situation, you will have to track down where the syntax differences are causing errors and then remediate your syntax. That is NO FUN.

A: Your local server error is due to file
from C:/Sites/nutri/config/application.rb:7:in '<top (required)>'

error is
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.5-x86-
mingw32/lib/sqlite3.rb:6:in 'require': cannot load such file --
sqlite3/sqlite3_native (LoadError)

check if file sqlite3/sqlite3_native exists.
First try to deploy locally and think about Heroku.
Heroku server issue
2017-12-10T06:10:00.375723+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-
5.0.6/lib/active_record/connection_adapters/
connection_specification.rb:176:in `rescue in spec': Specified
'sqlite3' for database adapter, but the gem is not loaded. Add `gem
'sqlite3'` to your Gemfile (and ensure its version is at the minimum
required by ActiveRecord). (Gem::LoadError)

says Gem compatibility issue between rails (ActiveRecord) and sqlite3. Any reason you commented the version for sqlite3? try uncommenting it
gem 'sqlite3', '1.3.5'

Only certain version of rails works with sqlite3 versions
Also, can pg gem have a version like below
gem 'pg', '0.18.4'

Try all this, move your Gemfile.lock file
mv Gemfile.lock Gemfile.lock_

install gems now
bundle install


text:
Q: OperationalError: (psycopg2.OperationalError) terminating connection due to idle-in-transaction timeout I have a function that performs a search like
def search(cls: Type[T], session, search_query):
        combined_search_vector = (
            x.y.search_vector
            | sa.func.coalesce(xClass.yClass.search_vector, "")
        )

        with session as ctx_session:
            query = (
                ctx_session.query(Class)
                .join(xClass.YClass)
                .filter(combined_search_vector.match(f"'{search_query}'"))
            )

        return query

Initially I had the search function writen like bellow, is possible that the idle transaction error came from this?
 @classmethod
    def search(cls: Type[T], session, search_query):
        combined_search_vector = (
            x.y.search_vector
            | sa.func.coalesce(xClass.yClass.search_vector, "")
        )

        try:
            query = (
                ctx_session.query(Class)
                .join(xClass.YClass)
                .filter(combined_search_vector.match(f"'{search_query}'"))
            )

        except sa_exc.DatabaseError:
            session.rollback()

        return query

The search functionality works fine but this function throws a lot of
 OperationalError: (psycopg2.OperationalError) terminating connection due to idle-in-transaction timeout

In my knowledge postgres should be handling the sessions here. What am I missing?
This is my set up at the top
     sessionmaker = attr.ib(default=None, repr=False)
    _session = attr.ib(default=None, repr=False)
    _engine = attr.ib(repr=False)
    _search_index_prefix = "search_"

    @_engine.default
    def create_engine(self):
        url = self.config["core"]["url"]
        engine = create_engine(url, echo=False)
        self._sessionmaker = sessionmaker(bind=engine)
        return engine

    @property
    def session(self):
        if self._session is None:
            self._session = self._sessionmaker()
            self._session.execute("SET pg_trgm.similarity_threshold = 0.2;")
        return self._session

    def close(self):
        if self._session is not None:
            self._session.close()
            self._session = None

Also is there a way for me to for connection to go idle on my development machine for testing purposes?


text:
Q: Uncaught ReferenceError: keyup errot at login page using ngnix +polymer js Code, here let me view the type values in text field in demo
<!DOCTYPE html>
<html>
<body>

     <input type="text" name="fname" onkeyup="keyup(this)"  value>

<script>
function keyup(element)
{
element.setAttribute("value",element.value);

}
</script>
</body>
</html>

However, when I move the same to actual website, I place the script inside <body> and also in head but I'm getting same error. I think something like an API or polymer js is interfering to find this `keyup' function.
Uncaught ReferenceError: keyup is not defined
    at HTMLDivElement.onkeyup ((index):1)

All the solution on stackoverflow talks about placing the function in head scope which i did but i get same error. I don't know how to invoke this function. Thanks

A: I would recommend to set up the event handler yourself instead of onkeyup=""
Here is a basic event handler for the keyup event.
addEventListener docu
<!DOCTYPE html>
<html lang="en">
    <body>
        Your input <input id="input" type="text" name="fname" />
        <br/>
        Your last input <input id="output" type="text" readonly/>
    </body>

    <script>
        document.getElementById('input').addEventListener('keyup', (event) => {
          console.log('Keyoup even fired', event);
          document.getElementById('output').value = event.key;
        });
    </script>
</html>


text:
Q: Largest substring with equal number of each symbol The task is similar to this one. Finding the largest balanced subarray (with equal number of each symbol). The difference is that the array consists of 4 different characters, not 0s and 1s. So the question would be how to change the approach with prefix sum in this case?
Time complexity has to be no more than O(n^2), the string length is at most 10^5.
I was thinking about giving two characters values 1 and -1 and the other two 1000000 and -1000000, but it wouldn't work, simply because you can have a zero sum with half the symbols.
Is there a simple way to do this?


text:
Q: Regarding: Child Class in a Array C++ Regarding: Child Class in a Array C++
Hi guys, sorry as i am stuck on some work.
Basically this is what happen
I have a parent class call vehicle and it got 2 child class call
Car and Motorcycle

Parent class have the following value:
string Name: value either Car or MotorCycle
wheels : 4 or 2 (depends is car or motorcycle)
Notes On Wheel:
wheel[0] : Fine condition
wheel[1] : need some repair
wheel[2] : Fine condition
wheel[3] : Fine condition

I wonder how do i record this all in  VehicleTwoD Array
Car / Motorcycle is a child class of Vehicle, what do you guys suggest. I try to create an object of VehicleTwoD vehtwod[100];
then i do a for loop to prompt. but how do i record the object car / motorcycle into my VehicleTwoD array and how do i record the string array inside too. so every VehicelTwoD array element contains the information
Name ( Motorcycle or Car)
Wheel ( depend on name - 2 or 4)
String array - notes size depend on what is choosen

How do i record all in 1 array.
Thank you very much , i know this is polymorphic and i know this is OOP and i know i need study more. but i really stuck on this part on creating such array that can hold other array.
THANKS!

A: Simplifying solution by not addressing irrelevant dimensionality of the storage array.
Create an array of Vehicle pointers, and store those:
vector<unique_ptr<Vehicle>> vehicles_;
vehicles_.push_back(new Car(...));
vehicles_.push_back(new Motocycle(...));

Since we're using unique_ptr here instead of a raw pointer, there's no need to explicitly delete.
By making the class polymorphic you can declare functions on the base class and implement class-spefici functionality by providing definitions in the derived classes.  This makes it possible to call methods through a pointer to the base class without having to cast to the derived type.
If you need to call methods that exist only on a derived class, then you will need to cast the pointer.  This should be done using dynamic_cast, and requires that your class is polymorphic.
EDIT:
Your comments suggest that you don't know how to use a vector and would prefer to use a raw array.  That's fine too.  Here's a simplified example that uses a C-style array of raw pointers.  Note that by using neither vector nor a smart pointer like unique_ptr you make your code more brittle and prone to errors, and you often have to use a Magic Number for the array size (which is gross).
Vehicle* vehicles_[100];
vehicles_[0] = new Car(...);
vehicles_[1] = new Motorcycle(...);


text:
Q: FlickityCall - prev/next event programmatically To properly handle my carousel I use flickity.
It works fine, but I'm currently trying to navigate with custom buttons.
Docs say to call carousel.flickity("next") - which I tried, but I doesn't seem to work.
import * as Flickity from 'flickity';

this.$elem = value.nativeElement;
this.carousel = new Flickity(this.$elem, {
  accessibility: true,
  prevNextButtons: false,
  pageDots: false,
  setGallerySize: false,
  draggable: true,
  freeScroll: true
});

Is there an equivalent to call the next event programmatically using javascript/typescript?

A: Hey I got a solution for that. Use query selector to access Flickity given next buttons and click them programmatically on your custom button onClick functions. You can hide the buttons given by Flickity using css. This is a work around but not based on official docs.
/*
    In my case I inspected the button given by Flickity and accessed those in my JS or TS file
*/

 let temp:any = document.querySelector('.flickity-button.flickity-prev-next-button.next');
 temp.click();

In your CSS file you can add visibility property hidden so that button functionality will be intact to click programmatically but in UI as expected Flikity buttons wont be found.
.flickity-button {
    position: absolute;
    visibility: hidden;
    border: none;
    color: #8c6238 !important;
}


text:
Q: View not unloading from stack I'm a newbie and I have the following issue I'am hoping someone can help me with. When my app loads it has several buttons that load different UIWebViews each which has a back button. The first view loads fine and when you press the back button takes you back to the main view, however when you load the second view the first url loads again and when you press the back button it then loads the second view.
It seems as though the first view is not unloading from the view. If any one can help it would much appreiciated. Here is my code.
To load each view
-(IBAction)displayLocationView:(id)sender {
locationViewController = [[LocationViewController alloc]initWithNibName:@"LocationViewController" bundle:nil];

[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

[self.view addSubview:locationViewController.view];
[UIView commitAnimations];
}

To load the url
-(void)viewDidLoad {
[super viewDidLoad];

NSURL *url = [NSURL URLWithString:@"http://www.kingsgroversl.com.au"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

[webView loadRequest:request];
}

To unload each view and return to main screen
-(IBAction)backButton:(id)sender {

[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view.superview cache:YES];

[self.view removeFromSuperview];
[UIView commitAnimations];
}

Thanks in advance.

A: The problem is here
-(IBAction)backButton:(id)sender {

[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view.superview cache:YES];

[self.view removeFromSuperview];// change this to

[locationViewController.view removeFromSuperview];
    [UIView commitAnimations];
    }
You need to change the above mentioned line.
Right now what you are doing is removing the sel.view.... which is not correct.
you need to remove your subviews.
like this way.
[locationViewController.view removeFromSuperview];

Hope this will help you

A: When you are using the removefromsuperview it means you are removing from superview.But not from the memory.So it is better to use the [self.navigationcontroller pushviewcontroller:viewcontroller animated:YES];


text:
Q: Detach event handlers selectively I have a html richText editor. My code structure is like this:
function richTextEditor(div)
{

   var self=this;
   self.instanceIdentifier=Math.floor(Date.now());
   //Richtext editor creation logic

   $(document).on('click.'+self.instanceIdentifier,function()
    {
      //some logic
    })

   self.destroy=function()
   {
     //delete all properties of self
     // detach all listeners
     $(document).off('click.'+self.instanceIdentifier) ;
   }
}

Our app is single page application, and there are multiple richtexteditor instances opened in different panes. I need to destroy the instance when the node corresponding to this has been removed. Destroy should remove all the event handlers attached by that instance.
So far Date.now() for uniquely identifying the handler is working but I think there must be some elegant way to do that.
   var div1=$('#notes')[0];
   var editorInstance1=new richTextEditor(div1);
   //remove is not a valid jquery event, its just for illustration
   // I am getting remove event from another library
   $(div1).on('remove',function(){
       editorInstance1.destroy();
    })

Please suggest if this is the correct way to go.

A: What you want is a GUID or UUID. There is a great answer to this question here.


text:
Q: Limit of Lebesgue integral over the real line For every $n \geq 1$ consider the integral:
$I_n=\int_{{\mathbb{R}}}^{}  \frac{\sin(x^2+n^2)}{x^2+n^2}  \,d\lambda$
I have to explain why $I_n$ is well-defined for every such $n$ and I want to compute $\lim_{n \to \infty} I_n$.
The part about explaining the well-definedness really confuses me. However, I tried to come up with an explanation. First I will find a majorant for the integrand:
$|\frac{sin(x^2+n^2)}{x^2+n^2}|\leq |\frac{1}{x^2+1}|=\frac{1}{x^2+1} $
I have a question to this: Are you allowed to choose a majorant depending on n?
I know that the Lebesgue integral is an extension of the proper Riemann integral. Hence this equality:
$\int_{[-k,k]}^{}  \frac{1}{x^2+1}  \,d\lambda = \int_{-k}^{k}  \frac{1}{x^2+1}  \,dx =2arctan(k)$
Now I will take a look at the limits:
$ \int_{\mathbb{R}}^{}  \frac{1}{x^2+1}d\lambda=\lim_{k \to \infty}\int_{[-k,k]}^{}  \frac{1}{x^2+1}  \,d\lambda = \lim_{k \to \infty}\int_{-k}^{k}  \frac{1}{x^2+1}  \,dx =\lim_{k \to \infty}2arctan(k)=\pi$
So by monotonicity it must hold that:
$ I_n=\int_{{\mathbb{R}}}^{}  |\frac{sin(x^2+n^2)}{x^2+n^2}|  \,d\lambda \leq \int_{\mathbb{R}}^{}  \frac{1}{x^2+1}d\lambda =\pi  $
Since $|\frac{sin(x^2+n^2)}{x^2+n^2}|$ is Lebesgue integrable, $\frac{sin(x^2+n^2)}{x^2+n^2}$ also is. Therefore $I_n$ is well-defined for every $n$. The conditions for using Lebesgue's dominated convergence theorem clearly are met, so I can simply push the limit into the integral:
$\lim_{n \to \infty}I_n=\lim_{n \to \infty}\int_{{\mathbb{R}}}^{}  \frac{sin(x^2+n^2)}{x^2+n^2}d\lambda=\int_{{\mathbb{R}}}^{}  \lim_{n \to \infty}\frac{sin(x^2+n^2)}{x^2+n^2}  \,d\lambda=\int_{{\mathbb{R}}}^{} 0  \,d\lambda=0$
I think the last part is right, but I am not sure about the first part since it is an improper integral.

A:
I have a question to this: Are you allowed to choose a majorant depending on $n$?

If your goal is to just show that $x\mapsto \frac{\sin(x^2+n^2)}{x^2+n^2}$ is Lebesgue-integrable on $\Bbb{R}$, then yes you can. For instance, this is bounded by $\frac{1}{x^2+n^2}$, and this latter function is clearly Lebesgue-integrable on $\Bbb{R}$. So such a reasoning will suffice to explain the well-definition of $I_n$.
However, your goal is two-fold: you want to show well-definition of $I_n$, and compute its limit. Thus, what you've done is better: you found an upper bound which is independent of $n$, and is still integrable on $\Bbb{R}$. This is good because it allows you to deduce well-definition of each $I_n$ as above; furthermore, you can now compute the limit $\lim\limits_{n\to\infty}I_n$ using dominated convergence, as you argued. And yes, the limit is indeed $0$ because of dominated convergence (Lebesgue integration and DCT holds for any measure space, so the fact that you're working on all of $\Bbb{R}$ is not at all a problem here).


text:
Q: How can I find a broken disc? I have a problem. I got 1 broken disc in RAID6. How can I find which one broke down?
I've tried
# cat /proc/mdstat  <--- to check condition of raid.

I want to know if this command
mdadm –detail /dev/md0

will give me the serial number of the physical disc.


text:
Q: Use of Universal link open jitsi video in my App of Meeting but it open only my App.not meetings Hi team I want to open jitsi link Video in my app. after clicking the the jitsi link Video which in getting from what'sup, iMessage in the iPhone . I am implemented Universal linking in iOS but its open the my App only not open meeting of the link.
Any One idea please Help me.
Thanks in Advance.

A: Please ask question clearly as it was really tough to understand your question.
please check your meeting url you have sent through whatsapp or iMessage. check whether the meeting room name is being passed or not.
and please post https://community.jitsi.org/ here to get more attention. Thanks


text:
Q: Need a box and on select and clicking on ">>" goes to next box I need a component in which I can select the options and while clicking on select or >> sign it will appear in another box. I don't know what this is called and how to do it.
Please also view image below:

A: You have to use multiselect with jQuery.  Good tutorial for this
Use this HTML code to create your UI:
<html>
  <head>
    <link href="path/to/multiselect.css" media="screen" rel="stylesheet" type="text/css">
  </head>
  <body>
    <select multiple="multiple" id="my-select" name="my-select[]">
      <option value='elem_1'>elem 1</option>
      <option value='elem_2'>elem 2</option>
      <option value='elem_3'>elem 3</option>
      <option value='elem_4'>elem 4</option>
      ...
      <option value='elem_100'>elem 100</option>
    </select>
    <script src="path/to/jquery.multi-select.js" type="text/javascript"></script>
  </body>
</html>

Then use this jQuery :
.multiSelect(options)
$('#my-select').multiSelect()

.multiSelect('select', String|Array)
$('#your-select').multiSelect('select', String|Array);

.multiSelect('deselect', String|Array)
$('#your-select').multiSelect('deselect', String|Array);

.multiSelect('select_all')
$('#your-select').multiSelect('deselect_all');

.multiSelect('deselect_all')
$('#your-select').multiSelect('select_all');

.multiSelect('refresh')
$('#your-select').multiSelect('refresh');

This code will help you, even if the link doesn't work. Happy coding.


text:
Q: How can one set up persistent collaborating objects in DigitalMicrograph via scripting? I have come to really appreciate the benefits of using objects to deploy a given application within the DigitalMicrograph environment via the DMS language.  The object-oriented approach opens the door to the use of reusable design patterns involving collaborating objects, e.g. Model-View-Controller (MVC).  However, objects within DM seem to be highly volatile due to the use of automatic reference counting to manage their life cycles.  In order for an MVC trio, or any other set of collaborating objects, to stay alive long enough to be useful, at least one of them must be rooted in a non-volatile object managed by the DM application.  So far, the only such objects I have come across within DM are those based on the UIFrame class (i.e. modeless dialogs and UI palettes).  For MVC implementations, this works out fine since it makes sense to implement the View as a UIFrame object.  It's just a bit unconventional in that the View object becomes the root object that keeps the MVC trio alive and functioning.  Normally it is the Controller object that is rooted in the application and manages the Model and View objects.  But what about design patterns that do not involve UI?  Is there any (acceptable) way to give a set of collaborating objects persistence without rooting them in a UIFrame object?  Are there other application-rooted object types that can serve this purpose?  I assume setting up a reference cycle would not be an acceptable approach due to the inevitable risk of memory leaks.

A: I can think of various ways to get this persistence, but the one which jumped to mind first was to launch one object into a background thread, like in the example below. The actual background thread can check every so often if the object should still remain, and by sharing the object ID with the outside world, other objects (which don't have to be persistent) can access the "anchored" object.
A word of warning though: If you keep things in memory like this, you have to be careful when closing DigitalMicrograph. If the object hangs on to some items DM wants to destroy, you might see errors or crashes at the end.
// This is the object "anchored". It will remain in memory, because we launch it on a separate thread.
// On this thread, it loops until a variable is set to false (or until SHIFT is pressed)
Class IPersist : Thread
{
    number keepme

    IPersist( object self ) { result("created IPersist:"+self.ScriptObjectGetID()+"\n");}
    ~IPersist( object self ) { result("killed IPersist:"+self.ScriptObjectGetID()+"\n\n\n\n");}

    void CallFromOutside( object self ) { Result( "\t IPersist can be used!\n" ); }
    void StopFromOutside( object self ) { keepme = 0; }
    void RunThread( object self )
    {
        keepme = 1
        Result( "\t Called once at start.\n")
        While( keepme && !ShiftDown() ) yield()
        Result( "\t Finished.\n")
    }
}

// Just and example class used to access the 'anchored' object
Class SomethingElse
{
    number keepID
    SomethingElse( object self ) { result("created SomethingElse:"+self.ScriptObjectGetID()+"\n");}
    ~SomethingElse( object self ) { result("killed SomethingElse:"+self.ScriptObjectGetID()+"\n");}
    void SetKeepID( object self, number id ) { keepID = id; }
    void CallOut( object self )
    {
        result( "SomethingElse object is accessing CallOut...\n" )
        object p = GetScriptObjectFromID( keepID )
        if ( p.ScriptObjectIsValid() )
        {
            p.CallFromOutside()
        }
    }
    void CallStop( object self )
    {
        result( "SomethingElse object is accessing CallOut...\n" )
        object p = GetScriptObjectFromID( keepID )
        if ( p.ScriptObjectIsValid() )
        {
            p.StopFromOutside()
        }
    }
}

// Main script. Create object on separate thread. Then feed it's ID as "weak reference" into the second object.
{
    object ob = Alloc(IPersist)
    ob.StartThread()

    object other = Alloc(SomethingElse)
    other.SetKeepID( ob.ScriptObjectGetID() )
    other.CallOut()
    If ( TwoButtonDialog( "You can either stop IPerstis now, or by pressing SHIFT later.", "Stop now", "later" ) )
        other.CallStop()
}

A: An alternative way would be to have two objects keep references of each other. This is a deadlock-situation one would normally rather avoid, but for the purpose of anchoring it works as well. No object can go out of scope until you release one on purpose.
Again, it is your responsibility to 'release' things when you want a proper shutdown of the system.
The code for the deadlock-situation is rather slim:
class SelfLock
{
    object partner
    SelfLock( object self ) { result("created SelfLock:"+self.ScriptObjectGetID()+"\n");}
    ~SelfLock( object self ) { result("killed SelfLock:"+self.ScriptObjectGetID()+"\n");}
    void SetPartner(object self, object p) { partner = p; }
    void ReleasePartner(object self) { partner = NULL; }
}

{
    object p1 = Alloc(SelfLock)
    object p2 = Alloc(SelfLock)
    p1.SetPartner(p2)
    p2.SetPartner(p1)

    if ( TwoButtonDialog( "Release partner", "Yes", "No keep locked" ) )
        p1.ReleasePartner()
}

A: The third, and by far the best and cleanest solution is to launch your object as a 'listener' to some event. As you are looking for an object which should stay in scope as long as DigitalMicrograph is open, its possibly best to listen to the application itself. By listening for the "about_to_close" message you also get the ideal handle to properly release all resources before shutdown. The code is the following:
From my 3 answers this is the one I would use. (The others should just illustrate options.)
class MyPermanentObject
{
    MyPermanentObject( object self ) { result("created MyPermanentObject :"+self.ScriptObjectGetID()+"\n");}
    ~MyPermanentObject( object self ) { result("killed MyPermanentObject :"+self.ScriptObjectGetID()+"\n");}
    void DeInitialize( object self, number eventFlags, object appObj )
    {
        OKDialog( "The application is closing now. Deinitialize stuff properly!" );
    }
}

{
    object listener = Alloc( MyPermanentObject )
    ApplicationAddEventListener( listener, "application_about_to_close:DeInitialize" )
}


text:
Q: jShowOff not showing numeric links, shows 'undefined' instead I made a content rotator with jShowOff in a wordpress site, and wanted to have numeric links to each slide, that normaly comes by default but somehow shows 'undefined', the only thing i found on the internet was that it has problems with jQuery under 1.6, and i believe wordpress has way above that.... tried a workaround by making a counter and giving each slide that title, but then it pops the number as a title, not just looking ugly but also like a bug...any help? Here's the code for the example:

                <?php $my_query = new WP_Query('category_name=oficiais&posts_per_page=7');
                    while ($my_query->have_posts()) : $my_query->the_post();
                    $do_not_duplicate[] = $post->ID; ?>

                    <?php the_post_thumbnail('recent-thumbnail',array('title' => "")); ?>
                    <?php the_title(); ?>

<?php $myExcerpt = get_the_excerpt();
                    $tags = array("
", "
");
                    $myExcerpt = str_replace($tags, "", $myExcerpt);
                    $myExcerpt = str_replace("
", " ", $myExcerpt);
                    echo $myExcerpt;
                    ?>
<a href="<?php the_permalink(); ?>">Ver artigo

                <?php endwhile; ?>


text:
Q: Any way to automate zoom meeting in a specific way? We are doing a meeting on zoom daily, where there is a list of about 30 participants. We have to handle the following situation manually right now by making someone host who has to manually do it:
Except one main speaker whose microphone we want to be on continuously unmute, the rest of the huge list of participants, we want them to speak one by one and we have a certain ordering who will speak first then next and next and so on.
Right now, the host has to look at the ordering list manually and then find out whose turn is to speak and then mute the already active participant and then unmute the one whose turn is next. This manually handling is very troublesome.
Is there any way to automate this process ? Any other alternative than zoom will also work.

A: I am a Zoom Host and a Zoom attender and have been using Zoom for almost as long as it has been out.
I researched my Host functions and there is no way to automate the order in which guests may speak - that is up to the Host to manage.
I also note from experience that Zoom does not create function out of dysfunction except as noted above, the Host can mute everyone to keep as much order as possible.
Edit and Followup:  Doing some review of my own notes, in a group of 30 people, statistically 6 to 10 of them will not really know how to run a meeting (this is a management skill). Consider having 8 people in your group run the meeting as a good host. That means 1 person runs a meeting every other month. This is time to prepare the strategy for managing as a good host. Try this.


text:
Q: Draw horizontal lines between dates in ggplot2 in r Consider example dataframe as:
df <- data.frame(Names = c("A", "A", "B", "B", "C", "C"),
                 Start = structure(c(18659, NA, 19024, NA, 19297, NA), class = "Date"),
                 End = structure(c(NA, 21062, NA, 20970, NA, 22552), class = "Date"),
                 Dates = structure(c(18659, 21062, 19024, 20970, 19297, 22552), class = "Date"))

I want to create a timeline plot with the Names on y-axis and Dates on x-axis. then I want to draw horizontal lines between the Start and End points:
ggplot(df, aes(x = Dates, y = Names)) + geom_point(size = 1) +
  theme_classic() + guides(color = FALSE) + labs(title = "title") +
  theme(axis.line.y = element_blank(), axis.ticks = element_blank(),
        axis.title = element_blank(), axis.text.y = element_text(size = 12, color = "black"),
        plot.title = element_text(size = 20, hjust = 0.5, face = "bold",
          margin = margin(c(0.3,0,0.5,0), unit = "in")),
        axis.text.x = element_text(size = 12, color = "black",
           margin = margin(c(0.27,0,0,0), unit = "in")),
        axis.line.x = element_line(size = 0.9, color = "navy")) +
  scale_x_date(date_break = "5 months", date_labels = "%b") +
  geom_segment(aes(x = Start, xend = End,
                   y = Names, yend = Names), size = 0.6, color = "navy")

But I cannot get the horizontal segment lines to show on the plot:

Desired output is:

A: You're looking for geom_linerange. Also, your dataframe is not ideally constructed, you should fill NAs.
df <- data.frame(Names = c("A", "A", "B", "B", "C", "C"),
           Start = structure(c(18659, NA, 19024, NA, 19297, NA), class = "Date"),
           End = structure(c(NA, 21062, NA, 20970, NA, 22552), class = "Date"),
           Dates = structure(c(18659, 21062, 19024, 20970, 19297, 22552), class = "Date")) %>%
  fill(Start) %>%
  fill(End, .direction = "up")

ggplot(df, aes(x = Dates, y = Names)) + geom_point(size = 1) +
  geom_linerange(aes(xmin = Start, xmax = End)) +
  scale_x_date(date_break = "5 months", date_labels = "%b")


text:
Q: Current regulation before or after voltage regulation? I'm making a +12V/-12V power supply (2.5A max. output current each) with voltage regulation and current limiter (+ option to go lower on voltage than 1.25V). In the datasheets, I've came across, that in the Datasheet, page 8, FIgure 20 that there's a current limiter BEFORE the voltage regulation, which didn't made much sense to me.
Isn't is supposed to be the voltage regulation first in a "row" here? Because if the current will be limited too low, there's not even necessarily that I could get 1.25V on the input of the "voltage LM-317"?

In the second photo, there's my schematic for the power supply with voltage segment before the current limiter. Is this the more correct one or is the one from the datasheet the one, which I should use?
I marked with red the voltage segment, while the current limiter is red.

A:
there's a current limiter BEFORE the voltage regulation, which didn't
  made much sense to me.

You can put current limiting after the voltage regulator only if the current limiter causes no excessive volt drops up until the point when it needs to regulate / limit the current.

Isn't is supposed to be the voltage regulation first in a "row" here?

Or, you can put a current limiter before the regulator and the odd volt or so of volt drop that it might incur (in normal operation) can be mitigated against by having a slightly higher feed voltage into the circuit.
Alternatively, you can put the current limiter after the voltage regulator's pass-transistor but, the voltage regulator's sensing feedback system should be after the current limiter thus the voltage regulator still effectively regulates and "lives with" the added volt drop of the current limiter in series with the output of the voltage regulator's pass transistor.

Because if the current will be limited too low, there's not even
  necessarily that I could get 1.25V on the input of the "voltage
  LM-317"?

And that is the whole point - if you are limiting current the voltage regulator must reduce its output else how can the current be limited. You cannot have simultaneously over-current limiting AND voltage regulation occuring together.

A: The current limiter will have a voltage drop across it. If you put it second then you will have an output that will not equal the voltage setting in the first section.
When you put the current limiter first then any voltage drop across it is not seen at the output as long as the input voltage is high enough and the voltage control does not adjust to too high of a voltage at the output. In this case the output section will need a minimal amount of current to bias the LM317 and its feedback network. But in any case the first stage will limit the total current that the output stage can pass through before its voltage output begins to sag down.


text:
Q: Deducting the value of one django field in a model class from another model class I am looking for a way to subtract from a field named total in the first class, which i get by multiplying the price and the quantity. It works well and the result is evident in the database. I would like, after calculating the total, to deduct that field by referencing it in my second class. Basically, the sales input value - the referenced total object should return a profit/loss and store that in a field named profit in the second class. I have tried a few ways, it posts the sales value but not the calculated value in terms of profit/loss. Is there something I am overlooking or I am oversimplifying the code?
    from django.db import models

    import datetime
    from django.utils import timezone
    from numpy import array

    class CowData(models.Model):
        title = models.CharField(max_length=20, default="")
        user = models.CharField(max_length=20, null=False)
        feed = models.CharField(max_length=20, null=True)
        quantity = models.PositiveIntegerField()
        price = models.PositiveIntegerField()
        total = models.PositiveIntegerField(editable=True, blank=True, null=True, unique=True)
    # here i calculate the total by multiplying the price and the total

        def save(self, *args, **kwargs):
            self.total = array(self.total)
            self.total = self.price * self.quantity
            super(CowData, self).save(*args, **kwargs)

    class Sales(models.Model):
        # total = models.ForeignKey(CowData, to_field='total', on_delete=models.CASCADE, default=False)
        sales = models.PositiveIntegerField()
        profit = models.PositiveIntegerField()

        # What I have tried :
        # def save(self, *args, **kwargs):
        #     self.profit = self.sales - self.total
        #     super(CowData, self).save(*args, **kwargs)
        # here is where things are vague

        def profit_made(self, *args, **kwargs):
            self.profit = self.sales - CowData.objects.get(pk=5).total
            super(CowData, self).save(*args, **kwargs)

A: I realize I had minor errors in my code. I have managed to solve it.
class Sales(models.Model):
    sales = models.PositiveIntegerField()
    profit = models.PositiveIntegerField(editable=True, blank=True, null=True)

    def save(self, *args, **kwargs):
        self.profit = self.sales - CowData.objects.get(pk=1).total
        return super().save(*args, **kwargs)


text:
Q: choosing a table column when using zend db select join so I'm using Zend DB select and the join() function to join two tables...
there are two columns in the joined tables that have the same name (say it's column "id") (and I'd like to keep it that way)
but then when I use Zend_Paginator::factory() on the object, the results would only have one "id" entry from one of the two tables...
how do I specify zend so that it'll return the id entry of one specific table over the other? ie. how do I choose which table to have the "id" value returned when there are multiple tables with the same column named "id" that are joined with each other

A: You can specify a field or list of returned fields as second parameter of from() OR third parameter of join(), joinLeft() ....
I mean 'OR' because you can't return field with same name twice.
You can specify returned fields using: null (none will be returned), '*' (all will be returned), array (values will be real field names, keys will be aliases - if needed)
zend.db.select.building.columns - Adding Columns


text:
Q: How to check if a date time is before midday I have a datetime object in python and I would like create a function to check whether the input is in the morning or afternoon on the day of the datetime (ie, before or after 12pm). How to I manually create the time 12:00 and can I use greater than or lesser than symbols for this (<, >)?

A: Call the datetime.datetime.time() method on the datetime object and compare it with a datetime.time() object:
if dt.time() < datetime.time(12):

or just look at the datetime.datetime.hour attribute:
if dt.hour < 12

The latter is simpler, the former gives you more flexibility to compare against times that include a minute component:
if dt.time() < datetime.time(12, 30)

Demo:
>>> import datetime
>>> dt = datetime.datetime.now()
>>> dt
datetime.datetime(2014, 2, 10, 10, 39, 30, 768979)
>>> dt.time() < datetime.time(12)
True
>>> dt.hour < 12
True
>>> dt = dt.replace(hour=20)
>>> dt
datetime.datetime(2014, 2, 10, 20, 39, 30, 768979)
>>> dt.time() < datetime.time(12)
False
>>> dt.hour < datetime.hour
False


text:
Q: How to switch from TTY to KDE in Oracle Linux I had installed Oracle Linux. While installing I had selected KDE for the desktop.
After finishing I assumed that I could login to KDE Desktop, but I got a TTY.
It asked for login and I gave root and for password entered what I had given while installing.
The thing is I want to go to KDE desktop from TTY. I got after logging in:
[root@techsunil ~]#

How can I switch to desktop of KDE?

A: There is a couple of things you need to be aware of.
What is the current run level ? 3 or 5?
Check it by

cat /etc/inittab | grep id\:

If it's 3 then change it to 5 by editing the file and restart or issue on the command line init 5.
If you want to have the GUI login screen, make sure you have KDM or GDM installed run

rpm -q kdm

If this returns no packages, you'll have to install it (but that should have been taken care of by installing KDE).

A: You need to install and setup KDM. This is easiest way.


text:
Q: Regex for splitting apparel sizes I have the following input (only for example, real input contains much more crazy data)
$values = [
    '32/34, 36/38, 40/42, 44/46',
    '40/42/44/46/48',
    '58/60',
    '39-42',
    '40-50-60',
    '24-25,26,28,30',
    '36 40,5 44',
];

and want to split it by separators like / or , but keep pairs of values. This should be done only, if separator does not occur multiple times, so the result should look like:
'32/34, 36/38, 40/42, 44/46'
    => [ '32/34', '36/38', '40/42', '44/46' ]
'40/42/44/46/48'
    => [ '40', '42', '44', '46', '48' ]
'58/60'
    => [ '58/60' ]
'39-42'
    => [ '39-42' ]
'40-50-60'
    => [ '40', '50', '60' ]
'24-25,26,28,30'
    => [ '24-25', '26', '28', '30' ]
'36 40,5 44'
    => [ '36', '40,5', '44' ]

What I have so far is
$separator = '^|$|[\s,\/-]';
$decimals = '\d+(?:[,.][05])?';
foreach ($values as $value) {
    preg_match_all('/' .
        '(?<=' . $separator . ')' .
        '(?:' .
            '(?P<var1>(' . $decimals . ')[\/-](?-1)|(?-1))' .
        ')(?=' . $separator . ')' .
    '/ui', $value, $matches);
    print_r($matches);
}

But this fails for 40/42/44/46/48 which returns
[var1] => Array
    (
        [0] => 40/42
        [1] => 44/46
        [2] => 48
    )

But each number should be returned separately. Modifying regex to '(?P<var1>(' . $decimals . ')([\/-])(?-2)|(?-2))(?!\3)' is better, but still returns wrong result
[var1] => Array
    (
        [0] => 40
        [1] => 42
        [2] => 44
        [3] => 46/48
    )

How should the correct regex look like?

A: As stated in comments above, I know that a 100% match is not possible, because of user input. But I've found a regex which fits most of my use cases:
(?<=^|$|[\s,\/-])(?:(?P<var1>(?<![\/-])(?!(?:(\d+(?:[,.][05])?)[\/-]){2}(?-1))(\d+(?:[,.][05])?)[\/-](?-1)|(?-1)))(?=^|$|[\s,\/-])

See https://regex101.com/r/q3YSa7/1


text:
Q: How to interpret Zend Framework 2 errors? I just got this error:
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with  message 'Module (ZfcUserOverride) could not be initialized.' in F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php:189 Stack trace:
#0 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(163): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
#1 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(90): Zend\ModuleManager\ModuleManager->loadModule('ZfcUserOverride')
#2 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#3 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent))
#4 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('loadModules', Object(Zend\ModuleManager\ModuleEvent), NULL)
#5 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(109): Zend\EventManager\EventManager->trigger('loadModules', Object(Zend\ModuleManager\ModuleManager), Object(Zend\ModuleManager\ModuleEvent))
#6 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(252): Zend\ModuleManager\ModuleManager->loadModules()
#7 F:\Server\domains\zf2-skeleton\public\index.php(17): Zend\Mvc\Application::init(Array)
#8 {main} thrown in F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php on line 189

All, what I get from this error is understanding that problem is in ZfcUserOverride module. But is there any other usefull information "encryped" here :) ?

A: I'm answering your question, "How to interpret Zend Framework 2 errors." I'm not addressing the error you encountered.
Identifying problem areas from ZF2 error reports can be a challenge.  Yes, the stack trace provides useful information – it points out exactly where things went wrong.  Unfortunately, what it says is where in the framework your code created a problem and not what part of your code created that problem.  So, if you want to spend hours digging into the framework, everything is neatly listed for you.  However, most of us use a framework to get away from the details, not to wrestle with them.
Here's what I do:  The error message has three parts: File, Message and Stack Trace; and clues can be found in each:
File: Except in rare circumstances, I find the File part of the message to be useless.  It might as well say, "you have a 'needle-in-a-haystack-error': happy hunting."
Stack Trace: The Stack Trace part of the message is where I look first.  While it simply lists locations in ZF2 framework that have ultimately led to the error, it will often identify some of your files, classes or variables that could have had some culpability.  I don't see an example of any of your files in the stack trace above, but I often find traces of my own work listed here.  In those instances, I scrutinize the suspect code for typos, bad syntax and other issues.
Message:  If I don't find anything in the stack trace, I look into the message.  I'm no ZF2 pioneer, so there's almost always someone who has encountered the same error before me.  I copy the entire error message and paste it into my favorite search engine (deleting my unique paths, of course).  The SO hits tend to be the most helpful so I go there first.  To save time, I skip over the question and go right to the answer because the questioner is often as lost as I am and has presented a whole lot of haystack info in search of his needle.  The answer(s) might say something like "it appears that you didn't tie your shoes this morning," which often causes me to say, "Hey, wait a second!  I forgot to tie my shoes this morning, too," and off I go to review the code for my shoe-tying method.
For example, searching Module (ZfcUserOverride) could not be initialized.' in Zend\ModuleManager\ModuleManager.php:189  leads to the SO question Zend Framework 2 tutorial: Module (Application) could not be initialized, which may have an answer that is pertinent to your problem.
If existing SO answers don't point me in the right direction, I ask one of my own.


text:
Q: Tkinter recursion error when calling update several times I want to create a frameless resizable window, the problem is, when there are many widgets, they glitch when the window is resized using a Sizegrip. The only solution that I found that removes this glitch effect is to update the window during the resize.
Unfortunately if you keep resizing for a few seconds a recursion error will occur and I have no idea why.
Here's my code
import tkinter as tk
from tkinter.ttk import Sizegrip

root = tk.Tk()
root.overrideredirect(True)
root.geometry("500x400")

def on_resize(event):
    global root
    root.update()

tk.Label(root, text = "Use the bottom right grip to resize, try for a few seconds").pack()

sg = Sizegrip(root)
sg.pack(side = tk.BOTTOM, anchor = tk.E)

sg.bind("<B1-Motion>", on_resize)

root.mainloop()

A: Check if you're already resizing and don't call root.update() again.
resizing = False

def on_resize(event):
    global resizing
    if not resizing:
        resizing = True
        root.update()
        resizing = False


text:
Q: MvcSiteMapProvider MVC4 Nuget installation failure Visual Studio 2013 Installation of MvcSiteMapProvider MVC4 fails when trying to install using Visual Studio 2013 Express edition.
It installs fine in Visual Studio 2012.
The error message I'm getting is:
Error: "Updating Microsoft.AspNet.Razor 3.0.0 to Microsoft.AspNet.Razor 2.0.3
My quess is that Visual Studio 2013 will not allow Microsoft.AspNet.Razor 3.0.0 to be overwritten by Microsoft.AspNet.Razor 2.0
Has anyone else had issues with MvcSiteMapProvider using VS 2013?

A: The original package for the MVCSitemapProvider has been marked as obsolete.
To Install the MvcSiteMapProvider, run the following command in the Package Manager Console.
install-package mvcsitemapprovider.mvc[X]
the [X] is what Mvc framework your targeting Ie MVC5 would be: install-package mvcsitemapprovider.mvc5.