text:
Q: Bluetooth Low Energy Peripheral mode I get some infomation that Android devices can now function in Bluetooth Low Energy (BLE) peripheral mode. Apps can use this capability to broadcast their presence to nearby devices from New in Android L.I'm making an application about this.
I was all configured(i.e. Settings for Bluetooth LE advertising and Advertisement data to be advertised in advertisement packet),When I started to startAdvertising,I found that I cannot listen to incoming connections.Who can help me?
I am a based on l-developer-preview-reference API(Added Package : android.bluetooth.le) to develop.

A: Any device with Android 4.3+ and a Bluetooth Low Energy chipset can detect beacons with this library. As of December 2014, this is approximately 40 percent of Android devices according to the Google Play Store and growing quickly.
To transmit as Peripheral Mode, Android 5.0+ and firmware supporting Bluetooth Low Energy Peripheral Mode are required. As of December 2014, only Nexus 6 and Nexus 9 devices are known to have firmware that supports Bluetooth Low Energy Peripheral Mode.


text:
Q: pandas: how to check for repeated values in one column and create a pairwise list of values from another column If I have a pandas dataframe like this:
Out[2]:
          A         B
0       200         5
2       100        11
4       200         3
6       300         6
8       300         9
10      200         4

I would like to be able to check for repeated values in column A (here the 200 & 300 are repeated) and then output a list of pairwise values from the values in column B which are on the same rows as the repeated values in column A, as follows:
[(5,3), (5,4), (3,4), (6,9)]
The order of the numbers in the tuples doesn't matter, i.e. (5,3) is as good as (3,5).
How would I do this please?

A: Timer set up for comparisons over a range of data sizes:
import itertools
import pandas as pd
import timeit

size = 100
setup = '''
import pandas as pd
from numpy.random import randint

size = %s

rv = pd.DataFrame(randint(0, high=9, size=(size,2)), columns=['A','B'])
rvg = rv.groupby('A')

def explicit(rvg):
    total = []
    for k, v in rvg.B:
        if len(v)> 1:
            total.append(list(itertools.combinations(v, 2)))
    return total

def listcomp(rvg):
    return [list(itertools.combinations(v[1:][0], 2)) for v in rvg.B if len(v[1:][0])>1]

'''
for size in (100, 500, 1000, 5000, 10000):
    print('%d records:'%size)
    print('Explicit loop: '),
    print(min(timeit.Timer('explicit(rvg)', setup=setup%size).repeat(7, 1000)))
    print('Implicit loop: '),
    print(min(timeit.Timer('listcomp(rvg)', setup=setup%size).repeat(7, 1000)))
'''
# to verify that they give the same results
print(explicit(rvg))
print('\n')
print(listcomp(rvg))
'''

implicit eventually is faster:

100 records:
Explicit loop:  1.04004383087
Implicit loop:  1.04814505577
500 records:
Explicit loop:  2.24344801903
Implicit loop:  2.28265190125
1000 records:
Explicit loop:  6.24254918098
Implicit loop:  6.72238111496
5000 records:
Explicit loop:  194.443366051
Implicit loop:  194.122081041
10000 records:
Explicit loop:  778.750103951
Implicit loop:  777.272083044

Comparing to dawg's generator version is left as an exercise for someone else.

A: Almost the same as cphlewis, but using Pandas:
>>> df
     A   B
0  200   5
1  100  11
2  200   3
3  300   6
4  300   9
5  200   4
>>> import itertools as it
>>> [list(it.combinations(t[1:][0], 2)) for t in df.groupby('A').B if len(t[1:][0])>1]
[[(5, 3), (5, 4), (3, 4)], [(6, 9)]]

Since it.combinations(t[1:][0], 2) and df.groupby('A').B are both iterators, you probably would want to write something like this to be more memory friendly:
def combo(df):
    for t in df.groupby('A').B:
        if len(t[1:][0])>1:
             yield it.combinations(t[1:][0], 2)

Which will yield each group of combinations in turn and not generate them all at once.

redpajama_set_name: RedPajamaStackExchange


text:
Q: User Control TextBox with Label How to make a user control which extend from TextBox ,and add a Label beside the textbox , not inside the textbox , the label must be beside it or on top of it.
BTW the user control must extend from TextBox .
For long time I have been searching for this problem and I cant find any anwser.

A: If I'm understanding you correctly, you want to place a Label next to a TextBox.  If you want to do this with code, it's as simple as:
int x, y;
x = y = 200;
TextBox tb = new TextBox();
tb.Width = 100;
tb.Left = x;
tb.Top = y;

Label lbl = new Label();
lbl.Width = 50;
//If you want it on the right of the TextBox
lbl.Left = tb.Right + 10;
//If you want it on the left of the TextBox
lbl.Right = tb.Left - 10;

You can obviously modify all of those values to your hearts desire.  Also, this seems kind of moot, because if you're going to be doing this in a WinForms Application, you can just drag and drop everything you want in to place.  You're obviously new to this...  Check out some YouTube on how to create WinForms Applications and get on MSDN...
https://www.youtube.com/watch?v=DdXrw6HUzCA
https://msdn.microsoft.com/en-us/dn308572.aspx


text:
Q: What am I doing wrong? Using the value of an Dependency Property in constructor I'm having some problems with the usage of an Dependency Property. I would like to use the value of the DP to initialize an object in the constructor.
The problem is that Month is always 0 (during construction time) which causes the wrong initialization of the ExpenseDetailPageDataModel. Right after the constructor finished his work the value of variable Month changes to correct value (in this case 11).
FinanceItemViewControl is a custom user control.
<common:FinanceItemViewControl Grid.Column="2" Month="11"/>

Month is a Dependency Property as shown in the code below:
public sealed partial class FinanceItemViewControl : UserControl
    {
...

        public static readonly DependencyProperty MonthProperty = DependencyProperty.Register
        (
             "Month",
             typeof(int),
             typeof(FinanceItemViewControl),
             new PropertyMetadata(
             0, new PropertyChangedCallback(MonthProperty_Changed))
        );

        public int Month
        {
            get { return (int)GetValue(MonthProperty); }
            set { SetValue(MonthProperty, value); }
        }
        #endregion

        private static void MonthProperty_Changed(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            //TODO: trigger data reload
        }

        public FinanceItemViewControl()
        {
            this.InitializeComponent();
...

            Debug.WriteLine("Constructor: " + Month);

            detailPageDataModel = new ExpenseDetailPageDataModel(Month);
...
        }

A: You can't put that logic in the constructor because, as you noticed, the Data Context hasn't loaded yet.  You could do one of two things:

*

*Put the logic inside the MonthProperty_Changed event.

*Use the control's Loaded event:

public FinanceItemViewControl()
{
    this.InitializeComponent();
    detailPageDataModel = new ExpenseDetailPageDataModel(Month);
    this.Loaded += UserControl_Loaded;
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
    Debug.WriteLine("Constructor: " + Month);
}


text:
Q: two arrays, find the missing numbers Given two arrays, first has 'n' numbers and the second one has 'n-m' numbers; the second array is not in the same order as the first. If there are several numbers with the same value, they end up in the order of the positions in the original array. Also, all the values from the second array are also found in the first array. I have to find the 'm' missing numbers in the order in which they appear in the first array.
input:
7 3
12 34 45 29 100 87 32
100 87 12 34

output:
45 29 32

#include <iostream>
using namespace std;

int main()
{
    int n, missing_number = 0, m, i, j, v[1201], w[1201];
    cin >> n >> m;
    for (i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for (i = 0; i < n - m; ++i) {
        cin >> w[i];
    }
    for (i = 0; i < n; ++i) {
        missing_number = 1;
        for (j = 0; j < n - m; ++j) {
            if (v[i] == w[j]) {
                missing_number = -1;
            }
        }
        if (missing_number == 1) {
            cout << v[i] << " ";
        }
    }
    if (m == 0)
        cout << "there are no missing numbers";
    return 0;
}

my code doesn't work for repeating numbers like:
7 3
2 6 1 9 3 2 4
4 1 2 3

where my output should be:
6 9 2

A: Your program seems to be outputting the correct result. However, I felt that I need to refactor your code to improve its readability and remove the bad practices used in it.
The below is the same as your code with a bit of improvement:
#include <iostream>
#include <array>
#include <limits>

int main( )
{
    std::array<int, 1201> arr1; // use std::array instead of raw arrays
    std::array<int, 1201> arr2;

    std::size_t arr1_size { }; // renamed n
    std::size_t arr2_size { }; // renamed m

    std::cin >> arr1_size >> arr2_size;

    if ( arr2_size == 0 ) // this if statement should be here to help end
    {                     // the program early on to prevent the execution
                          // of the for-loops
        std::cout << "There are no missing numbers.\n";
        return 0;
    }

    for ( std::size_t idx { }; idx < arr1_size; ++idx ) // use std::size_t
    {                                                   // for the loop counters
        std::cin >> arr1[ idx ];
    }

    for ( std::size_t idx { }; idx < arr1_size - arr2_size; ++idx )
    {
        std::cin >> arr2[ idx ];
    }

    for ( std::size_t arr1_idx { }; arr1_idx < arr1_size; ++arr1_idx )
    {
        bool isNumberMissing { true }; // this should be of type bool

        for ( std::size_t arr2_idx { }; arr2_idx < arr1_size - arr2_size; ++arr2_idx )
        {
            if ( arr1[ arr1_idx ] == arr2[ arr2_idx ] )
            {
                isNumberMissing = false;

                // this is my trick for solving your code's bug
                arr2[ arr2_idx ] = std::numeric_limits<int>::min( );

                break; // break here to improve performance
            }
        }

        if ( isNumberMissing )
        {
            std::cout << arr1[ arr1_idx ] << " ";
        }
    }

    std::cout << '\n';
}

Sample input/output #1:
7 3
12 34 45 29 100 87 32
100 87 12 34
45 29 32

Sample input/output #2:
7 3
2 6 1 9 3 2 4
4 1 2 3
6 9 2

Note: See Why is "using namespace std;" considered bad practice?


text:
Q: JUnit concurrent access to synchronizedSet I have a problem with running JUnit tests on my server. When I run the test on my machine, there is no problem at all. When I run it on the server, there is a failure on all my server "sometimes". It means tests pass sometimes in 60% of attempts and 40% fail.
I am using Mockito. My test starts with mocking some replies using MessageListener and map every request to a response and under the hood I am using Collections.synchronizedSet(new HashSet<>()) which is thread-safe.(Every modification on my synchronizedSet happens in a synchronized(mySynchronizedSet){....}) Then, I am using RestAssurd to get the response of a particular REST endpoint and assert some values.
When a test fails and I look on the Stacktrace, I see that one of my mappings (always on the same object) didn't work and there is no map between this specific request and response in my collection and naturally, I get null on requesting this endpoint.
I am using Jenkins to automate the compilation and running the test and I get the stack trace on fail or my Printlns otherwise, there are no debug facilities available.
It sounds like a concurrency problem to me. I mean it seems my collection does not have time to get ready before RestAssurd request for an endpoint. I've tested locks, sleep, and another simple java concurrency  solutions but they don't help and the probabilistic character of this problem has led me to a dead end.
Every thought will be appreciated.

A: Judging by what you said, it seems you have a misunderstanding of how things work in 3 specific cases.
First
and most obvious, and I apologize for even mentioning this, but the reason that I do at all is because I'm gathering that you're still learning (I apologize further if you're not still learning! and at the same rate, you might not have even implied it with the way I read it, so sorry if I misread): you aren't compiling with Jenkins, you're compiling with whatever JDK flavor you have on your machine (be it Oracle, Apple, GCJ, etc). Jenkins is an automation tool that helps facilitate your tedious jobs you expect to run regularly. I only mention this because I know college students nowadays use IDE's in there opening classes and can't distinguish between the compiler, the runtime, and the IDE.
Secondly
by using a threadsafe library, it doesn't automatically make everything you do inherently threadsafe. Consider the following example:
  final Map<Object, Object> foo = Collections.synchronizedMap(new HashMap <>());
  final String bar = "bar";
  foo.put(bar, new Object());
  new Thread(new Runnable(){
      @Override
      public void run(){
          foo.remove(bar);
      }
  }).start();
  new Thread(new Runnable(){
      @Override
      public void run(){
          if(foo.containsKey(bar)){
              foo.get(bar).toString();
          }
      }
  }).start();

There is no guarantee that the second thread's call to #get(Object) will happen before or after the first thread's call to #remove(Object). Consider that

*

*the second thread could call #containsKey(Object)

*then the first thread obtains CPU time and calls #remove(Object)

*then the second thread now has CPU time and calls #get(Object)
at this point, the returned value from get(Object) will be null, and the call to #toString() will result in a NullPointerDereference. You say you're using Set, so this example using a Map is mainly to prove a point: just because you're using a threadsafe collection, doesn't automatically make everything you do threadsafe. I imagine there are things you are doing with your set that match this sort of behavior, but without code snippets, I can only speculate.
And Lastly
You should be careful with how you write JUnits. A proper JUnit test is what's called a "whitebox" test. In otherwords, you know everything that is happening in the test, and you are explicitly testing everything that is happening in only the unit under test. The unit under test is just the method you are calling - not the methods that are called by your method, only the method itself. What that means, is that you need a good mocking framework, and mock out any subsequent method calls that your unit under test may invoke. Some good frameworks are JMockit, Mockito+PowerMock, etc.
The importance of this is that your test is supposed to test your isolated code. If you're allowing network access, disk access, etc, then your test may fail and it may have nothing to do with code you wrote, and it invalidates the test entirely. In your case, you hint at network access, so imagine that there is some throughput issue with your switches/router/etc, or that your NIC buffer gets full and can't process fast enough for what your program is trying to do. Sure, the failure is not good, and should be fixed, but that should be tested in "blackbox" testing. Your tests should be written so that you eliminate these sort of issues from being present and only test your code in the particular method for the unit under test, and nothing else.
Edit: I actually posted an answer to a separate discussion about whitebox testing that might be relevant: Is using a test entity manager a legitamate testing practice?


text:
Q: Training and validating on images with different resolution in Keras I'm using Keras to build a convolutional neural net to perform regression from microscopic images to 2D label data (for counting). I'm looking into training the network on smaller patches of the microscopic data (where the patches are the size of the receptive field). The problem is, the fit() method requires validation data to be of the same size as the input. Instead, I'm hoping to be able to validate on entire images (not patches) so that I can validate on my entire validation set and compare the results to other methods I've used so far.
One solution I found was to alternate between fit() and evaluate() each epoch. However, I was hoping to be able to observe these results using Tensorboard. Since evaluate() doesn't take in callbacks, this solution isn't ideal. Does anybody have a good way validating on full-resolution images while training on patches?

A: You could use fit generator instead of fit and provide a different generator for validation set. As long as the rest of your network is agnostic to the image size, (e.g, fully convolutional layers), you should be fine.

A: You need to make sure that your network input is of shape (None,None,3), which means your network accepts an input color image of arbitrary size.


text:
Q: Why am I getting btx halted trying to install FreeBSD? When trying to install FreeBSD 8 off a USB Drive (UNetBootin loaded) I receive

BTX Halted

when choosing any of the Boot options.

*

*Boot FreeBSD [default]

*Boot FreeBSD width ACPI disabled

*Boot FreeBSD in Safe Mode

*Boot FreeBSD in single user mode

*Boot FreeBSD with verbose logging

Here is my system
I have 256meg of ram on it, and a Transcend CF 133x 4GB for its drive.
I searched the FreeBSD supported hardware and It says AMD Geode LX is supported..
I have also read a post by someone who suggested:

My solution to the BTX halted was to turn of the BIOS IDE DMA Transfers option
  in the DeviceOptions menu in the BIOS.

but that also did nothing.
Am I missing something? Any help would be greatly appreciated.

11/24 - I just had luck installed FreeBSD 7.4 .. strange that my hardware is listed as supported in the newer versions yet I cannot load the bootloader... I would still like to be able to use the newest version.

A: I don't have a strong answer for you, but I do have some suggestions.
Non-Geode-specific versions of this problem are all over the web, and it looks like you've already tried some of the common suggestions:

*

*disabling ACPI

*disabling IDE DMA

I've also seen folks have success with:

*

*Change disk geometry in fdisk to match what BIOS sees for the boot drive (this might mean having to make a different USB image?)

It might be a good idea to narrow down the problem by eliminating the USB-specific parts of the boot process.  Are you able to boot from another device (for example, a Compact Flash card or SATA drive) with a newer FreeBSD already installed?
The fact that the problem is commonly associated with virtualization is also interesting.  That doesn't directly apply in your case, but the breadcrumbs of folks investigating it there could be helpful.
You also mentioned in chat that you'd gotten farther with UnetBootin than you'd gotten otherwise; can you elaborate a bit on that - the failure modes that you encounter when trying other methods?
I assume that you've already checked for a newer BIOS, but thought I'd mention it just in case.
If you're really ambitious, you can do a 'binary walk' of updates to source between 7.4 and the next newer OS that worked (8.0? 8.1?) and see where the problem begins.  I used this method to track down a problem booting my Whistle InterJets to a change made between 5.2 and 5.2.1.


text:
Q: Can't make/configure the difficult function
While solving sudoku I can remove possibility digits (1) and (2) from the cells D[1,2] and D[2,2]. Because (8) and (9) are possible only in those cells, so those cells are either (8 and 9) or (9 and 8). This means that digits (1) and (2) are at the 3rd line of the D block. Thats why I can eliminate the possibility of the digit (1) from the cell A[3,3].
I have been configuring a function to do this during last 40 hours, but couldn't manage. Is there anyone who can make the function to detect this type of intellectual issue (eliminating some possibilities because some other n count of possibilities can exist only in n count of cells, in our case 2 digits 8 and 9 can exist in 2 cells D[1,2] and D[2,2]).
Please dont advice me about other functions of sudoku; I have already done them, the only algorithm that I couldn't program is this one. Btw you can use r[i] (string which consists the possibilities for the row number i), c[i] for the column, and b[i] for the blocks (ex: b[4] (in this image block A) = 1,2,3,4,5,6,7 because 8 and 9 are already defined). Thanks

A: I really don't see the problem, you basically already answered your problem.
In general you should do the following:
Step 1: Loop over all 9 cells of one block and check if (1) is contained only in two cells.
Step 2: If not, try the next number. If yes, Loop over all 9 cells and check if (2) is also in those two cells but not in any other of the remaining 7.
Step 3: If not, check the next number. If yes, remove the other possibilities of the two cells except for the two numbers you found and you are basically done.
Step 4: If no matching number could be found for (1) (or any larger number that was chosen in the "not" part of step 2), start over from step 1 but trying the next number, unless you are already at 8, then you can stop.
In the end you could dynamically extend the same pattern for 3 numbers in 3 cells, 4 numbers...


text:
Q: How to bring to front an application opened using PsExec I'm invoking an application on a remote machine using PsExec (called from a C# test project). The invoked application has a GUI and also listens to a TCP port. At certain times I need to send it a command (using TCP) that takes a screenshot of the application and returns the screenshot back to my test.
The issue is that for that to work properly, the window of the application should be in front of other windows, but for some reason, PsExec always opens in behind all other application windows.
Note that I do use the /i switch and I can see the window if I bring it to front manually (e.g. using Alt+Tab), but I can't make PsExec to open it in front of other applications.


text:
Q: Bootstrap: Container is smaller than its columns, they cause an overflow I have an attached background image on the container, but it only goes with like half the columns and then the columns overflow and the bg image stops.
i tried min-height
the 2 columns are in a container and the columns contain multiple rows
i don't understand why on earth the container is not growing with the columns
HTML:

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css">
  <link rel="stylesheet" href="style.css" type="text/css">

COVER

Lorem ipsum dolor sit amet, consectetur adipisici elit.

          Button

      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbar2SupportedContent" aria-controls="navbar2SupportedContent" aria-expanded="false" aria-label="Toggle navigation">  </button>

            Home (current)

            Features

            Pricing

            About

Summary

Jumbotron

This is a modified jumbotron that occupies the entire horizontal space of its parent.

Heading

Paragraph

Dark Responsive Timeline with Bootstrap

Apr 2014

Surprising Headline Right Here

 3 hours ago

Lorem Ipsum and such.

Breaking into Spring!

 4/07/2014

Hope the weather gets a bit nicer...

Y'know, with more sunlight.

Mar 2014

New Apple Device Release Date

 3/22/2014

In memory of Steve Jobs.

No icon here

 3/16/2014

Here you'll find some beautiful photography for your viewing pleasure, courtesy of
                                  lorempixel.

Some Important Date!

 3/03/2014

Write up a quick summary of the event.

Secondary Timeline Box

 3/01/2014

This might be a follow-up post with related info. Maybe we include some extra links, tweets, user comments, photos, etc.

Feb 2014

The Winter Months

 02/23/2014

Gee time really flies when you're having fun.

Yeah we're pretty much done here

 02/11/2014

Wasn't this fun though?

A: It's a bug in Boostrap 4 alpha 6.
It's fixed in Boostrap 4 beta 1 that it's under development.
I noticed you are using Pingendo, you can use the Bootstrap 4 beta 1 version changing the import at the end of your sass file in
@import 'bootstrap-4.0.0-alpha.6';

A: It seems you haven't included bootstrap references inside your head tag
Here are the links - Bootstrap Js Link
Bootstrap CSS Link
Add them like this.

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.1/css/bootstrap.min.css" integrity="sha512-siwe/oXMhSjGCwLn+scraPOWrJxHlUgMBMZXdPe2Tnk3I0x3ESCoLz7WZ5NTH6SZrywMY+PB1cjyqJ5jAluCOg==" crossorigin="anonymous" referrerpolicy="no-referrer"
  />


text:
Q: omp.h header file not found in SUSE linux I wanted to execute a simple OPENMP Program in Suse linux and when I compile it with commmand "gcc -openmp example.c -O example" it gives an error "omp.h header not found" . How can include this header file so that i can execute this .

A:
when I compile it with commmand "gcc -openmp example.c -O example"

You error is that the flag that enables OpenMP handling in GCC is -fopenmp and not -openmp. With -fopenmp the path to omp.h is added automatically to the list of include paths.
As to where the actual omp.h file is located - it is usually located together with the other support files in the library folder. On RedHat-based distros it is in /usr/lib/gcc/<arch>-redhat-linux/<version>/include/omp.h where <arch> is the architecture (e.g. x86_64) and <version> is the GCC version (e.g. 4.4.4). Other distros may choose a different place.
One more thing - the option to specify the output executable is -o (small letter O). -O (capital letter O) enables some basic optimisations on the compiled code.


text:
Q: Connecting HTC 3D to ADB I'm trying to connect my Android HTC3D phone to my laptop and have been chugging away at this problem for quite some time now. I have done some research and scanned stackoverflow but nothing has solved my problem. So far I have followed the tutorial at: http://developer.android.com/tools/device.html but to no avail I would execute ./adb devices and it would give me an empty list. I then started searching around and I found this stackoverflow Q&A HTC Desire usb connection issue with Ubuntu 10.04 which recommended I rename them to 70, 71, 90, and 99. So I tried that, still nothing... This lead me to another post: Debugging Android App on Device which gave me a script to automagically generate the 70-android.rules file... Still nothing.
So far This is my setup:

*

*OS - Linux Mint 11

*IDE - Eclipse

*Phone: HTC 3D

*Phone Model Number: PG86100

*Phone has been set to debugging mode via Settings->Developer Options->USB Debugging

*rules file:
# Acer
SUBSYSTEM=="usb", SYSFS{idVendor}=="0502", MODE="0666"
# Dell
SUBSYSTEM=="usb", SYSFS{idVendor}=="413c", MODE="0666"
# Foxconn
SUBSYSTEM=="usb", SYSFS{idVendor}=="0489", MODE="0666"
# Garmin-Asus
SUBSYSTEM=="usb", SYSFS{idVendor}=="091E", MODE="0666"
# Google
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
# HTC
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
# Huawei
SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", MODE="0666"
#Kyocera
SUBSYSTEM=="usb", SYSFS{idVendor}=="0482", MODE="0666"
# LG
SUBSYSTEM=="usb", SYSFS{idVendor}=="1004", MODE="0666"
# Motorola
SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666"
# Nvidia
SUBSYSTEM=="usb", SYSFS{idVendor}=="0955", MODE="0666"
# Pantech
SUBSYSTEM=="usb", SYSFS{idVendor}=="10A9", MODE="0666"
# Samsung
SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"
# Sharp
SUBSYSTEM=="usb", SYSFS{idVendor}=="04dd", MODE="0666"
# Sony Ericsson
SUBSYSTEM=="usb", SYSFS{idVendor}=="0fce", MODE="0666"
# ZTE
SUBSYSTEM=="usb", SYSFS{idVendor}=="19D2", MODE="0666"
Any help or advice would be amazing. Thanks in advance.

A: SOLUTION:
I was using a griffon USB cable I had picked up at BestBuy for my old cellphone. Switched that cable out with the USB cable the HTC came with an badabang-badaboom it worked.


text:
Q: How to keep Docker container volume files? I'd like to share ~/mydir directory with host, but not replace Docker container directory with host files.
So, I have docker-compose.yml
version: '2'
services:
  app:
    container_name: mono
    build: .
    volumes:
      # save .composer files on host to keep cache warmed up
      - '/srv/mono/mydir:/root/mydir'
    command: sleep infinity

And Dockerfile
#/bin/bash
FROM php:5.6

RUN mkdir /root/mydir && echo '{}' > /root/mydir/myfile.json

VOLUME /root/mydir

Directory /srv/mono/mydir is empty. It was replaced with host directory. It's clear.
But how to keep original files?
For example it work for MySQL Percona containers:
version: '2'
services:
  percona-56:
    container_name: percona-56
    image: percona/percona-server:5.6
    volumes:
    - /srv/mysql/percona-56:/var/lib/mysql
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'

There are original files from the container:
$ ll /srv/mysql/percona-56
total 176220
    auto.cnf
    error.log
    ibdata1
    ib_logfile0
    ib_logfile1
    init.ok
    mysql
    performance_schema

I've tried to inspect Percona Dockerfile but didn't find something related to the volume sharing.
$ docker --version
Docker version 1.12.3, build 6b644ec

A: When you add a VOLUME at docker run, what you are saying is to use the main host filesystem instead of the copy-on-write filesystem that Docker uses for images.  There are two main options here:

*

*You bind-mount an actual filesystem location into the image.  This is what you are doing here.

*You let Docker handle the location... in this case, Docker creates the location on the main filesystem, and then copies the contents of the image into that location to get things started.

You are looking to get both- you want a fixed location on your filesystem, but you want files from your image to be there.  Now, there is a reason it doesn't work this way!  What happens if 'auto.conf' already exists in that folder and you launch your container?  What happens if you run two containers with different versions of that file pointed at the same location?  That is why if you pick a real location, it does not attempt to guess what to do with conflicts between the image and the filesystem, it just goes with the filesystem.
You CAN achieve what you want though.  There are really two options.  The better one would be to have your app read from two seperate folders- one that is populated inside the image, and one that is on your filesystem.  That completely avoids this problem ;)  The second option is to go in and tell Docker how to handle individual files in your image.
version: '2'
services:
  app:
    container_name: mono
    build: .
    volumes:
      # save .composer files on host to keep cache warmed up
      - '/srv/mono/mydir:/root/mydir'
      # Marking a volume this way will tell Docker to use THIS file
      # from the image, even though the parent directory is a regular
      # volume.  If you have an auto.cnf file in your directory, it
      # will be ignored.
      - /root/mydir/auto.cnf
    command: sleep infinity

......


text:
Q: Laravel Scout поиск по полной строке Сейчас даже при SearchUsingFullText скаут ищет по фрагменту, как эту проблему можно решить?
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;
use Laravel\Scout\Attributes\SearchUsingFullText;

class search_key extends Model
{
use HasFactory, Searchable;

public $table = 'request_list_view';

protected $fillable = ['id_request','fio','stud_group','name','type_name','comment', 'search_key'];

#[SearchUsingFullText(['search_key'])]
public function toSearchableArray()
{
    return [
        'search_key' => $this->search_key
    ];
}
}


text:
Q: Find the limit of the sequence $y_n$ defined by $x_{n}$ The sequence is defined as : $y_0 = x_0$ and $y_n = x_n - \alpha x_{n-1}$ where $ -1 \lt \alpha \lt 1 $
Also $ \lim\limits_{n\to \infty}{y_n}=b $
Find $ \lim\limits_{n\to \infty} {x_n}$
In my book there is a hint that says :
$x_1 = y_1 + \alpha y_0$
$x_2 = y_2 + \alpha y_1 + \alpha^2 y_0$
And so on till : $ x_n =y_n + \alpha y_{n-1} + \alpha^2 y_{n-2} + ... + \alpha^n y_0 $
Then it states that from last equality is :
$ \frac{b}{1-\alpha} = b + \alpha b + ... \alpha^n b + \frac{b \alpha^{n+1}}{1 - \alpha}$
First I would like to help me understand how it came to that last equality and maybe possible hints afterwards how to solve the limit.
Thank you

A: Idea: If $y_n = b$ for all $n$, then
$$\begin{split}
x_n  &= y_n + \alpha y_{n-1} + \alpha^2 y_{n-2} + \cdots + \alpha^n y_0 \\
&= b + \alpha b + \alpha^2 b+ \cdots + \alpha^n b \\
&= b(1+\alpha + \alpha^2+\cdots + \alpha^n) \\
&= \frac{b(1-\alpha^{n+1})}{1-\alpha}.
\end{split}$$
Since $-1<\alpha<1$, $\alpha^{n+1} \to 0$ as $n\to \infty$, this implies
$$\tag{1} \lim_{n\to \infty} x_n = \frac{b}{1-\alpha}.$$
Of course this is not true in general that $y_n = b$. But we have
$$\lim_{n\to \infty} y_n = b$$
we hope that in general $(1)$ still holds. With that in mind, consider
$$\begin{split}
\left| x_n - \frac{b}{1-\alpha}\right| &= \left|x_n - \frac{b(1-\alpha^{n+1})}{1-\alpha} + \frac{b(1-\alpha^{n+1})}{1-\alpha} - \frac{b}{1-\alpha} \right| \\
&\le \left|x_n - \frac{b(1-\alpha^{n+1})}{1-\alpha}\right| + \left| \frac{b(1-\alpha^{n+1})}{1-\alpha} - \frac{b}{1-\alpha} \right| \\
&= \left|x_n - \frac{b(1-\alpha^{n+1})}{1-\alpha}\right| + \left| \frac{b}{1-\alpha}\right| |\alpha^{n+1}|.
\end{split}$$
Note that the second term on the right goes to zero as $n \to \infty$. For the first term, consider
$$\begin{split}
x_n - \frac{b(1-\alpha^{n+1})}{1-\alpha} &= y_n + \alpha y_{n-1} + \alpha^2 y_{n-2} + \cdots + \alpha^n y_0 - b(1+ \alpha + \alpha^2 + \cdots + \alpha^n) \\
&= (y_n -b) + \alpha (y_{n-1} - b) + \alpha^2(y_{n-2} -b) + \cdots + \alpha^n (y_0 - b),
\end{split}$$
which implies that for all $n$,
$$\begin{split} \left| x_n - \frac{b(1-\alpha^{n+1})}{1-\alpha}\right| &\le  |y_n -b| + |\alpha | \cdot |y_{n-1} - b| + |\alpha|^2 \cdot |y_{n-2} -b| + \cdots + |\alpha| ^n |y_0 - b|\\
&= \sum_{k=0}^n |\alpha|^{n-k} |y_k  -b|
\end{split}$$
Note that $|y_n - b|$ is small when $n$ is large. In particular, for all $\epsilon >0$, there is $N_1\in \mathbb N$ so that
$$|y_n - b|<\epsilon $$
whenever $n\ge N_1$.
So we have
$$\begin{split}
\sum_{k=0}^n |\alpha|^{n-k}| y_k - b| &= \sum_{k=0}^{N_1-1} |\alpha|^{n-k}| y_k - b| + \sum_{k=N_1}^n |\alpha|^{n-k}| y_k - b| \\
&\le \sum_{k=0}^{N_1-1} |\alpha|^{n-k}| y_k - b| +\epsilon \sum_{k=N_1}^n |\alpha|^{n-k} \\
& =   \sum_{k=0}^{N_1-1} |\alpha|^{n-k}| y_k - b| + \epsilon \frac{1-|\alpha|^{n-N_1+1} }{1-|\alpha|} \\
&\le |\alpha|^{n-N_1+1} M + \epsilon \frac{1}{1-|\alpha|},
\end{split}$$
where $M$ depends only on $N_1$. Now we choose $N_2 >N_1+1$ so that
$$|\alpha|^{n-N_1+1} <\epsilon/M,\ \ |\alpha|^{n+1} <\epsilon $$
whenever $n\ge N_2$. So we have
$$\left| x_n - \frac{b}{1-\alpha}\right| \le \left( 1 + \frac{1}{1-|\alpha|} + \left| \frac{b}{1-\alpha}\right|\right) \epsilon$$
whenever $n\ge N_2$. Thus
$$\lim_{n\to \infty} x_n = \frac{b}{1-\alpha}.$$


text:
Q: Codeigniter My_payment Authorize.net Library. How to send invoice number? I am using the authorize.net my_payment.php library for codeigniter to do authorize.net payments for a site I made for one of my clients. They have just now come to me with a request to have their invoice number sent with the authorize.net payment. I have tried to add 'invoice_number' => $orderNumber to the params it sends but its not working.
Any ideas on how I could record the invoice number in authorize.net with the payment?
Here is the my_payment library:
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    /*
    |--------------------------------------------------------------------------
    | Authorize.net Payment Module
    |--------------------------------------------------------------------------
    |
    | Just add the following config to your application/config/config.php file
    |
    | $config['at_login']   = "xxxxxxxxxx"; //your login
    | $config['at_password']    = "xxxxxxxxxxxx"; //your transaction key
    | $config['at_test']    = 1; //Set to 0 for live transactions
    | $config['at_debug']   = 1; //Set to 0 for live transactions
    | $config['at_site'] = 'https://test.authorize.net/gateway/transact.dll'; //comment for live trans
    | //$config['at_site'] = 'https://secure.authorize.net/gateway/transact.dll'; //uncomment for live trans
    |
    |   Call it by doing this:
    |
    |       $this->load->library('my_payment');
    |       $params->cc = '1293081309812039812039' ;//etc... you get the idea
    |
    |       $result = $this->my_payment->authorize($params);
    |       print_r($result); //response codes from authorize.net
    |
    |
    |
    */

    class My_payment {

        public function Authorize($params)
        {
            $CI =& get_instance();

            $x_Login = $CI->config->item('at_login');
            $x_Password = $CI->config->item('at_password');

            $DEBUGGING                  = $CI->config->item('at_debug');
            $TESTING                    = $CI->config->item('at_test');
            $ERROR_RETRIES              = 2;

            $auth_net_url               = $CI->config->item('at_site');

            $authnet_values             = array
            (
                "x_login"               => $x_Login,
                "x_version"             => "3.1",
                "x_delim_char"          => "|",
                "x_delim_data"          => "TRUE",
                "x_type"                => "AUTH_CAPTURE",
                "x_method"              => "CC",
                "x_tran_key"            => $x_Password,
                "x_relay_response"      => "FALSE",
                "x_card_num"            => $params->cc,
                "x_exp_date"            => $params->exp,
                "x_description"         => $params->desc,
                "x_amount"              => $params->amount,
                "x_first_name"          => $params->firstName,
                "x_last_name"           => $params->lastName,
                "x_address"             => $params->address,
                "x_city"                => $params->city,
                "x_state"               => $params->state,
                "x_zip"                 => $params->zip,
                "SpecialCode"           => $params->specialCode,
            );

            $fields = "";
            foreach( $authnet_values as $key => $value ) $fields .= "$key=" . urlencode( $value ) . "&";

            $ch = curl_init($auth_net_url);

            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " ));

            $result = curl_exec($ch);

            curl_close ($ch);

            return $result;

        }
    }
    /* End of file My_payment.php */
    /* Location: ./system/application/libraries/My_payment.php */

Here is my code that sends the payment:
    //Process via Authorize.net
            //Load the authorize.net payment library
            $this->load->library('my_payment');
            $params = new stdClass();
            //Process the transaction
            $params->cc = $_POST['finalCardNumber'];
            $params->exp = $_POST['finalExpMonth'].'/'.$_POST['finalExpYear'];
            $params->desc = 'Stoles.com Order';
            $params->amount = $_POST['finalGrandTotal'];
            $params->firstName = $_POST['finalBillingFirstName'];
            $params->lastName = $_POST['finalBillingLastName'];
            $params->address = $_POST['finalBillingAddress'];
            $params->city = $_POST['finalBillingCity'];
            $params->state = $_POST['finalBillingState'];
            $params->zip = $_POST['finalBillingZipcode'];
            $params->specialCode = $_POST['finalCardCode'];
            $params->invoice_number = $orderNumber;

            $result = $this->my_payment->authorize($params);

            $authres = str_split($result);

A: Just adding an extra value to params isn't going to make the request actually send that value, as the class is clearly only sending the parameters specified in $authnet_values.
In this case, you need to modify $authnet_values to pass an additional parameter x_invoice_num in the Authorization request.


text:
Q: Iterator on several sets I am writing a Graph class,
I keep a HashMap in which ids of nodes (int values) are mapped to the associated nodes, and I'm using adjacency list approach to keep edges starting from a node (keeping them in form of a HashSet)
Note that : This graph is directed and unweighted,
I want to implement a method which returns an iterator over objects of class Edge :
When getting next on this iterator , one will get an object of class Edge which is created right when it's being traversed, and if there's no more neighbors for a node, it goes to the next node (order is not important) and if there's no more starting nodes (all are traversed), it finishes.
Any idea on how to implement this iterator on the edges without previously keeping the edges in Edge class objects ?
class Graph{
    HashMap<Integer , GraphNode> nodes;
    public Graph(){
        nodes = new HashMap<Integer ,GraphNode>();
    }
    public boolean addEdge(GraphNode n1 , GraphNode n2){
        if (!nodes.containsKey(n1) || !nodes.containsKey(n2))
            return false;
        return n1.addNeighbor(n2);
    }
    public boolean addNode(int id){
        if (nodes.containsKey(id))
            return false;
        nodes.put(id , new GraphNode(id));
        return true;
    }
    public boolean removeNode(GraphNode n1){
        if (!nodes.containsKey(n1.content))
            return false;
        for (GraphNode m : n1.neighbors)
            m.removeNeighbor(n1);
        nodes.remove(n1);
        return false;
    }
    public boolean removeEdge(GraphNode n1 , GraphNode n2){
        if (!nodes.containsKey(n1) || !nodes.containsKey(n2))
            return false;
        return n1.removeNeighbor(n2);
    }
    public Iterator<GraphNode> NodeIterator(){
        return nodes.values().iterator();
    }

   public Iterator<Edge> EdgeIterator(){
        Iterator<GraphNode> itr = this.NodeIterator();
        while (itr.hasNext){
            GraphNode n = itr.next();
            //......

        }
    }

}
class GraphNode{
    HashSet<GraphNode> neighbors;
    int content;
    public GraphNode(int content){
        this.content = content;
        neighbors = new HashSet<GraphNode>();
    }
    boolean addNeighbor(GraphNode n){
        if (neighbors.contains(n))
            return false;
        neighbors.add(n);
        return true;
    }
    boolean removeNeighbor(GraphNode n){
        if (!neighbors.contains(n))
            return false;
        neighbors.remove(n);
        return true;
    }

   }

class Edge{
    Node start , end;
    public Edge(Node start , Node end){
        this.start = start;
        this.end = end;
    }
}

A: I think something like this might work :
public Iterator<Edge> EdgeIterator(){
    Iterator <Edge> edgeIter = new Iterator<Edge>() {

        private Iterator<GraphNode> itr = this.NodeIterator();
        private GraphNode currentNode;
        ... // additional private members as required

        public void remove()
        {
          // you don't have to implement this method if you don't need to support
          // this operation
        }

        public Edge next()
        {
          if (!hasNext())
            throw new NoSuchElementException ();

          return new Edge (x , y); // where you find x & y based on the current state
                                   // of the iterator (kept in the private members of
                                   // this instance)
        }

        public boolean hasNext()
        {
            return ?; // you return a boolean value based on the current state
                      // of the iterator (kept in the private members of
                      // this instance)
        }
    };

    return edgeIter;
}

The EdgeIterator method creates an Iterator<Edge> and defines the methods of the Iterator interface (I left the implementation of these methods to you). The Iterator instance contains an instance of Iterator<GraphNode>, which it uses to iterate over the nodes.
You should add to the iterator some additional private members that keep track of the current node (the last node returned by the node iterator) and the current edge you are iterating on. Whenever you finish iterating over the edges of a node, you get the next node using itr.next() (after checking there is a next node available). next() of the edge iterator can construct the next Edge based on those private members.

A: As Eran said , I completed the code of the iterator methods ,
Do you think this one works ?
public Iterator<Edge> EdgeIterator(){
    Iterator<Edge> edgeIter = new Iterator<Edge>() {

        private Iterator<GraphNode> node_itr = NodeIterator();
        private Iterator<GraphNode> neighbor_itr;
        private GraphNode current_node;
        private GraphNode current_neighbor;
        public void remove()
        {
            if (current_node == null || current_neighbor == null)
                return;
            current_node.removeNeighbor(current_neighbor);
        }
        public Edge next()
        {
            if (neighbor_itr == null || !neighbor_itr.hasNext())
                if (node_itr.hasNext()){
                    current_node = node_itr.next();
                    neighbor_itr = current_node.neighbors.iterator();
                }else
                    return null;
            current_neighbor = neighbor_itr.next();
            return new Edge(current_node , current_neighbor);
        }
        public boolean hasNext()
        {
            if (neighbor_itr == null || !neighbor_itr.hasNext())
                if (node_itr.hasNext())
                    return node_itr.next().neighbors.iterator().hasNext();
                else
                    return false;
            return true;
        }
    };

    return edgeIter;
}

Update : The edited/working version :
public Iterator<Edge> EdgeIterator(){
    Iterator<Edge> edgeIter = new Iterator<Edge>() {
        private Iterator<GraphNode> node_itr = NodeIterator();
        private Iterator<GraphNode> neighbor_itr;
        private GraphNode current_node;
        private GraphNode current_neighbor;
        public void remove()
        {
            if (current_node == null || current_neighbor == null)
                return;
            current_node.removeNeighbor(current_neighbor);
        }
        private void moveNext(){
            if (neighbor_itr == null || !neighbor_itr.hasNext()){
                while (node_itr.hasNext()){
                    current_node = node_itr.next();
                    neighbor_itr = current_node.neighbors.iterator();
                    if (neighbor_itr.hasNext()){
                        break;
                    }
                }
            }
        }
        public Edge next()
        {
            moveNext();
            current_neighbor = neighbor_itr.next();
            return new Edge(current_node , current_neighbor);
        }
        public boolean hasNext()
        {
            moveNext();
            return neighbor_itr.hasNext();
        }
    };

    return edgeIter;
}


text:
Q: Image compression with Huffman tree So I recently built a Huffman tree and it worked well for encoding text. Now I wanted to try and see if I could compress images aswell. Obviously, images that differ little (like abstract images) should be better to compress. My question is if I'm thinking about this correct. Let's say I got a jpg image that is 786x463 pixels big. Each pixel have 3 color values, which each can be 256 different colors, therefore 8 bits. We got three colors, RGB, so each pixel is effectivly 24 bits all and all. So (786x463) * 24 = 853 40 16 bits which is about 1 Mb.
Now I can loop over all the pixels, and put the three color values in a list, and then count the occurences of each color from that list and remove the duplicates and put them in my tree.
private void saveColors() {
    BufferedImage img = readImage(url);
    int width = img.getWidth();
    int height = img.getHeight();
    int size = (width * height) * 3;
    pixels = new ArrayList<Integer>(size);

    WritableRaster inraster = img.getRaster();
    for (int i = 0; i < width; i++)
        for (int j = 0; j < height; j++) {
            pixels.add(inraster.getSample(i, j, 0));
            pixels.add(inraster.getSample(i, j, 1));
            pixels.add(inraster.getSample(i, j, 2));
        }
    countColors();
}

/**
 * Counts occurences and removes duplicates
 */
private void countColors() {
    List<Integer> duplicateRemoved;
    duplicateRemoved = new ArrayList<Integer>(pixels);

    Set<Integer> hs = new HashSet<Integer>();
    hs.addAll(duplicateRemoved);
    duplicateRemoved.clear();
    duplicateRemoved.addAll(hs);

    pixelFreq = new int[duplicateRemoved.size()];
    pixelArr = new int[duplicateRemoved.size()];

    for (int i = 0; i < pixelArr.length; i++) {
        int p = duplicateRemoved.get(i);
        int count = Collections.frequency(pixels, p);
        pixelArr[i] = p;
        pixelFreq[i] = count;
    }
//Build tree...
}

So I tried to encode this picture : [Just black and white1
And the encoding results gave me this:
color   Freq    Code   bits
'0' -- 4410 -- '0010'--17640
'1' -- 1185 -- '001001'--7110
'2' -- 858 -- '00100'--4290
'3' -- 591 -- '00100101'--4728
'4' -- 315 -- '0010010101'--3150
'5' -- 180 -- '0010010101010'--2340
'6' -- 75 -- '0010001010010'--975
'7' -- 30 -- '00100010100100'--420
'8' -- 9 -- '0010001010010000'--144
'246' -- 3 -- '001000101001000'--45
'247' -- 15 -- '001000101001000'--225
'248' -- 84 -- '0010001010'--840
'249' -- 138 -- '001001010101'--1656
'250' -- 273 -- '0010001010'--2730
'251' -- 480 -- '0010001'--3360
'252' -- 1227 -- '0001'--4908
'253' -- 1749 -- '00010'--8745
'254' -- 2475 -- '00'--4950
'255' -- 1077657 -- '0'--1077657
 Original compressed reduction percent
8734032--1145913---7588119--86.879906%

Which seems resonably, white occurs the most of times and get's the smallest code, where the black get's a slightly larger code.
Now as you can see, the total number of bits ended up being 1145913.
So we calculate the difference: 8534016 - 1145913 = 7388103 which is about 0,4 Mb. So the difference is about 0,6 Mb, 60% reduction.
So my question is, am I thinking about this right? I mean counting all the color values for each pixel?


text:
Q: Adding a preview step to the rails create and update actions This is a part of an app allowing the user to create HTML newsletters. After making edits, I'd like to let them preview the final look before saving the edits.
The preview page would display the preview and add the data in a hidden field to get resubmitted on approval. On "back to editing," the hidden field data would be passed back to the edit view.
I would have to add a "preview" action to the controller.
Is there a simpler way or best practice for this pattern?

A: In my opinion it would be good to add a kind of "preview" - Attribute to the model. When you klick on "Preview" you could copy the record or set "preview" to "true" and show it as static page when tis is the case. If the preview is ok, then you could set preview to false and that would state, that the Newsletter is ready to send.
Hope it is clear how i mean it, kinda late for me ;)


text:
Q: Vue router shows only one component I'm making a login application with Login and ResetPassword components. Currently, my Login component displays correctly. However, when I try to go to my /reset-password route, it only shows my Login component. I cannot get the content of my ResetPassword component to display no matter what I do. Am I missing something?
Directory structure
The structure of my src directory (minus assets and shims`:
src/
├── App.vue
├── components
│   ├── HelloWorld.vue
│   ├── Login.vue
│   └── ResetPassword.vue
├── main.ts
├── plugins
│   └── vuetify.ts
├── router
│   └── index.ts
└── views
    ├── About.vue
    ├── Home.vue
    └── ResetPasswordPage.vue

main.ts
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import * as config from '../config.json'
import vuetify from './plugins/vuetify'

Vue.config.productionTip = false
Vue.prototype.$secureCookies = config.secureCookies
Vue.prototype.$secureApi = config.secureApi
Vue.prototype.$hostApi = config.hostApi
Vue.prototype.$domain = config.domain

new Vue({
  router,
  vuetify,
  render: h => h(App)
}).$mount('#app')

App.vue
Note: I am using the Login component here.
<template>
  <v-app>
    <v-main>
      <Login/>
    </v-main>
  </v-app>
</template>

<script lang="ts">
import Vue from 'vue'
import Login from './components/Login.vue'

export default Vue.extend({
  name: 'App',
  components: {
    Login
  },

  data: () => ({
    //
  })
})
</script>

router/index.ts
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Home from '../views/Home.vue'
import ResetPasswordPage from '../views/ResetPasswordPage.vue'
import About from '../views/About.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: About
  },
  {
    path: '/reset-password',
    name: 'Reset Password',
    component: ResetPasswordPage
  },
  {
    path: '*',
    redirect: '/'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router

components/ResetPassword.vue stub
<template>
</template>
<script lang="ts">

import { Component, Vue } from 'vue-property-decorator'
import fetch from 'node-fetch'
import VueCookies from 'vue-cookies'

Vue.use(VueCookies)

@Component
export default class ResetPassword extends Vue {
  //
}
</script>

components/Login.vue stub
<template>
</template>
<script lang="ts">

import { Component, Vue } from 'vue-property-decorator'
import fetch from 'node-fetch'
import VueCookies from 'vue-cookies'

Vue.use(VueCookies)

@Component
export default class Login extends Vue {
  //
}
</script>

Versions

Tool
Version

TypeScript
3.9.3

Vue
2.6.11

Vuetify
2.4.0

A: You should use router-view component to render the current route component instead of <Login/>
App.vue
<template>
  <v-app>
    <v-main>
      <router-view/>
    </v-main>
  </v-app>
</template>

then just add your login route to the routes definition:
router/index.ts :
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Home from '../views/Home.vue'
import ResetPasswordPage from '../views/ResetPasswordPage.vue'
import About from '../views/About.vue'
import Login from '../components/Login.vue'
Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: About
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/reset-password',
    name: 'Reset Password',
    component: ResetPasswordPage
  },

  {
    path: '*',
    redirect: '/'
  }
]


text:
Q: Load data to redshift from ec2 without uploading to s3 I am developing a java program and is looking to load data to redshift table directly from ec2. I know s3 is a storage location. About ec2 I know only that ec2 instance is a like a virtual machine. I am now loading data from s3. Now I want to know how to load data from ec2 without the help of s3.
Please help I am new to this

A: It is possible to do so. Since your question is too broad, I can only give relevant links from Redshift documentation:

*

*Explanation of the solution: http://docs.aws.amazon.com/redshift/latest/dg/loading-data-from-remote-hosts.html

*SQL reference of the Copy command: http://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-source-ssh.html

A: You cannot COPY from ec2 without the help of s3.  See: https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-source.html
You would have to connect to redshift from ec2 and perform INSERT queries.

A: An alternative method (though not better) is to insert the values as literals from SQL.  It is not better b/c this is a highly inefficient data transfer method but for small data payloads works just fine.
Insert into <table> values
    ('A', 1, 9),
    ('B', 2, 8),
    ('C', 3, 7);

Again, this is NOT a good method for transferring even moderate amounts of data.  There is also SQL character length limit of 64K characters but if you are running up against this you are using this for too much data.  The best method for moving large amounts of data to Redshift is COPY from S3.


text:
Q: separate columns on condition in dataframe in R I think my image will probably convey 90% of the problem. My try is what I have posted below: (Separate only last occurrence of / when ColB contains "Sep")
df <- structure(list(ColA = c("abc/def", "bcd/efg", "def/ghj/yes",
"fet/hjk/yes"), ColB = c("sep", "no", "sep", "no")), class = "data.frame", row.names = c(NA,
-4L))

library(tidyverse)
df %>%
mutate(across(str_detect(ColB,"sep")~separate(ColA,into=c("A1","A2"),sep="/",
TRUE ~ NA))

A: Using extract we can divide the data in different columns and turn the values to NA if colB != 'sep.
library(dplyr)
library(tidyr)

df %>%
  extract(ColA, c('A1', 'A2'), '(.*)/(.*)', remove = FALSE) %>%
  mutate(across(A1:A2, ~replace(., ColB != 'sep', NA)))

#         ColA      A1   A2 ColB
#1     abc/def     abc  def  sep
#2     bcd/efg    <NA> <NA>   no
#3 def/ghj/yes def/ghj  yes  sep
#4 fet/hjk/yes    <NA> <NA>   no

A: We can do this in base R
df[paste0('A', 1:2)] <- read.csv(text = sub("/(\\w+)$",
          ",\\1", df$ColA), header = FALSE)
df[paste0("A", 1:2)] <- replace(df[paste0("A", 1:2)], df$Col1B != 'sep', NA)

Or we can use the OP's method with separate
library(dplyr)
library(tidyr)
df %>%
     separate(ColA, into = c("A1", "A2"), remove = FALSE, sep="/(?=[^/]+$)") %>%
     mutate(across(A1:A2, ~ case_when(ColB == 'sep' ~ .)))
#         ColA      A1   A2 ColB
#1     abc/def     abc  def  sep
#2     bcd/efg    <NA> <NA>   no
#3 def/ghj/yes def/ghj  yes  sep
#4 fet/hjk/yes    <NA> <NA>   no

Or with str_split and unnest_wider
df %>%
 mutate(new = str_split(case_when(ColB == 'sep' ~ ColA), "/(?=[^/]+$)")) %>%
 unnest_wider(c(new))


text:
Q: Android ksoap web service issue getting pullParserExcepstion I am consuming a .net web service using ksoap2 but getting the following Exception:

org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@412caa08)`

My request dump is the same as I needed but I'm not getting response dump and it has come as null. I am trying, but getting the same error.Please some one help me. My code is given below-
public class Login extends Activity {

private final String NAMESPACE = "http://xyz.public/imageupload/1.0/";
private final String URL = "http://public.service.xyz.com/ImageUpload.svc";
private final String SOAP_ACTION = "http://xyz.public/imageupload/1.0/Services/Authentication";
private final String METHOD_NAME = "Authentication";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                .permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    SoapSerializationEnvelope envelope = null;
    SoapObject request = null;
    HttpTransportSE httpTransportSE = null;
    try {
        request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("userId", "admin");
        request.addProperty("password", "password");

        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
        envelope.dotNet = true;
        envelope.encodingStyle = SoapSerializationEnvelope.ENC;

        /**
         * below code for custom header
         */
        Element actionElement = new Element().createElement(null,
                "d:Action");
        actionElement.setAttribute("", "s:mustUnderstand", "1");
        actionElement.addChild(Node.TEXT, SOAP_ACTION);

        Element toElement = new Element().createElement(null, "d:To");
        toElement.setAttribute("", "s:mustUnderstand", "1");
        toElement.addChild(Node.TEXT, URL);

        Element[] header = { actionElement,toElement };
        envelope.headerOut = header;
        envelope.env = "http://schemas.xmlsoap.org/soap/envelope/";
        /**
         * Custom header part end
         */
        envelope.setOutputSoapObject(request);

        httpTransportSE = new HttpTransportSE(URL);
        httpTransportSE.debug = true;
        httpTransportSE.call(SOAP_ACTION, envelope);
        SoapObject result = (SoapObject) envelope.getResponse();
        // To get the data.
        String textResult = result.toString();
        Log.i("textResult", textResult);

    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        Log.e("Exception:", e.toString());

    }

    finally {
        Log.i(getClass().getSimpleName(), "requestDump : "+ httpTransportSE.requestDump);
        Log.i(getClass().getSimpleName(), "responseDump : "+ httpTransportSE.responseDump);
    }

  }
}


text:
Q: Batch run script when closed My question is how would I make a batch script instead of closing when the X in the top right is pressed to execute a file called exit.exe.

A: There are a couple points in this question that are not clear enough:

*

*If you want that when the rigth top X is pressed on the cmd.exe window it not close, but do a different thing instead, then there is no way to achieve such thing with any existent window, that is, with the windows of all existent applications.

*If you want to differentiate if the window that execute your Batch file terminated normally or terminated because the user click on the right top X, then the way to achieve that is via a previous "starter" program that execute your Batch file and expects a certain value returned from it. If the returned value is not the expected one, then it is assumed that the window was cancelled via the right top X.

starter.bat:
@echo off

echo Start yourScript.bat:
start "" /W yourScript.bat
echo Value returned from the script: %errorlevel%
if %errorlevel% neq 12345 ECHO execute exit.exe

yourScript.bat:
@echo off

echo I am the script.bat
set /P var=input value:

rem Terminate normally:
exit 12345

A: the [X] is "out of reach" for cmd. Only way, I can think of is: create another cmd to watch the presence of the current window:
@echo off
title WatchMe
more +7 %~f0 >t2.bat
start "watcher" t2.bat

exit /b

@echo off
:running
tasklist /v|find "WatchMe" >nul &&echo waiting || goto finished
timeout 1 >nul
goto running
:finished
echo "the process has finished


text:
Q: how to extract accurate information from multiple tags in perl I want to extract url information from ask . com
this is the tag

maps.google.com

This is the code, I tried but it's extracting junk info with it.
$p = HTML::TokeParser->new(\$rrs);

while ($p->get_tag("p")) {

    my @link = $p->get_trimmed_text("/p");

     foreach(@link) { print "$_\n"; }

      open(OUT, ">>askurls.txt"); print OUT "@link\n"; close(OUT);

  }

I only want domain urls, like maps.google.com
but it's extracting, Source , Images and all sorts of other p class info junk with it, filling askurls.txt with irrelevant information
Added:
askurls.txt filled with this information:
Videos
Change Settings
OK
Sites Google
Sites Google.com Br
Google
Cookie Policy
assistant.google.com
Meet your Google Assistant. Ask it questions. Tell it to do things. It's your own personal Google, always ready to help whenever you need it.
www.google.com/drive
Safely store and share your photos, videos, files and more in the cloud. Your first 15 GB of storage are free with a Google account.
translate.google.com
Google's free service instantly translates words, phrases, and web pages between English and over 100 other languages.
duo.google.com

A: You can use a simple regex that will parse what you want for you
use strict;
use warnings;

my $text = <<'HTML'; # we are creating example data using a heredoc

 maps.google.com

example.com

HTML

while ($text =~ m/class="PartialSearchResults-item-url">(.*?)<\/p>/g) { # while loop to check all the existing match for the regex
  print $1."\n";
}

If you are not sure if there is whitespace in the tag where the domain is
(like here
maps.google.com
)
You can use \s* like:
m/class="PartialSearchResults-item-url">\s*(.*?)\s*<\/p>/g # here we are checking if there is space before and after the url

And if you want to check if domain is valid you can use is_domain() from Data::Validate::Domain module:
# previous script
use Data::Validate::Domain qw(is_domain);

while ($text =~ m/class="PartialSearchResults-item-url">(.*?)<\/p>/g) {
   if (is_domain($1)) {
      print $1."\n";
   }
}


text:
Q: Bootstrap 4 navbar - first bottom of viewport and after scrolling sticky on top - in IE 11 not working My matter has been described here countless times and some people seeking help have found a solution. Unfortunately, I have not yet found anything for my case. I am trying to resolve the following famous effect in IE 11 and down: Page finished loading, navigation in viewport is on postition bottom and when scrolling the page up, navigation is sticky on top. Like the template "twentyseventeen" in Wordpress. I work on Windows and use Xampp. It works with Firefox, Chrome, Edge, Opera. Not Safari, which isn't so bad as long as appels mobile version goes along. Also, the browsers of my mobile devices, such as Chrome and FireFox, have a good behavior, when I connect via the localhost IP. Even the Samsung browser gets everything right. Only the famous IE on my laptop doesn't work.
I am using Bootstrap v4.3.1 with jQuery v3.5.1: Does anyone have a solution please?
Thank you for taking action on my issue.
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/style.css" />
    <link rel="stylesheet" href="css/bootstrap.css" />

                    <picture>
                        <source srcset="./images/body.jpg" media="(min-width: 1600px)">
                        <source srcset="./images/bg400x240.svg" media="(max-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                    <picture>
                        <source srcset="./images/body.jpg" media="(min-width: 1600px)">
                        <source srcset="./images/bg400x240.svg" media="(max-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                    <picture>
                        <source srcset="./images/body.jpg" media="(min-width: 1600px)">
                        <source srcset="./images/bg400x240.svg" media="(max-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

            Logo
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">

            </button>

                        Inicio (current)

                        Prólogo

                        Manejo

                        Equidad de Género

                        TGyC

Home

                        Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis
                        evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

                        Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis
                        evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

                            <picture>
                                <source srcset="./images/body.jpg" media="(max-width: 1600px)">
                                <source srcset="./images/bg400x240.svg" media="(max-width: 400px)">

                            </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                            <picture>
                                <source srcset="./images/body.jpg" media="(max-width: 1600px)">
                                <source srcset="./images/bg400x240.svg" media="(max-width: 400px)">

                            </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                            <picture>
                                <source srcset="./images/body.jpg" media="(max-width: 1600px)">
                                <source srcset="./images/bg400x240.svg" media="(max-width: 400px)">

                            </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluissetconcludaturque et eum, altera fabulas ut quo.

Banner heading 2

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluissetconcludaturque et eum, altera fabulas ut quo.

auto height content here

                A div 944 x 322 px for: a div 800 px and 3 iframes

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                A div 944 x 322 px for: a div 800 px and 3 iframes

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

Banner heading 2

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

 The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

 The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

 The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

 The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

body {
    margin: 0;
    padding: 0;
    font-size: 28px;
    font-family: Arial, Helvetica, sans-serif;
  }

  .carousel .item {
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    width: 100%;
    height:100vh;
  }

  #carouselExampleIndicators .carousel-indicators {
      bottom: 280px;
       z-index: 1;
  }

  .carousel-item .carousel-caption {
      bottom: 200px;
       z-index: 1;
  }

    /*@-webkit-keyframes zoom {
        from {
        -webkit-transform: scale(1, 1);
        }
        to {
        -webkit-transform: scale(1.5, 1.5);
        }
    }

    @keyframes zoom {
        from {
        transform: scale(1, 1);
        }
        to {
        transform: scale(1.5, 1.5);
        }
    }*/

.carousel-inner img {
  -webkit-animation: zoom 20s;
  animation: zoom 20s;
}

  #navbar{
      position: sticky;
      z-index: 2;
      bottom: 0;
  }

   hr {
    border-top: 2px solid #ff0000 !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

  .banner{
      background: url('./images/placeholder2000x1200.svg');
      background-position: center;
      background-size: cover;
      width: 100%;
      font-weight: 700;
  }

  .content {
    padding: 16px;
  }

  .sticky {
    position: fixed;
    top: 0;
    width: 100%;
  }

  .sticky + .content {
    padding-top: 60px;
  }
  .banner2{
      height: 350px;
  }
  .h-100{
      height: 100%;
  }
  .bg3{
    background: url('./images/1024x698backgroundImage.jpg');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    width: 100%;
    height:100vh;
  }
  .bg4{
    background: url('./images/820x558backgroundImage.jpg');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    width: 100%;
    height:100vh;
  }
  .breadcrumb-outer{
      background: #e9ecef !important;
  }
  .select{
      width: 20% !important;
  }
  .dropbtn {
    background-color: #4CAF50;
    color: white;
    padding: 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px
        0px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f1f1f1
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown:hover .dropbtn {
    background-color: #3e8e41;
}

By the way, if anyone is interested in this information: as you know, the Bootstrap carousel is already responsive, but not enough. For an image exchange for different viewports I have tried a few things, of which in the end only the variant in my html works properly. But the default settings don't let the images be zoomed on touch devices. One solution here was the zoom effect, which is actually an elegant variant, because it lasts the user a moment longer on the site.

A: Thank you for your answers and sorry that I'm replying late.
I have changed a little and commented everything a little more clearly. The main-nav and breadcrumb-nav are now enclosed in a parent div and sticky together. Now it works better, but I have this message: This site appears to be using a scroll-linked positioning effect. This might interact badly with asynchronous panning; see https://developer.mozilla.org/docs/Mozilla/Performance/ScrollLinkedEffects for more details and join the discussion about related tools and functions!
Would stickybits be a better solution?
Your opinions are very welcome. Many thanks.
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap-4.3.1-dist/css/bootstrap.css" />
    <link rel="stylesheet" href="style.css" />

                    <picture>
                        <source srcset="./images/placeholder2.jpg" media="(max-width: 1599px)">
                        <source srcset="./images/placeholder.jpg" media="(min-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                    <picture>
                        <source srcset="./images/placeholder2.jpg" media="(max-width: 1600px)">
                        <source srcset="./images/placeholder.jpg" media="(min-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                    <picture>
                        <source srcset="./images/placeholder2.jpg" media="(max-width: 1600px)">
                        <source srcset="./images/placeholder.jpg" media="(min-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                Previous

                Next

    **
**

                Logo

bla bla bla

                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">

                    </button>

                                Inicio

                                Prólogo

                                Manejo

                                Equidad de Género

                                TGyC

Home

    **
**

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.
                           Atqui causae gloriatur ius te, id agam omnis evertitur eum.Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.
                           Atqui causae gloriatur ius te, id agam omnis evertitur eum.Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

                   <picture>
                        <source srcset="./images/placeholder2.jpg" media="(max-width: 1599px)">
                        <source srcset="./images/placeholder.jpg" media="(min-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                    <picture>
                        <source srcset="./images/placeholder2.jpg" media="(max-width: 1599px)">
                        <source srcset="./images/placeholder.jpg" media="(min-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                    <picture>
                        <source srcset="./images/placeholder2.jpg" media="(max-width: 1599px)">
                        <source srcset="./images/placeholder.jpg" media="(min-width: 400px)">

                    </picture>

sample heading

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

                Previous

                Next

Banner heading 2

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

auto height content here

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.
               Atqui causae gloriatur ius te, id agam omnis evertitur eum.Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.
               Atqui causae gloriatur ius te, id agam omnis evertitur eum.Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

                    A div 944 x 322 px for: a div 800 px and 3 iframes

auto height content here

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.
               Atqui causae gloriatur ius te, id agam omnis evertitur eum.Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.
               Atqui causae gloriatur ius te, id agam omnis evertitur eum.Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

                    A div 944 x 322 px for: a div 800 px and 3 iframes

auto height content here

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.
               Atqui causae gloriatur ius te, id agam omnis evertitur eum.Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.
               Atqui causae gloriatur ius te, id agam omnis evertitur eum.Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.

Banner heading 2

Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo.

 The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

 The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

 The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

 The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.

/* fixed-navbar.js*/

const nav = document.querySelector('#navbar-wrapper');
        const offset = nav.getBoundingClientRect();

        window.addEventListener('scroll', function () {
            if (window.pageYOffset > offset.top) {
                nav.style.position = 'fixed';
                nav.style.top = 0;
            } else {
                nav.style.position = 'relative';
                nav.style.top = '';
            }
        });

/* CSS */

/*---------------------------------------------------------------------------- Carousel ---------------------------------------------------------------*/

/*.image {
    width: 100%;
    height: 100vh;
}*/

/*#carousel-1 #carousel-2 .carousel-indicators {    /* depence on the viewport of device */
    /*bottom: 280px;
    z-index: 1;
}*/

/*.carousel-item .carousel-caption {                /* depence on the viewport of device */
    /*bottom: 200px;
    z-index: 1;
}*/

.carousel-inner img {
    -webkit-animation: zoom 20s;
    animation: zoom 20s;
}

@-webkit-keyframes zoom {
    from {
        -webkit-transform: scale(1, 1);
        }
    to {
        -webkit-transform: scale(1.5, 1.5);
        }
}

@keyframes zoom {
    from {
        transform: scale(1, 1);
        }
    to {
        transform: scale(1.5, 1.5);
        }
}

/*-------------------------------------------------------------------------- Main Navbar --------------------------------------------------------------*/
#navbar-wrapper {
    z-index: 111;
    width: 100%;
}

/*------------------------------------------------------------------------- Breadcrumb-Nav ------------------------------------------------------------*/
.breadcrumb-outer {
    background: #e9ecef !important;
}

/*------------------------------------------------------------------------- Banners -------------------------------------------------------------------*/
.bannerAfter2ndCarousel {
    height: 350px;
    background-color: #e5ff80 !important;
}

.bannerContent {
    height: 350px;
    background-color: #e5ff80 !important;
}

/*------------------------------------------------------------------------- Videos ---------------------------------------------------------------------*/
.banner-videos {
    background-color: #edceba;
}

/*------------------------------------------------------------------------ Select Menu manejo.html------------------------------------------------------*/

/*.bg-upper{
    height: 100%;
   align-items: flex-end;

  }*/

.select {
    width: 20% !important;
}

.dropbtn {
    background-color: #4CAF50;
    color: white;
    padding: 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f1f1f1
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown:hover .dropbtn {
    background-color: #3e8e41;
}

Thank you


text:
Q: Pivot dynamic columns - 12 months at a time My table has data in the following format; where period refers to a given month of the year.
   // table
   id name location type period     value
   1  foo  bar      baz  2021-01-01 500
   2  foo  bar      baz  2021-02-01 1500
   3  foo  bar      baz  2021-03-01 1500
   ...

   // desired output
   id  name location  type MonthJan  MonthFeb MonthMar
   1   foo  bar       baz  500       1500     1500
   ...

And I (think) I need to pivot the results to show any given 12 months of data. Having searched Stackoverflow, have hashed together this which is a "semi-dynamic" pivot in my eyes. It seems to work but looks a bit simple/clunky.
The end goal is to get the sum of amount for each period
select name, location, type,
  sum(case when MONTH(period) = '1' then amount else 0 end) MonthJan,
  sum(case when MONTH(period) = '2' then amount else 0 end) MonthFeb,
  sum(case when MONTH(period) = '3' then amount else 0 end) MonthMar,
  ...
from myTable
where period >= '2021-01-01' and period <= '2021-12-31' ## 1 calendar year
group by name, location, type

It was my intention then to let the user pass in conditions to "period" to then return say all data between 1st Feb 2021 - 31st Jan 2022 - essentially 12 months.
This sort of works but if they wanted to see data for 2 years it soon falls flat on its face (I'd need 24 columns then not just 12).
I've looked at dynamic queries - it seems like my approach is just wrong - is this workable or does it need a rethink?
I'm currently using MySQL which I understand doesn't have a pivot function, but the solution needs to be as flexible as possible (i.e. work with SQL server) hence my looking at this SUM/case approach.


text:
Q: Can I define an add method for a descriptor in python 3? I referenced the python docs here to see how to create a class property in python that has controlled getter and setter methods.
https://docs.python.org/3/howto/descriptor.html#id6
I created a descriptor property class with this code:
class PropNumberString(object):
    def __init__(self, initval=None, name='var_int'):
        self.val = initval
        self.name = name

    def __get__(self, obj, objtype):
        print("in getter")
        return self.val

    def __set__(self, obj, val):
        print("in setter")
        self.val = int(val)

    def __add__(self, val):
        print("adding")
        print("val to add: ", val)
        self.val = int(self.val) + int(val)
        return self

    def __radd__(self, val):
        return self.__add__(val)

class ConnectionTemplate(object):
    tid = PropNumberString(0, "ID")

I tried to define an add method as well, intending it always add an integer even if a string is provided. This doesn't work, it seems that "__get__" is called and then the add method of the integer returned is called instead of my add method.
Here is a test to demonstrate:
my_template = ConnectionTemplate()

print("Getting value")
print(my_template.tid)

print("Updating value")
my_template.tid = 100

print("Doing add")
my_template.tid = my_template.tid + "1"

print(my_template.tid)
print("type: ", type(my_template.tid))

Output:
Getting value
in getter
0
Updating value
in setter
Doing add
in getter
Traceback (most recent call last):
  File "connection_template.py", line 53, in <module>
    my_template.tid = my_template.tid + "1"
TypeError: unsupported operand type(s) for +: 'int' and 'str'

Is there a good solution for this?
EDIT:
This is what I ended up doing, which incorporates the answer provided by Alex Hall
class StrInt(int):
    def __add__(self, val):
        return StrInt(super().__add__(int(val)))
    __radd__ = __add__

class PropNumberString(object):
    def __init__(self, val=None, name='var_name'):
        self.val = StrInt(val)
        self.name = name

    def __get__(self, obj, objtype):
        return self.val

    def __set__(self, obj, val):
        self.val = StrInt(val)

class ConnectionTemplate(object):
    tid_field = "ID"

    def __init__(self, tid=0):
        self.tid = PropNumberString(tid, self.ansa_tid_field)

    def __getattribute__(self, key):
        # see https://docs.python.org/3/howto/descriptor.html#id5
        "Emulate type_getattro() in Objects/typeobject.c"
        attrib = object.__getattribute__(self, key)
        if hasattr(attrib, '__get__'):
            return attrib.__get__(None, self)
        return attrib

    def __setattr__(self, key, val):
        try:
            attrib = object.__getattribute__(self, key)
        except AttributeError:
            self.__dict__[key] = val
            return
        if hasattr(attrib, '__set__'):
            attrib.__set__(None, val)
            return
        self.__dict__[key] = val

note:
My motivation for using a custom descriptor instead of the property decorator is that I want my properties to be able to contain custom metadata, i.e. key value for json dump.

A: You shouldn't need to define a custom descriptor for this. You just need tid to return a class that adds the way you want. It's probably best to do the conversion on setting rather than getting. Here is an implementation:
class MyInt(int):
    def __add__(self, val):
        return MyInt(super().__add__(int(val)))

    __radd__ = __add__

class ConnectionTemplate(object):
    def __init__(self):
        self._tid = 0

    @property
    def tid(self):
        return self._tid

    @tid.setter
    def tid(self, val):
        self._tid = MyInt(val)


text:
Q: laravel left join property of non-object when no result I am creating an application with 3 models: bookstore, shelve and book. All 1-to-many relations.
When I want a list of all shelves: I do:
Controller:
$shelves = Shelve::leftJoin('books', 'books.shelve_id', '=', 'book.id')->paginate(5);

Blade:
@if ( !$shelves->count() )
    No shelves
@else
@endif

This works fine when there is at least 1 shelve created. When there are no shelves (empty table), I get Trying to get property of non-object.
What can I do?

A: @if(!isset($shelves))
      no shelves
@else
@endif

Try this! You are trying to count what doesn't exist that's why it's giving an error.


text:
Q: Python GET Requests causing 100% CPU Usage Spike I'm using the python requests library (version 2.4.1) for performing a simple get request, code is below, nothing fancy here. On most website's there are no issues. But on some websites, one in particular www.pricegrabber.com, I experience 100% CPU usage and the code never moves past the point of the get request. No timeout occurs, nothing, just a huge CPU usage spike that never stops.
import requests
url = 'http://www.pricegrabber.com'
r = requests.get(url, timeout=(1, 1))
print 'SUCESS'
print r

A: Using python 2.7, the latest stable version of the 'requests' library, and enabling logging as shown in this answer indicates that the HTTP request is stuck in a redirect loop.

INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): www.pricegrabber.com
  DEBUG:requests.packages.urllib3.connectionpool:"GET / HTTP/1.1" 301 20
  DEBUG:requests.packages.urllib3.connectionpool:"GET /index.php/ut=43bb2597a77557f5 HTTP/1.1" 301 20
  DEBUG:requests.packages.urllib3.connectionpool:"GET /?ut=43bb2597a77557f5 HTTP/1.1" 301 20
  DEBUG:requests.packages.urllib3.connectionpool:"GET /?ut=43bb2597a77557f5 HTTP/1.1" 301 20
  DEBUG:requests.packages.urllib3.connectionpool:"GET /?ut=43bb2597a77557f5 HTTP/1.1" 301 20
...

This continues a bit until:

requests.exceptions.TooManyRedirects: Exceeded 30 redirects.

And the code I used to discover this:
#!/usr/bin/env python

import logging
import requests

logging.basicConfig(level=logging.DEBUG)

url = 'http://www.pricegrabber.com'
r = requests.get(url, timeout=(1, 1))

print 'SUCCESS'
print r


text:
Q: What type of addresses can the port 7 store AGU handle on recent Intel x86? Starting with Haswell, Intel CPU micro-architectures have had a dedicated store-address unit on port 7 which can handle the address-generation uop for some store operations (the other uop, store data always goes to port 4).
Originally it was believed that this could handle any type of addresses, but this seems not to be the case. What types of addresses can this port handle?

A: This answer applies to Haswell and Skylake (/Kaby Lake / Coffee Lake).  Future ISAs (Cannon Lake / Ice Lake) will have to be checked when they're available.  The port 7 AGU was new in Haswell.

For instructions that can use port7 at all (e.g. not vextracti128), any non-indexed addressing mode can use port 7.
This includes RIP-relative, and 64-bit absolute (mov [qword abs buf], eax, even in a PIE executable loaded above 2^32, so the address really doesn't fit in 32 bits), as well as normal [reg + disp0/8/32] or absolute [disp32].
An index register always prevents use of port7, e.g. [rdi + rax], or [disp32 + rax*2].  Even [NOSPLIT disp32 + rax*1] can't use port 7 (so HSW/SKL doesn't internally convert an indexed with scale=1 and no base register into a base+disp32 addressing mode.)
I tested myself with ocperf.py stat -etask-clock,context-switches,cpu-migrations,page-faults,cycles,instructions,uops_dispatched_port.port_2,uops_dispatched_port.port_3,uops_dispatched_port.port_7 ./testloop on a Skylake i7-6700k.

The [+0, +2047] range of displacements makes no different for stores: mov [rsi - 4000], rax can use port 7.
Non-indexed loads with small positive displacements have 1c lower latency.  No special case for stores is mentioned in Intel's optimization manual.  Skylake's variable-latency store-forwarding (with worse latency when the load tries to execute right away after the store) makes it hard to construct a microbenchmark that includes store latency but isn't affected by having store-address uops compete with loads for fewer ports.  I haven't come up with a microbenchmark with a loop-carried dependency chain through a store-address uop but not through the store-data uop.  Presumably it's possible, but maybe needs an array instead of a single location.

Some instructions can't use port7 at all:
vextracti128 [rdi], ymm0, 0 includes a store-address uop (of course), but it can only run on port 2 or port 3.
Agner Fog's instruction tables have at least one error here, though: he lists pextrb/w/d/q as only running the store-address uop on p23, but in fact it can use any of p237 on HSW/SKL.

I haven't tested this exhaustively, but one difference between HSW and SKL I found1 was VCVTPS2PH [mem], xmm/ymm, imm8.  (The instruction changed to use fewer ALU uops, so that doesn't indicate a change in p7 between HSW and SKL).

*

*On Haswell: VCVTPS2PH is 4 uops (fused and unfused domain): p1 p4 p5 p23 (Agner Fog is right).

*On Skylake: VCVTPS2PH xmm is 2 fused / 3 unfused uops: p01 p4 p237

*On Skylake: VCVTPS2PH ymm is 3 fused / 3 unfused uops: p01 p4 p237
(Agner Fog lists VCVTPS2PH v as 3F/3U (one entry for both vector widths), missing the micro-fusion with the xmm version, and incorrectly lists the port breakdown as p01 p4 p23).
In general, beware that Agner's recent updates seem a little sloppy, like copy/paste or typo errors (e.g. 5 instead of 0.5 for Ryzen vbroadcastf128 y,m128 throughput).
1:  HSW testing was on an old laptop that's no longer usable (I used its RAM to upgrade another machine that still gets regular use).  I don't have a Broadwell to test on.  Everything in this answer is definitely true on Skylake: I double checked it just now.  I tested some of this a while ago on Haswell, and still had my notes from that.


text:
Q: Tell if we are running linux inside WSL? I have a few linux systems, including those running as WSL (Windows Subsystem for Linux) on a Windows machine.
I'd like to be able that a script/program/whatever can tell if it's running inside of WSL.  I could do something hacky like look for the existence of /mnt/c/...   but that could just be a Windows disk mounted on a Linux system.
Is there a clean way to do this, or is WSL too much like a virtual machine to know that we aren't running inside of Windows?

A: uname -a

Seems like quite a reasonable solution to me.
~# uname -a
Linux Eve 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux

The clear denotation of "Microsoft" in the uname makes it clear that we're running in WSL. Now in fairness to your example, this could be just a forged uname string. But for where the rubber meets the road, this more than fills the bill.