text:
Q: SFML program having thread errors I've recently started using the Library SFML with visual studios 2012 c++.
It all worked fine until i started to use custom fonts, and then these messages popped up and nothing worked:
'Graphics test.exe' (Win32): Loaded 'C:\Users\Oliver Bolt\Documents\Visual Studio 2012\Projects\Graphics test\Debug\Graphics test.exe'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Program Files\AVAST Software\Avast\snxhk.dll'. Cannot find or open the PDB file.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\opengl32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\glu32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ddraw.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dciman32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\setupapi.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\devobj.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvinit.dll'. Cannot find or open the PDB file.
'Graphics test.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\_etoured.dll'. Cannot find or open the PDB file.
'Graphics test.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\Nvd3d9wrap.dll'. Cannot find or open the PDB file.
'Graphics test.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\nvdxgiwrap.dll'. Cannot find or open the PDB file.
'Graphics test.exe' (Win32): Loaded 'C:\PROGRA~2\OPTIMI~1\OPTPRO~1.DLL'. Module was built without symbols.
'Graphics test.exe' (Win32): Unloaded 'C:\PROGRA~2\OPTIMI~1\OPTPRO~1.DLL'
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ig7icd32.dll'. Cannot find or open the PDB file.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igdusc32.dll'. Cannot find or open the PDB file.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\version.dll'
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dinput.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\hid.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wintrust.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\crypt32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msasn1.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded.
'Graphics test.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll'
The thread 0xed8 has exited with code 0 (0x0).
The thread 0x131c has exited with code 0 (0x0).
The thread 0x105c has exited with code 0 (0x0).
The thread 0x19e8 has exited with code 0 (0x0).
The thread 0xeb4 has exited with code 0 (0x0).
The thread 0x187c has exited with code 0 (0x0).
The thread 0x1c78 has exited with code 0 (0x0).
The thread 0x480 has exited with code 0 (0x0).
The thread 0x1244 has exited with code 0 (0x0).
The program '[4124] Graphics test.exe' has exited with code 0 (0x0).

The program that caused these errors:
#include <SFML\System.hpp>
#include <SFML\Graphics.hpp>
#include <ctime>
#include <sstream>

using namespace sf;
using namespace std;

int main()
{
    VideoMode videoMode(320, 240);
    RenderWindow window(videoMode, "Plus or minus");

    Font font;
    if (!font.loadFromFile("TOMB.TTF"))
    {
        return EXIT_FAILURE;
    }

    Text title("Plus Or Minus", font, 20);
    title.setPosition(10, 10);
    title.setColor(Color::White);

    Text question("What is your guess ?",font,20);
    question.setPosition(5,30);
    question.setColor(Color::White);

    Text enter("", font, 20);
    enter.setPosition(5, 50);
    enter.setColor(Color::Green);
    String textEntered;
    int numEntered = 0;

    Text status("", font, 16);
    status.setPosition(100, 50);
    status.setColor(Color::Yellow);
    stringstream out("");

    Text won("You have discovered\n the secret number\n in less than 10 tries,\n well played !", font, 20);
    won.setPosition(5, 70);
    won.setColor(Color::Green);

    Text lost("You have failed to\n discover the secret\n number in less than\n 10 tries, better \nluck next time!", font, 20);
    lost.setPosition(5, 70);
    lost.setColor(Color::Red);

    srand(static_cast<unsigned int> (time(NULL)));

    int secretNumber = rand() % 100;

    bool isGameOn = true;
    bool playerWon = false;
    int tryNumber = 0;

    while (window.isOpen())
    {
        window.clear();
        window.draw(title);
        if (isGameOn)
        {
            window.draw(question);
            window.draw(enter);
            window.draw(status);
        }
        else
        {
            if (playerWon)
            {
                window.draw(won);
            }
            else
            {
                window.draw(lost);
            }
        }

        window.display();

        Event event;
        while (window.pollEvent(event))
        {
            if ((event.type == Event::Closed) || ((event.type == Event::KeyPressed) && (event.key.code == Keyboard::Escape)))
            {
                window.close();
            }

            if (event.type == Event::TextEntered)
            {
                char c = static_cast<char> (event.text.unicode);
                if (c >= '0' && c <= '9')
                {
                    textEntered += event.text.unicode;
                    enter.setString(textEntered);
                }
                else if (c == '\r')
                {
                    tryNumber++;

                    stringstream in(enter.getString());
                    in >> numEntered;

                    if (numEntered > secretNumber)
                    {
                        out << tryNumber;
                        out << ". ";
                        out << numEntered;
                        out << ": Minus" << endl;
                        status.setString(out.str());
                    }
                    if (numEntered < secretNumber)
                    {
                        out << tryNumber;
                        out << ". ";
                        out << numEntered;
                        out << ": Plus" << endl;
                        status.setString(out.str());
                    }
                    if (numEntered == secretNumber)
                    {
                        playerWon = true;
                        status.setString("");
                        isGameOn = false;
                    }
                    if (tryNumber > 10)
                    {
                        playerWon = false;
                        status.setString("");
                        isGameOn = false;
                    }
                    textEntered = "";
                }
            }
        }
        return EXIT_SUCCESS;
    }
}

I have searched around, but i didn't really find an answer to this problem, would be really grateful if someone could help me solve this! :)
Best Regards
FreeSirenety

A: You have a return statement at the end of your while (window.isOpen()) { ... } loop.
So the loop runs only once.


text:
Q: Javascript autoplay soundfile, stop when one of the buttons is clicked So I've got some buttons, which people can press to hear audio files. Of course, the audio files can't "overlap" because that would be a mess. This works, but now I want one of the files to play automatically when the website loads, still maintaining the fact that it will stop whenever I press another button.
This is what I've got so far:
Head:

Body:

A: Try this jquery solution:
http://archive.plugins.jquery.com/project/sound_plugin
I used this successfully in a reaction time test where I had to play a sound just before each test.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Excel stacked columns chart target line I have searched but unfortunatelly did not find any answer to my issue.
I have the following table:
_ |   A   |   B    |   C    |
-----------------------------
1 |  feb  | yes/no | target |
2 |  feb  |  yes   |  90%   |
3 |  feb  |   no   |  90%   |
4 |  feb  |  yes   |  90%   |
5 |  feb  |  yes   |  90%   |
6 |  feb  |  yes   |  90%   |
7 |  feb  |  yes   |  90%   |
8 |  feb  |  yes   |  90%   |
9 |  feb  |  yes   |  90%   |
. |  mar  |  yes   |  90%   |
. |  mar  |   .    |   .    |
. |  mar  |   .    |   .    |

With the table above I created a pivot table:
| Row Labels | Yes  | target of Yes |  No  | target of no |
 ---------------------------------------------------------
| feb        | 87%  | 90%           | 13%  | 90%          |
| mar        | 95%  | 90%           |  5%  | 90%          |
 ---------------------------------------------------------

My problem is that I do not need "target of Yes" and "target of No".. This is the general target of it. If I create a chart I get two target lines. One for "Yes" and one for "No".
I just need Target (90%) in the pivot table, like so:
| Row Labels | Yes  |  No  | target |
 -----------------------------------
| feb        | 87%  | 13%  | 90%    |
| mar        | 95%  |  5%  | 90%    |
 -----------------------------------

Like that I would get a stacked chart something like:
100%    -13%-       --5%-
95%    |     |     |-95%-|
90%  --|-----|--------------  >> target line
85%    |-87%-|     |     |
80%    |     |     |     |
75%    |     |     |     |
70%    |     |     |     |
60%    |     |     |     |
50%    |     |     |     |
.%     |     |     |     |
0%     |     |     |     |
       -------------------
    |    feb    |    mar    |

I hope it is understandable.
How can I achieve that? I need it in order to add the 99% mark in the stacked chart of excel.
Thank you all in advance for any suggestion.

A: From your 3rd table.. just highlight it all and press F11 .
Correct the axis/bar : r-click on chart > select data > switch row/column.
Then design> chg chart type > Combo .
select "Stacked Column" for Yes/No. || select "line" for Target .
done. ( :
hope it helps.


text:
Q: PdfInfoNotInstalledError on Ubuntu-18 running python convert_from_path pdf2image I am running a python script using the pdf2image library on ubuntu-18.04. I am using the convert_from_path function specifically to convert a pdf to a PIL image. This function works perfectly locally on my mac environment, but when running on Ubuntu on a production server I am receiving this error:
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
I have installed poppler-utils  on ubuntu as stated in the project's github: https://github.com/Belval/pdf2image
However, this error is still persisting and I think I am doing something incorrect with placing these utils in the correct path or not fully installing poppler on Ubuntu. Thanks for any help you can provide!


text:
Q: how to iterate through consecutive lines of a csv file Sorry for the rookie question. I'm trying to iterate through consecutive (tuples) lines of a csv file in python. what I'm trying is this:
with open ('my_file.csv','rb') as f_obj:
    reader=csv.reader(f_obj)
    for f_row , s_row in zip(reader , reader[1:]):
          do something

it does not work with izip as well. Thanks in advance.

A: A csv.reader in an iterator, and as such it can only be read once, then it's exhausted. Also, an iterator is not indexable, so zip(reader , reader[1:]) does not work.
I suggest you use itertools.tee to copy the reader, skip one line on one of the readers, and then zip those:
with open('my_file.csv') as f_obj:
    reader1, reader2 = itertools.tee(csv.reader(f_obj))
    next(reader2) # skip first line in reader2
    for f_row , s_row in zip(reader1, reader2):
          print f_row, s_row

For input file containing numbers 1 through 5 on separate lines, output is
['1'] ['2']
['2'] ['3']
['3'] ['4']
['4'] ['5']


text:
Q: Android GCM push notification shows every day We have a pretty big issue in our app which is set up to receive GCM push notifications: Without launching a push notification, the app receives a push notification - this happens every day!
I've implemented a GCM Client (and obviously the Server side too) pretty much exactly as stipulated here: http://developer.android.com/google/gcm/client.html and here http://developer.android.com/google/gcm/client.html#sample-receive
Here is my onHandleIntent function in my GCMIntentService:
    @Override
    protected void onHandleIntent(Intent intent) {
        Bundle extras = intent.getExtras();
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        // The getMessageType() intent parameter must be the intent you received
        // in your BroadcastReceiver.
        String messageType = gcm.getMessageType(intent);

        if (!extras.isEmpty()) {  // has effect of unparcelling Bundle

            // If it's a regular GCM message (and the user is logged in), do some work.
            if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType) && prefsMan.getLoggedIn(this)) {

            // Post notification of received message.
            sendNotification(extras.getString("message"));
            Log.i(TAG, "Received: " + extras.toString());
            }
        }
        // Release the wake lock provided by the WakefulBroadcastReceiver.
        GcmBroadcastReceiver.completeWakefulIntent(intent);
    }

What is causing the push notification from appearing every day, without it being launched from the server side?
Just as a side note, if I could set a bounty on this today already, I would do it, so please - any help will be appreciated, and I'll eventually give some of my rep to anyone who can help me with this issue, as soon as I'm allowed to do this on SO (two days from now).


text:
Q: TabControl's SelectedItem gets overwritten by NewItemPlaceholder when adding tab I'm working on a WPF TabControl whose last item is always a button to add a new tab, similar to Firefox:

The TabControl's ItemSource is bound to an ObservableCollection, and adding an item to the collection via this "+" button works very well. The only problem I'm having is that, after having clicked the "+" tab, I cannot for the life of me set the newly created (or any other existing tab) to focus, and so when a tab is added, the UI looks like this:

To explain a bit how I'm achieving this "special" tab behavior, the TabControl is templated and its NewButtonHeaderTemplate has a control (Image in my case) which calls the AddListener Command in the view-model (only relevant code is shown):
<Window x:Class="AIS2.PortListener.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ais="http://www.leica-geosystems.com/xaml"
    xmlns:l="clr-namespace:AIS2.PortListener"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
    DataContext="{Binding Source={StaticResource Locator}>

<Window.Resources>
    <ResourceDictionary>
       <DataTemplate x:Key="newTabButtonHeaderTemplate">
            <Grid>
                <Image Source="..\Images\add.png" Height="16" Width="16">
                </Image>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseLeftButtonDown">
                        <cmd:EventToCommand
                         Command="{Binding Source={StaticResource Locator},
                                   Path=PortListenerVM.AddListenerCommand}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="newTabButtonContentTemplate"/>

        <DataTemplate x:Key="itemHeaderTemplate">
            <TextBlock Text="{Binding Name}"/>
        </DataTemplate>

        <DataTemplate x:Key="itemContentTemplate">
            <l:ListenerControl></l:ListenerControl>
        </DataTemplate>

        <l:ItemHeaderTemplateSelector x:Key="headerTemplateSelector"
           NewButtonHeaderTemplate="{StaticResource newTabButtonHeaderTemplate}"
           ItemHeaderTemplate="{StaticResource itemHeaderTemplate}"/>
        <l:ItemContentTemplateSelector x:Key="contentTemplateSelector"
           NewButtonContentTemplate="{StaticResource newTabButtonContentTemplate}"
           ItemContentTemplate="{StaticResource itemContentTemplate}"/>
    </ResourceDictionary>
</Window.Resources>

<TabControl Name="MainTab" Grid.Row="2" ItemsSource="{Binding Listeners}"
            ItemTemplateSelector="{StaticResource headerTemplateSelector}"
            ContentTemplateSelector="{StaticResource contentTemplateSelector}"
            SelectedItem="{Binding SelectedListener}">
</TabControl>

The AddListener command simply adds an item to the ObservableCollection which has for effect to update the TabControl's ItemSource and add a new tab:
private ObservableCollection<Listener> _Listeners;
public ObservableCollection<Listener> Listeners
{
    get { return _Listeners; }
}

private object _SelectedListener;
public object SelectedListener
{
    get { return _SelectedListener; }
    set
    {
        _SelectedListener = value;
        OnPropertyChanged("SelectedListener");
    }
}

public PortListenerViewModel()
{
    // Place the "+" tab at the end of the tab control
    var itemsView = (IEditableCollectionView)CollectionViewSource.GetDefaultView(_Listeners);
    itemsView.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd;
}

private RelayCommand _AddListenerCommand;
public RelayCommand AddListenerCommand
{
    get
    {
        if (_AddListenerCommand == null)
            _AddListenerCommand = new RelayCommand(param => this.AddListener());

        return _AddListenerCommand;
    }
}

public void AddListener()
{
    var newListener = new TCPListener(0, "New listener");
    this.Listeners.Add(newListener);
    // The following two lines update the property, but the focus does not change
    //this.SelectedListener = newListener;
    //this.SelectedListener = this.Listeners[0];
}

But setting the SelectedListener property does not work, even though the TabControl's SelectedItem is bound to it. It must have something to do with the order in which things get updated in WPF, because if I set a breakpoint in the SelectedListener's set I can see the following happening:

*

*this.Listeners.Add(newListener);

*this.SelectedListener = newListener;

*SelectedListener set gets called with correct Listener object

*SelectedListener set gets called with NewItemPlaceholder object (of type MS.Internal.NamedObject according to the debugger)

Is there a way that I can work around this issue? Do I have the wrong approach?

A: I think you are triggering two events when you click the new tab: MouseLeftButtonDown and TabControl.SelectionChanged
I think they're both getting queued, then processing one at a time.
So your item is getting added, set as selected, and then before the re-draw occurs the SelectionChanged event occurs to change the selection to the [+] tab.
Perhaps try using the Dispatcher to set the SelectedItem so it occurs after the TabControl changes it's selection. Or make it so if the user tries to switch to the NewTab, it cancels the SelectionChanged event so the selected tab doesn't actually change (of course, the SelectedTab will be your NewItem since the MouseDown event will have occurred)
When I did something like this in the past, I actually overwrote the TabControl Template to create the AddTab button as a Button, not as a TabItem. I want to suggest doing that instead of using the NewItemPlaceholder in the first place, but I've never tried working with the NewItemPlaceholder so don't really know if it's better or worse than overwriting the Template.

A: Take a look at this post regarding sentinel objects:  WPF Sentinel objects and how to check for an internal type
There are several ways to work around issues with them, that post offers one of them.


text:
Q: SQL QUERY: deleting duplicate rows from different tables with same columns I have two tables with the same columns (ID, name, etc.). But it appears that I have duplicate rows from both of them. I am supposed to move/copy the rows from table1 to table2 but it won't let me since I have a lot of duplicate rows and I can't get the right syntax to merge them properly.
I am using phpMyAdmin, btw.
Can someone help, please? Thank you in advance.

A: Please see the INSERT IGNORE & ON DUPLICATE KEY UPDATE from http://dev.mysql.com/doc/refman/5.5/en/insert.html

A: If you would simply like to delete the rows which are duplicates, do a JOIN like this:
DELETE table1.*
FROM table1
INNER JOIN table2 ON table2.Id = table1.Id


text:
Q: AES MixColumns with Python I am trying to create an aes mix column function in python. But the result is not as expected. What am I doing wrong?
Here I test on the first column.
[2, 3, 1, 1, 1, 2, 3, 1, 1, 1, 2, 3, 3, 1, 1, 2]
[0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255]

print((0*2)^(17*3)^(34*1)^(51*1))
print((0*1)^(17*2)^(34*3)^(51*1))
print((0*1)^(17*1)^(34*2)^(51*3))
print((0*3)^(17*1)^(34*1)^(51*2))

The result is as follows:
34
119
204
85

What I think is the expected result is:
34
119
0
85

Is the expected result wrong or am I doing wrong?

A: In the posted code, the multiplication is implemented wrongly. Multiplication is modulo irreducible polynomial x8 + x4 + x3 + x + 1 in the Galois field GF(28). This is described in detail in the Wikipedia article Rijndael MixColumns. Here you can also find various implementations. Another, easier to understand description can be found on SO in the accepted answer to the post How to solve MixColumns?.
In the following implementation the multiplication (with 1, 2 and 3) is implemented in the function gmul():
def mixColumns(a, b, c, d):
    printHex(gmul(a, 2) ^ gmul(b, 3) ^ gmul(c, 1) ^ gmul(d, 1))
    printHex(gmul(a, 1) ^ gmul(b, 2) ^ gmul(c, 3) ^ gmul(d, 1))
    printHex(gmul(a, 1) ^ gmul(b, 1) ^ gmul(c, 2) ^ gmul(d, 3))
    printHex(gmul(a, 3) ^ gmul(b, 1) ^ gmul(c, 1) ^ gmul(d, 2))
    print()

def gmul(a, b):
    if b == 1:
        return a
    tmp = (a << 1) & 0xff
    if b == 2:
        return tmp if a < 128 else tmp ^ 0x1b
    if b == 3:
        return gmul(a, 2) ^ a

def printHex(val):
    return print('{:02x}'.format(val), end=' ')

# test vectors from https://en.wikipedia.org/wiki/Rijndael_MixColumns#Test_vectors_for_MixColumn()
mixColumns(0xdb, 0x13, 0x53, 0x45) # 0x8e 0x4d 0xa1 0xbc
mixColumns(0xf2, 0x0a, 0x22, 0x5c) # 0x9f 0xdc 0x58 0x9d
mixColumns(0x01, 0x01, 0x01, 0x01) # 0x01 0x01 0x01 0x01
mixColumns(0xc6, 0xc6, 0xc6, 0xc6) # 0xc6 0xc6 0xc6 0xc6
mixColumns(0xd4, 0xd4, 0xd4, 0xd5) # 0xd5 0xd5 0xd7 0xd6
mixColumns(0x2d, 0x26, 0x31, 0x4c) # 0x4d 0x7e 0xbd 0xf8

# example from question
mixColumns(0, 17, 34, 51) # 0x22 0x77 0x00 0x55 = 34 119 0 85

with the output:
8e 4d a1 bc
9f dc 58 9d
01 01 01 01
c6 c6 c6 c6
d5 d5 d7 d6
4d 7e bd f8
22 77 00 55

The first 6 lines are the results to the test vectors from the Wikipedia article. The last line corresponds to the example from the posted question: 0x22, 0x77, 0x00, 0x55 or 34, 119, 0, 85 decimal. As you can see, the third value is 0 not 204.

A: It seems you are doing wrong : answer of (0*1)^(17*1)^(34*2)^(51*3) is 204.

*

*(0*1)  = 00000000

*(17*1) = 00010001

*(34*2) = 01000100

*(51*3) = 10011001
Then applying XOR operator on these lines result in : 11001100.
XOR operator sets each bit to 1 if only one of two bits is 1. That means for each bits, if  there is an odd number of 1, the resulting bit will be set to 1.
Please explain how you computed 0 if this answer doesn't help you to understand why the answer is 204.


text:
Q: Determine all homomorphism $\varphi : \mathbb{Z}^{+}\rightarrow \mathbb{Z}^{+}$
Determine all homomorphism $\varphi : \mathbb{Z}^{+}\rightarrow \mathbb{Z}^{+}$, and determine which are injective, surjective, and isomorphism.

Answer of first part:Note that $\varphi (a+b) =\varphi(a)+\varphi(b), a,b\in \mathbb{Z}^+$
Then for $n\in \mathbb{Z}^+$
$\varphi (n) =\varphi (1+1+\dots + 1\space[\text{$n$ times]}), \text{when}\space n>0\\ \varphi(n)=\varphi(0) ,\space \text{when $n=0$}\\ \varphi (n) =\varphi (-1-1-\dots - 1\space[\text{$n$ times]}), \text{when}\space n<0$
i.e.$ \varphi (n) =n\varphi(1)$
Surjective part is clear since it is only for $\varphi(1)=+1, -1$.
Now if $\varphi(1)\neq 0$ all $\varphi$'s are injective, isn't??And what about isomorphism? Where am I wrong!! Please help me.

A: All $\varphi$ are injective (except the trivial homomorphism) as $|Ker (\varphi)|=1$. The only surjective homomorphism is $\varphi(1)=1,-1$, else there is no $n$ such that $\varphi(n)=1$. This also determines the only isomorphisms.


text:
Q: How do I create a static class using DOJO in Javascript I am trying to create a Utility class in JavaScript and am using the Dojo framework. I can't find anywhere on here about how to properly create a static class within the Dojo framework. I don't want to have to create a new Utility object every time. I would prefer not to use a Singleton either.
I currently have something like this...
//Util.js

define(["dojo/_base/declare",
    "dojo/domReady!"], function (declare) {
        return declare(null, {
            //Pass in string format of element's ID
            clearTextBox: function (elemID) {
                document.getElementById(elemID).value = "";
            }
        });
    });

NOTE: I am using AMD not Legacy code

A: As alluded to in one of the comments, you don't need a "class" at all to do what you are asking.  This is JavaScript, not Java or C# or etc.
You just need to define a module which returns an object with utility functions.
define([], function () {
    return {
        clearTextBox: function (id) {
            document.getElementById(id).value = '';
        }
    };
});

This is a very common practice, even employed by Dojo itself for utility modules such as dojo/_base/array, dojo/_base/lang, and dojo/date.
This also does not create a new object each time, as each AMD module is only ever loaded once, and its factory function is only ever executed once.
Dojo is a toolkit, not a framework, and generally never forces you to do something a certain way.  Don't get trapped into thinking that every module you ever create needs to be a "class" using declare.  Use declare when you need to define a constructor or mixin with inheritance capabilities.


text:
Q: sock failed (2: No such file or directory) Django 1.8, Nginx, Gunicorn I am confused by 502 error at my django project. As far as I understand nginx fails to pass to gunicorn, but I am not sure. I followed all steps from here very accurately https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
/etc/systemd/system/gunicorn.service:
[Unit]
Description=gunicorn daemon
After=network.target[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=root
Group=www-data
WorkingDirectory=/home/root/glboy
ExecStart=/home/root/glboy/denv/bin/gunicorn --workers 3 --bind unix:/home/root/glboy/closer.sock closer.wsgi:application

[Install]
WantedBy=multi-user.target

/etc/nginx/sites-available/closer and /etc/nginx/sites-enabled:
server {
    listen 80;
    server_name 46.101.192.66;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/glboy/static;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/root/glboy/closer.sock;
    }
}

also found tutorial where /etc/nginx/sites-available/default was also edited, tried as well despite I do not fully understand the purpose :
 server {
    listen 80;
    server_name 46.101.192.66;
    access_log  /var/log/nginx/example.log;

    location /static/ {
        root /home/glboy/static;
        expires 30d;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }

In nginx error log absence of socket is reported
/home/root/glboy/closer.sock failed (2: No such file or directory)

I just copied the path how should it be according to instruction, but if it's wrong what path is right or what is wrong otherwise?


text:
Q: How to go (seek) particular timestamp on Video in React native (Expo) I am using the expo-cli for application and I am using expo install expo-av for display video in application.
I need functionality, when i click on button to directly got particular time (Ex. 5 minutes)
For example:
Video length is 28 seconds and i Have button to go to 15 second. So when i click this button to this time and then play
Here is my code:
import * as React from 'react';
import { View, StyleSheet, Button, Text } from 'react-native';
import { Video, AVPlaybackStatus } from 'expo-av';

export default function App() {
  const video = React.useRef(null);
  const [status, setStatus] = React.useState({});

  return (
    <View style={styles.container}>
      <Video
        ref={video}
        style={styles.video}
        source={{
          uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4',
        }}
        useNativeControls
        resizeMode="contain"
        onPlaybackStatusUpdate={status => setStatus(() => status)}
      />
      <View style={styles.buttons}>
        <Button
          title={status.isPlaying ? 'Pause' : 'Play'}
          onPress={() =>
            status.isPlaying ? video.current.pauseAsync() : video.current.playAsync()
          }
        />
      </View>
      <Button
        title={'Goto to 15 seconds'}
        onPress={() => {
          console.log("status.positionMillis --> ", status.positionMillis)
        }}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
  },
  video: {
    alignSelf: 'center',
    width: 320,
    height: 200,
  },
  buttons: {
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
  },
});

A: I know that I am a bit late to this question, but I suggest that you use positionMillis.
     <Video
        ref={video}
        style={styles.video}
        source={{
          uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4',
        }}
        useNativeControls
        resizeMode="contain"
        onPlaybackStatusUpdate={status => setStatus(() => status)}
        positionMillis={this.state.time} //set to whatever you want
      />


text:
Q: ion-select component of Ionic 3 not working in IOS 9 We have developed one application using Ionic 3. We have used ion-select component at multiple places. In android & IOS version > 10, everything is working fine as expected.
But In IOS 9, ion-select component breaks. It shows blank options when tapping on ion-select.
<ion-item>
   <ion-label>Gender</ion-label>
   <ion-select>
     <ion-option value="f">Female</ion-option>
     <ion-option value="m">Male</ion-option>
   </ion-select>
</ion-item>

Result:

Environment Details:
Specific IOS version in which issue is reproducible: 9.3.5
global packages:
@ionic/cli-utils : 1.5.0
Cordova CLI      : 6.5.0
Ionic CLI        : 3.5.0

local packages:
@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : android 6.1.2 ios 4.2.1
Ionic Framework                 : ionic-angular 3.7.1-201710060319

System:
Node       : v7.8.0
OS         : OS X El Capitan
Xcode      : Xcode 8.2.1 Build version 8C1002
ios-deploy : 1.9.1
ios-sim    : 5.0.13
npm        : 4.2.0

A: I was able to resolve the issue by downgrading the app-scripts version to 2.1.4 from 3.0.1.
I also had to add dev dependency tsc-wrapped to resolve some ts lint issues.
"devDependencies": {
    "@angular/tsc-wrapped": "^4.4.6",
    "@ionic/app-scripts": "2.1.4",
    "typescript": "2.3.4"
},

After changing my configuration to above, the webpack process duration came down to 3-4 minutes from 35 minutes.


text:
Q: Disloyal Whiterun Horse The horse I bought from the stables next to Whiterun starts to walk away when I dismount it. I bought another horse to fix this problem. It is the palomino one from one of the northern Holds. This one does not run away when I dismount it, but the other one still does. Is there any way to fix this?
I know it is not necessary to fix the Whiterun horse since the other one is working, but I'm just curious as to why this is happening. I have tried loading previous saves, but that hasn't worked.

A: Fix 1
According to the UESP:

Only the horse that you last rode will travel with you. Horses you bought will return to where they were purchased as soon as you mount a different horse, while horses obtained as quest rewards will stay where you leave them.

See if you go back to Whiterun Stable, you can mount your horse and it will be loyal to you.
Fix 2
A way to fix this is to target the horse in the console, then type:
disable

and then
enable

Fix 3
You can also try to target your player and then use setownership <ID>
With ID being the Horse's ID.
From the UESP:

You can set the owner of the targeted item with a faction ID or a character's base ID. If you don't add the parameter, the default owner would be yourself. This can be used to remove the "stolen" tag from any items. Simply drop the item on the ground, open the console, click on the item, and enter the command. It can be difficult to select certain items. If the displayed ID code does not begin with "ff", you have not selected an item, but rather an object in the world (ground texture, light, container, etc.). Can also be used to remove the "owned" attribute of beds and gain the ownership of a stolen horse.

Why it might happen:
There is a couple of things that can go wrong here:

*

*The ownership has not been set properly (fix 3)

*The AI of the horse does not recognize your position (fix 1 or 2)


text:
Q: inequality, preferably using elementary methods I was trying to prove an inequality with 3 variables, and after simplification, it boiled down to trying to prove
$$x^2 y+xz^2 +y^2 z \geq x+y+z$$, where $xyz=1$, and $x,y,z$ are all positive real numbers.
Once, I prove this I would be able to prove the overall inequality, however I am stuck at this part. The original question is supposed to be an olympiad style question, so i hope that i can prove this lemma without Lagrange Multipliers, etc.
Sincere thanks for any help!
(I have tried AM-GM, but that would lead to $x^2 y+xz^2 +y^2 z \geq 3\sqrt[3]{x^3y^3z^3}=3$ which is not sharp enough)

A: Hint: By AM-GM,
$$x^2y+x^2y+xz^2\ge 3\left(x^5y^2z^2\right)^{\frac{1}{3}}=3x.$$


text:
Q: Adding An ArrayList To Another ArrayList I am currently studying for the Java Programmer 1 certificate and the following piece of code came up about adding an ArrayList to another.
ArrayList<String> myArrList = new ArrayList<String>();
            myArrList.add("One");
            myArrList.add("Two");
            ArrayList<String> yourArrList = new ArrayList<String>();
            yourArrList.add("Three");
            yourArrList.add("Four");
            myArrList.addAll(1, yourArrList);
            for (String val : myArrList)
             System.out.println(val);

This is what the author then says:

What happens if you modify the common object references in these
  lists, myArrList and yourArrList? We have two cases here:
In the first one, you reassign the object reference using either of the lists. In
  this case, the value in the second list will remain unchanged.
In the second case, you modify the internals of any of the common list
  elements,in this case, the change will be reflected in both of the
  lists.

What is the author trying to say?? I am a bit confused about the 2 cases he mentions!
Any help would be greatly appreciated.

A: I think I know what the author is trying to say. But Strings are a bad example to do it with. Imagine something like this. He is explaining the difference between adding two different instances of a class to the lists, or adding the same instance to both lists. When you add the same instance to both lists, if you modify that instance the change is reflected in both lists.
import java.util.ArrayList;

public class Example {

    private static class Node {
        private int value;

        public Node(final int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }

        public void setValue(final int value) {
            this.value = value;
        }
    }

    public static void main(final String... args) {
        final ArrayList<Node> nodes1 = new ArrayList<>();
        final ArrayList<Node> nodes2 = new ArrayList<>();

        // add two different Node objects that happen to have same value
        nodes1.add(new Node(1337));
        nodes2.add(new Node(1337));

        Node node = new Node(69);

        // add the same node to both lists
        nodes1.add(node);
        nodes2.add(node);

        node.setValue(420);

        // do your join here and print result to see {1337, 420, 1337, 420}
        nodes1.addAll(0, nodes2);
        for (final Node n : nodes1)
            System.out.println(n.getValue());
    }

}


text:
Q: Resize partition for Ubuntu/Windows dual-boot I'm dual-booting Windows 8.1 and Ubuntu 14.04. While installing, I gave Ubuntu 50GB of my disk space but now I'm finding that it is small for me. So is there any way I can decrease my Windows C: drive and increase the Ubuntu partition without affecting dual-boot. I've read posts saying how to do it but I'm afraid that I'll mess up my dual-boot and break my bootloader.
My GParted:

I want to take 50GB from from C: Drive(/dev/sda4) and give it to the Ubuntu drive(/dev/sda9). Please guide me through it.
UPDATE : I removed 50GB from my C: drive but I am now unable to add it to my /home directory. I can only make that 50GB into a new partition which is not what I need. Is there any way how I can add that 50GB to /dev/sda9.

The /dev/sda10 [50GB Volume] is the one I want to delete and add to /dev/sda9.


text:
Q: Are black hole regarded as baryonic matter in cosmology? Black holes do not have any property as baryonic or non-baryonic matter, as is stated by the no-hair theorem. Regarding conventional theories, in different models of cosmology, like Lambda-CDM, are black holes regarded as baryonic matter, and does the black hole matter significantly affect the baryonic density?

A: Baryonic doesn't literally mean baryonic. It's a label of convenience for something that behaves in a certain way. The main evidence for dark matter comes from big bang nucleosynthesis (BBN), and from the fact that we need it in order to reconcile the observed rotation curves of galaxies with the observed strength of the CMB fluctuations. In the BBN era, presumably we didn't have any black holes, so the issue doesn't arise. If we want to explain a galaxy's rotation curve, then a black hole is exactly the same as any other star, so it would presumably go on the census as baryonic matter, but in any case black holes are a negligible fraction of baryonic matter, and they always will be. (There is a common misconception that all matter will end up in black holes, which simply isn't true.)


text:
Q: Separar palabras y guardar en array en C++ Estoy intentando de un texto tipo string, separar todas las palabras y luego meterlas en un arreglo. Por ejemplo: Texto="La casa es amarilla" -- Arreglo={"La","casa","es","amarilla"}
No se me ocurre una lógica para darle recorrer el arreglo, darle un stop cuando haya espacio y guardar lo que encontro y luego volver a repetir..
Aqui mi codigo:
int main(){
string texto="La casa es amarilla";
int contador=1;
for (int i=0;i<texto.length();i++){
if (texto[i]==' ')
{
    contador++;
}
}
string palabras[contador];
for (int i=0;i<texto.length();i++){

//No se como seguir
}

}

A: Puedes ocupar otro string a modo de buffer para ir almacenando la letras hasta encontrar un espacio, cuando pase eso vuelcas toda esa información (que sería una palabra) al array
int main()
{
    string texto="La casa es amarilla";
    int contador=1;
    for (int i=0;i<texto.length();i++){
        if (texto[i]==' ')
        {
            contador++;
        }
    }

    string palabras[contador];
    string palabraAux="";
    int index=0; //para recorrer el arreglo
    for (int i=0;i<texto.length();i++){

        //si es un espacio volcamos todo lo guardado en palabraAux al array
        if (texto[i]==' ')
        {
            palabras[index] = palabraAux;
            index++;
            palabraAux="";
        }
        else{ //si es una letra, la concatenamos a palabraAux para guardarla
            palabraAux+=texto[i];
        }
    }
    //agregamos la última palabra, que siempre quedará fuera del for anterior
    palabras[index] = palabraAux;

    //Imprimir resultado
    for (int i=0;i<contador;i++){
        cout<<"\n"<<palabras[i];
    }

    return 0;
}

Update
Siguiendo la recomendación de @PaperBirdMaster, y además esta excelente publicación voy a añadir una respuesta utilizando vector.
El único punto a considerar es el contexto de la pregunta original, la cual evidentemente se refiere a alguna tarea de un curso básico de programación, por lo que utilizar este método puede resultar fuera de lugar.
#include "iostream"
#include "string"
#include <vector>
using namespace std;
int main()
{
    string texto="La casa es amarilla";
    int contador=1;
    for (int i=0;i<texto.length();i++){
        if (texto[i]==' ')
        {
            contador++;
        }
    }

    std::vector<string> palabras(contador);
    string palabraAux;
    int index=0; //para recorrer el arreglo
    for (int i=0;i<texto.length();i++){

        //si es un espacio volcamos todo lo guardado en palabraAux al array
        if (texto[i]==' ')
        {
            palabras[index] = palabraAux;
            index++;
            palabraAux="";
        }
        else{ //si es una letra, la concatenamos a palabraAux para guardarla
            palabraAux+=texto[i];
        }
    }
    //agregamos la última palabra, que siempre quedará fuera del for anterior
    palabras[index] = palabraAux;

    //Imprimir resultado
    for (int i=0;i<contador;i++){
        cout<<"\n"<<palabras[i];
    }

    return 0;
}

A: Algo mucho más sencillo, puedes utilizar la función strtok() para dividir la cadena con los delimitadores que le definas, en este caso serán los espacios, veamos:
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    char str[100] = "La casa es amarilla";

    char *ptr;
    ptr = strtok(str, " , ");

    while (ptr != NULL)
    {
        cout << ptr  << endl;
        ptr = strtok (NULL, " , ");
    }
    return 0;
}

Ouput:
// La
// casa
// es
// amarilla

A: Utilizando el metodo substr() puedes obtener substrings determinado por un rango, siendo el primer argumento la posicion del primer caracter hasta la posicion indicada por el segundo argumento, seria algo como substr(inicio,fin) y el fin es delimitado por la posicion del caracter espacio y para obtenerlo se usa el metodo find(' ') y su argumento es caracter espacio, luego para que se repita este proceso se elimina del texto la primera palabra usando erase() pasando como argumento el mismo rango que se le entrego al substr() pero el segundo argumento incrementado en uno.
#include <iostream>

using namespace std;

int main(){
    string texto = "La casa es amarilla";
    int contador = 1;

    for(size_t i = 0; i < texto.length(); i++){
        if(texto[i] == ' '){
            contador++;
        }
    }

    string palabras[contador];

    for(int i = 0; i < contador; i++){
        palabras[i] = texto.substr(0,texto.find(' '));
        texto.erase(0,texto.find(' ') + 1);
    }

    for(int i = 0; i < contador; i++){
        cout<<palabras[i]<<"\n";
    }

    return 0;
}


text:
Q: Getting error : Unable to Use Amazon Authorization Manager. APIKey is incorrect or does not exist I am trying to use Amazon Alexa in my android App.
I have added api_key.txt in my asset folder but still getting above error.

A: the api_key should be generated from the android developer site withe the MD5 and SHA-256 of your application then only it will work properly. Check the link for detailed information.
https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/getting-started-with-the-alexa-voice-service

A: We just need to correct the android applicationID ID with applicationID mentioned in amazon developer portal.
In Android Studio Right click 'app'>Open Module Settings>Flavors
The "Application Id" should be match
Amazon Developer Console>Alexa>Alexa Voice Service>Your Registered Products>Security Profile>Android/Kindle Settings>Package


text:
Q: Show that the following $\phi: \mathbb{R}\to GL_{2}(\mathbb{R})$ is not a homomorphism.
Show that $\phi: \mathbb{R}\to GL_{2}(\mathbb{R})$ defined by $\phi(a) = \begin{bmatrix}
1 &a \\
1 & 0
\end{bmatrix}$ is not a homomorphism.

I know I can show this by showing it does not preserve the operations, however I want to show this by showing it is not well-defined. Can I just say that since $\phi(0)\notin GL_{2}(\mathbb{R})$, it is not well-defined?

A: It's a bad question because you can answer it that way. I think you may want to add that as a comment, but also extend the codomain to all matrices and show it's still not a homomorphism.
I should mention the professors always loved to read my homework because of the detail,  and when they handed out the answers sometimes they copied mine verbatim. You may be shooting for less effort, in which case your answer should be fine.

A: No. Asking if a function is a homomorphism does not make sense when it is not well defined.


text:
Q: How to Re-bind / Refresh Dom after ajax call in vuejs2 (like $scope.$apply in angularjs)? I am using vue.js 2 with webpack template. i am new to vue.js.
i want to bind DOM after data is received in ajax call.
here in my code contains v-for in which the response html is need to bind with v-html="tHtml[index]" every time after data is received from api call.
What can be used to re-bind or refresh view/DOM as we use $scope.$apply() in angularjs.
home.vue
<template>

{{msg}}

</template>


text:
Q: How Route 53 servers get into the DNS resolver chain? I am using the following typical DNS resolution procedure as a reference to my question toward using AWS Route 53 as the DNS server(s).

Let's say, I registered example1.com with Route53 and use it as my DNS service and I registered example2.com with Godaddy and use Godaddy DNS service.
From the above diagram, it seems to me that DNS servers being contacted/reached before Step 4 would be identical. My question is how would the .COM server be able to return Route53 servers as the DNS server list for example1.com, and return Godaddy servers as the DNS server list for example2.com

A: Simply because your DNS servers are registered with your domain.
If you make a whois domain.com on a domain or a dig domain.com NS you will see which dns servers are registered


text:
Q: Trying to use a function that returns three values as the input for a function that takes 3 values I have a function that does a few things, but ultimately returns three lists.
I have another function, a set method in a class, which takes three inputs.
When I try to use the first function as the argument for the set function, it complains that there's not enough inputs, despite the fact its returning the right amount. Is there a way around this? Should I just declare some temporary local variables to do this?
a simplified version of my code
class hello(object):
    a, b, c = 0, 0, 0
    def __init__(self, name):
        self.name = name

    def setThings(one, two, three):
        self.a = one
        self.b = two
        self.c = three

def someStuff(x, y, z):
    newX = x * 1337
    newY = y * 420
    newZ = z * 69
    return newX, newY, newZ

first = int(input("first"))
second = int(input("second"))
third = int(input("third"))
kenzi = hello(input("name pls"))
kenzi.setThings(someStuff(first, second, third))

A: Add a asterix before the function when calling it as a argument.
kenzi.setThings(*someStuff(first, second, third))


text:
Q: JQuery Animation: Animate DIV left to right at different speed than top to bottom trying to animate 1 DIV at a certain speed left to right (and back), and also animate it top to bottom (and back) at a different speed (essentially creating a windows-like screensaver effect).
problem is that each animation occurs after each other (obviously) but i'm hung up on trying to combine so that the image will animate diagonally.
coming from CSS animation this is easy, but with that it can't detect responsive window width/height so bounce edges get real wonky.
any ideas? big thanks.
code so far is:
$(document).ready(function() {

    updateWindowsize();
    $(window).resize(function() {
        updateWindowsize();
    });
    bounceBounce();

});

var imageWidth = '540'
    imageHeight = '705'

function updateWindowsize() {
    var $window = $(window);
    windowHeight = $window.height();
    windowWidth = $window.width();
}

function bounceBounce() {

    $('.div-1').animate({"left": windowWidth - imageWidth}, 3000, 'linear',
          function(){ $(this).animate({left: 0}, 3000, 'linear');
    });

    $('.div-1').animate({"top": windowHeight - imageHeight}, 6000, 'linear',
          function(){ $(this).animate({top: 0}, 6000, 'linear');
    });

    bounceBounce();

};

A: Did you try this:
$('.div-1').animate({"left": windowWidth - imageWidth, "top": windowHeight - imageHeight}, 6000, 'linear',
      function(){ $(this).animate({left: 0, top: 0}, 6000, 'linear');
});


text:
Q: Determining whether a UTC timestamp is within a time range in a timezone? Let's frame this problem as a scheduling application. Users specify a minimum time in their timezone ("8am" in "America/New_York") after which they're willing to take appointments. (we also have a similar constraint on the maximum time)
Given an incoming appointment request (say, for 2016-09-07 03:00:00 in UTC time), we need to determine which users can take the appointment.
How can we determine whether a UTC timestamp is between two timezone-adjusted times?
My approach has been to convert the incoming timestamp to the user's timezone, extract the time portion and compare it to the time constraints:
SELECT * FROM users u WHERE
   ('2016-09-07 03:00:00' AT TIME ZONE u.timezone)::time >= u.earliest_start_time AND
   ('2016-09-07 03:00:00' AT TIME ZONE u.timezone)::time <= u.latest_stop_time

(earliest_start_time and latest_stop_time are of type time without time zone; timezone is an Olson tz string)
There's all sorts of odd behavior as timezone offsets causes days to roll over and I'm just generally very confused and hazy about this.

A: To make the code below more readable, suppose that the placeholder $1 holds a value of type timestamp with time zone. Then the following query will find all users that are available at that time:
SELECT * FROM users u WHERE
    $1 BETWEEN
      ($1::date || ' ' || u.earliest_start_time)::timestamp without time zone AT TIME ZONE u.timezone
    AND
      ($1::date || ' ' || u.latest_stop_time)::timestamp without time zone AT TIME ZONE u.timezone;

Explanation: we take $1 which is a timestamp with time zone and we keep only the date part by type casting it into a date. Then we take earliest_start_time which is a time and combine it with the previous date and we get full time stamp which doesn't have time zone information (yet). Then we specify the time zone to convert that into a timestamp with time zone. We do the same for latest_stop_time. So now that we have found those 2 timestamp with time zone values, we can just compare them with $1 which has the same type.
This will have problem with ambiguous timestamps though (i.e. in the transition from DST to standard time), but you cannot avoid that. If you only use it for typical businesses hours, it might be ok.


text:
Q: Which is better to use in Android, a 1px*1px .png image or a drawable .xml with a solid rectangle? Which is better to use in Android and why?

*

*Load a .png file that is 1x1 and has, obviously, one pixel of one color (ie #000)

*Use an .xml drawable that contains a solid rectangle of the same solid color (#000)

A:
Which is better to use in Android and why?

Use an .xml drawable that contains a solid rectangle of the same solid color (#000).
Why? Because that's the point of the XML layouts, is to enable developers to quickly make changes to visuals (in this case colors) without having to open image-editing software.
If you were to really only load a 1x1 PNG then some could argue the PNG loading is faster, but in reality, this is never going to happen. The point here is that it will be stretched or manipulated in some way, or set to tile as a background and this will eventually be slower than defining a background color or shape in Android XML Layout.

A: i think that png is better, because is native and take less time to load.xml is needed parser, so is a little low than png. i think, but i never tried it.
UPDATE
i make a files with these specifications, and the results are those:
png 1x1 black dot [119 bytes]
xml rectangle blac [261 bytes]
UPDATE 2
Performance wise, what is typically better, using an image or a xml created shape as a drawable?

A: For a single color, use a color resource. http://developer.android.com/guide/topics/resources/more-resources.html#Color This will be more performant than a 1x1 stretched image or an xml drawable.
As general performance guidelines, solid colors are the cheapest, followed by unstretched bitmaps, followed by 9-patches and stretched bitmaps. Shape drawables are usually the most expensive at runtime.


text:
Q: How to apply gesture handling greedy for Embedded Maps in IFrame (React) I want to allow single finger touch for mobile devices instead of using double fingers for gestures and for web need scrolling feature  on an embedded map.
I found out that I can use gesture handling "greedy" or "cooperative" to achieve this but I am not able to understand where to apply it in my code.
Code:
const MY_API = configData.googleMapKey;

  let _url = `https://www.google.com/maps/embed/v1/directions?key=${MY_API}&origin=${queryPickup}&destination=${queryDrop}`;

  return(

        <div>
          <iframe  frameBorder="0" width="100%" height="350" style={{ border: 0 }} src={_url}>
          </iframe>
        </div>

  );

};


text:
Q: Implementing Proguard Security with my APK I want to configure proguard with my Application. But while doing so I am receiving the following problems :
[2013-09-24 12:27:46 - DemoProguard] Proguard returned with error code 1. See console
[2013-09-24 12:27:46 - DemoProguard] Warning: com.google.android.gms.internal.bn$b: can't find referenced method 'android.view.Display getDisplay()' in class android.view.View
[2013-09-24 12:27:46 - DemoProguard] Warning: com.google.android.gms.internal.bn$b: can't find referenced method 'void removeOnGlobalLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener)' in class android.view.ViewTreeObserver
[2013-09-24 12:27:46 - DemoProguard]       You should check if you need to specify additional program jars.
[2013-09-24 12:27:46 - DemoProguard] Warning: there were 2 unresolved references to program class members.
[2013-09-24 12:27:46 - DemoProguard]          Your input classes appear to be inconsistent.
[2013-09-24 12:27:46 - DemoProguard]          You may need to recompile them and try again.
[2013-09-24 12:27:46 - DemoProguard]          Alternatively, you may have to specify the option
[2013-09-24 12:27:46 - DemoProguard]          '-dontskipnonpubliclibraryclassmembers'.
[2013-09-24 12:27:46 - DemoProguard] java.io.IOException: Please correct the above warnings first.
[2013-09-24 12:27:46 - DemoProguard]    at proguard.Initializer.execute(Initializer.java:321)
[2013-09-24 12:27:46 - DemoProguard]    at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-09-24 12:27:46 - DemoProguard]    at proguard.ProGuard.execute(ProGuard.java:86)
[2013-09-24 12:27:46 - DemoProguard]    at proguard.ProGuard.main(ProGuard.java:492)
[2013-09-24 12:40:50 - DemoProguard] Proguard returned with error code 1. See console
[2013-09-24 12:40:50 - DemoProguard] Warning: com.google.android.gms.internal.bn$b: can't find referenced method 'android.view.Display getDisplay()' in class android.view.View
[2013-09-24 12:40:50 - DemoProguard] Warning: com.google.android.gms.internal.bn$b: can't find referenced method 'void removeOnGlobalLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener)' in class android.view.ViewTreeObserver
[2013-09-24 12:40:50 - DemoProguard]       You should check if you need to specify additional program jars.
[2013-09-24 12:40:50 - DemoProguard] Warning: there were 2 unresolved references to program class members.
[2013-09-24 12:40:50 - DemoProguard]          Your input classes appear to be inconsistent.
[2013-09-24 12:40:50 - DemoProguard]          You may need to recompile them and try again.
[2013-09-24 12:40:50 - DemoProguard]          Alternatively, you may have to specify the option
[2013-09-24 12:40:50 - DemoProguard]          '-dontskipnonpubliclibraryclassmembers'.
[2013-09-24 12:40:50 - DemoProguard] java.io.IOException: Please correct the above warnings first.
[2013-09-24 12:40:50 - DemoProguard]    at proguard.Initializer.execute(Initializer.java:321)
[2013-09-24 12:40:50 - DemoProguard]    at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-09-24 12:40:50 - DemoProguard]    at proguard.ProGuard.execute(ProGuard.java:86)
[2013-09-24 12:40:50 - DemoProguard]    at proguard.ProGuard.main(ProGuard.java:492)

Here is my proguard-text file
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:
-dontskipnonpubliclibraryclassmembers

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

A: try to add these line very first on our proguard.cfg file on your project as below:
-ignorewarnings

if you have any annotation in your project so, please add the next line as below
-keepattributes *Annotation*

and ensure your gradle file has minifyEnabled as false


text:
Q: I'm trying to add new product on my new project. But why it's show (no such table: main.auth_user__old) I'm trying to add new product details on product table. But whenever I try to save this it's show me
OperationalError at /admin/products/product/add/
*Here are errors detail: *
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/products/product/add/
Exception Type: OperationalError at /admin/products/product/add/
Exception Value: no such table: main.auth_user__old
This is model
from django.db import models

class Product(models.Model):
    name = models.CharField(max_length=255)
    price = models.FloatField()
    stock = models.IntegerField()
    image_url = models.CharField(max_length=2088)

class Offer(models.Model):
    code = models.CharField(max_length=10)
    description = models.CharField(max_length=255)
    discount = models.FloatField()

admin
from django.contrib import admin
from .models import Product

admin.site.register(Product)

A: I don't know if you are still struggling with this, but I had the same issue. The solution was deleting and re-downloading db.sqlite3 with an older version of django.

*

*Go to the virtual environment and install django(version 2.1.7)
pip install django==2.1.7

*Delete the db.sqlite3 file in your root folder. (Search for it in your PyCharm projects in the root folder if that's where it's stored)

*Create a new db.sqlite3 by doing python manage.py makemigrations

*Re-run migrations, after doing python manage.py makemigrations run python manage.py migrate .


text:
Q: Excel - Refreshing PivotTable data as Power Query auto refreshes PivotTable source I have a database which auto refreshes and updates the table from an external source every 15 minutes. I tried the following code which updates the PivotTable every time the source data is edit/added/deleted:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("PIVOT TABLE WORKSHEET").PivotTables("PIVOT TABLE NAME").RefreshTable
End Sub

When i manually edit the source data, the PivotTables refresh accordingly. However, when the source data is updated automatically the PivotTables remain unchanged. Is there a way to make the Pivot tables refresh together with the database without the need of a user input?

A: You'll have better results if you use the Worksheet_Change event instead of the Worksheet_SelectionChange event, so that the procedure runs when data changes, not when you select a cell with the mouse or keyboard.

Worksheet_Change vs. Worksheet_SelectionChange events

*

*Worksheet_SelectionChange fires when the selection changes on a worksheet.
  For example, when the user clicks on a cell, or pushes an arrow key.

*Worksheet_Change fires when cells on the worksheet are changed, either by the user or by an external link.
Note: Worksheet_Change does **not** occur when cells change during a re-calculation; use theCalculate` event to trap a sheet re-calculation.)

Depending on how the data is laid out in your worksheet(s), you may want to limit the execution of this procedure by checking which cell(s) were changed, which is easiest overall by comparing the event procedure's Target parameter to a specific cell or cell-range, using the Intersect function.

 Caution: Beware of infinity!
When using code that changes cells within the area being "watched" by the Worksheet_Change event procedure, you risk entering into an infinite loop, since the change fires the event again, which changes cells again, etc.

(Click image to enlarge.)
There are several ways this could be avoided. This most common is to temporarily disable events with the Application.EnableEvents property while the Change event does what it needs to do.  (Don't forget to re-enable events at the end of the procedure... see example below.)

Example:
Here's an untested example using all these points:
Private Sub Worksheet_Change(ByVal Target As Range)
    Const cellsToWatch = "A1:D4"
    With Worksheets("PIVOT TABLE WORKSHEET")
        'exit the procedure if at least part of the changed cells were not within `A1:D4`
        If Application.Intersect(.Range(cellsToWatch), Target) Is Nothing Then
            'the change wasn't within `cellsToWatch`
            Exit Sub
        End If
        Application.EnableEvents = False 'disable execution of this or other events

        '----------Run your code here:--------------
        .Calculate
        .PivotTables("PIVOT TABLE NAME").RefreshTable
        '-------------------------------------------

        Application.EnableEvents = True  're-enable events
    End With
End Sub

More Information:

*

*MSDN : Worksheet_Change event (Excel)

*MSDN : Worksheet_SelectionChange event (Excel)

*MSDN : Application.Intersect method (Excel/VBA)

*Office Support : Intercept function (Excel/Worksheet)

*Stack Overflow : Stop Excel from firing Worksheet_Change before _BeforeSave?

*MSDN : Application.EnableEvents property (Excel)


text:
Q: ccd with response "time constant" of less than 0.5 ns & maximum "radiant sensitivity" exceeding 10 mA/W I'm building a Raman Spectrometer.
Update: For this Stellarnet Sony ILX511 CCD. https://www.stellarnet.us/wp-content/uploads/ILX511.pdf
What is its response "time constant"? How do you understand the meaning of "response "time constant""? Do you think it has response "time constant" of less than 0.5 ns?
Original message:
The following specs are listed under the U.S. Strategic Goods list where export license is required for any electronic item to be shipped out of the country.
Does a normal NIR spectrometer ccd1 have specifications "with response "time constant" of less than 0.5 ns and maximum "radiant sensitivity" exceeding 10 mA/W?
What kinds of items use these specs? Are they typical or only components used in say patriot missile systems?
Quoting from the Commerce Control List (where export license is required):

"a.3.a. Non-"space-qualified" "focal plane arrays" having all of the
  following:
a.3.a.1. Individual elements with a peak response within the
  wavelength range exceeding 900 nm but not exceeding 1,050 nm; and
a.3.a.2. Any of the following:
a.3.a.2.a. A response "time constant" of less than 0.5 ns; or
a.3.a.2.b. "Specially designed" or modified to achieve 'charge
  multiplication' and having a maximum "radiant sensitivity" exceeding
  10 mA/W;"

1 Such as this one  ... the ccd can detect from 785nm to 1100nm, and so falls under "Individual elements with a peak response within the wavelength range exceeding 900 nm but not exceeding 1,050 nm". I'd like to know if this unit has response "time constant" of less than 0.5 ns or having a maximum "radiant sensitivity" exceeding 10 mA/W;". What do you think?

A: Generally speaking, the specifications that export controls are concerned with are well outside the realm of typical consumer electronics. These are no exception.

A response "time constant" of less than 0.5 ns

This describes an extremely fast CCD which can respond to light pulses in the GHz realm. The Sony CCD you've referenced has an integration time of 10 ms -- it's millions of times slower than what this specification is concerned with.

"Specially designed" or modified to achieve 'charge multiplication' and having a maximum "radiant sensitivity" exceeding 10 mA/W;"

This describes an EMCCD -- an unusual type of high-efficiency CCD used in astronomy and various other applications, sometimes including biochemical research equipment (including Raman spectroscopy!). These CCDs require exotic cooling technology. However, the Sony ILX511 isn't one of these. It's a totally normal CCD designed for use in consumer electronics like bar code scanners -- its use in spectroscopes is incidental. It's fine.


text:
Q: The 'name' does not exist in the current context C# I was using the sample code for my project to export Html-pdf using EvoPdf converter. This is the If Else statement.
if (convertUrlRadioButton.Checked)
            {
                string url = urlTextBox.Text;
                outPdfBuffer = htmlToPdfConverter.ConvertUrl(url);
            }
            else
            {
                string htmlString = htmlStringTextBox.Text;
                string baseUrl = baseUrlTextBox.Text;
                outPdfBuffer = htmlToPdfConverter.ConvertHtml(htmlString, baseUrl);
            }

The name convertUrlRadioButton does not exists in the current context
I get this error, The name 'convertUrlRadioButton' does not exist in the current context.
What am I doing wrong?
I tried to generate a field object with the name convertUrlRadioButton but
 'type' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'type' could be found (are you missing a using directive or an assembly reference?).  This error occurs.


text:
Q: How to add parameter and expression in rdlc I am getting a result of #error when I view it using ReportViewer reports
I was expecting to add the expression with the result of the two parameter
this is the syntax


text:
Q: Parameter passing an Object instead of entire Form I've created a simple Pokemon WinForm application with just 2 forms.  Form1 shows the Pokemon and its associated values.

Upon Clicking the Edit button, Form2 appears (EditCharacter) allowing the user to edit the attributes of the character.

To get the selected Pokemon to appear in Form2 (EditCharacter), I've passed in the currentCharacter from Form1.
Here is the code for Form1.
public partial class Form1 : Form
{
    CardCollection cardCollection;
    public Character currentCharacter;

    public Form1()
    {
        InitializeComponent();
        cardCollection = new CardCollection();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

        foreach (var keyValuePair in cardCollection.Cards)
        {
            cmbPokemon.Items.Add(keyValuePair.Key);
        }
    }

    private void cmbPokemon_SelectedIndexChanged(object sender, EventArgs e)
    {
        currentCharacter = cardCollection.Cards[cmbPokemon.Text];
        updateControls();
    }

    public void updateControls()
    {
        lblHP.Text = currentCharacter.HealthPoints.ToString();
        lblStrength.Text = currentCharacter.Strength.ToString();
        lblSpecialPower.Text = currentCharacter.SpecialPower;
        pbPokemon.ImageLocation = @currentCharacter.FileName;
    }

    private void btnEdit_Click(object sender, EventArgs e)
    {
        EditCharacter EditChar = new EditCharacter(currentCharacter);
        EditChar.ShowDialog();
    }
}

And here is the code with Constructor for the EditCharacter form:
public partial class EditCharacter : Form
    {
        Character currentCharacter;
        public EditCharacter( Character c)
        {
            InitializeComponent();
            currentCharacter  = new Character();
            currentCharacter = c;
            lblCharacter.Text = c.Name;
            pbCharacter.ImageLocation = c.FileName;
            txtPower.Text = c.SpecialPower;
            tbHP.Value = c.HealthPoints;
            tbStrength.Value = c.Strength;
            lblHP.Text = c.HealthPoints.ToString();
            lblStrength.Text = c.Strength.ToString();
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            lblHP.Text = tbHP.Value.ToString();
        }

        private void tbPower_Scroll(object sender, EventArgs e)
        {
            lblStrength.Text = tbStrength.Value.ToString();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            currentCharacter.Name = lblCharacter.Text;
            currentCharacter.FileName = pbCharacter.ImageLocation;
            currentCharacter.SpecialPower = txtPower.Text;
            currentCharacter.HealthPoints = tbHP.Value;
            currentCharacter.Strength = tbStrength.Value;
            currentCharacter.SpecialPower = txtPower.Text;
            this.Close();
        }
    }

My question is (and I've tried), how to preserve the values set in the EditForm to appear in Form1? For example, I edit Rayquaza's HealthPoints to 0, but when I return to Form1, it hasn't changed.

A: You can use interface to pass the same object directly to EditCharacter from and get it back when it has been updated.

*

*Create new interface , that contains two methods one for reading and the other for writing.
public interface ICharacterManager
{
    Character ReadCharacterData();
    void WriteCharacterData(Character character);
}

*Update your Form1 code by applying ICharacterManager interface, like this :
public partial class Form1 : Form , ICharacterManager
{
    CardCollection cardCollection;
    public Character currentCharacter;

    public Form1()
    {
        InitializeComponent();
        cardCollection = new CardCollection();
    }

    // The  currentCharacter object which will be passed to EditCharacter form.
    public Character ReadCharacterData()
    {
        return currentCharacter;
    }

    // Get back Character object from EditCharacter form after updating data and pressing Save Button
    public WirteCharacterData(Character character)
    {
        currentCharacter = character;

        // Call you updateControls() Method here.
        updateControls();
    }

    private void btnEdit_Click(object sender, EventArgs e)
    {
        // You can still  use this code, because already the type of Form1 is IChatacterManager now.
       EditCharacter EditChar = new EditCharacter(this);
       EditChar.ShowDialog();
    }
}

*Update your EditCharacter code by adding ICharacterManager variable like this :
 public partial class EditCharacter : Form
 {
     private ICharacterManager _characterManager;
     Character currentCharacter;

     public EditCharacter(ICharacterManager characterManager)
     {
         InitializeComponent();

         _characterManager = characterManager;

         // Character object which come form Form1.
         currentCharacter = _characterManager.ReadCharacterData();

         lblCharacter.Text = currentCharacter.Name;
         pbCharacter.ImageLocation = currentCharacter.FileName;
         txtPower.Text = currentCharacter.SpecialPower;
         tbHP.Value = currentCharacter.HealthPoints;
         tbStrength.Value = currentCharacter.Strength;
         lblHP.Text = currentCharacter.HealthPoints.ToString();
         lblStrength.Text = currentCharacter.Strength.ToString();
     }

     private void btnSave_Click(object sender, EventArgs e)
     {
         currentCharacter.HealthPoints = tbHP.Value;
         currentCharacter.Strength = tbStrength.Value;
         currentCharacter.SpecialPower = txtPower.Text;

         // Check if _characterManager object is not equal to null.
         if (_characterManager != null)
         {
             // Pass the updated object back to Form1
             _characterManager.WriteCharacterData(currentCharacter);
         }

         this.Close();
     }

Hope this was helpful.
Happy coding :) ...


text:
Q: Why does reference optimization prevents from registering DLLs? I am registering a DLL in a Visual Studio post build event, and regsrv32 is failing as if a library dependency was missing. The DLL has a DllRegisterServer entry point, a DEF file and was correctly setup. the registration was done correctly until we changed library dependencies. Right .
Now that the DLL depends on a cross compiled library, I have to disable the reference optimization option /OPT:REF to make the registration successful again. Why is that?
Furthermore dependency walker was not able to find entry points of dependent libraries (ffmpeg libs). See the difference /OPT:NOREF vs /OPT:REF below:

Note that the linking process is successful.


text:
Q: Как сохранить JSP в переменную типа String? Использую SPRING.
Мне нужно заполнить шаблон в JSP и вернуть его в переменную.
При этом, операция производится не в контроллере, а в сервисе.
Как это правильно сделать ?


text:
Q: Excel vba to generate a list of files and sizes in subfolders Hello I have inherited some excel vba code which produces a list of files which are less than 100 days old and captures the file sizes that sit in a specific folder and sub folders.   When running the code, it tries to access some sub folders which I don't have access to and it crashes can anyone assist? I would also like it to ignore subfolders that start 02-Recs.
thanks
Sub getfiles()

    Dim oFSO As Object
    Dim oFolder As Object
    Dim oFile As Object, sf
    Dim i As Integer, colFolders As New Collection, ws As Worksheet

    Set ws = ActiveSheet
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFSO.getfolder("F:\test\")

    colFolders.Add oFolder          'start with this folder

    Do While colFolders.Count > 0      'process all folders
        Set oFolder = colFolders(1)    'get a folder to process
        colFolders.Remove 1            'remove item at index 1

        For Each oFile In oFolder.Files
            If oFile.DateLastModified > Now - 100 Then
                ws.Cells(i + 1, 1) = oFolder.Path
                ws.Cells(i + 1, 2) = oFile.Name
                ws.Cells(i + 1, 3) = "RO"
                ws.Cells(i + 1, 4) = oFile.DateLastModified
                ws.Cells(i + 1, 5) = oFile.Size / 1024 ^ 2
                i = i + 1
            End If
        Next oFile

        'add any subfolders to the collection for processing
        For Each sf In oFolder.subfolders
            colFolders.Add sf 'add to collection for processing
        Next sf
    Loop

End Sub


text:
Q: PHP, pass parameters from command line to a PHP script I want to pass parameters from PHP Command Line Interface, and then read in the values using PHP script, something like this:
<?php
  $name1 = $argv[1];
  echo $name1;
?>

I pass the variable from CLI like this:
C:\xampp\php\php.exe name.php Robby

The above works, I get Robby as the output.
But I want to do something like this:
C:\xampp\php\php.exe name.php -inputFirstName="Robby"

So that the user is well informed to enter the correct parameters in the correct places.  What is the appropriate way to parse these parameters?

A: you can send parameters as one argument then parse that argument like a $_GET array
C:\xampp\php\php.exe name.php "inputFirstName=Robby&LastName=John"

and in your PHP file
if (!empty($argv[1])) {
  parse_str($argv[1], $_GET);
}

you'll get arguments in $_GET array like usual

A: When calling a PHP script from the command line you can use $argc to find out how many parameters are passed and $argv to access them. For example running the following script:
<?php
    var_dump($argc); //number of arguments passed
    var_dump($argv); //the arguments passed
?>

Like this:-
php script.php arg1 arg2 arg3

Will give the following output
int(4)
array(4) {
  [0]=>
  string(21) "d:\Scripts\script.php"
  [1]=>
  string(4) "arg1"
  [2]=>
  string(4) "arg2"
  [3]=>
  string(4) "arg3"
}

See $argv and $argc for further details.
To do what you want, lets say
php script.php arg1=4

You would need to explode the argument on the equals sign:-
list($key, $val) = explode('=', $argv[1]);
var_dump(array($key=>$val));

That way you can have whatever you want in front of the equals sign without having to parse it, just check the key=>value pairs are correct. However, that is all a bit of a waste, just instruct the user on the correct order to pass the arguments.

A: The getopt() function is probably the most correct answer in the case of the question. Especially since it was made platform independent with PHP 5.3. In the particular case of this question and parsing multiple parameters, one way to leverage this function would be as follows:
$defaultValues = array("inputFirstName" => "");
$givenArguments = getopt("", array("inputFirstName:"));
$options = array_merge($defaultValues, $givenArguments);
$inputFirstName = $options['inputFirstName'];

The call to set $inputFirstName with the value "Robby" would be:
> php script.php --inputFirstName="Robby"

Explanation
Default values for all expected parameters are set in the $defaultValues array. Input sent through via command line arguments are collected by PHP's getopt function and stored by the $givenArguments. Note that the colon (:) at the end of the "inputFirstName:" string indicates that this is a required argument. Without a colon here, only the presence of the argument would be detected, not the actual value (more information in the PHP Manual). Merging these two arrays together on the third line results in array with all expected parameters being set with either default values or arguments provided from the command line/terminal if they are available.

A: I use this fairly concise method:
if($argc>1)
  parse_str(implode('&',array_slice($argv, 1)), $_GET);

Which would handle a call such as:
php script.php item1=4 item2=300

By sending it into $_GET you automatically handle web or CLI access.
For commentary, this is doing the following:

*

*If the count of arguments is greater than one (as first item is the name of the script) the proceed

*Grab the arguments array excluding first item

*Turn it into a standard query string format with ampersands

*use parse_str to extract to the $_GET array

A: While the answer is correct and you could do the parsing by hand, PHP also offers the getopt() function that might actually provide useful here.
There's also object-oriented alternatives (written in PHP, available in a number of libraries) that might turn out to be what you need. Googling for "php getopt" will yield helpful results.

A: I don't know if at the time this question has being asked what i going to answer to it was available but if you call php-cgi -f myfile.php var=something you can retrieved whit $var=$_GET['var'];  from the command line then you don't have to change your code to call it from the web browser or the command line

A: If you don't mind using a library, I suggest you take a look at The Console Component by Symfony.
It can be used to create command line applications and supports the use of Arguments & Options.
The documentation page contains a couple of excellent examples to get you started.
Of course under the hood it uses the same techniques as explained by vascowhite.

A: your best hope is to use
exec("php -f php.file.php example=js.json > ech0");
echo file_get_contents("ech0");
unlink("ech0");

That's what I use in PipesJS

A: You can parse the user input on your program looking for specific strings such as -inputFirstName="x" (using regular expressions, for example) and then set the correct variable to x.


text:
Q: How to upload image to node after cropping from ngx-image cropper in Angular on change event of file Below is my function
UploadImage(){
  let file: File = this.fileToReturn; //fileToReturn is returned file from the cropper
  let formData:FormData = new FormData();
  formData.append('uploadFile', file, file.name);
  console.log(JSON.stringify(formData))

  formData.forEach((value,key) => {
     console.log(key+" "+value)
   })
  this.authservice.uploadPhoto(formData)
  .subscribe(
    (response) => {
      console.log('response received is ', response);
    }
  )
  // debugger;
  // console.log(formData);
}

Upon logging the value to the console & server I get the empty json  '{}'.
What should be done?
Do I have to use any other libraries?

A: UploadImage(){
  let file: File = this.fileToReturn;
  let formData:FormData = new FormData();
  formData.append('uploadFile', file, file.name);
  console.log(JSON.stringify(formData))

  formData.forEach((value,key) => {
     console.log(key+" "+value)
   })
  this.authservice.uploadPhoto(formData)
  .subscribe(
    (response) => {
      console.log('response received is ', response);
      this.openSnackBar('Profile picture updated!','Close');
      // this.shared_user.getProfilepic(response);
    }
  )
  // debugger;
  // console.log(formData);
}
base64ToFile(data, filename) {

  const arr = data.split(',');
  const mime = arr[0].match(/:(.*?);/)[1];
  const bstr = atob(arr[1]);
  let n = bstr.length;
  let u8arr = new Uint8Array(n);

  while(n--){
      u8arr[n] = bstr.charCodeAt(n);
  }

  return new File([u8arr], filename, { type: mime });
}

imageCropped(event: ImageCroppedEvent) {
      this.croppedImage = event.base64;
      console.log(this.croppedImage);
      this.fileToReturn = this.base64ToFile(
        event.base64,
        this.imageChangedEvent.target.files[0].name,
      )
      return this.fileToReturn
  }

This worked for me


text:
Q: Change default assist app via intent After downloading Cortana, it lets you set as the default device assist app. The app does that by firing up the specific settings page via intent. So, what is the specific intent for doing so?
I have asked the same question to many forums, but I got the same answer- It is not possible... Turn out, it is.
Can anyone help me?

A: The intent code you are looking for is ACTION_VOICE_INPUT_SETTINGS. Here is the doc.
startActivityForResult(new Intent(android.provider.Settings. ACTION_VOICE_INPUT_SETTINGS), 0);


text:
Q: read file content and print only some lines i have a text file with several content from emails (>20) like this:
Von: xx@hsu-xxs.de
Betreff: test
Datum: 13. Juni 2018 um 06:30:10 MESZ
An: xx@xxs.net
Antwort an: xx@hsu-xxs.de

Header
------------------------------

(content)
(content)

(content)

--
footer

i load this file at the moment with this:
$file_handle = fopen($file, 'r');

while (!feof($file_handle)) {

  $line = fgets($file_handle);
  (do something ....)

}

fclose($file_handle);

my problem is - how can i only read the content of this file? the rest isn't important!
any ideas how to solve this problem?
thanks for help
Andreas


text:
Q: Make screensaver fire whenever computer locks? Is it possible to force the screensaver to appear whenever a computer becomes locked? Specifically on XP, 7 if possible.

A: I believe that the SS is only triggered when the timeout is reached, regardless if the PC is locked or not.
The other way to think of this is to lock the PC whenever the screensaver fired.
Windows 2000 and above has an option to enable lock the PC when the screensaver is active, just enable this, and set the timeout and you are ready to go.

A: Windows has several desktops.  You're familiar with the one you are looking at right now.  There's another one for the login screen.  And there's one for the screen saver.  Locking the workstation switches the desktop to the login screen.  You cannot switch back to another desktop (like the screen saver one) until you login.
You can however get the screen saver started, that selects the screen saver desktop.  Which automatically switches to the login desktop if you configure the screen saver that way.


text:
Q: Reading data from Excel-sheet and comparing with existing users I want to read an excel-sheet and compare each one of the username/email with our existing Active Directory and spit out only those users where Enabled=False. Meaning expired users.
Code so far is as below:
# Specify the path to the Excel file and the WorkSheet Name
$FilePath = "C:\Users\user\Downloads\mfausers.xlsx"
$SheetName = "mfassuers"

# Create an Object Excel.Application using Com interface
$objExcel = New-Object -ComObject Excel.Application

# Disable the 'visible' property so the document won't open in excel
$objExcel.Visible = $false

# Open the Excel file and save it in $WorkBook
$WorkBook = $objExcel.Workbooks.Open($FilePath)

# Load the WorkSheet 'BuildSpecs'
$WorkSheet = $WorkBook.sheets.item($SheetName)

Get-ADUser -Filter {Name -eq "$worksheet.Range("A77").Text"}

Gives me error as below:
Get-ADUser : Error parsing query: 'Name -eq "$worksheet.Range("A77").Text"' Error Message: 'syntax error' at position: '29'.
At line:17 char:1
+ Get-ADUser -Filter {Name -eq "$worksheet.Range("A77").Text"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [Get-ADUser], ADFilterParsingException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADFilterParsingException,Microsoft.ActiveDirectory.M
   anagement.Commands.GetADUser

The above code I'm using from the site below:
https://lazywinadmin.com/2014/03/powershell-read-excel-file-using-com.html
I have the commands handy but I'm not an experienced PowerShell dude.
The script should look for column A which has user names, I want to then use some basic check like below:
Get-ADUser -Filter {Name -eq "FirstName1 LastName1"}

DistinguishedName : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Enabled           : True
GivenName         : xxxxxxxxxxxxxxx
Name              : xxxxxxxxxxxxxxx
ObjectClass       : user
ObjectGUID        : xxxxxxxxxxxxxxx
SamAccountName    : xxxxxxxxxxxxxxx
SID               : xxxxxxxxxxxxxxx
Surname           : xxxxxxxxxxxxxxx
UserPrincipalName : xxxxxxxxxxxxxxx

If Enabled = False, then spit this user, else continue.

A: Remove quotes
{Name -eq $worksheet.Range("A77").Text}


text:
Q: how to prove that $f_n\to f$ in $L^1$ Let Q be the unit square in $R^2$. Consider functions $f_n\in L^1(Q)$ such that $f_n\to f$ almost everywhere in Q and $\int_{Q}|f_n|\to \int_{Q} |f|<\infty $
(a)prove that $\int_A|f_n|\to \int_A |f| $ for every measurable subset A of Q
(b)prove that $f_n \to f$ in $L^1$
I am just thinking about whether I can use Fatou's theorem to prove part(a), but still have no idea how to prove it.

A: Hint: Apply Fatou's Lemma to $|f_n| + |f| -|f_n-f|.$ (A classic application, but not so obvious on your first encounter.)


text:
Q: Run app to embedded jboss server using maven I create the simple rest server application using resteasy and maven as build tool by this post http://buraktas.com/resteasy-example-without-using-a-web-xml/. Or it is possible to run created war to the embedded jboss server using maven? I want implement this scenario: 1. I push my project to git hub with source files and pom.xml 2. User clone repo and use maven to build and run app. 3. Go to browser http://localhost:8080/rest-helloworld/helloworld and get hello msg.
pom.xml <- now need mvn clean install to prepare .war and need copy paste to the application server. I want skip this step.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>buraktas.com</groupId>
  <artifactId>rest-helloworld</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>rest-helloworld</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>3.0.6.Final</version>
        <scope>provided</scope>
    </dependency>
  </dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <warName>rest-helloworld</warName>
            </configuration>
        </plugin>
    </plugins>
</build>

</project>

A: You can use Maven JBoss Plugin to perform start/stop and deploy/undeploy tasks using Maven.


text: Q: instantaneous backup to external drive I have an external hard drive, and I want to use it as a backup drive. So my question is "how to update a backup folder when the original folder gets updated?", I'm talking about an instant backup. As I can remember Linus sebastian made a server like an instant backup server and I want this to be the same via external drive. Is there a software that I should download or do I need to make the program in a .bat format.