问:
Add placeholder text inside UITextView in Swift?
How can I add a placeholder in a UITextView, similar to the one you can set for UITextField, in Swift?

答:
Here's something that can be dropped into a UIStackView, it will size itself using an internal height constraint. Tweaking may be required to suit specific requirements.

```<code>import UIKit

public protocol PlaceholderTextViewDelegate: class {
  func placeholderTextViewTextChanged(_ textView: PlaceholderTextView, text: String)
}

public class PlaceholderTextView: UIView {

  public weak var delegate: PlaceholderTextViewDelegate?
  private var heightConstraint: NSLayoutConstraint?

  public override init(frame: CGRect) {
    self.allowsNewLines = true

    super.init(frame: frame)

    self.heightConstraint = self.heightAnchor.constraint(equalToConstant: 0)
    self.heightConstraint?.isActive = true

    self.addSubview(self.placeholderTextView)
    self.addSubview(self.textView)

    self.pinToCorners(self.placeholderTextView)
    self.pinToCorners(self.textView)

    self.updateHeight()
  }

  public override func didMoveToSuperview() {
    super.didMoveToSuperview()

    self.updateHeight()
  }

  private func pinToCorners(_ view: UIView) {
    NSLayoutConstraint.activate([
      view.leadingAnchor.constraint(equalTo: self.leadingAnchor),
      view.trailingAnchor.constraint(equalTo: self.trailingAnchor),
      view.topAnchor.constraint(equalTo: self.topAnchor),
      view.bottomAnchor.constraint(equalTo: self.bottomAnchor)
    ])
  }

  // Accessors
  public var text: String? {
    didSet {
      self.textView.text = text
      self.textViewDidChange(self.textView)
      self.updateHeight()
    }
  }

  public var textColor: UIColor? {
    didSet {
      self.textView.textColor = textColor
      self.updateHeight()
    }
  }

  public var font: UIFont? {
    didSet {
      self.textView.font = font
      self.placeholderTextView.font = font
      self.updateHeight()
    }
  }

  public override var tintColor: UIColor? {
    didSet {
      self.textView.tintColor = tintColor
      self.placeholderTextView.tintColor = tintColor
    }
  }

  public var placeholderText: String? {
    didSet {
      self.placeholderTextView.text = placeholderText
      self.updateHeight()
    }
  }

  public var placeholderTextColor: UIColor? {
    didSet {
      self.placeholderTextView.textColor = placeholderTextColor
      self.updateHeight()
    }
  }

  public var allowsNewLines: Bool

  public required init?(coder _: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  private lazy var textView: UITextView = self.newTextView()
  private lazy var placeholderTextView: UITextView = self.newTextView()

  private func newTextView() -> UITextView {
    let textView = UITextView()
    textView.translatesAutoresizingMaskIntoConstraints = false
    textView.isScrollEnabled = false
    textView.delegate = self
    textView.backgroundColor = .clear
    return textView
  }

  private func updateHeight() {
    let maxSize = CGSize(width: self.frame.size.width, height: .greatestFiniteMagnitude)

    let textViewSize = self.textView.sizeThatFits(maxSize)
    let placeholderSize = self.placeholderTextView.sizeThatFits(maxSize)

    let maxHeight = ceil(CGFloat.maximum(textViewSize.height, placeholderSize.height))

    self.heightConstraint?.constant = maxHeight
  }
}

extension PlaceholderTextView: UITextViewDelegate {
  public func textViewDidChangeSelection(_: UITextView) {
    self.placeholderTextView.alpha = self.textView.text.isEmpty ? 1 : 0
    self.updateHeight()
  }

  public func textViewDidChange(_: UITextView) {
    self.delegate?.placeholderTextViewTextChanged(self, text: self.textView.text)
  }

  public func textView(_: UITextView, shouldChangeTextIn _: NSRange,
                       replacementText text: String) -> Bool {
    let containsNewLines = text.rangeOfCharacter(from: .newlines)?.isEmpty == .some(false)
    guard !containsNewLines || self.allowsNewLines else { return false }

    return true
  }
}
</code>```

Body:
Here's something that can be dropped into a UIStackView, it will size itself using an internal height constraint. Tweaking may be required to suit specific requirements.

import UIKit

public protocol PlaceholderTextViewDelegate: class {
  func placeholderTextViewTextChanged(_ textView: PlaceholderTextView, text: String)
}

public class PlaceholderTextView: UIView {

  public weak var delegate: PlaceholderTextViewDelegate?
  private var heightConstraint: NSLayoutConstraint?

  public override init(frame: CGRect) {
    self.allowsNewLines = true

    super.init(frame: frame)

    self.heightConstraint = self.heightAnchor.constraint(equalToConstant: 0)
    self.heightConstraint?.isActive = true

    self.addSubview(self.placeholderTextView)
    self.addSubview(self.textView)

    self.pinToCorners(self.placeholderTextView)
    self.pinToCorners(self.textView)

    self.updateHeight()
  }

  public override func didMoveToSuperview() {
    super.didMoveToSuperview()

    self.updateHeight()
  }

  private func pinToCorners(_ view: UIView) {
    NSLayoutConstraint.activate([
      view.leadingAnchor.constraint(equalTo: self.leadingAnchor),
      view.trailingAnchor.constraint(equalTo: self.trailingAnchor),
      view.topAnchor.constraint(equalTo: self.topAnchor),
      view.bottomAnchor.constraint(equalTo: self.bottomAnchor)
    ])
  }

  // Accessors
  public var text: String? {
    didSet {
      self.textView.text = text
      self.textViewDidChange(self.textView)
      self.updateHeight()
    }
  }

  public var textColor: UIColor? {
    didSet {
      self.textView.textColor = textColor
      self.updateHeight()
    }
  }

  public var font: UIFont? {
    didSet {
      self.textView.font = font
      self.placeholderTextView.font = font
      self.updateHeight()
    }
  }

  public override var tintColor: UIColor? {
    didSet {
      self.textView.tintColor = tintColor
      self.placeholderTextView.tintColor = tintColor
    }
  }

  public var placeholderText: String? {
    didSet {
      self.placeholderTextView.text = placeholderText
      self.updateHeight()
    }
  }

  public var placeholderTextColor: UIColor? {
    didSet {
      self.placeholderTextView.textColor = placeholderTextColor
      self.updateHeight()
    }
  }

  public var allowsNewLines: Bool

  public required init?(coder _: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  private lazy var textView: UITextView = self.newTextView()
  private lazy var placeholderTextView: UITextView = self.newTextView()

  private func newTextView() -> UITextView {
    let textView = UITextView()
    textView.translatesAutoresizingMaskIntoConstraints = false
    textView.isScrollEnabled = false
    textView.delegate = self
    textView.backgroundColor = .clear
    return textView
  }

  private func updateHeight() {
    let maxSize = CGSize(width: self.frame.size.width, height: .greatestFiniteMagnitude)

    let textViewSize = self.textView.sizeThatFits(maxSize)
    let placeholderSize = self.placeholderTextView.sizeThatFits(maxSize)

    let maxHeight = ceil(CGFloat.maximum(textViewSize.height, placeholderSize.height))

    self.heightConstraint?.constant = maxHeight
  }
}

extension PlaceholderTextView: UITextViewDelegate {
  public func textViewDidChangeSelection(_: UITextView) {
    self.placeholderTextView.alpha = self.textView.text.isEmpty ? 1 : 0
    self.updateHeight()
  }

  public func textViewDidChange(_: UITextView) {
    self.delegate?.placeholderTextViewTextChanged(self, text: self.textView.text)
  }

  public func textView(_: UITextView, shouldChangeTextIn _: NSRange,
                       replacementText text: String) -> Bool {
    let containsNewLines = text.rangeOfCharacter(from: .newlines)?.isEmpty == .some(false)
    guard !containsNewLines || self.allowsNewLines else { return false }

    return true
  }
}


来源: stackexchange

问:
Connecting aws backend to firebase database
I'm currently running python code in my aws server and trying to connect to my friend's firebase database. I read the documentation provided by firebase to connect to aws server.

https://firebase.google.com/docs/admin/setup

I have followed every step but I'm getting an error when I try to connect to my server. I have added google-service.json for credential.
Error that I get :

ValueError: Invalid service account certificate. Certificate must
  contain a "type" field set to "service_account".

Do I need to modify the google-services.json ?

My code:

```<code>import firebase_admin
from firebase_admin import credentials

cred = credentials.Certificate('/home/ec2-user/google-services.json')
#default_app = firebase_admin.initialize_app(cred)
other_app = firebase_admin.initialize_app(cred, name='other')
ault_app = firebase_admin.initialize_app()
</code>```

答: google-services.json is typically the name of an Android app configuration file.  That's not the same as a service account.  To get a hold of the credentials for a service account for your project, you'll need to generate one from the Firebase console from Project Settings -> Service Accounts.  The documentation is here.  Once you have this file, you can initialize the Admin SDK with it to begin accessing the data in your project.</p>

ContentLicense: CC BY-SA 3.0

Body:
I'm currently running python code in my aws server and trying to connect to my friend's firebase database. I read the documentation provided by firebase to connect to aws server.

https://firebase.google.com/docs/admin/setup

I have followed every step but I'm getting an error when I try to connect to my server. I have added google-service.json for credential.
Error that I get :

ValueError: Invalid service account certificate. Certificate must
  contain a "type" field set to "service_account".

Do I need to modify the google-services.json ?

My code:

import firebase_admin
from firebase_admin import credentials

cred = credentials.Certificate('/home/ec2-user/google-services.json')
#default_app = firebase_admin.initialize_app(cred)
other_app = firebase_admin.initialize_app(cred, name='other')
ault_app = firebase_admin.initialize_app()


问:
How to animate centered square to the top
I have a UIView in a portrait-only app.

The view is centered vertically and horizontally with AutoLayout ("manually" using storyboards).

The width equals the (main)view.width * 0.9

The height is the same size of the width (it is a square).

I want to tap a button inside this UIView and animate it only vertically until it reaches the top border of the screen (eg. height*0.9, 10 pts, whatever is possible).

When I click again, I want to reposition back the view to its original position (centered as it was when I first tapped).

During the transition the square should not be tappable.

After reading many posts I could not understand what's the best way to do this (I red mainly developers saying old techniques using centerX should be avoided and lamentations about some versions of the SO behaving in strange ways).

I suppose I should find a way to get the current "position" of the constraints and to assign a constraint the "final" position, but I was not able to do it.

Any help is appreciated

答:
You are all going the wrong way about this.

Add one constraint that pins the view to the top, and add one constraint that pins the view to centerY. It will complain, so pick one and disable it (I think the property in Interface Builder is called Installed).

If the initial state is the view in the center, disable the constraint that pins it to the top, and viceversa.

Now write IBOutlets for both constraints in your controller and connect them to those constraints. Make sure the declaration of that variable is not weak, otherwise the variable will become nil when the constraint is disabled.

Whenever you want to toggle your animation you can enable one constraint and disable the other.

```<code>@IBOutlet var topConstraint: NSLayoutConstraint!
@IBOutlet var centerConstraint: NSLayoutConstraint!

func toggleState(moveToTop: Bool) {
  UIView.animateWithDuration(0.25) {
    self.topConstraint.isActive = moveToTop
    self.centerConstraint.isActive = !moveToTop
    self.view.layoutIfNeeded()
  }
}
</code>```

Body:
You are all going the wrong way about this.

Add one constraint that pins the view to the top, and add one constraint that pins the view to centerY. It will complain, so pick one and disable it (I think the property in Interface Builder is called Installed).

If the initial state is the view in the center, disable the constraint that pins it to the top, and viceversa.

Now write IBOutlets for both constraints in your controller and connect them to those constraints. Make sure the declaration of that variable is not weak, otherwise the variable will become nil when the constraint is disabled.

Whenever you want to toggle your animation you can enable one constraint and disable the other.

@IBOutlet var topConstraint: NSLayoutConstraint!
@IBOutlet var centerConstraint: NSLayoutConstraint!

func toggleState(moveToTop: Bool) {
  UIView.animateWithDuration(0.25) {
    self.topConstraint.isActive = moveToTop
    self.centerConstraint.isActive = !moveToTop
    self.view.layoutIfNeeded()
  }
}


问:
Run du on parallel
I have a very big storage disk (16T). I want to run 'du' on it to figure out how much each subdirectory takes. However, that takes a very long time. Luckily, I have at my disposal a cluster of computers. I can therefore run 'du' on parallel, each job runs on a separate subdirectory, and write a simple script that does that. Is there already such a thing or must I write it myself?</p>

答:
Is there already such a thing or must I write it myself?

I wrote sn for myself, but you might appreciate it too.

```<code>sn p .
</code>```

will give you sizes of everything in the current directory. It runs in parallel and is faster than du on large directories.

Title: Run du on parallel

Body:
Is there already such a thing or must I write it myself?

I wrote sn for myself, but you might appreciate it too.

sn p .

will give you sizes of everything in the current directory. It runs in parallel and is faster than du on large directories.


问:
Highcharts heatmap shows unkown grid on top
I was wondering why I get this grid at the top of the heatmap (not all the time) :

http://jsfiddle.net/08hruku5/1/

```<code>Highcharts.chart('container', {});
</code>```

答:
Setting turboThreshold to 0 resolves the problem.

API Reference:

https://api.highcharts.com/highcharts/plotOptions.series.turboThreshold

Example:

http://jsfiddle.net/d0qfw4dc/

Body:
I was wondering why I get this grid at the top of the heatmap (not all the time) :

http://jsfiddle.net/08hruku5/1/

Highcharts.chart('container', {});


问:
SQL dependency event not being triggered
First time working with SQL Dependency... but after having gone over several examples I feel as I am doing everything correct. I've checked that the Broker is Enabled. I've further checked that my query is correct. I am not receiving any exceptions at all! All and all everything seems as it should work... but it is not, and I have no idea how to begin to troubleshoot it without any exceptions being thrown.

Any help would be VERY much appreciated!

Here is my class:

```<code>public class NotificationEvent
{
    private delegate void RateChangeNotification(DataTable table);
    private SqlDependency dependency;
    string ConnectionString = @"ConnectionString";
    string UserName = Environment.UserName;

    public async void StartNotification()
    {
        SqlDependency.Start(this.ConnectionString, "UserNotificationsQueue");
        SqlConnection connection = new SqlConnection(this.ConnectionString);
        await connection.OpenAsync();

        SqlCommand command = new SqlCommand();
        command.Connection = connection;
        command.CommandType = CommandType.Text;
        command.CommandText = string.Format("SELECT [NotificationID],[UserFrom],[UserTo],[DateTimeSent],[Notification] FROM [dbo].[PersonnellNotifications]", UserName);
        command.Notification = null;

        this.dependency = new SqlDependency(command, "Service=PostUserNotificationsQueue;", Int32.MaxValue);
        dependency.OnChange += new OnChangeEventHandler(this.SqlDependencyOnChange);
        await command.ExecuteReaderAsync();
    }

    private void SqlDependencyOnChange(object sender, SqlNotificationEventArgs eventArgs)
    {
        if (eventArgs.Info == SqlNotificationInfo.Invalid)
        {
            Console.WriteLine("The above notification query is not valid.");
        }
        else
        {
            Console.WriteLine("Notification Info: " + eventArgs.Info);
            Console.WriteLine("Notification source: " + eventArgs.Source);
            Console.WriteLine("Notification type: " + eventArgs.Type);
        }
    }

    public void StopNotification()
    {
        SqlDependency.Stop(this.ConnectionString, "QueueName");
    }
}
</code>```

I am initializing this from another classes IniatializeComponent() as seen:

```<code>private void InitializeComponent()
{
    // Initialize SQL Dependancy
    ne.StartNotification();
}
</code>```

答:
Are you setting SQLClientPermission? see:
https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql/enabling-query-notifications</p>

```<code>// Code requires directives to
// System.Security.Permissions and
// System.Data.SqlClient

private bool CanRequestNotifications()
{
    SqlClientPermission permission =
        new SqlClientPermission(
        PermissionState.Unrestricted);
    try
    {
        permission.Demand();
        return true;
    }
    catch (System.Exception)
    {
        return false;
    }
}
</code>```

Body:
First time working with SQL Dependency... but after having gone over several examples I feel as I am doing everything correct. I've checked that the Broker is Enabled. I've further checked that my query is correct. I am not receiving any exceptions at all! All and all everything seems as it should work... but it is not, and I have no idea how to begin to troubleshoot it without any exceptions being thrown.

Any help would be VERY much appreciated!

Here is my class:

public class NotificationEvent
{
    private delegate void RateChangeNotification(DataTable table);
    private SqlDependency dependency;
    string ConnectionString = @"ConnectionString";
    string UserName = Environment.UserName;

    public async void StartNotification()
    {
        SqlDependency.Start(this.ConnectionString, "UserNotificationsQueue");
        SqlConnection connection = new SqlConnection(this.ConnectionString);
        await connection.OpenAsync();

        SqlCommand command = new SqlCommand();
        command.Connection = connection;
        command.CommandType = CommandType.Text;
        command.CommandText = string.Format("SELECT [NotificationID],[UserFrom],[UserTo],[DateTimeSent],[Notification] FROM [dbo].[PersonnellNotifications]", UserName);
        command.Notification = null;

        this.dependency = new SqlDependency(command, "Service=PostUserNotificationsQueue;", Int32.MaxValue);
        dependency.OnChange += new OnChangeEventHandler(this.SqlDependencyOnChange);
        await command.ExecuteReaderAsync();
    }

    private void SqlDependencyOnChange(object sender, SqlNotificationEventArgs eventArgs)
    {
        if (eventArgs.Info == SqlNotificationInfo.Invalid)
        {
            Console.WriteLine("The above notification query is not valid.");
        }
        else
        {
            Console.WriteLine("Notification Info: " + eventArgs.Info);
            Console.WriteLine("Notification source: " + eventArgs.Source);
            Console.WriteLine("Notification type: " + eventArgs.Type);
        }
    }

    public void StopNotification()
    {
        SqlDependency.Stop(this.ConnectionString, "QueueName");
    }
}

I am initializing this from another classes IniatializeComponent() as seen:

private void InitializeComponent()
{
    // Initialize SQL Dependancy
    ne.StartNotification();
}

Body:
Are you setting SQLClientPermission? see:
https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql/enabling-query-notifications

// Code requires directives to
// System.Security.Permissions and
// System.Data.SqlClient

private bool CanRequestNotifications()
{
    SqlClientPermission permission =
        new SqlClientPermission(
        PermissionState.Unrestricted);
    try
    {
        permission.Demand();
        return true;
    }
    catch (System.Exception)
    {
        return false;
    }
}


问:
How to run an R script and show a plot?

How to wait for a keypress in R?

I am attempting to construct a simple script, which creates a graph; closes it when a key is pressed. My code:

```<code>#!/usr/bin/Rscript
library(tidyverse)
ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy), colour = "blue")
</code>```

I have tried the answers from the linked question to pause the script after the plot is drawn. However:

No plot appears, alto the code works fine from the interactive R shell.

readline() works only in interactive mode, as per the documentation, and scan() is line-buffered, instead of reacting to a single keypress

How does this work? My environment is Debian.

答:
It seems the problems I was trying to solve is non-existent. The mentioned above functions have a very good reason not to work in non-interactive mode - they are not needed.

Long story short, ggplot2 automatically exports plots to a .pdf when run in non-interacive mode!

Title: How to run an R script and show a plot?

Body:
How to wait for a keypress in R?

I am attempting to construct a simple script, which creates a graph; closes it when a key is pressed. My code:

#!/usr/bin/Rscript
library(tidyverse)
ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy), colour = "blue")

I have tried the answers from the linked question to pause the script after the plot is drawn. However:

No plot appears, alto the code works fine from the interactive R shell.

readline() works only in interactive mode, as per the documentation, and scan() is line-buffered, instead of reacting to a single keypress

How does this work? My environment is Debian.


问:
Issue deploying rails app on heroku
I am new to rails and I was to work on a code. The website works perfect on my local but when deploying remotely on heroku, the css files seem not found.

I am running the app with ruby 2.4, Rails 5.0 and gemfile

```<code>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

gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
gem 'autoprefixer-rails'
gem 'font-awesome-rails', '~> 4.6', '>= 4.6.3.1'
gem 'animate-rails', '~> 1.0', '>= 1.0.10'
gem 'owlcarousel-rails', '~> 1.1', '>= 1.1.3.3'
gem 'wow-rails', '~> 0.0.1'
gem 'magnific-popup-rails', '~> 1.1'
gem 'google-api-client', '~> 0.12.0'
gem 'figaro'
# cron task
gem 'whenever', require: false
# Authentication
gem 'devise'
gem 'cancancan', '~> 1.15'
# serach and autocompletion
gem 'pg_search'
# mailer dev
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.3'
# Use sqlite3 as the database for Active Record
gem 'pg'
# 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'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails', '~> 5.0'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
#gem 'capistrano3-puma', github: "seuros/capistrano-puma"

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  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'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  # Use Capistrano for deployment
  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-rvm'
end

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

ruby "2.4.1"
</code>```

Here's the log via the command heroku log --tail

```<code>2017-11-16T16:07:52.898937+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 6818 -e production`
2017-11-16T16:07:58.371812+00:00 app[web.1]: => Booting Puma
2017-11-16T16:07:58.371821+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:6818
2017-11-16T16:07:58.371822+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:07:58.371822+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:07:58.371827+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Environment: production
2017-11-16T16:07:58.371978+00:00 app[web.1]: * Listening on tcp://0.0.0.0:6818
2017-11-16T16:07:58.372379+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:07:58.939021+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:07:59.757157+00:00 app[web.1]: I, [2017-11-16T16:07:59.757044 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Started GET "/" for 80.12.27.252 at 2017-11-16 16:07:59 +0000
2017-11-16T16:07:59.766621+00:00 app[web.1]: I, [2017-11-16T16:07:59.766547 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:07:59.763739+00:00 app[web.1]: I, [2017-11-16T16:07:59.763642 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Processing by PagesController#index as HTML
2017-11-16T16:07:59.767481+00:00 app[web.1]: I, [2017-11-16T16:07:59.767416 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered pages/index.html.erb within layouts/application (0.7ms)
2017-11-16T16:07:59.936841+00:00 app[web.1]: I, [2017-11-16T16:07:59.936713 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_nav.html.erb (0.4ms)
2017-11-16T16:07:59.941558+00:00 app[web.1]: I, [2017-11-16T16:07:59.941458 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_footer.html.erb (4.1ms)
2017-11-16T16:07:59.941919+00:00 app[web.1]: I, [2017-11-16T16:07:59.941858 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Completed 200 OK in 178ms (Views: 177.2ms)
2017-11-16T16:07:59.942814+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=b03307de-5170-474a-9f27-50cd05bf07a3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=190ms status=200 bytes=14894 protocol=https
2017-11-16T16:08:00.224613+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=d2c6dfd6-4660-4844-9d44-143e3d21b917 fwd="80.12.27.252" dyno=web.1 connect=5ms service=10ms status=200 bytes=290 protocol=https
2017-11-16T16:08:00.469689+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=c7adcbdd-8478-4916-9aff-0a90a52058bc fwd="80.12.27.252" dyno=web.1 connect=0ms service=8ms status=200 bytes=3889 protocol=https
2017-11-16T16:08:00.354457+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=720bf865-6dc4-401f-aac2-bf8eb96c5e90 fwd="80.12.27.252" dyno=web.1 connect=0ms service=5ms status=200 bytes=15746 protocol=https
2017-11-16T16:08:00.331984+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=c58820a6-ce78-43d8-b9da-f188ab36a9d4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:08:00.351225+00:00 app[web.1]: I, [2017-11-16T16:08:00.351111 #4]  INFO -- : [720bf865-6dc4-401f-aac2-bf8eb96c5e90] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.464437+00:00 app[web.1]: I, [2017-11-16T16:08:00.464337 #4]  INFO -- : [62f2a2a3-392b-446d-be9b-a32e38f68397] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.465587+00:00 app[web.1]: I, [2017-11-16T16:08:00.464658 #4]  INFO -- : [c7adcbdd-8478-4916-9aff-0a90a52058bc] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.582164+00:00 app[web.1]: I, [2017-11-16T16:08:00.582059 #4]  INFO -- : [2c5ed467-5129-4e52-9794-c22a611efaec] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.480539+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=62f2a2a3-392b-446d-be9b-a32e38f68397 fwd="80.12.27.252" dyno=web.1 connect=1ms service=19ms status=200 bytes=230727 protocol=https
2017-11-16T16:08:00.628238+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=f9d88aa4-d176-4190-8ad7-08f15cffc6fd fwd="80.12.27.252" dyno=web.1 connect=0ms service=7ms status=200 bytes=19242 protocol=https
2017-11-16T16:08:00.584670+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=2c5ed467-5129-4e52-9794-c22a611efaec fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=8918 protocol=https
2017-11-16T16:08:00.623571+00:00 app[web.1]: I, [2017-11-16T16:08:00.623424 #4]  INFO -- : [f9d88aa4-d176-4190-8ad7-08f15cffc6fd] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:01.911423+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=69791277-1eb3-4067-a23a-51987305595b fwd="80.12.27.252" dyno=web.1 connect=1ms service=1ms status=200 bytes=180 protocol=https
2017-11-16T16:08:04.306986+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=9d090e84-2bfe-49d8-afe1-7a5769d84497 fwd="80.12.27.252" dyno=web.1 connect=1ms service=5ms status=304 bytes=48 protocol=https
2017-11-16T16:12:50.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:08.103929+00:00 heroku[web.1]: Restarting
2017-11-16T16:13:08.116568+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:13:07.390096+00:00 app[api]: Release v7 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:07.390096+00:00 app[api]: Deploy 99038abe by user benchoufi.mehdi@gmail.com
2017-11-16T16:12:50.000000+00:00 app[api]: Build succeeded
2017-11-16T16:13:08.751218+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:13:08.761369+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:13:08.788899+00:00 app[web.1]: Exiting
2017-11-16T16:13:08.789433+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `close': stream closed (IOError)
2017-11-16T16:13:08.789487+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:398:in `handle_servers'
2017-11-16T16:13:08.789453+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `ensure in handle_servers'
2017-11-16T16:13:08.789489+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:327:in `block in run'
2017-11-16T16:13:08.907475+00:00 heroku[web.1]: Process exited with status 1
2017-11-16T16:13:13.745852+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 5997 -e production`
2017-11-16T16:13:22.652430+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:13:22.424108+00:00 app[web.1]: => Booting Puma
2017-11-16T16:13:22.424142+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:5997
2017-11-16T16:13:22.424145+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:13:22.424195+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:13:22.424286+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:13:22.424247+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:13:22.424352+00:00 app[web.1]: * Environment: production
2017-11-16T16:13:22.424528+00:00 app[web.1]: * Listening on tcp://0.0.0.0:5997
2017-11-16T16:13:22.425055+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:13:57.966340+00:00 app[web.1]: I, [2017-11-16T16:13:57.966187 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Started GET "/" for 80.12.27.252 at 2017-11-16 16:13:57 +0000
2017-11-16T16:13:58.001708+00:00 app[web.1]: I, [2017-11-16T16:13:58.001639 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered pages/index.html.erb within layouts/application (0.9ms)
2017-11-16T16:13:57.996269+00:00 app[web.1]: I, [2017-11-16T16:13:57.996152 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Processing by PagesController#index as HTML
2017-11-16T16:13:58.000897+00:00 app[web.1]: I, [2017-11-16T16:13:58.000568 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:13:58.296994+00:00 app[web.1]: I, [2017-11-16T16:13:58.296906 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Completed 200 OK in 301ms (Views: 299.3ms)
2017-11-16T16:13:58.286219+00:00 app[web.1]: I, [2017-11-16T16:13:58.286073 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_nav.html.erb (0.7ms)
2017-11-16T16:13:58.296500+00:00 app[web.1]: I, [2017-11-16T16:13:58.296376 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_footer.html.erb (9.3ms)
2017-11-16T16:13:58.290239+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=e8dd584a-d608-4421-ac81-44cd455ed936 fwd="80.12.27.252" dyno=web.1 connect=0ms service=348ms status=200 bytes=14894 protocol=https
2017-11-16T16:13:58.571091+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=92a4edc0-7f6f-4317-b7b8-7ea7e202aff4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=290 protocol=https
2017-11-16T16:13:58.704480+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=db83d660-cedf-4642-972c-1d2b4e08d156 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:13:58.832979+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=16ea7daf-d704-43f0-a8ce-91243a15b8f3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=26ms status=200 bytes=15746 protocol=https
2017-11-16T16:13:58.817763+00:00 app[web.1]: I, [2017-11-16T16:13:58.817635 #4]  INFO -- : [16ea7daf-d704-43f0-a8ce-91243a15b8f3] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:13:58 +0000
2017-11-16T16:13:59.035120+00:00 app[web.1]: I, [2017-11-16T16:13:59.035020 #4]  INFO -- : [7191af72-e7a6-4c9f-b34d-f866349e19fe] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.038959+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=7191af72-e7a6-4c9f-b34d-f866349e19fe fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=230727 protocol=https
2017-11-16T16:13:59.146207+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=f54b3701-44ae-4d9c-b76a-200a5be5f4f7 fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=3889 protocol=https
2017-11-16T16:13:59.137862+00:00 app[web.1]: I, [2017-11-16T16:13:59.137756 #4]  INFO -- : [b5620bf1-cd26-430e-bdc4-4b18d283d602] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.152893+00:00 app[web.1]: I, [2017-11-16T16:13:59.152788 #4]  INFO -- : [f54b3701-44ae-4d9c-b76a-200a5be5f4f7] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.158096+00:00 app[web.1]: I, [2017-11-16T16:13:59.158011 #4]  INFO -- : [19624a74-80a0-4796-b349-47e1a359291a] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.161169+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=b5620bf1-cd26-430e-bdc4-4b18d283d602 fwd="80.12.27.252" dyno=web.1 connect=0ms service=34ms status=200 bytes=8918 protocol=https
2017-11-16T16:13:59.176271+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=19624a74-80a0-4796-b349-47e1a359291a fwd="80.12.27.252" dyno=web.1 connect=0ms service=43ms status=200 bytes=19242 protocol=https
2017-11-16T16:14:00.250138+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=8f82cf74-f19c-4fd8-af88-aaa76fba7f60 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=180 protocol=https
2017-11-16T16:38:30.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Deploy 504623ba by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Release v8 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:30.000000+00:00 app[api]: Build succeeded
2017-11-16T16:38:49.057909+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:38:49.057351+00:00 heroku[web.1]: Restarting
2017-11-16T16:38:50.018531+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:38:50.030701+00:00 app[web.1]: === puma shutdown: 2017-11-16 16:38:50 +0000 ===
2017-11-16T16:38:50.030736+00:00 app[web.1]: - Goodbye!
2017-11-16T16:38:50.030914+00:00 app[web.1]: Exiting
2017-11-16T16:38:50.172254+00:00 heroku[web.1]: Process exited with status 143
2017-11-16T16:38:50.003821+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:38:52.617190+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 3626 -e production`
2017-11-16T16:38:56.842223+00:00 app[web.1]: => Booting Puma
2017-11-16T16:38:56.842258+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:3626
2017-11-16T16:38:56.842260+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:38:56.842261+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:38:56.842261+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:38:56.842267+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:38:56.842268+00:00 app[web.1]: * Environment: production
2017-11-16T16:38:56.842314+00:00 app[web.1]: * Listening on tcp://0.0.0.0:3626
2017-11-16T16:38:56.842706+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:38:56.991984+00:00 heroku[web.1]: State changed from starting to up
</code>```

besides, here's the content of the application.css.scss

```<code>*= require animate
*= require jquery-ui
*= require owl.carousel
*= require owl.theme
*= require magnific-popup
*= require_self
*= require_tree .
*/
@import "bootstrap";
@import "bootstrap-sprockets";
@import "font-awesome";
</code>```

答:
is it possible to have more detail of what happened exactly maybe you can share your heroku logs.

Type => heroku logs --tail on terminal

Thanks

Title: Issue deploying rails app on heroku

Body:
I am new to rails and I was to work on a code. The website works perfect on my local but when deploying remotely on heroku, the css files seem not found.

I am running the app with ruby 2.4, Rails 5.0 and gemfile

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

gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
gem 'autoprefixer-rails'
gem 'font-awesome-rails', '~> 4.6', '>= 4.6.3.1'
gem 'animate-rails', '~> 1.0', '>= 1.0.10'
gem 'owlcarousel-rails', '~> 1.1', '>= 1.1.3.3'
gem 'wow-rails', '~> 0.0.1'
gem 'magnific-popup-rails', '~> 1.1'
gem 'google-api-client', '~> 0.12.0'
gem 'figaro'
# cron task
gem 'whenever', require: false
# Authentication
gem 'devise'
gem 'cancancan', '~> 1.15'
# serach and autocompletion
gem 'pg_search'
# mailer dev
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.3'
# Use sqlite3 as the database for Active Record
gem 'pg'
# 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'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails', '~> 5.0'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
#gem 'capistrano3-puma', github: "seuros/capistrano-puma"

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  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'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  # Use Capistrano for deployment
  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-rvm'
end

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

ruby "2.4.1"

Here's the log via the command heroku log --tail

2017-11-16T16:07:52.898937+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 6818 -e production`
2017-11-16T16:07:58.371812+00:00 app[web.1]: => Booting Puma
2017-11-16T16:07:58.371821+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:6818
2017-11-16T16:07:58.371822+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:07:58.371822+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:07:58.371827+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Environment: production
2017-11-16T16:07:58.371978+00:00 app[web.1]: * Listening on tcp://0.0.0.0:6818
2017-11-16T16:07:58.372379+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:07:58.939021+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:07:59.757157+00:00 app[web.1]: I, [2017-11-16T16:07:59.757044 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Started GET "/" for 80.12.27.252 at 2017-11-16 16:07:59 +0000
2017-11-16T16:07:59.766621+00:00 app[web.1]: I, [2017-11-16T16:07:59.766547 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:07:59.763739+00:00 app[web.1]: I, [2017-11-16T16:07:59.763642 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Processing by PagesController#index as HTML
2017-11-16T16:07:59.767481+00:00 app[web.1]: I, [2017-11-16T16:07:59.767416 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered pages/index.html.erb within layouts/application (0.7ms)
2017-11-16T16:07:59.936841+00:00 app[web.1]: I, [2017-11-16T16:07:59.936713 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_nav.html.erb (0.4ms)
2017-11-16T16:07:59.941558+00:00 app[web.1]: I, [2017-11-16T16:07:59.941458 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_footer.html.erb (4.1ms)
2017-11-16T16:07:59.941919+00:00 app[web.1]: I, [2017-11-16T16:07:59.941858 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Completed 200 OK in 178ms (Views: 177.2ms)
2017-11-16T16:07:59.942814+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=b03307de-5170-474a-9f27-50cd05bf07a3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=190ms status=200 bytes=14894 protocol=https
2017-11-16T16:08:00.224613+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=d2c6dfd6-4660-4844-9d44-143e3d21b917 fwd="80.12.27.252" dyno=web.1 connect=5ms service=10ms status=200 bytes=290 protocol=https
2017-11-16T16:08:00.469689+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=c7adcbdd-8478-4916-9aff-0a90a52058bc fwd="80.12.27.252" dyno=web.1 connect=0ms service=8ms status=200 bytes=3889 protocol=https
2017-11-16T16:08:00.354457+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=720bf865-6dc4-401f-aac2-bf8eb96c5e90 fwd="80.12.27.252" dyno=web.1 connect=0ms service=5ms status=200 bytes=15746 protocol=https
2017-11-16T16:08:00.331984+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=c58820a6-ce78-43d8-b9da-f188ab36a9d4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:08:00.351225+00:00 app[web.1]: I, [2017-11-16T16:08:00.351111 #4]  INFO -- : [720bf865-6dc4-401f-aac2-bf8eb96c5e90] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.464437+00:00 app[web.1]: I, [2017-11-16T16:08:00.464337 #4]  INFO -- : [62f2a2a3-392b-446d-be9b-a32e38f68397] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.465587+00:00 app[web.1]: I, [2017-11-16T16:08:00.464658 #4]  INFO -- : [c7adcbdd-8478-4916-9aff-0a90a52058bc] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.582164+00:00 app[web.1]: I, [2017-11-16T16:08:00.582059 #4]  INFO -- : [2c5ed467-5129-4e52-9794-c22a611efaec] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.480539+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=62f2a2a3-392b-446d-be9b-a32e38f68397 fwd="80.12.27.252" dyno=web.1 connect=1ms service=19ms status=200 bytes=230727 protocol=https
2017-11-16T16:08:00.628238+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=f9d88aa4-d176-4190-8ad7-08f15cffc6fd fwd="80.12.27.252" dyno=web.1 connect=0ms service=7ms status=200 bytes=19242 protocol=https
2017-11-16T16:08:00.584670+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=2c5ed467-5129-4e52-9794-c22a611efaec fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=8918 protocol=https
2017-11-16T16:08:00.623571+00:00 app[web.1]: I, [2017-11-16T16:08:00.623424 #4]  INFO -- : [f9d88aa4-d176-4190-8ad7-08f15cffc6fd] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:01.911423+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=69791277-1eb3-4067-a23a-51987305595b fwd="80.12.27.252" dyno=web.1 connect=1ms service=1ms status=200 bytes=180 protocol=https
2017-11-16T16:08:04.306986+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=9d090e84-2bfe-49d8-afe1-7a5769d84497 fwd="80.12.27.252" dyno=web.1 connect=1ms service=5ms status=304 bytes=48 protocol=https
2017-11-16T16:12:50.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:08.103929+00:00 heroku[web.1]: Restarting
2017-11-16T16:13:08.116568+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:13:07.390096+00:00 app[api]: Release v7 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:07.390096+00:00 app[api]: Deploy 99038abe by user benchoufi.mehdi@gmail.com
2017-11-16T16:12:50.000000+00:00 app[api]: Build succeeded
2017-11-16T16:13:08.751218+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:13:08.761369+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:13:08.788899+00:00 app[web.1]: Exiting
2017-11-16T16:13:08.789433+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `close': stream closed (IOError)
2017-11-16T16:13:08.789487+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:398:in `handle_servers'
2017-11-16T16:13:08.789453+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `ensure in handle_servers'
2017-11-16T16:13:08.789489+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:327:in `block in run'
2017-11-16T16:13:08.907475+00:00 heroku[web.1]: Process exited with status 1
2017-11-16T16:13:13.745852+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 5997 -e production`
2017-11-16T16:13:22.652430+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:13:22.424108+00:00 app[web.1]: => Booting Puma
2017-11-16T16:13:22.424142+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:5997
2017-11-16T16:13:22.424145+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:13:22.424195+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:13:22.424286+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:13:22.424247+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:13:22.424352+00:00 app[web.1]: * Environment: production
2017-11-16T16:13:22.424528+00:00 app[web.1]: * Listening on tcp://0.0.0.0:5997
2017-11-16T16:13:22.425055+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:13:57.966340+00:00 app[web.1]: I, [2017-11-16T16:13:57.966187 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Started GET "/" for 80.12.27.252 at 2017-11-16 16:13:57 +0000
2017-11-16T16:13:58.001708+00:00 app[web.1]: I, [2017-11-16T16:13:58.001639 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered pages/index.html.erb within layouts/application (0.9ms)
2017-11-16T16:13:57.996269+00:00 app[web.1]: I, [2017-11-16T16:13:57.996152 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Processing by PagesController#index as HTML
2017-11-16T16:13:58.000897+00:00 app[web.1]: I, [2017-11-16T16:13:58.000568 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:13:58.296994+00:00 app[web.1]: I, [2017-11-16T16:13:58.296906 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Completed 200 OK in 301ms (Views: 299.3ms)
2017-11-16T16:13:58.286219+00:00 app[web.1]: I, [2017-11-16T16:13:58.286073 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_nav.html.erb (0.7ms)
2017-11-16T16:13:58.296500+00:00 app[web.1]: I, [2017-11-16T16:13:58.296376 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_footer.html.erb (9.3ms)
2017-11-16T16:13:58.290239+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=e8dd584a-d608-4421-ac81-44cd455ed936 fwd="80.12.27.252" dyno=web.1 connect=0ms service=348ms status=200 bytes=14894 protocol=https
2017-11-16T16:13:58.571091+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=92a4edc0-7f6f-4317-b7b8-7ea7e202aff4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=290 protocol=https
2017-11-16T16:13:58.704480+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=db83d660-cedf-4642-972c-1d2b4e08d156 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:13:58.832979+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=16ea7daf-d704-43f0-a8ce-91243a15b8f3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=26ms status=200 bytes=15746 protocol=https
2017-11-16T16:13:58.817763+00:00 app[web.1]: I, [2017-11-16T16:13:58.817635 #4]  INFO -- : [16ea7daf-d704-43f0-a8ce-91243a15b8f3] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:13:58 +0000
2017-11-16T16:13:59.035120+00:00 app[web.1]: I, [2017-11-16T16:13:59.035020 #4]  INFO -- : [7191af72-e7a6-4c9f-b34d-f866349e19fe] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.038959+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=7191af72-e7a6-4c9f-b34d-f866349e19fe fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=230727 protocol=https
2017-11-16T16:13:59.146207+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=f54b3701-44ae-4d9c-b76a-200a5be5f4f7 fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=3889 protocol=https
2017-11-16T16:13:59.137862+00:00 app[web.1]: I, [2017-11-16T16:13:59.137756 #4]  INFO -- : [b5620bf1-cd26-430e-bdc4-4b18d283d602] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.152893+00:00 app[web.1]: I, [2017-11-16T16:13:59.152788 #4]  INFO -- : [f54b3701-44ae-4d9c-b76a-200a5be5f4f7] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.158096+00:00 app[web.1]: I, [2017-11-16T16:13:59.158011 #4]  INFO -- : [19624a74-80a0-4796-b349-47e1a359291a] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.161169+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=b5620bf1-cd26-430e-bdc4-4b18d283d602 fwd="80.12.27.252" dyno=web.1 connect=0ms service=34ms status=200 bytes=8918 protocol=https
2017-11-16T16:13:59.176271+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=19624a74-80a0-4796-b349-47e1a359291a fwd="80.12.27.252" dyno=web.1 connect=0ms service=43ms status=200 bytes=19242 protocol=https
2017-11-16T16:14:00.250138+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=8f82cf74-f19c-4fd8-af88-aaa76fba7f60 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=180 protocol=https
2017-11-16T16:38:30.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Deploy 504623ba by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Release v8 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:30.000000+00:00 app[api]: Build succeeded
2017-11-16T16:38:49.057909+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:38:49.057351+00:00 heroku[web.1]: Restarting
2017-11-16T16:38:50.018531+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:38:50.030701+00:00 app[web.1]: === puma shutdown: 2017-11-16 16:38:50 +0000 ===
2017-11-16T16:38:50.030736+00:00 app[web.1]: - Goodbye!
2017-11-16T16:38:50.030914+00:00 app[web.1]: Exiting
2017-11-16T16:38:50.172254+00:00 heroku[web.1]: Process exited with status 143
2017-11-16T16:38:50.003821+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:38:52.617190+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 3626 -e production`
2017-11-16T16:38:56.842223+00:00 app[web.1]: => Booting Puma
2017-11-16T16:38:56.842258+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:3626
2017-11-16T16:38:56.842260+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:38:56.842261+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:38:56.842261+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:38:56.842267+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:38:56.842268+00:00 app[web.1]: * Environment: production
2017-11-16T16:38:56.842314+00:00 app[web.1]: * Listening on tcp://0.0.0.0:3626
2017-11-16T16:38:56.842706+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:38:56.991984+00:00 heroku[web.1]: State changed from starting to up

besides, here's the content of the application.css.scss

*= require animate
*= require jquery-ui
*= require owl.carousel
*= require owl.theme
*= require magnific-popup
*= require_self
*= require_tree .
*/
@import "bootstrap";
@import "bootstrap-sprockets";
@import "font-awesome";


问:
Access SQL Avoid Cartesian Product using Instr = 0 or Not Like
I have two tables

```<code>T1        T2
list      remark
abc       this is my list
def       i have abc remark
ghi       other than I have def comment
jkl       ghi is also there
          and this one will
          and this one too
</code>```

I am attempting to write a query that will return all remarks in T2 that are not like the list in T1.

I have tried both Instr and Join with Not Like, but am stuck on the Cartesian Product issue.

Running a query where Instr = True returns the list I expect

```<code>SELECT DISTINCT t2.remark, InStr([t2].[remark],[t1].[list]) AS [Check]
FROM t2, t1
WHERE (((InStr([t2].[remark],[t1].[list]))=True));
</code>```

ghi is also there

  I have abc remark

  other than I have def comment

But running for False is where I get all results, due to Cartesian Product:

Same with using Not Like

```<code>SELECT DISTINCT t2.remark
FROM t2 LEFT JOIN t1 ON t2.Remark NOT LIKE "*" & t1.List & "*"
</code>```

I have also tried sub queries, but no luck. Any idea how I can solve this with Access SQL?

I suppose I could write the statement with TRUE then do another query where the remarks do not equal the result of my first query, but that seems a bit inefficient.

答:
The usual way (at least in Access) is like this:

```<code>SELECT tr.remark
FROM t2 LEFT JOIN t1
  ON t2.Remark LIKE "*" & t1.List & "*"
WHERE t1.List IS NULL
</code>```

although I'm not sure if I have ever used this with LIKE.

Body:
I have two tables

T1        T2
list      remark
abc       this is my list
def       i have abc remark
ghi       other than I have def comment
jkl       ghi is also there
          and this one will
          and this one too

I am attempting to write a query that will return all remarks in T2 that are not like the list in T1.

I have tried both Instr and Join with Not Like, but am stuck on the Cartesian Product issue.

Running a query where Instr = True returns the list I expect

SELECT DISTINCT t2.remark, InStr([t2].[remark],[t1].[list]) AS [Check]
FROM t2, t1
WHERE (((InStr([t2].[remark],[t1].[list]))=True));

ghi is also there

  I have abc remark

  other than I have def comment

But running for False is where I get all results, due to Cartesian Product:

Same with using Not Like

SELECT DISTINCT t2.remark
FROM t2 LEFT JOIN t1 ON t2.Remark NOT LIKE "*" & t1.List & "*"

I have also tried sub queries, but no luck. Any idea how I can solve this with Access SQL?

I suppose I could write the statement with TRUE then do another query where the remarks do not equal the result of my first query, but that seems a bit inefficient.

Body:
The usual way (at least in Access) is like this:

SELECT tr.remark
FROM t2 LEFT JOIN t1
  ON t2.Remark LIKE "*" & t1.List & "*"
WHERE t1.List IS NULL

although I'm not sure if I have ever used this with LIKE.


问:
How to set quality option on all images without using querystring?
Using https://imageresizing.net, how to set default quality so that all jpg and pngs are rendered with quality=90 without using querystring?

All photos should rendered like this:
https://azure.content.bloc.net/widget/200000184/363/2017/10/5/adam---eva-11.09.177001-copy.png?quality=90

without having to specify querystrings:
https://azure.content.bloc.net/widget/200000184/363/2017/10/5/adam---eva-11.09.177001-copy.png

Is it possible?

答:
I managed to do it in my custom plugin. I've created a custom virtual image provider, and I implemented the interface ISettingsModifier. Using it i managed to set the quality I wanted without using querystring.</p>

```<code>public ResizeSettings Modify(ResizeSettings settings)
    {
        settings.Quality = 50;
        return settings;
    }
</code>```

Body:
I managed to do it in my custom plugin. I've created a custom virtual image provider, and I implemented the interface ISettingsModifier. Using it i managed to set the quality I wanted without using querystring.

public ResizeSettings Modify(ResizeSettings settings)
    {
        settings.Quality = 50;
        return settings;
    }


问:
Using textvariable for a Tkinter (or ttk) LabelFrame
I want to update the label of a Tkinter LabelFrame widget.

For a Label widget, this can be done using the textvariable attribute, to which one can assign a StringVar.

I want to do the same thing, but for a LabelFrame

```<code>self.labelText = StringVar()
self.selectionFrame = ttk.LabelFrame(self, textvariable=self.labelText)

(...)

if A:
     self.labelText.set("LabelA")
elif B:
     self.labelText.set("LabelB")
</code>```

How can I achieve this?

答:
You can't. Neither the Tkinter LabelFrame nor the ttk LabelFrame support associating a variable with the widget.

If what you're really asking is how can you change the label, then you can use the configure method:

```<code>self.selectionFrame.configure(text="hello")
</code>```

Body:
I want to update the label of a Tkinter LabelFrame widget.

For a Label widget, this can be done using the textvariable attribute, to which one can assign a StringVar.

I want to do the same thing, but for a LabelFrame

self.labelText = StringVar()
self.selectionFrame = ttk.LabelFrame(self, textvariable=self.labelText)

(...)

if A:
     self.labelText.set("LabelA")
elif B:
     self.labelText.set("LabelB")

How can I achieve this?

Body:
You can't. Neither the Tkinter LabelFrame nor the ttk LabelFrame support associating a variable with the widget.

If what you're really asking is how can you change the label, then you can use the configure method:

self.selectionFrame.configure(text="hello")


问:
Get row indexes of H2O dataframe when split into train and test
I am new to H2O. So far for the train-test split I have used the StratifiedKFold() of sklearn.

```<code>skf = StratifiedKFold(n_splits=n, random_state=None, shuffle=False)
for train_index, test_index in skf.split(X, y):
    X_train, X_test = X[train_index], X[test_index]
    y_train, y_test = y[train_index], y[test_index]
</code>```

I need the indexes for some further processing later.

In H2O I can't figure out how to get the indexes while doing cross validation. From what I have gathered via videos and blogs, this is how we do CV in H2O:

```<code>gbm_model = H2OGradientBoostingEstimator(model_id = 'gbm_model',nfolds=5)
</code>```

How do I get the train and test indexes of each fold?

Also, how do I get the indexes while doing a simple split?

```<code>data_split = data.split_frame(ratios=[0.8],seed = 1234)
train_df = data_split[0]
test_df = data_split[1]
</code>```

How do I get the indexes that went into train and test?

答:
you could use stratified_kfold_column(n_folds=3, seed=-1) or stratified_split(test_frac=0.2, seed=-1) which create a column with the splits you can use to subset to split on later.

see more about these in the docs

Body:
I am new to H2O. So far for the train-test split I have used the StratifiedKFold() of sklearn.

skf = StratifiedKFold(n_splits=n, random_state=None, shuffle=False)
for train_index, test_index in skf.split(X, y):
    X_train, X_test = X[train_index], X[test_index]
    y_train, y_test = y[train_index], y[test_index]

I need the indexes for some further processing later.

In H2O I can't figure out how to get the indexes while doing cross validation. From what I have gathered via videos and blogs, this is how we do CV in H2O:

gbm_model = H2OGradientBoostingEstimator(model_id = 'gbm_model',nfolds=5)

How do I get the train and test indexes of each fold?

Also, how do I get the indexes while doing a simple split?

data_split = data.split_frame(ratios=[0.8],seed = 1234)
train_df = data_split[0]
test_df = data_split[1]

How do I get the indexes that went into train and test?


问:
How to parse JSON manually in Kotlin?
I want to parse JSON response manually in Kotlin. Since I am getting complex JSON response which is having some common fields. For example I am getting below response.

```<code>{
  status: "success/false"
  apiId: 6
  message: "Error msg if any"
  .
  .
  .    // Here comes some JSON with complex structure where some fields are
  .    // missing/omitted. Sometime array is missing/response in array is
  .    // getting changed, getting lot of unwanted stuff Or whatever you can
  .    // think. And because of this I need to parse it manually.
  .
}
</code>```

Now how can I parse this type of response manually in data class of Kotlin? One more thing I would like to know, can I use any base class for common fields in the response?

答:
Should be something like this:</p>

```<code>data class Response(val status: String, val apiId: Int , val message: String)
</code>```

Title: How to parse JSON manually in Kotlin?

Body:
I want to parse JSON response manually in Kotlin. Since I am getting complex JSON response which is having some common fields. For example I am getting below response.

{
  status: "success/false"
  apiId: 6
  message: "Error msg if any"
  .
  .
  .    // Here comes some JSON with complex structure where some fields are
  .    // missing/omitted. Sometime array is missing/response in array is
  .    // getting changed, getting lot of unwanted stuff Or whatever you can
  .    // think. And because of this I need to parse it manually.
  .
}

Now how can I parse this type of response manually in data class of Kotlin? One more thing I would like to know, can I use any base class for common fields in the response?

Body:
Should be something like this:

data class Response(val status: String, val apiId: Int , val message: String)


问:
.focus() not working after closing a DOMWindow() [JQuery]
I have a series of DIV elements that, when clicked on, trigger a DOMWindow open event. No problem there.

Then I had to add keyboard accessibility. DOH!!

I added tabindex attributes to the DIVs, which allows the user to tab from one DIV to the next, and I added a keypress handler to deal with the Enter Key. No problem there.

The problem I AM experiencing is trying to set the focus back to the div that the user was on when he or she hit the Enter Key and opened the DOMWindow (so they can continue tabbing to the next DIV in the series).

I tried adding a function to the "functionCallOnClose" setting of the DOMWindow, but that doesn't appear to do anything.

Here is a code snippet. This is binding the click and keypress events to all DIVs that have a class name of "timeEntry":

```<code>$(".timeEntry").live("click keypress", function () {

    // bunch of code here to set up the DOMWindow...

    $.openDOMWindow({

        // bunch of settings here...

        functionCallOnClose: function () {
            // this doesn't work
            // 'DivId' is the object (DIV) that was clicked on
            $(DivId).focus();
        }
    });

});
</code>```

Does anyone have a clue why I can't seem to get the focus back to the original DIV after the click or keypress events are fired and handled?

I realize this is a pretty obscure question, so I'm throwing it out there in hopes that someone else reading this is using JQuery, DOMWindow, and handling click and keypress events (or at least knows how)

:o)

EDIT: After doing some further debugging, it seems that there is a problem with jQuery getting the tabIndex attribute from DIV tags. When I view the source of my page, I can see the attributes:

```<code><div id="someDiv" class="someClass" tabindex="1"> ... </div>
</code>```

However, when I try to get the attribute using jQuery, it does not appear to be there.

This code returns "undefined"

```<code>var tabindex = $("#someDiv").attr("tabindex");
</code>```

However, if I set the attribute using jQuery, I can turn around and retrieve it:

```<code>// set the tabindex
$("#someDiv").attr("tabindex", "1");

// now this returns "1"
var tabindex = $("#someDiv").attr("tabindex");
</code>```

Does anyone have a clue why jQuery doesn't return the tabindex attribute when it is set in the HTML, but it will after it is set dynamically using code?

Hope this makes sense...

答:
the problem sound interesting so I did some search and found this: http://api.jquery.com/attr/#comment-92512642

It may be a bug in jquery version 1.4.3 (works in 1.4.2 according to link).

ContentLicense: CC BY-SA 2.5

Body:
I have a series of DIV elements that, when clicked on, trigger a DOMWindow open event. No problem there.

Then I had to add keyboard accessibility. DOH!!

I added tabindex attributes to the DIVs, which allows the user to tab from one DIV to the next, and I added a keypress handler to deal with the Enter Key. No problem there.

The problem I AM experiencing is trying to set the focus back to the div that the user was on when he or she hit the Enter Key and opened the DOMWindow (so they can continue tabbing to the next DIV in the series).

I tried adding a function to the "functionCallOnClose" setting of the DOMWindow, but that doesn't appear to do anything.

Here is a code snippet. This is binding the click and keypress events to all DIVs that have a class name of "timeEntry":

$(".timeEntry").live("click keypress", function () {

    // bunch of code here to set up the DOMWindow...

    $.openDOMWindow({

        // bunch of settings here...

        functionCallOnClose: function () {
            // this doesn't work
            // 'DivId' is the object (DIV) that was clicked on
            $(DivId).focus();
        }
    });

});

Does anyone have a clue why I can't seem to get the focus back to the original DIV after the click or keypress events are fired and handled?

I realize this is a pretty obscure question, so I'm throwing it out there in hopes that someone else reading this is using JQuery, DOMWindow, and handling click and keypress events (or at least knows how)

:o)

EDIT: After doing some further debugging, it seems that there is a problem with jQuery getting the tabIndex attribute from DIV tags. When I view the source of my page, I can see the attributes:

 ...

However, when I try to get the attribute using jQuery, it does not appear to be there.

This code returns "undefined"

var tabindex = $("#someDiv").attr("tabindex");

However, if I set the attribute using jQuery, I can turn around and retrieve it:

// set the tabindex
$("#someDiv").attr("tabindex", "1");

// now this returns "1"
var tabindex = $("#someDiv").attr("tabindex");

Does anyone have a clue why jQuery doesn't return the tabindex attribute when it is set in the HTML, but it will after it is set dynamically using code?

Hope this makes sense...


问:
Refresh All on a PowerQuery from a Web Query not pulling updated data - Excel
Sorry for the long title. I am trying to "refresh all" on an Excel PowerQuery. The query should go to the website http://www.cmegroup.com/trading/energy/coal/coal-api-4-fob-richards-bay-argus-mccloskey.html and pull the table there. When I set this up in a new spreadsheet it works fine. However the following day(s), when I refresh all it often will not go to the website and grab the new data. I can go to the website and see it has updated but the PowerQuery setup will not grab it. Can someone advise what is causing the issue of it not retrieving the new info when hitting refresh all? </p>

答:
Use IsRetry flag in Web.Contents function to force PQ ignore cache

```<code>response = Web.Contents(your_url, [IsRetry=true])
</code>```

Body:
Use IsRetry flag in Web.Contents function to force PQ ignore cache

response = Web.Contents(your_url, [IsRetry=true])


问:
User Group Setup
I have created a user group "Sub-Users" under the "Registered" user group.
Now I have created and assigned some menus for Registered group and Sub-Users group.

Now when I logged in as Registered user I can't see the Sub-Users group menus and its OK for me,
But when I logged in as Sub-User group I can see the both menus (Registered & Sub User Group) and its not OK for me.

Now I am looking for solution if I logged in as Sub User I want to see only Sub User menus.

Can you please let me know if there is any solution.

Thanks

答:
Access control is managed via 'viewing access levels' as opposed to 'user groups'

If you haven't already done so, check Users > Access Levels. Open the level names in question and check which groups you have configured for each access level.

Good luck!

Title: User Group Setup


问:
Vendor prefixes are glued together in Radium
I'm using Radium to inline my styles in a simple React app, but somehow Radium is compiling the vendor prefixes one after the other:

```<code>import Radium from 'radium'
import React from 'react'

const styles = {
    base: {
        width: 'calc(100% - 4rem)',
        maxWidth: '60rem',
        margin: '0 auto'
    }
}

const Container = function (props) {
    return <div className='container' style={styles.base}>
        {props.children}
    </div>
}

export default Radium(Container)
</code>```

This all seems to work fine with attributes that don't need vendor prefixing (like maxWidth or margin), but widths gets compiled as:

```<code>width: -webkit-calc(100% - 4rem),-moz-calc(100% - 4rem),calc(100% - 4rem);
</code>```

And of course the browser is complaining that this is an invalid value. Same with display: flex, for example.

Any idea?

答: Fixed, I missed one piece of information: this was old rendered in the server. Adding the appropriate user agent in the radium configuration solved it (https://github.com/FormidableLabs/radium/tree/master/docs/api#configuseragent).</p>

Body:
I'm using Radium to inline my styles in a simple React app, but somehow Radium is compiling the vendor prefixes one after the other:

import Radium from 'radium'
import React from 'react'

const styles = {
    base: {
        width: 'calc(100% - 4rem)',
        maxWidth: '60rem',
        margin: '0 auto'
    }
}

const Container = function (props) {
    return

        {props.children}

}

export default Radium(Container)

This all seems to work fine with attributes that don't need vendor prefixing (like maxWidth or margin), but widths gets compiled as:

width: -webkit-calc(100% - 4rem),-moz-calc(100% - 4rem),calc(100% - 4rem);

And of course the browser is complaining that this is an invalid value. Same with display: flex, for example.

Any idea?


问:
Neo4j Store Data In Array Or User Super Node
In early editions of Neo4j, Super nodes were typically seen as a bad thing for performance.  I have not seen too much about that recently with the 2.X and 3.X releases so was wondering if that was still a problem.

The issue I have is I need to store a finite number of options for a specific Node type.  For example, Person and favorite colors.  I can store an array in the Person Node that stores the colors the user likes, or I can create a Node for each color and then create a relationship from the Person to the Color Node.  It seems the super node option would be faster to query but am worried as super nodes were bad in the past.

If I am trying to look up people who like a specific color, what's the recommended way to store such data in Neo?

答:
I think the major issue here will be that the Color node will become a very connected node.

Maybe you need an Options subgraph to have a template of these options and then :

copy template node option to link this copy with the main entity node

or

copy only the choosen option into a property of the main entity node, like your array proposition

or, if your option has no properties

add label onto your main entity node

I think, even with the increase in performance of hyperlinked nodes with newer Neo4j versions, the read/write time will be always more than the one who has less.

I hope this help a bit.


问:
python-xarray: xarray.Dataset.keep?
I have a fairly large xr.Dataset with about 20 Data variables. I am only interested in keeping two of them. I see xr.Dataset.drop with drop variables for a Dataset.

I'm looking for syntax to keep variables. I tried f['hs','t01'] and got

Traceback (most recent call last):   File
  "/nethome/rxb826/local/bin/miniconda3/lib/python3.6/site-packages/xarray/core/dataset.py",
  line 662, in _construct_dataarray
      variable = self._variables[name] KeyError: ('hs', 't01')

If there isn't simply syntax I could have a look at developing xr.Dataset.keep

I can also clunky manually create the Dataset as
ds = xr.Dataset({'hs': f['hs'], 't01': f['t01']})

答:
You can use your getitem syntax using a iterable of variable names:

```<code>f_with_two_vars = f[['hs','t01']]
</code>```

(See the xarray manual section on Indexing and selecting data for a more detailed explanation.)

Title: python-xarray: xarray.Dataset.keep?

Body:
You can use your getitem syntax using a iterable of variable names:

f_with_two_vars = f[['hs','t01']]

(See the xarray manual section on Indexing and selecting data for a more detailed explanation.)


问:
Crystal report PDF showing differently

See the picture, There is no columns in second page but it is showing header i want to remove that one.

答: Most likely you will need to make report body smaller in the report designer. Please try that and try to reduce your report margins. If this will not help, please post the picture of your report in the designer </p>

Title: Crystal report PDF showing differently


问:
How to add all the values of a map without using recurrsion or var
I want to add all the values in a map without using var or any mutable structures. I have tried to do something like this but it doens't work:

```<code>val mymap = ("a" -> 1, "b" -> 2)
    val sum_of_alcohol_consumption =
    for ((k,v) <- mymap ) yield (sum_of_alcohol_consumption += v)
</code>```

I have been told that I can use .sum on a list
Please help

Thanks

答:
To get the only values of map, it provides a function values which will return iterable,we can directly appy sum function to it.    </p>

```<code>scala> val mymap = Map("a" -> 1, "b" -> 2)
mymap: scala.collection.immutable.Map[String,Int] = Map(a -> 1, b -> 2)

scala> mymap.values.sum
res7: Int = 3
</code>```

Body:
I want to add all the values in a map without using var or any mutable structures. I have tried to do something like this but it doens't work:

val mymap = ("a" -> 1, "b" -> 2)
    val sum_of_alcohol_consumption =
    for ((k,v) <- mymap ) yield (sum_of_alcohol_consumption += v)

I have been told that I can use .sum on a list
Please help

Thanks

Body:
To get the only values of map, it provides a function values which will return iterable,we can directly appy sum function to it.

scala> val mymap = Map("a" -> 1, "b" -> 2)
mymap: scala.collection.immutable.Map[String,Int] = Map(a -> 1, b -> 2)

scala> mymap.values.sum
res7: Int = 3


问:
C#,Multiple condition for if statement
I am a matlab user. How can I use the following if statment in c#

```<code>    double angle;
    //angle=45.00;// just for idea
        if (0.0<=angle<90.0)||(170.0<=angle<181.0)
        {
// do something
        }
</code>```

// It is just demo code what I want to do.......

答:
You can't combine comparisons like that in C#:</p>

```<code>if ((0 <= angle && angle < 90) || (170 <= angle && angle < 181)
{
    // do something
}
</code>```

Title: C#,Multiple condition for if statement

Body:
I am a matlab user. How can I use the following if statment in c#

    double angle;
    //angle=45.00;// just for idea
        if (0.0<=angle<90.0)||(170.0<=angle<181.0)
        {
// do something
        }

// It is just demo code what I want to do.......

Body:
You can't combine comparisons like that in C#:

if ((0 <= angle && angle < 90) || (170 <= angle && angle < 181)
{
    // do something
}


问:
time series with variable parameter as list column
I have a tibble with column alpha denoting the parameter of an AR1 process:

```<code>df = data_frame(alpha = seq(-.5, .5, .1))
</code>```

Now, for each value of alpha I want to sample an AR1 process of length 100, and add the processes to df as a list column.
The following doesn't work:

```<code>df %>% mutate(ar1 = list(arima.sim(n=100, model=list(ar=alpha))))
</code>```

Each element of the new column ar1 is exactly the same process. How can I ensure that each element of the column ar1 is a realization of an AR1 process with the corresponding parameter alpha?

Body:
I have a tibble with column alpha denoting the parameter of an AR1 process:

df = data_frame(alpha = seq(-.5, .5, .1))

Now, for each value of alpha I want to sample an AR1 process of length 100, and add the processes to df as a list column.
The following doesn't work:

df %>% mutate(ar1 = list(arima.sim(n=100, model=list(ar=alpha))))

Each element of the new column ar1 is exactly the same process. How can I ensure that each element of the column ar1 is a realization of an AR1 process with the corresponding parameter alpha?

Body:
You can use lapply:

library(dplyr)
df = data_frame(alpha = seq(-.5, .5, .1))

df = df %>%
  mutate(ar1 = lapply(alpha, function(x) arima.sim(n=100, model=list(ar=x))))

or with map from purrr:

df = df %>%
  mutate(ar1 = purrr::map(alpha, ~ arima.sim(n=100, model=list(ar=.))))

Result:

> df
# A tibble: 11 x 2
   alpha      ar1
   <dbl>   <list>
 1  -0.5 <S3: ts>
 2  -0.4 <S3: ts>
 3  -0.3 <S3: ts>
 4  -0.2 <S3: ts>
 5  -0.1 <S3: ts>
 6   0.0 <S3: ts>
 7   0.1 <S3: ts>
 8   0.2 <S3: ts>
 9   0.3 <S3: ts>
10   0.4 <S3: ts>
11   0.5 <S3: ts>

> df$ar1 %>% lapply(head)
[[1]]
[1] -0.3514397  0.6665273  0.1932043 -0.5509680 -0.5857840 -0.6412465

[[2]]
[1] -1.3324151  0.9639404 -1.2454844  0.1048227 -0.4667547  1.2749614

[[3]]
[1] -0.2049486 -0.5751628  0.4895776  0.1538311  2.0552770 -1.3351100

[[4]]
[1] -0.1118248  0.4838552  2.7614692 -0.7824381  0.5151733  2.2416832

[[5]]
[1]  1.7293663  0.5335523 -0.4605581 -0.7785337  0.7875933 -0.8702821

[[6]]
[1]  1.15512596 -1.14722217  0.44119379  0.03748791  0.03285100 -0.05754903

[[7]]
[1]  0.5513116  1.4185419 -0.7616093  1.5258314  1.7186733 -0.9435652

[[8]]
[1] -1.0346102 -1.9515274  0.3263094 -0.9846696 -0.1100608  1.2949033

[[9]]
[1]  1.3427732  0.8074878 -2.0393332 -0.0580785  0.9315681  1.1272597

[[10]]
[1]  1.5801751  0.6694740  0.3058637 -0.8653836  0.3402794  1.3181050

[[11]]
[1]  1.7001214  2.8050716  0.6580970  3.0519142  2.3411307 -0.6577423


问:
C# Can I display images in a list box?
C# In a nut shell can I display images in a list box? I have a list of users and I want to display a green tick next to some of the names, is this possible?

Thanks

答: System.Windows.Forms.ListView will do the trick very easily. You might have to work a little harder than a ListBox if you want the list in 'details' view though.</p>

OwnerDisplayName: Steve

LastEditorDisplayName: Steve

Title: C# Can I display images in a list box?

OwnerDisplayName: Coincoin


问:
"hg commit -m 'My changes' " error
I follow this article to create a repository using Mercurial:

```<code>$ hg clone http://selenic.com/repo/hello
$ cd hello
$ hg add a.txt
$ hg commit -m 'My changes'
</code>```

but when i use hg commit -m 'My changes', it shows error :

```<code>abort: changes':
</code>```

What can I do about it?

答:
If you simply do

```<code>hg commit
</code>```

it will show you the editor, where you can type in your commit message.

As others have pointed out, though, double quotes should do the trick too.

Title: "hg commit -m 'My changes' " error

Body:
I follow this article to create a repository using Mercurial:

$ hg clone http://selenic.com/repo/hello
$ cd hello
$ hg add a.txt
$ hg commit -m 'My changes'

but when i use hg commit -m 'My changes', it shows error :

abort: changes':

What can I do about it?

Body:
If you simply do

hg commit

it will show you the editor, where you can type in your commit message.

As others have pointed out, though, double quotes should do the trick too.


问:
Send an array from C# to TwinCat 3 via ADS.Net
I want to make an automated graphical fountain using TwinCat 3 to control the valves and Visual Studio C# for processing the image that want to show on the fountain.

The final form of the image processing program is a binary array image (attached) :
Image Processing Result 1;
Image Processing Result 2;

I want to used the final form of the image processing to control the valve on the machine (the valve will turn on when it's 1, and the valve will turn off when it's 0).I am very new with TwinCat 3 especially with the ADS Library.

The sample from infosys beckhoff not really helpful for me, can someone help me with this ?

Thank You

答:
I used System.Runtime.InteropServices.MarshalAs with TwinCAT 3.1.4022.0

Array declaration:

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] data;
```

<p>And then I can send it via</p>

<pre class="lang-cs prettyprint-override"><code>TcAdsClient.WriteAny( ixGroup, ixOffset, data )
</code>```

Body:
I used System.Runtime.InteropServices.MarshalAs with TwinCAT 3.1.4022.0

Array declaration:

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] data;

And then I can send it via

TcAdsClient.WriteAny( ixGroup, ixOffset, data )