问:
Are there any Kimonolabs alternatives?
Recently kimonolabs announced they will be shutting down which is a major let down as my app heavily relies on this service in terms of getting data. It's really dissapointing that they're just shutting this service. I've been using import.io in the mean time but it's no where near the standard of kimono and is missing some features.

I was wondering if there are any services that are similar to kimono that have the following features:

Scheduled crawls i.e. schedule a crawl every 24 hours or Alternatively you can call a link to update the latest data for a crawl.

Bulk or single url crawls i.e. Enter a list or a single url to scrape.

Call a link to get the results from the crawl in JSON.

Use a single api key to make a call for the api.

It's free for most of these features.

Alternatively i may be tempted to create my own it's just that i don't want to increase my dev time learning Node.js or Python which is why i'm asking this question.

答:
My team and I are working on a very similar tool and we will launch it soon. Here is more about it:

Automatio is Web Automation Tool which you can use to scrape data from any website in very easy way.

Some of the features are:

Previewing scrapped data in different formats, like CSV, JSON, RSS, and API. There is download option as well.

Generating widgets from same data and getting iframe output to display on your website.

Visualizing data with different chart types.

Supports regular pagination and infinite scroll

Scheduling and looping tasks

Integration with other platforms

If you are interested you can signup for early access here https://automatio.co

Check few videos to see it in action:

https://www.youtube.com/watch?v=p-JdpnfuB58

https://www.youtube.com/watch?v=9Cll_8-8a2s

https://www.youtube.com/watch?v=PsZY7tHE-K8

Title: Are there any Kimonolabs alternatives?


来源: stackexchange

问:
calling a function via LPVOID with up to 10 arguments of different types
I need to call a function where I have the LPVOID and the number of arguments. Furthermore I know the types and positions of the arguments.
The arguments can be of type int, int*, double, double*, string, string*.
As the arguments can be in any order the possible list of templates would be very large. The return value is always boolean.

```<code>bool Func1(int);
bool Func1(int*);
bool Func1(double);
(...)
bool Func2(int,int);
bool Func2(int,int*);
(...)
</code>```

So this is not an option. I've tried to use std::tuple but with no success.
The following examples only works for a function with arguments (int, double).

```<code>    template <typename R, typename... Args>
    R call(FARPROC fp, Args... args) throw(HRESULT)
    {
        typedef R(__stdcall * function_pointer)(Args...);
        function_pointer P = (function_pointer)fp;
        const auto return_value = (*P)(std::forward<Args>(args)...);
        ().do_cast(fetch_back(args))...);
        return return_value;
     }

(...)
LPVOID function;
int iVal1 = 2;
double dbVal1 = 3.0;
auto t = std::make_tuple(iVal1 , dbVal1);
bool bRes = call<bool>((FARPROC)function, std::get<0>(t), std::get<1>(t));
</code>```

What I am thinking about is a generic way of creating the std::tuple based on some input (string etc.), something like: auto t = create_tuple("int,int*,int").

答:
My suggestion, for anyone interested in alternatives...

Bury the LPVOID function under a meaningful API and never use it directly again.

Obviously, an LPVOID function taking a bunch of void *ters is not self-documenting, so provide something that is.

Provide various constructors or helper methods that accept the values required for making a specific low level call to the LPVOID and provide conversion methods for handing the values down to the LPVOID.

ContentLicense: CC BY-SA 3.0

Body:
I need to call a function where I have the LPVOID and the number of arguments. Furthermore I know the types and positions of the arguments.
The arguments can be of type int, int*, double, double*, string, string*.
As the arguments can be in any order the possible list of templates would be very large. The return value is always boolean.

bool Func1(int);
bool Func1(int*);
bool Func1(double);
(...)
bool Func2(int,int);
bool Func2(int,int*);
(...)

So this is not an option. I've tried to use std::tuple but with no success.
The following examples only works for a function with arguments (int, double).

    template <typename R, typename... Args>
    R call(FARPROC fp, Args... args) throw(HRESULT)
    {
        typedef R(__stdcall * function_pointer)(Args...);
        function_pointer P = (function_pointer)fp;
        const auto return_value = (*P)(std::forward<Args>(args)...);
        ().do_cast(fetch_back(args))...);
        return return_value;
     }

(...)
LPVOID function;
int iVal1 = 2;
double dbVal1 = 3.0;
auto t = std::make_tuple(iVal1 , dbVal1);
bool bRes = call<bool>((FARPROC)function, std::get<0>(t), std::get<1>(t));

What I am thinking about is a generic way of creating the std::tuple based on some input (string etc.), something like: auto t = create_tuple("int,int*,int").


问:
Where does mono put app.config
I have a winforms app which has an app.config.

If the config file is not present it is automatically generated. However it is not generated in the directory that the app is running from. I can't find it anywhere.

I know it is generated because my setting are persisted as expected.

So where has mono put it.

(running on ubuntu 10.04) mono 2.4.

It seems that on windows a deleted .config file is not regenerated (I get an error) until I do a rebuild, But on mono it quite happily continues saving my settings after I delete the config file.

答: Check the output directory - by default the application configuration file is emitted to the same directory as the assembly.</p>

ContentLicense: CC BY-SA 2.5

Title: Where does mono put app.config


问:
How to get and plot a signal envelope
I would like to know if there is a function envelope in Python to have the same result as this

I have already tried an envelope function in Python but there is this result and it doesn't correspond with what I want.

答:
Sometimes I would use obspy.signal.filter.envelope(data_array); But you can only get the upper line in your given example.
Obspy is a very useful package dealing with seismogram. </p>

ContentLicense: CC BY-SA 4.0

Title: How to get and plot a signal envelope


问:
Unable to connect to local server
I am working on a project which uses pycharm and Google Cloud for back end. While debugging the application , I am unable to connect to localhost location http://127.0.0.1:8080/, and instead keeps waiting forever.

In the console window, I see the below warnings. I would like to know what is preventing connecting to http://127.0.0.1:8080/ and also if the warnings listed below have any impact?.

```<code>Connected to pydev debugger (build 171.4694.38)
INFO     2017-07-05 18:25:44,914 api_server.py:272] Starting API server
at: http://localhost:51197
INFO     2017-07-05 18:25:44,922 dispatcher.py:205] Starting module
"internal-api" running at: http://127.0.0.1:8080
INFO     2017-07-05 18:25:44,929 admin_server.py:116] Starting admin
          server at: http://localhost:8000
WARNING  2017-07-05 18:25:44,929 devappserver2.py:766] No default
          module found. Ignoring.
pydev debugger: process 940 is connecting

pydev debugger: process 941 is connecting

/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_xml
    .py:73:
       RuntimeWarning: Parent module '_pydevd_bundle' not found while handling absolute import
/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_xml.py:79: RuntimeWarning: Parent module '_pydevd_bundle' not found while handling absolute import
/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_xml.py:86: RuntimeWarning: Parent module '_pydevd_bundle' not found while handling absolute import
/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_xml.py:93: RuntimeWarning: Parent module '_pydevd_bundle' not found while handling absolute import
</code>```

答: Issue is resolved. Can't believe myself, it is a hidden breakpoint which i could not see it which kept the serve waiting.</p>

Title: Unable to connect to local server

Body:
I am working on a project which uses pycharm and Google Cloud for back end. While debugging the application , I am unable to connect to localhost location http://127.0.0.1:8080/, and instead keeps waiting forever.

In the console window, I see the below warnings. I would like to know what is preventing connecting to http://127.0.0.1:8080/ and also if the warnings listed below have any impact?.

Connected to pydev debugger (build 171.4694.38)
INFO     2017-07-05 18:25:44,914 api_server.py:272] Starting API server
at: http://localhost:51197
INFO     2017-07-05 18:25:44,922 dispatcher.py:205] Starting module
"internal-api" running at: http://127.0.0.1:8080
INFO     2017-07-05 18:25:44,929 admin_server.py:116] Starting admin
          server at: http://localhost:8000
WARNING  2017-07-05 18:25:44,929 devappserver2.py:766] No default
          module found. Ignoring.
pydev debugger: process 940 is connecting

pydev debugger: process 941 is connecting

/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_xml
    .py:73:
       RuntimeWarning: Parent module '_pydevd_bundle' not found while handling absolute import
/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_xml.py:79: RuntimeWarning: Parent module '_pydevd_bundle' not found while handling absolute import
/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_xml.py:86: RuntimeWarning: Parent module '_pydevd_bundle' not found while handling absolute import
/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_xml.py:93: RuntimeWarning: Parent module '_pydevd_bundle' not found while handling absolute import


问:
How can I search lucene for "John J" and get people like "John Jameson" not just people with John?
For reasons out of my control, I must do this with a global search. I've taken converting a search term "John J" into (John AND J), which works for anyone who's last name doesn't start with the same letter as their first.

How can I make the search for "John J" become "find all people who have John and then another, different J in the field"?

Thanks for your time.

答:
You may want to try out Wildcard Query. For example:

```<code>Term term = new Term("secondName", "J*");
Query query = new WildcardQuery(term);
</code>```

I am assuming you have a different fields for first and second name. You can create a boolean query with a combination of queries for first and second names.

Documentation for WildcardQuery: http://lucene.apache.org/core/6_2_0/core/org/apache/lucene/search/WildcardQuery.html

I hope this helps.

Body:
You may want to try out Wildcard Query. For example:

Term term = new Term("secondName", "J*");
Query query = new WildcardQuery(term);

I am assuming you have a different fields for first and second name. You can create a boolean query with a combination of queries for first and second names.

Documentation for WildcardQuery: http://lucene.apache.org/core/6_2_0/core/org/apache/lucene/search/WildcardQuery.html

I hope this helps.


问:
How to control the volume of multiple sounds at once using multiple SeekBars (Android)?
How can I control the volume of multiple sounds playing at the same time using multiple SeekBars? There are three mp3 files are played at the same time. There are three SeekBars, each Seekbar progress should relate to the volume of it's relative sound file. The issue I'm having is that when I move one SeekBar, that controls the volume of all three sounds.

Here's the Android code followed by the XML:

```<code>/*
Created by: Justin Clark
Company: VaughnX
Date: June 15 2017
Purpose: To block out external sound using white, brown, and pink noise.
To do:  -Increase duration of brown and pink noise files.
        -use seek slider as an in-app volume controller
 */

package com.vaughnx.vaugi.soundwall;

import android.app.Activity;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.ToggleButton;
import android.media.MediaPlayer;
import android.media.AudioManager;

public class MainActivity extends Activity {

    private SeekBar whiteVolumeSeekBar;
    private SeekBar pinkVolumeSeekBar;
    private SeekBar brownVolumeSeekBar;
    private AudioManager whiteAudioManager;
    private AudioManager pinkAudioManager;
    private AudioManager brownAudioManager;
    private int maxVolume;
    private int curVOlume;
    final MediaPlayer whiteNoiseMP = MediaPlayer.create(this, R.raw.whitenoise);
    final MediaPlayer brownNoiseMP = MediaPlayer.create(this, R.raw.brownnoise);
    final MediaPlayer pinkNoiseMP = MediaPlayer.create(this, R.raw.pinknoise);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setVolumeControlStream(AudioManager.STREAM_MUSIC);
        initializeSoundController();
        initializeVolumeController();
    }
    //Sets up white, brown, and pink noise players. Uses toggle buttons to turn sound on
    //and off.
    public void initializeSoundController() {

        ToggleButton whiteNoiseToggle = (ToggleButton) findViewById(R.id.whitenoisebutton);
        whiteNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    whiteNoiseMP.start();
                } else {
                    // The toggle is disabled
                    whiteNoiseMP.pause();
                }
            }
        });
        ToggleButton brownNoiseToggle = (ToggleButton) findViewById(R.id.brownnoisebutton);
        brownNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    brownNoiseMP.start();
                } else {
                    // The toggle is disabled
                    brownNoiseMP.pause();
                }
            }
        });
        ToggleButton pinkNoiseToggle = (ToggleButton) findViewById(R.id.pinknoisebutton);
        pinkNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    pinkNoiseMP.start();
                } else {
                    // The toggle is disabled
                    pinkNoiseMP.pause();
                }
            }
        });

    }
    //End of sound controller initializations

    //Start of control volume with sliders//
    private void initializeVolumeController()
    {
        try{
            whiteVolumeSeekBar = (SeekBar) findViewById(R.id.whiteVolumeSeekBar);
            whiteVolumeSeekBar.setMax(50);
            whiteVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    whiteNoiseMP.setVolume(1-log1, 1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
            pinkVolumeSeekBar.setProgress(25);
        } catch (Exception e){

        }
        try{
            pinkVolumeSeekBar = (SeekBar) findViewById(R.id.pinkVolumeSeekBar);
            pinkVolumeSeekBar.setMax(50);
            pinkVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    pinkNoiseMP.setVolume(1-log1, 1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
            pinkVolumeSeekBar.setProgress(25);
        } catch (Exception e){

        }
        try{
            brownVolumeSeekBar = (SeekBar) findViewById(R.id.brownVolumeSeekBar);
            brownVolumeSeekBar.setMax(50);
            brownVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    brownNoiseMP.setVolume(1-log1, 1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
            brownVolumeSeekBar.setProgress(25);

        } catch (Exception e){

        }

        //end of volume controller

}}

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/numbsound"
    tools:context="com.vaughnx.vaugi.soundwall.MainActivity">

    <ToggleButton
        android:id="@+id/whitenoisebutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textOff="@string/whiteToggleButton"
        android:textOn="@string/whiteToggleButton"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="247dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="16dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <ToggleButton
        android:id="@+id/pinknoisebutton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button"
        android:textOff="@string/pinkToggleButton"
        android:textOn="@string/pinkToggleButton"
        tools:layout_editor_absoluteX="260dp"
        tools:layout_editor_absoluteY="247dp"
        android:layout_marginTop="48dp"
        android:layout_below="@+id/brownnoisebutton"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <ToggleButton
        android:id="@+id/brownnoisebutton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/whitenoisebutton"
        android:layout_marginTop="44dp"
        android:text="Button"
        android:textOff="@string/brownToggleButton"
        android:textOn="@string/brownToggleButton"
        tools:layout_editor_absoluteX="137dp"
        tools:layout_editor_absoluteY="247dp" />

    <SeekBar
        android:id="@+id/whiteVolumeSeekBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/pinknoisebutton"
        android:layout_marginTop="62dp" />
    <SeekBar
        android:id="@+id/brownVolumeSeekBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/whiteVolumeSeekBar"
        android:layout_marginTop="62dp" />
    <SeekBar
        android:id="@+id/pinkVolumeSeekBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/brownVolumeSeekBar"
        android:layout_marginTop="62dp" />

</RelativeLayout>

**************************************************************************
        LogCat Results:
07-09 17:05:52.621: E/AndroidRuntime(3147): FATAL EXCEPTION: main
07-09 17:05:52.621: E/AndroidRuntime(3147): Process: com.vaughnx.vaugi.soundwall, PID: 3147
07-09 17:05:52.621: E/AndroidRuntime(3147): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.vaughnx.vaugi.soundwall/com.vaughnx.vaugi.soundwall.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3135)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3418)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread.access$1100(ActivityThread.java:231)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.os.Handler.dispatchMessage(Handler.java:102)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.os.Looper.loop(Looper.java:148)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread.main(ActivityThread.java:7422)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at java.lang.reflect.Method.invoke(Native Method)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
07-09 17:05:52.621: E/AndroidRuntime(3147): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.content.ContextWrapper.getResources(ContextWrapper.java:92)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:81)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.support.v7.app.AppCompatActivity.getResources(AppCompatActivity.java:549)
</code>```

答:
You should use MediaPlayer.setVolume instead of Audio Manager to control volume.

```<code>package com.vaughnx.vaugi.soundwall;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.ToggleButton;
import android.media.MediaPlayer;

public class MainActivity extends AppCompatActivity {

    private SeekBar whiteVolumeSeekBar;
    private SeekBar pinkVolumeSeekBar;
    private SeekBar brownVolumeSeekBar;
    private int maxVolume;
    private int curVOlume;
    private MediaPlayer whiteNoiseMP;
    private MediaPlayer brownNoiseMP;
    private MediaPlayer pinkNoiseMP;
    private ToggleButton whiteNoiseToggle;
    private ToggleButton brownNoiseToggle;
    private ToggleButton pinkNoiseToggle;

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

        //Sets up white, brown, and pink noise players. Uses toggle buttons to turn sound on
        //and off.
        whiteNoiseMP = MediaPlayer.create(MainActivity.this, R.raw.whitenoise);
        brownNoiseMP = MediaPlayer.create(MainActivity.this, R.raw.brownnoise);
        pinkNoiseMP = MediaPlayer.create(MainActivity.this, R.raw.pinknoise);
        whiteNoiseToggle = (ToggleButton) findViewById(R.id.whitenoisebutton);
        whiteNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    whiteNoiseMP.start();
                } else {
                    // The toggle is disabled
                    whiteNoiseMP.pause();
                }
            }
        });
        brownNoiseToggle = (ToggleButton) findViewById(R.id.brownnoisebutton);
        brownNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    brownNoiseMP.start();
                } else {
                    // The toggle is disabled
                    brownNoiseMP.pause();
                }
            }
        });
        pinkNoiseToggle = (ToggleButton) findViewById(R.id.pinknoisebutton);
        pinkNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    pinkNoiseMP.start();
                } else {
                    // The toggle is disabled
                    pinkNoiseMP.pause();
                }
            }
        });
       //End of sound controller initializations

       //Start of control volume with sliders//
       try{
           whiteVolumeSeekBar = (SeekBar) findViewById(R.id.whiteVolumeSeekBar);
           whiteVolumeSeekBar.setMax(50);
           whiteVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
               @Override
               public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                   float log1 = (float) (Math.log(50-progress)/Math.log(50));
                   whiteNoiseMP.setVolume(1-log1);
               }

               @Override
               public void onStartTrackingTouch(SeekBar seekBar) {

               }

               @Override
               public void onStopTrackingTouch(SeekBar seekBar) {

               }
           });
           pinkVolumeSeekBar.setProgress(25);
        } catch (Exception e){
            Log.e("Exception", e.getMessage());
        }
        try{
            pinkVolumeSeekBar = (SeekBar) findViewById(R.id.pinkVolumeSeekBar);
            pinkVolumeSeekBar.setMax(50);
            pinkVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    pinkNoiseMP.setVolume(1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
            pinkVolumeSeekBar.setProgress(25);
        } catch (Exception e){
            Log.e("Exception", e.getMessage());
        }
        try{
            brownVolumeSeekBar = (SeekBar) findViewById(R.id.brownVolumeSeekBar);
            brownVolumeSeekBar.setMax(50);
            brownVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    brownNoiseMP.setVolume(1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
           brownVolumeSeekBar.setProgress(25);

        } catch (Exception e){
            Log.e("Exception", e.getMessage());
        }
        //end of volume controller
    }
}
</code>```

I have set 50 as the maximum volume and starting volume to be 50% i.e. 25.

Body:
How can I control the volume of multiple sounds playing at the same time using multiple SeekBars? There are three mp3 files are played at the same time. There are three SeekBars, each Seekbar progress should relate to the volume of it's relative sound file. The issue I'm having is that when I move one SeekBar, that controls the volume of all three sounds.

Here's the Android code followed by the XML:

/*
Created by: Justin Clark
Company: VaughnX
Date: June 15 2017
Purpose: To block out external sound using white, brown, and pink noise.
To do:  -Increase duration of brown and pink noise files.
        -use seek slider as an in-app volume controller
 */

package com.vaughnx.vaugi.soundwall;

import android.app.Activity;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.ToggleButton;
import android.media.MediaPlayer;
import android.media.AudioManager;

public class MainActivity extends Activity {

    private SeekBar whiteVolumeSeekBar;
    private SeekBar pinkVolumeSeekBar;
    private SeekBar brownVolumeSeekBar;
    private AudioManager whiteAudioManager;
    private AudioManager pinkAudioManager;
    private AudioManager brownAudioManager;
    private int maxVolume;
    private int curVOlume;
    final MediaPlayer whiteNoiseMP = MediaPlayer.create(this, R.raw.whitenoise);
    final MediaPlayer brownNoiseMP = MediaPlayer.create(this, R.raw.brownnoise);
    final MediaPlayer pinkNoiseMP = MediaPlayer.create(this, R.raw.pinknoise);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setVolumeControlStream(AudioManager.STREAM_MUSIC);
        initializeSoundController();
        initializeVolumeController();
    }
    //Sets up white, brown, and pink noise players. Uses toggle buttons to turn sound on
    //and off.
    public void initializeSoundController() {

        ToggleButton whiteNoiseToggle = (ToggleButton) findViewById(R.id.whitenoisebutton);
        whiteNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    whiteNoiseMP.start();
                } else {
                    // The toggle is disabled
                    whiteNoiseMP.pause();
                }
            }
        });
        ToggleButton brownNoiseToggle = (ToggleButton) findViewById(R.id.brownnoisebutton);
        brownNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    brownNoiseMP.start();
                } else {
                    // The toggle is disabled
                    brownNoiseMP.pause();
                }
            }
        });
        ToggleButton pinkNoiseToggle = (ToggleButton) findViewById(R.id.pinknoisebutton);
        pinkNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    pinkNoiseMP.start();
                } else {
                    // The toggle is disabled
                    pinkNoiseMP.pause();
                }
            }
        });

    }
    //End of sound controller initializations

    //Start of control volume with sliders//
    private void initializeVolumeController()
    {
        try{
            whiteVolumeSeekBar = (SeekBar) findViewById(R.id.whiteVolumeSeekBar);
            whiteVolumeSeekBar.setMax(50);
            whiteVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    whiteNoiseMP.setVolume(1-log1, 1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
            pinkVolumeSeekBar.setProgress(25);
        } catch (Exception e){

        }
        try{
            pinkVolumeSeekBar = (SeekBar) findViewById(R.id.pinkVolumeSeekBar);
            pinkVolumeSeekBar.setMax(50);
            pinkVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    pinkNoiseMP.setVolume(1-log1, 1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
            pinkVolumeSeekBar.setProgress(25);
        } catch (Exception e){

        }
        try{
            brownVolumeSeekBar = (SeekBar) findViewById(R.id.brownVolumeSeekBar);
            brownVolumeSeekBar.setMax(50);
            brownVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    brownNoiseMP.setVolume(1-log1, 1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
            brownVolumeSeekBar.setProgress(25);

        } catch (Exception e){

        }

        //end of volume controller

}}

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/numbsound"
    tools:context="com.vaughnx.vaugi.soundwall.MainActivity">

    <ToggleButton
        android:id="@+id/whitenoisebutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textOff="@string/whiteToggleButton"
        android:textOn="@string/whiteToggleButton"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="247dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="16dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <ToggleButton
        android:id="@+id/pinknoisebutton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button"
        android:textOff="@string/pinkToggleButton"
        android:textOn="@string/pinkToggleButton"
        tools:layout_editor_absoluteX="260dp"
        tools:layout_editor_absoluteY="247dp"
        android:layout_marginTop="48dp"
        android:layout_below="@+id/brownnoisebutton"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <ToggleButton
        android:id="@+id/brownnoisebutton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/whitenoisebutton"
        android:layout_marginTop="44dp"
        android:text="Button"
        android:textOff="@string/brownToggleButton"
        android:textOn="@string/brownToggleButton"
        tools:layout_editor_absoluteX="137dp"
        tools:layout_editor_absoluteY="247dp" />

    <SeekBar
        android:id="@+id/whiteVolumeSeekBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/pinknoisebutton"
        android:layout_marginTop="62dp" />
    <SeekBar
        android:id="@+id/brownVolumeSeekBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/whiteVolumeSeekBar"
        android:layout_marginTop="62dp" />
    <SeekBar
        android:id="@+id/pinkVolumeSeekBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/brownVolumeSeekBar"
        android:layout_marginTop="62dp" />

</RelativeLayout>

**************************************************************************
        LogCat Results:
07-09 17:05:52.621: E/AndroidRuntime(3147): FATAL EXCEPTION: main
07-09 17:05:52.621: E/AndroidRuntime(3147): Process: com.vaughnx.vaugi.soundwall, PID: 3147
07-09 17:05:52.621: E/AndroidRuntime(3147): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.vaughnx.vaugi.soundwall/com.vaughnx.vaugi.soundwall.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3135)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3418)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread.access$1100(ActivityThread.java:231)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.os.Handler.dispatchMessage(Handler.java:102)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.os.Looper.loop(Looper.java:148)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.app.ActivityThread.main(ActivityThread.java:7422)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at java.lang.reflect.Method.invoke(Native Method)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
07-09 17:05:52.621: E/AndroidRuntime(3147): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.content.ContextWrapper.getResources(ContextWrapper.java:92)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:81)
07-09 17:05:52.621: E/AndroidRuntime(3147):     at android.support.v7.app.AppCompatActivity.getResources(AppCompatActivity.java:549)

Body:
You should use MediaPlayer.setVolume instead of Audio Manager to control volume.

package com.vaughnx.vaugi.soundwall;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.ToggleButton;
import android.media.MediaPlayer;

public class MainActivity extends AppCompatActivity {

    private SeekBar whiteVolumeSeekBar;
    private SeekBar pinkVolumeSeekBar;
    private SeekBar brownVolumeSeekBar;
    private int maxVolume;
    private int curVOlume;
    private MediaPlayer whiteNoiseMP;
    private MediaPlayer brownNoiseMP;
    private MediaPlayer pinkNoiseMP;
    private ToggleButton whiteNoiseToggle;
    private ToggleButton brownNoiseToggle;
    private ToggleButton pinkNoiseToggle;

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

        //Sets up white, brown, and pink noise players. Uses toggle buttons to turn sound on
        //and off.
        whiteNoiseMP = MediaPlayer.create(MainActivity.this, R.raw.whitenoise);
        brownNoiseMP = MediaPlayer.create(MainActivity.this, R.raw.brownnoise);
        pinkNoiseMP = MediaPlayer.create(MainActivity.this, R.raw.pinknoise);
        whiteNoiseToggle = (ToggleButton) findViewById(R.id.whitenoisebutton);
        whiteNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    whiteNoiseMP.start();
                } else {
                    // The toggle is disabled
                    whiteNoiseMP.pause();
                }
            }
        });
        brownNoiseToggle = (ToggleButton) findViewById(R.id.brownnoisebutton);
        brownNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    brownNoiseMP.start();
                } else {
                    // The toggle is disabled
                    brownNoiseMP.pause();
                }
            }
        });
        pinkNoiseToggle = (ToggleButton) findViewById(R.id.pinknoisebutton);
        pinkNoiseToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    // The toggle is enabled
                    pinkNoiseMP.start();
                } else {
                    // The toggle is disabled
                    pinkNoiseMP.pause();
                }
            }
        });
       //End of sound controller initializations

       //Start of control volume with sliders//
       try{
           whiteVolumeSeekBar = (SeekBar) findViewById(R.id.whiteVolumeSeekBar);
           whiteVolumeSeekBar.setMax(50);
           whiteVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
               @Override
               public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                   float log1 = (float) (Math.log(50-progress)/Math.log(50));
                   whiteNoiseMP.setVolume(1-log1);
               }

               @Override
               public void onStartTrackingTouch(SeekBar seekBar) {

               }

               @Override
               public void onStopTrackingTouch(SeekBar seekBar) {

               }
           });
           pinkVolumeSeekBar.setProgress(25);
        } catch (Exception e){
            Log.e("Exception", e.getMessage());
        }
        try{
            pinkVolumeSeekBar = (SeekBar) findViewById(R.id.pinkVolumeSeekBar);
            pinkVolumeSeekBar.setMax(50);
            pinkVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    pinkNoiseMP.setVolume(1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
            pinkVolumeSeekBar.setProgress(25);
        } catch (Exception e){
            Log.e("Exception", e.getMessage());
        }
        try{
            brownVolumeSeekBar = (SeekBar) findViewById(R.id.brownVolumeSeekBar);
            brownVolumeSeekBar.setMax(50);
            brownVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    float log1 = (float) (Math.log(50-progress)/Math.log(50));
                    brownNoiseMP.setVolume(1-log1);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
           brownVolumeSeekBar.setProgress(25);

        } catch (Exception e){
            Log.e("Exception", e.getMessage());
        }
        //end of volume controller
    }
}

I have set 50 as the maximum volume and starting volume to be 50% i.e. 25.


问:
Slide show shows 2 pictures at a time
I try to make slide show with a transition through transparency, but the problem is when I have 4 images and 4th image changing with 1st, 1st image probably somehow show early and push 3rd image down. Another problem is when 3rd image changing with 4th, 4th image does not create some free space under him like all others (In case of bad resolution it may not be visible). This problem occurs also when I add more than 4 images and always only on the last picture. Any suggestions how to fix it and what I do wrong?

var slides = document.querySelectorAll('.imageSlide');
var currentSlide = 0;
var slideInterval = setInterval(nextSlide, 2000);

function nextSlide() {
  slides[currentSlide].className = "imageSlide";
  currentSlide = (currentSlide + 1) % slides.length;
  slides[currentSlide].className = "imageSlide showing";
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  box-sizing: border-box
}

body {
  font-family: Verdana, sans-serif;
  margin: 0;
  padding: 0;
}

.imageSlide-container {
  position: relative;
  margin: auto;
}

.imageSlide {
  position: absolute;
  width: 100%;
  height: auto;
  opacity: 0;
  z-index: 1;
  -webkit-transition: opacity 1.0s;
  -moz-transition: opacity 1.0s;
  -o-transition: opacity 1.0s;
  transition: opacity 1.0s;
}

.showing {
  position: static;
  opacity: 1;
  z-index: 2;
  transform: translateZ(0);
}

.prev,
.next {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: auto;
  cursor: pointer;
  margin-top: -22px;
  padding: 15px;
  color: red;
  font-size: 18px;
  font-weight: bold;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
}

.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

.prev:hover,
.next:hover {
  background-color: rgba(0, 0, 0, 0.8)
}

@media only screen and (max-width: 300px) {
  .prev,
  .next,
  .text {
    font-size: 11px
  }
}</code>```

  ❮
  ❯

test text
test text
test text```

答:
The problem is that you use position: absolute and position: static for one item.

.container {
  position: relative;
}

.item {
  position: absolute;
}

.showing {
  position: static;
  border: 1px solid;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
  <div class="item showing">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
  <div class="item">4</div>
</div></code>```

That's the reason why you get this weird behaviour. Every item must be on top.

```<code>.item {
    position: absolute;
    top: 0;
}
</code>```

Respectively

```<code>.imageSlide {
    position: absolute;
    top: 0;
    ...
}
</code>```

Title: Slide show shows 2 pictures at a time

Body:
I try to make slide show with a transition through transparency, but the problem is when I have 4 images and 4th image changing with 1st, 1st image probably somehow show early and push 3rd image down. Another problem is when 3rd image changing with 4th, 4th image does not create some free space under him like all others (In case of bad resolution it may not be visible). This problem occurs also when I add more than 4 images and always only on the last picture. Any suggestions how to fix it and what I do wrong?

var slides = document.querySelectorAll('.imageSlide');
var currentSlide = 0;
var slideInterval = setInterval(nextSlide, 2000);

function nextSlide() {
  slides[currentSlide].className = "imageSlide";
  currentSlide = (currentSlide + 1) % slides.length;
  slides[currentSlide].className = "imageSlide showing";
}

* {
  box-sizing: border-box
}

body {
  font-family: Verdana, sans-serif;
  margin: 0;
  padding: 0;
}

.imageSlide-container {
  position: relative;
  margin: auto;
}

.imageSlide {
  position: absolute;
  width: 100%;
  height: auto;
  opacity: 0;
  z-index: 1;
  -webkit-transition: opacity 1.0s;
  -moz-transition: opacity 1.0s;
  -o-transition: opacity 1.0s;
  transition: opacity 1.0s;
}

.showing {
  position: static;
  opacity: 1;
  z-index: 2;
  transform: translateZ(0);
}

.prev,
.next {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: auto;
  cursor: pointer;
  margin-top: -22px;
  padding: 15px;
  color: red;
  font-size: 18px;
  font-weight: bold;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
}

.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

.prev:hover,
.next:hover {
  background-color: rgba(0, 0, 0, 0.8)
}

@media only screen and (max-width: 300px) {
  .prev,
  .next,
  .text {
    font-size: 11px
  }
}

  ❮
  ❯

test text
test text
test text

Body:
The problem is that you use position: absolute and position: static for one item.

.container {
  position: relative;
}

.item {
  position: absolute;
}

.showing {
  position: static;
  border: 1px solid;
}

<div class="container">
  <div class="item showing">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
  <div class="item">4</div>
</div>

That's the reason why you get this weird behaviour. Every item must be on top.

.item {
    position: absolute;
    top: 0;
}

Respectively

.imageSlide {
    position: absolute;
    top: 0;
    ...
}


问:
How to query historical table size of database in Redshift to determine database size growth
I want to project forward the size of my Amazon Redshift tables because I'm planning to expand my Redshift cluster size.

I know how to query the table size for today (see query below) but how can I measure the growth of my table sizes over time without make an ETL job to make snapshot day-by-day table size?

```<code>-- Capture table sizes
select
    trim(pgdb.datname) as Database,
    trim(pgn.nspname) as Schema,
    trim(a.name) as Table,
    b.mbytes,
    a.rows
from (
    select db_id, id, name, sum(rows) as rows
    from stv_tbl_perm a
    group by db_id, id, name
) as a
join pg_class as pgc on pgc.oid = a.id
join pg_namespace as pgn on pgn.oid = pgc.relnamespace
join pg_database as pgdb on pgdb.oid = a.db_id
join (
    select tbl, count(*) as mbytes
    from stv_blocklist
    group by tbl
) b on a.id = b.tbl
order by mbytes desc, a.db_id, a.name;
</code>```

答:
There is no historical table size information retained by Amazon Redshift. You would need to run a query on a regular basis, such as the one in your question.

You could wrap the query in an INSERT statement and run it on a weekly basis, inserting the results into a table. This way, you'll have historical table size information for each table each week that you can use to predict future growth.

It would be worth doing a VACUUM prior to such measurements, to remove deleted rows from storage.

Body:
I want to project forward the size of my Amazon Redshift tables because I'm planning to expand my Redshift cluster size.

I know how to query the table size for today (see query below) but how can I measure the growth of my table sizes over time without make an ETL job to make snapshot day-by-day table size?

-- Capture table sizes
select
    trim(pgdb.datname) as Database,
    trim(pgn.nspname) as Schema,
    trim(a.name) as Table,
    b.mbytes,
    a.rows
from (
    select db_id, id, name, sum(rows) as rows
    from stv_tbl_perm a
    group by db_id, id, name
) as a
join pg_class as pgc on pgc.oid = a.id
join pg_namespace as pgn on pgn.oid = pgc.relnamespace
join pg_database as pgdb on pgdb.oid = a.db_id
join (
    select tbl, count(*) as mbytes
    from stv_blocklist
    group by tbl
) b on a.id = b.tbl
order by mbytes desc, a.db_id, a.name;


问:
Is it possible to take input from a file in NotesSQL
For example I have to run a query to fetch data for a list of part numbers.

The list is very big say 1000. So I do not want to give all the part numbers in the query instead want to take it from a file say .txt or .xls

Is It possible with Notes SQL?

答:
Notes SQL is just a driver that maps SQL queries onto Notes and Domino databases, views, and documents. It's up to you to construct the queries and run them somehow.

There's nothing in the syntax of NotesSQL that can take input from files.

If the program that you are using to generate and run the Notes SQL queries has the ability to read files and use the contents of a file to modify the query before giving it to NotesSQL, then the answer is yes, it's possible to do what you want with Notes SQL.


问:
Swift: Have SearchBar search through both sections and not combine them
Using Swift 3, the app is a blog reader reading from a MYSQL database using PHP and JSON.

Currently my SearchBar is not doing what I want, I have it searching in my mainArray (section 1) with the 'All' scope. As it's being filtered the objects that are being filtered are moved to filteredArray. I did this in the mean time because I can not figure out how to make it do what I want.

What it's supposed to do is this, when the user is searching for an object, I want the object to show up wether it's in mainArray or followedArray and not move it to a different array so its doesn't combine. Basically filter the tableview and not remove any sections or combine any objects as it will confuse the user by not knowing which section the object was in, and of course make sure the scope bar is working properly.

Learning how to implement a search bar so you can see my trouble when I try to take it a level further. Thank you!

SearchBar & Scope code

```<code>let searchController = UISearchController(searchResultsController: nil)

override func viewDidLoad() {
    // Search Bar
    searchController.searchResultsUpdater = self
    searchController.dimsBackgroundDuringPresentation = false
    definesPresentationContext = true
    myTableView.tableHeaderView = searchController.searchBar
    searchController.searchBar.backgroundColor = UIColor.white
    searchController.searchBar.barTintColor = UIColor.white

    // Scope Bar
    searchController.searchBar.scopeButtonTitles = ["All", "Released", "Unreleased", "Free"]
    searchController.searchBar.delegate = self
}

// Title for Header
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {

    if !(searchController.isActive && searchController.searchBar.text != "") {

        if section == 0 {
            return "Followed Blogs"
        }
        else {
            return "All Blogs"
        }
    }
    return "Filtered Blogs"
}

// Number of Rows in Section
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    if !(searchController.isActive && searchController.searchBar.text != "") {

        if section == 0 {

            return followedArray.count
        }
        else if (section == 1) {

            return mainArray.count
        }
    }
    return filteredArray.count
}

// Number of Sections
func numberOfSections(in tableView: UITableView) -> Int {

    if !(searchController.isActive && searchController.searchBar.text != "") {

        return 2
    }
    return 1
}

// CellForRowAt indexPath
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let CellIdentifier = "Cell"
    var cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier) as! CustomCell

    if cell != cell {
        cell = CustomCell(style: UITableViewCellStyle.default, reuseIdentifier: CellIdentifier)
    }

    // Configuring the cell
    var blogObject: Blog

    if !(searchController.isActive && searchController.searchBar.text != "") {
        if indexPath.section == 0 {
            blogObject = followedArray[indexPath.row]
            cell.populateCell(blogObject, isFollowed: true, indexPath: indexPath, parentView: self)
        }
        else if indexPath.section == 1 {
            blogObject = mainArray[indexPath.row]
            cell.populateCell(blogObject, isFollowed: false, indexPath: indexPath, parentView: self)
        }
    }
    else {
        blogObject = filteredArray[indexPath.row]
        cell.populateCell(blogObject, isFollowed: false, indexPath: indexPath, parentView: self)
    }

    return cell
}

// SEARCH BAR: Filtering Content
func filterContentForSearchText(searchText: String, scope: String = "All") {

    filteredArray = mainArray.filter { Blog in

        let categoryMatch = (scope == "All") || (Blog.blogType == scope)

        return categoryMatch && (Blog.blogName.lowercased().contains(searchText.lowercased()))
    }
    myTableView.reloadData()
}

// SEARCH BAR: Updating Results
func updateSearchResults(for searchController: UISearchController) {

    filterContentForSearchText(searchText: searchController.searchBar.text!)
}

// SEARCH BAR: Scope
func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {

    filterContentForSearchText(searchText: searchBar.text!, scope: searchBar.scopeButtonTitles![selectedScope])
}

// SEARCH BAR: Updating Scope
func updateSearchResultsForSearchController(searchController: UISearchController) {

    let searchBar = searchController.searchBar
    let scope = searchBar.scopeButtonTitles![searchBar.selectedScopeButtonIndex]
    filterContentForSearchText(searchText: searchController.searchBar.text!, scope: scope)
}

// Deallocating Search Bar
deinit{
    if let superView = searchController.view.superview {
        superView.removeFromSuperview()
    }
}
</code>```

答:
Right now you create a single array (filteredArray) and assume you have 1 section when searching.

I would remove that assumption.

Inside your filterContentForSearchText method, create an array of arrays (where each inner array represents a section).

Then update all of your table view data source methods to work with that array of arrays to get the proper values.

First, update your declaration of filteredArray to be an array of arrays.

Now update your table view methods:

```<code>func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if !(searchController.isActive && searchController.searchBar.text != "") {
        if section == 0 {
            return followedArray.count
        } else {
            return mainArray.count
        }
    } else {
        return filteredArray[section].count
    }
}

// Number of Sections
func numberOfSections(in tableView: UITableView) -> Int {
    if !(searchController.isActive && searchController.searchBar.text != "") {
        return 2
    } else {
        return filteredArray.count
    }
}

// CellForRowAt indexPath
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let CellIdentifier = "Cell"
    var cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier) as! CustomCell

    if cell != cell {
        cell = CustomCell(style: UITableViewCellStyle.default, reuseIdentifier: CellIdentifier)
    }

    // Configuring the cell
    var blogObject: Blog

    if !(searchController.isActive && searchController.searchBar.text != "") {
        if indexPath.section == 0 {
            blogObject = followedArray[indexPath.row]
            cell.populateCell(blogObject, isFollowed: true, indexPath: indexPath, parentView: self)
        } else {
            blogObject = mainArray[indexPath.row]
            cell.populateCell(blogObject, isFollowed: false, indexPath: indexPath, parentView: self)
        }
    } else {
        blogObject = filteredArray[indexPath.section][indexPath.row]
        cell.populateCell(blogObject, isFollowed: false, indexPath: indexPath, parentView: self)
    }

    return cell
}
</code>```

And finally update the filterContentForSearchText method:

```<code>func filterContentForSearchText(searchText: String, scope: String = "All") {
    let filteredFollowed = followedArray.filter { Blog in
        let categoryMatch = (scope == "All") || (Blog.blogType == scope)

        return categoryMatch && (Blog.blogName.lowercased().contains(searchText.lowercased()))
    }

    let filteredMain = mainArray.filter { Blog in
        let categoryMatch = (scope == "All") || (Blog.blogType == scope)

        return categoryMatch && (Blog.blogName.lowercased().contains(searchText.lowercased()))
    }

    filteredArray = [ filteredFollowed, filteredMain ]

    myTableView.reloadData()
}
</code>```

Body:
Using Swift 3, the app is a blog reader reading from a MYSQL database using PHP and JSON.

Currently my SearchBar is not doing what I want, I have it searching in my mainArray (section 1) with the 'All' scope. As it's being filtered the objects that are being filtered are moved to filteredArray. I did this in the mean time because I can not figure out how to make it do what I want.

What it's supposed to do is this, when the user is searching for an object, I want the object to show up wether it's in mainArray or followedArray and not move it to a different array so its doesn't combine. Basically filter the tableview and not remove any sections or combine any objects as it will confuse the user by not knowing which section the object was in, and of course make sure the scope bar is working properly.

Learning how to implement a search bar so you can see my trouble when I try to take it a level further. Thank you!

SearchBar & Scope code

let searchController = UISearchController(searchResultsController: nil)

override func viewDidLoad() {
    // Search Bar
    searchController.searchResultsUpdater = self
    searchController.dimsBackgroundDuringPresentation = false
    definesPresentationContext = true
    myTableView.tableHeaderView = searchController.searchBar
    searchController.searchBar.backgroundColor = UIColor.white
    searchController.searchBar.barTintColor = UIColor.white

    // Scope Bar
    searchController.searchBar.scopeButtonTitles = ["All", "Released", "Unreleased", "Free"]
    searchController.searchBar.delegate = self
}

// Title for Header
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {

    if !(searchController.isActive && searchController.searchBar.text != "") {

        if section == 0 {
            return "Followed Blogs"
        }
        else {
            return "All Blogs"
        }
    }
    return "Filtered Blogs"
}

// Number of Rows in Section
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    if !(searchController.isActive && searchController.searchBar.text != "") {

        if section == 0 {

            return followedArray.count
        }
        else if (section == 1) {

            return mainArray.count
        }
    }
    return filteredArray.count
}

// Number of Sections
func numberOfSections(in tableView: UITableView) -> Int {

    if !(searchController.isActive && searchController.searchBar.text != "") {

        return 2
    }
    return 1
}

// CellForRowAt indexPath
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let CellIdentifier = "Cell"
    var cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier) as! CustomCell

    if cell != cell {
        cell = CustomCell(style: UITableViewCellStyle.default, reuseIdentifier: CellIdentifier)
    }

    // Configuring the cell
    var blogObject: Blog

    if !(searchController.isActive && searchController.searchBar.text != "") {
        if indexPath.section == 0 {
            blogObject = followedArray[indexPath.row]
            cell.populateCell(blogObject, isFollowed: true, indexPath: indexPath, parentView: self)
        }
        else if indexPath.section == 1 {
            blogObject = mainArray[indexPath.row]
            cell.populateCell(blogObject, isFollowed: false, indexPath: indexPath, parentView: self)
        }
    }
    else {
        blogObject = filteredArray[indexPath.row]
        cell.populateCell(blogObject, isFollowed: false, indexPath: indexPath, parentView: self)
    }

    return cell
}

// SEARCH BAR: Filtering Content
func filterContentForSearchText(searchText: String, scope: String = "All") {

    filteredArray = mainArray.filter { Blog in

        let categoryMatch = (scope == "All") || (Blog.blogType == scope)

        return categoryMatch && (Blog.blogName.lowercased().contains(searchText.lowercased()))
    }
    myTableView.reloadData()
}

// SEARCH BAR: Updating Results
func updateSearchResults(for searchController: UISearchController) {

    filterContentForSearchText(searchText: searchController.searchBar.text!)
}

// SEARCH BAR: Scope
func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {

    filterContentForSearchText(searchText: searchBar.text!, scope: searchBar.scopeButtonTitles![selectedScope])
}

// SEARCH BAR: Updating Scope
func updateSearchResultsForSearchController(searchController: UISearchController) {

    let searchBar = searchController.searchBar
    let scope = searchBar.scopeButtonTitles![searchBar.selectedScopeButtonIndex]
    filterContentForSearchText(searchText: searchController.searchBar.text!, scope: scope)
}

// Deallocating Search Bar
deinit{
    if let superView = searchController.view.superview {
        superView.removeFromSuperview()
    }
}

Body:
Right now you create a single array (filteredArray) and assume you have 1 section when searching.

I would remove that assumption.

Inside your filterContentForSearchText method, create an array of arrays (where each inner array represents a section).

Then update all of your table view data source methods to work with that array of arrays to get the proper values.

First, update your declaration of filteredArray to be an array of arrays.

Now update your table view methods:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if !(searchController.isActive && searchController.searchBar.text != "") {
        if section == 0 {
            return followedArray.count
        } else {
            return mainArray.count
        }
    } else {
        return filteredArray[section].count
    }
}

// Number of Sections
func numberOfSections(in tableView: UITableView) -> Int {
    if !(searchController.isActive && searchController.searchBar.text != "") {
        return 2
    } else {
        return filteredArray.count
    }
}

// CellForRowAt indexPath
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let CellIdentifier = "Cell"
    var cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier) as! CustomCell

    if cell != cell {
        cell = CustomCell(style: UITableViewCellStyle.default, reuseIdentifier: CellIdentifier)
    }

    // Configuring the cell
    var blogObject: Blog

    if !(searchController.isActive && searchController.searchBar.text != "") {
        if indexPath.section == 0 {
            blogObject = followedArray[indexPath.row]
            cell.populateCell(blogObject, isFollowed: true, indexPath: indexPath, parentView: self)
        } else {
            blogObject = mainArray[indexPath.row]
            cell.populateCell(blogObject, isFollowed: false, indexPath: indexPath, parentView: self)
        }
    } else {
        blogObject = filteredArray[indexPath.section][indexPath.row]
        cell.populateCell(blogObject, isFollowed: false, indexPath: indexPath, parentView: self)
    }

    return cell
}

And finally update the filterContentForSearchText method:

func filterContentForSearchText(searchText: String, scope: String = "All") {
    let filteredFollowed = followedArray.filter { Blog in
        let categoryMatch = (scope == "All") || (Blog.blogType == scope)

        return categoryMatch && (Blog.blogName.lowercased().contains(searchText.lowercased()))
    }

    let filteredMain = mainArray.filter { Blog in
        let categoryMatch = (scope == "All") || (Blog.blogType == scope)

        return categoryMatch && (Blog.blogName.lowercased().contains(searchText.lowercased()))
    }

    filteredArray = [ filteredFollowed, filteredMain ]

    myTableView.reloadData()
}


问:
Realign buttons

JavaScript

```<code>$(function(){
  $('.select-another-button').each(function(){
    $(this).bind('click', function(e) {
      $(this).attr('disabled','true'); //disables the button
      $('#overlay').show(); //after disabling show the overlay for hover
      setTimeout(function(){
        $(this).attr('disabled','false'); //enables after 5mins
        $('#overlay').hide(); //hide the overlay
      }, 300000);
      e.preventDefault();
      fileBrowser(this);
      return false;
    });
  });
});

$("#overlay").hover(function(){
    $('#message').show();
},function(){
    $('#message').hide();
});
</code>```

HTML

```<code><div class="card-title">
    <div class="title-actions">

        <a href="#" id="id_select_request_document" title="Select file(s)" class="btn btn-icon select-button"
                data-turbolinks="false" data-save-label="Ok" data-close-label="Cancel" data-copy-to="9"
                data-reload="true" data-url="/documents/select/8/">
            <i class="material-icons">folder</i>
        </a>

        <a href="#" id="id_upload_request_document" title="Upload file(s)" class="btn btn-icon upload-button"
                data-turbolinks="false" data-url="/documents/upload/9/"
                data-complete-post="/requests/validate-requirements/2/" data-max-uploader-connections="1"
                style="position: relative; overflow: visible; direction: ltr;">
            <i class="material-icons">cloud_upload</i>
            <i style="overflow: hidden;display: block;position: absolute;top: 0;left: 0;width: 35px;height: 35px;"><input
                        multiple="multiple" type="file" name="file"
                        style="position: absolute; right: 0px; top: 0px; font-family: Arial; font-size: 118px; margin: 0px; padding: 0px; cursor: pointer; opacity: 0;"></i>
        </a>
        <div class="wrapper">
            <div id="overlay"></div>
            <a href="#" title="Send email - rejected file(s)" class="btn btn-icon select-another-button"
                    data-url="/messaging/send/2/">
                <i class="material-icons">assignment_late</i>
                <div class="alert alert-success" id="send-message" style="display: none;">
                    <p>
                        The message was sent to the client. Please wait 5 minutes <br> before sending the message again.
                    </p>
                </div>
            </a>
        </div>

        <a href="/admin/filer/folder/9/list/" class="btn-icon"><i class="material-icons">settings</i></a>

    </div>
    <h5>Request documents</h5>
</div>
</code>```

 CSS

```<code>.title-actions {
    float: right;
    height: 50px;
    margin-top: 13px;
}

.title-actions a {
    transition: background 0.3s ease;
}

.title-actions a.btn {
    padding: 2px 14px;
    line-height: 26px;
    max-height: 28px;
    position: relative;
    top: -1px;
    margin-left: 8px;
}

.title-actions a:hover {
    background: #4382B5;
}

.title-actions span {
    color: #444;
    background: #E6E6E6;
    padding: 6px 10px;
    border-radius: 3px;
    float: none;
    position: relative;
    margin-left: 6px;
}

.title-actions .btn {
    padding: 2px 14px;
    line-height: 26px;
    max-height: 28px;
    position: relative;
    top: -1px;
    margin-left: 8px;
}

.title-actions .btn-icon {
    background: transparent;
    position: relative;
    color: #3E5366;
    text-align: center;
    display: inline-block;
    padding: 0 !important;
    transition: color 0.3s ease;
    box-shadow: none !important;
    margin-top: -16px;
    margin-left: 6px;
}

.title-actions .btn-icon i {
    font-size: 35px;
    line-height: 20px;
    position: relative;
    top: 12px;
}

.title-actions .btn-icon:hover {
    color: #4382B5;
    background: transparent;
}

.title-actions .badge .material-icons {
    font-size: 1.2em;
    line-height: 0;
    position: relative;
    top: 4px;
}
</code>```

In the html block, I added the

```<code><div class="wrapper">
            <div id="overlay"></div>
            <a href="#"
               title="{% trans "Send email - rejected file(s)" %}"
               class="btn btn-icon select-another-button"
               data-url="{% url "messaging:send" request_id=object.pk %}">
                <i class="material-icons">assignment_late</i>
                <div class='alert alert-success' id='send-message' style="display: none;">
                    <p>
                    The message was sent to the client. Please wait 5 minutes <br> before sending the message again.
                    </p>
                </div>
            </a>
        </div>
</code>```

In fact, I didn't add everything. I just did add the first two div tags, and I got a little issue with the different button from this code. It changed the old line of  to the new line of , but I don't even know how to fix it. How could I modify my code to bring back two the old line of buttons? I think I could style with css, but I can't say how because I don't have a lot of experience with it.

答:
.wrapper is a block element, so it won't stay beside it's siblings. All of those siblings have .btn-icon which sets display: inline-block. You could either add .btn-icon to the .wrapper element so it will display inline-block (although then it will inherit the rest of the .btn-icon styles), or just set .wrapper to display: inline-block; (what I did)

.title-actions {
  float: right;
  height: 50px;
  margin-top: 13px;
}

.title-actions a {
  transition: background 0.3s ease;
}

.title-actions a.btn {
  padding: 2px 14px;
  line-height: 26px;
  max-height: 28px;
  position: relative;
  top: -1px;
  margin-left: 8px;
}

.title-actions a:hover {
  background: #4382B5;
}

.title-actions span {
  color: #444;
  background: #E6E6E6;
  padding: 6px 10px;
  border-radius: 3px;
  float: none;
  position: relative;
  margin-left: 6px;
}

.title-actions .btn {
  padding: 2px 14px;
  line-height: 26px;
  max-height: 28px;
  position: relative;
  top: -1px;
  margin-left: 8px;
}

.title-actions .btn-icon {
  background: transparent;
  position: relative;
  color: #3E5366;
  text-align: center;
  display: inline-block;
  padding: 0 !important;
  transition: color 0.3s ease;
  box-shadow: none !important;
  margin-top: -16px;
  margin-left: 6px;
}

.title-actions .btn-icon i {
  font-size: 35px;
  line-height: 20px;
  position: relative;
  top: 12px;
}

.title-actions .btn-icon:hover {
  color: #4382B5;
  background: transparent;
}

.title-actions .badge .material-icons {
  font-size: 1.2em;
  line-height: 0;
  position: relative;
  top: 4px;
}

.wrapper {
  display: inline-block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="card-title">
  <div class="title-actions">

      <i class="material-icons">folder</i>

      <i class="material-icons">cloud_upload</i>
      <i style="overflow: hidden;display: block;position: absolute;top: 0;left: 0;width: 35px;height: 35px;"><input
                        multiple="multiple" type="file" name="file"
                        style="position: absolute; right: 0px; top: 0px; font-family: Arial; font-size: 118px; margin: 0px; padding: 0px; cursor: pointer; opacity: 0;"></i>

    <div class="wrapper">
      <div id="overlay"></div>

        <i class="material-icons">assignment_late</i>
        <div class="alert alert-success" id="send-message" style="display: none;">
          <p>
            The message was sent to the client. Please wait 5 minutes <br> before sending the message again.
          </p>
        </div>

    </div>

    <i class="material-icons">settings</i>

  </div>
  <h5>Request documents</h5>
</div></code>```

Title: Realign buttons

Body:
JavaScript

$(function(){
  $('.select-another-button').each(function(){
    $(this).bind('click', function(e) {
      $(this).attr('disabled','true'); //disables the button
      $('#overlay').show(); //after disabling show the overlay for hover
      setTimeout(function(){
        $(this).attr('disabled','false'); //enables after 5mins
        $('#overlay').hide(); //hide the overlay
      }, 300000);
      e.preventDefault();
      fileBrowser(this);
      return false;
    });
  });
});

$("#overlay").hover(function(){
    $('#message').show();
},function(){
    $('#message').hide();
});

HTML

            folder

            cloud_upload
            <input
                        multiple="multiple" type="file" name="file"
                        style="position: absolute; right: 0px; top: 0px; font-family: Arial; font-size: 118px; margin: 0px; padding: 0px; cursor: pointer; opacity: 0;">

                assignment_late

                        The message was sent to the client. Please wait 5 minutes
 before sending the message again.

        settings

Request documents

 CSS

.title-actions {
    float: right;
    height: 50px;
    margin-top: 13px;
}

.title-actions a {
    transition: background 0.3s ease;
}

.title-actions a.btn {
    padding: 2px 14px;
    line-height: 26px;
    max-height: 28px;
    position: relative;
    top: -1px;
    margin-left: 8px;
}

.title-actions a:hover {
    background: #4382B5;
}

.title-actions span {
    color: #444;
    background: #E6E6E6;
    padding: 6px 10px;
    border-radius: 3px;
    float: none;
    position: relative;
    margin-left: 6px;
}

.title-actions .btn {
    padding: 2px 14px;
    line-height: 26px;
    max-height: 28px;
    position: relative;
    top: -1px;
    margin-left: 8px;
}

.title-actions .btn-icon {
    background: transparent;
    position: relative;
    color: #3E5366;
    text-align: center;
    display: inline-block;
    padding: 0 !important;
    transition: color 0.3s ease;
    box-shadow: none !important;
    margin-top: -16px;
    margin-left: 6px;
}

.title-actions .btn-icon i {
    font-size: 35px;
    line-height: 20px;
    position: relative;
    top: 12px;
}

.title-actions .btn-icon:hover {
    color: #4382B5;
    background: transparent;
}

.title-actions .badge .material-icons {
    font-size: 1.2em;
    line-height: 0;
    position: relative;
    top: 4px;
}

In the html block, I added the

                assignment_late

                    The message was sent to the client. Please wait 5 minutes
 before sending the message again.

In fact, I didn't add everything. I just did add the first two div tags, and I got a little issue with the different button from this code. It changed the old line of  to the new line of , but I don't even know how to fix it. How could I modify my code to bring back two the old line of buttons? I think I could style with css, but I can't say how because I don't have a lot of experience with it.

Body:
.wrapper is a block element, so it won't stay beside it's siblings. All of those siblings have .btn-icon which sets display: inline-block. You could either add .btn-icon to the .wrapper element so it will display inline-block (although then it will inherit the rest of the .btn-icon styles), or just set .wrapper to display: inline-block; (what I did)

.title-actions {
  float: right;
  height: 50px;
  margin-top: 13px;
}

.title-actions a {
  transition: background 0.3s ease;
}

.title-actions a.btn {
  padding: 2px 14px;
  line-height: 26px;
  max-height: 28px;
  position: relative;
  top: -1px;
  margin-left: 8px;
}

.title-actions a:hover {
  background: #4382B5;
}

.title-actions span {
  color: #444;
  background: #E6E6E6;
  padding: 6px 10px;
  border-radius: 3px;
  float: none;
  position: relative;
  margin-left: 6px;
}

.title-actions .btn {
  padding: 2px 14px;
  line-height: 26px;
  max-height: 28px;
  position: relative;
  top: -1px;
  margin-left: 8px;
}

.title-actions .btn-icon {
  background: transparent;
  position: relative;
  color: #3E5366;
  text-align: center;
  display: inline-block;
  padding: 0 !important;
  transition: color 0.3s ease;
  box-shadow: none !important;
  margin-top: -16px;
  margin-left: 6px;
}

.title-actions .btn-icon i {
  font-size: 35px;
  line-height: 20px;
  position: relative;
  top: 12px;
}

.title-actions .btn-icon:hover {
  color: #4382B5;
  background: transparent;
}

.title-actions .badge .material-icons {
  font-size: 1.2em;
  line-height: 0;
  position: relative;
  top: 4px;
}

.wrapper {
  display: inline-block;
}

<div class="card-title">
  <div class="title-actions">

    <a href="#" id="id_select_request_document" title="Select file(s)" class="btn btn-icon select-button" data-turbolinks="false" data-save-label="Ok" data-close-label="Cancel" data-copy-to="9" data-reload="true" data-url="/documents/select/8/">
      <i class="material-icons">folder</i>
    </a>

    <a href="#" id="id_upload_request_document" title="Upload file(s)" class="btn btn-icon upload-button" data-turbolinks="false" data-url="/documents/upload/9/" data-complete-post="/requests/validate-requirements/2/" data-max-uploader-connections="1" style="position: relative; overflow: visible; direction: ltr;">
      <i class="material-icons">cloud_upload</i>
      <i style="overflow: hidden;display: block;position: absolute;top: 0;left: 0;width: 35px;height: 35px;"><input
                        multiple="multiple" type="file" name="file"
                        style="position: absolute; right: 0px; top: 0px; font-family: Arial; font-size: 118px; margin: 0px; padding: 0px; cursor: pointer; opacity: 0;"></i>
    </a>
    <div class="wrapper">
      <div id="overlay"></div>
      <a href="#" title="Send email - rejected file(s)" class="btn btn-icon select-another-button" data-url="/messaging/send/2/">
        <i class="material-icons">assignment_late</i>
        <div class="alert alert-success" id="send-message" style="display: none;">
          <p>
            The message was sent to the client. Please wait 5 minutes <br> before sending the message again.
          </p>
        </div>
      </a>
    </div>

    <a href="/admin/filer/folder/9/list/" class="btn-icon"><i class="material-icons">settings</i></a>

  </div>
  <h5>Request documents</h5>
</div>


问:
simulating an onClick method with a parameter using Enzyme in React
I'm trying to simulate an onClick method in my unit tests using Enzyme for React. I've found many guides to simulating an onClick that takes some event e, such as:

```<code>handleClick(e) {
    // Does something
}

....
<MyComponent
onClick = {handleClick}
></MyComponent>
</code>```

However I want to be able to simulate my onClick which does not take the event as a parameter but takes something else instead, ie:

```<code>onClick = {() => handleClick(myParam)}
</code>```

I've tried using .simulate('click', [myParam]); but it did not pass the parameter as I expected.

How would I go about simulating a click that sends a specific parameter to the handler?

答:
according to the documentaton it states that:

.simulate(event[, mock]) => Self Simulate events

Arguments

event (String): The event name to be simulated mock (Object
  [optional]): A mock event object that will be merged with the
  event object passed to the handlers.

so you need to fix your code and pass an object:

```<code>.simulate('click', {myParam});
</code>```

You can also take a look at the implementaion and see how it is passed to the event handler here:

```<code>simulate(event, ...args) {
    const handler = this.prop(propFromEvent(event));
    if (handler) {
      withSetStateAllowed(() => {
        // TODO(lmr): create/use synthetic events
        // TODO(lmr): emulate React's event propagation
        performBatchedUpdates(this, () => {
          handler(...args);
        });
        this.root.update();
      });
    }
    return this;
  }
</code>```

Body:
I'm trying to simulate an onClick method in my unit tests using Enzyme for React. I've found many guides to simulating an onClick that takes some event e, such as:

handleClick(e) {
    // Does something
}

....
<MyComponent
onClick = {handleClick}
></MyComponent>

However I want to be able to simulate my onClick which does not take the event as a parameter but takes something else instead, ie:

onClick = {() => handleClick(myParam)}

I've tried using .simulate('click', [myParam]); but it did not pass the parameter as I expected.

How would I go about simulating a click that sends a specific parameter to the handler?

Body:
according to the documentaton it states that:

.simulate(event[, mock]) => Self Simulate events

Arguments

event (String): The event name to be simulated mock (Object
  [optional]): A mock event object that will be merged with the
  event object passed to the handlers.

so you need to fix your code and pass an object:

.simulate('click', {myParam});

You can also take a look at the implementaion and see how it is passed to the event handler here:

simulate(event, ...args) {
    const handler = this.prop(propFromEvent(event));
    if (handler) {
      withSetStateAllowed(() => {
        // TODO(lmr): create/use synthetic events
        // TODO(lmr): emulate React's event propagation
        performBatchedUpdates(this, () => {
          handler(...args);
        });
        this.root.update();
      });
    }
    return this;
  }


问:
Chain/transform method calls with ByteBuddy
Using ByteBuddy, can I implement one instance method by calling another and transforming the result?

For instance (toy example):

```<code>public abstract class Foo {
  public String bar() {
    return "bar";
  }

  public abstract int baz();
}
</code>```

Given the above, can I implement baz such that it calls bar() and returns the length of the returned string? I.e., as if it were:

```<code>public int baz() {
  return bar().length();
}
</code>```

Naively, I tried the following:

```<code>Method bar = Foo.class.getDeclaredMethod("bar");
Method baz = Foo.class.getDeclaredMethod("baz");

Method length = String.class.getDeclaredMethod("length");

Foo foo = new ByteBuddy()
  .subclass(Foo.class)
  .method(ElementMatchers.is(baz))
  .intercept(
    MethodCall.invoke(bar)                 // call bar()...
      .andThen(MethodCall.invoke(length))  // ... .length()?
  ).make()
  .load(Foo.class.getClassLoader())
  .getLoaded()
  .newInstance();

System.out.println(foo.baz());
</code>```

However, it looks like I was wrong in thinking andThen() is invoked on the return value of the first invocation; it looks like it's invoked on the generated instance.

```<code>Exception in thread "main" java.lang.IllegalStateException:
  Cannot invoke public int java.lang.String.length() on class Foo$ByteBuddy$sVgjXXp9
    at net.bytebuddy.implementation.MethodCall$MethodInvoker$ForContextualInvocation
    .invoke(MethodCall.java:1667)
</code>```

I also tried an interceptor:

```<code>class BazInterceptor {
  public static int barLength(@This Foo foo) {
    String bar = foo.bar();
    return bar.length();
  }
}
</code>```

with:

```<code>Foo foo = new ByteBuddy()
  .subclass(Foo.class)
  .method(ElementMatchers.is(baz))
  .intercept(MethodDelegation.to(new BazInterceptor()))
  // ...etc.
</code>```

This ran, but produced the nonsensical result 870698190, and setting breakpoints and/or adding print statements in barLength() suggested it's never getting called; so clearly I'm not understanding interceptors or @This properly, either.

How can I get ByteBuddy to invoke one method and then invoke another on its return value?

Per k5_'s answer: BazInterceptor works if either:

we delegate to new BazInterceptor(), as above, but make barLength() an instance method, or:

we leave barLength() a class method, but delegate to BazInterceptor.class instead of to an instance.

I suspect the 870698190 was delegating to hashCode() of the BazInterceptor instance, though I didn't actually check.

答:
There is not currently a good way in Byte Buddy but this would be an easy feature to add. You can track the progress on GitHub. I will add it once I find some time.

If you want to implement such chained calls today, you can implement them in Java code and inline this code using the Advice component. Alternatively, you can write the byte code more explicitly by creating your own ByteCodeAppender based on MethodInvocation instances where you have to load the arguments manually however.

Body:
Using ByteBuddy, can I implement one instance method by calling another and transforming the result?

For instance (toy example):

public abstract class Foo {
  public String bar() {
    return "bar";
  }

  public abstract int baz();
}

Given the above, can I implement baz such that it calls bar() and returns the length of the returned string? I.e., as if it were:

public int baz() {
  return bar().length();
}

Naively, I tried the following:

Method bar = Foo.class.getDeclaredMethod("bar");
Method baz = Foo.class.getDeclaredMethod("baz");

Method length = String.class.getDeclaredMethod("length");

Foo foo = new ByteBuddy()
  .subclass(Foo.class)
  .method(ElementMatchers.is(baz))
  .intercept(
    MethodCall.invoke(bar)                 // call bar()...
      .andThen(MethodCall.invoke(length))  // ... .length()?
  ).make()
  .load(Foo.class.getClassLoader())
  .getLoaded()
  .newInstance();

System.out.println(foo.baz());

However, it looks like I was wrong in thinking andThen() is invoked on the return value of the first invocation; it looks like it's invoked on the generated instance.

Exception in thread "main" java.lang.IllegalStateException:
  Cannot invoke public int java.lang.String.length() on class Foo$ByteBuddy$sVgjXXp9
    at net.bytebuddy.implementation.MethodCall$MethodInvoker$ForContextualInvocation
    .invoke(MethodCall.java:1667)

I also tried an interceptor:

class BazInterceptor {
  public static int barLength(@This Foo foo) {
    String bar = foo.bar();
    return bar.length();
  }
}

with:

Foo foo = new ByteBuddy()
  .subclass(Foo.class)
  .method(ElementMatchers.is(baz))
  .intercept(MethodDelegation.to(new BazInterceptor()))
  // ...etc.

This ran, but produced the nonsensical result 870698190, and setting breakpoints and/or adding print statements in barLength() suggested it's never getting called; so clearly I'm not understanding interceptors or @This properly, either.

How can I get ByteBuddy to invoke one method and then invoke another on its return value?

Per k5_'s answer: BazInterceptor works if either:

we delegate to new BazInterceptor(), as above, but make barLength() an instance method, or:

we leave barLength() a class method, but delegate to BazInterceptor.class instead of to an instance.

I suspect the 870698190 was delegating to hashCode() of the BazInterceptor instance, though I didn't actually check.


问:
Java Socket know when request to gmail
I'm trying to create an application event (java) that would raise as soon as the machine gets connected to gmail onto the login page (https://www.google.com/accounts/), so I'm trying to build a Socket that would listen to this particular httprequest.
but I can only create a ServerSocket that listens to a port, to a specific ip adress (gmail login page can have so many different ips), but not to a host...
anyone got an idea ?
thank you !</p>

答: Best bet is inside the browser like Google's Mail Checker extension for Chrome.  Modify the extension to forward notifications to a localhost HTTP service which your Java application is hosting.</p>

Title: Java Socket know when request to gmail


问:
Onmouseover hover effect in SVG when hosted on Sharepoint
Could You help me that:
I have svg file:
FILE_SVG
 exported from Illustrator. Designated target for me is to add "hover" effect to it (it could be Zomm effect or color changing), but at the end file will be uploaded into company's intranet site which is running on Sharepoint. I've made it with CSS but internal template is cutting whole css part/code.

As i know it's possible to be done with Javascript...
Cany You help Me with that or provide an extewrnal link to start with (for amateurs ofc).
Thanks for any help...

答:
If your internal template is cutting your custom CSS, then it's likely going to cut your custom JavaScript as well. To my knowledge, you cannot embed hover effects into an SVG. But if you have access to the HTML and CSS or JavaScript then start with the following and experiment.

So you need to have three files.

Your SVG

Your HTML

Your CSS

in your SVG, it's going to have some weird code like:

```<code><svg version="1.1" xmlns="http://www.w3.org/2000/svg">
    <rect x="10" y="10" width="30" height="30" stroke="black" fill="transparent" stroke-width="5"/>
</svg>
</code>```

copy that into your HTML, and add an id to the svg:

```<code><div class="svg-wrapper">
    <svg id="mySVG" version="1.1" xmlns="http://www.w3.org/2000/svg">
        <rect x="10" y="10" width="30" height="30" stroke="black" fill="transparent" stroke-width="5"/>
    </svg>
</div>
</code>```

and something like this in your CSS:

```<code>#mySVG {
    width: 200px;
    height: 300px;
}
#mySVG:hover {
    width: 250px;
    height: 375px;
    fill: blue;
}
</code>```

if you do decide to do JavaScript instead of CSS, it will look something like:

```<code>document.getElementById("mySVG").addEventListener("mouseover", function () {
    event.target.style.fill="blue";
});
</code>```

Try this tutorial for using SVG: https://css-tricks.com/using-svg/

Try this tutorial for JavaScript hover events: https://www.w3schools.com/jsref/event_onmouseover.asp

Body:
If your internal template is cutting your custom CSS, then it's likely going to cut your custom JavaScript as well. To my knowledge, you cannot embed hover effects into an SVG. But if you have access to the HTML and CSS or JavaScript then start with the following and experiment.

So you need to have three files.

Your SVG

Your HTML

Your CSS

in your SVG, it's going to have some weird code like:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
    <rect x="10" y="10" width="30" height="30" stroke="black" fill="transparent" stroke-width="5"/>
</svg>

copy that into your HTML, and add an id to the svg:

<div class="svg-wrapper">
    <svg id="mySVG" version="1.1" xmlns="http://www.w3.org/2000/svg">
        <rect x="10" y="10" width="30" height="30" stroke="black" fill="transparent" stroke-width="5"/>
    </svg>
</div>

and something like this in your CSS:

#mySVG {
    width: 200px;
    height: 300px;
}
#mySVG:hover {
    width: 250px;
    height: 375px;
    fill: blue;
}

if you do decide to do JavaScript instead of CSS, it will look something like:

document.getElementById("mySVG").addEventListener("mouseover", function () {
    event.target.style.fill="blue";
});

Try this tutorial for using SVG: https://css-tricks.com/using-svg/

Try this tutorial for JavaScript hover events: https://www.w3schools.com/jsref/event_onmouseover.asp