Posts

counting surrounding true's in numpy matrix (python)

Image
Clash Royale CLAN TAG #URR8PPP counting surrounding true's in numpy matrix (python) I want to make something similiar to minesweeper input matrix: matrix = [[true, false, false], [false, true, false], [false, false, false]] if a bomb is on the field I do not count it as bomb is surrounding. I thought about doing it with numpy convolve somehow but I am struggling with how to go through the matrix and always check the left, top, right and bottom fields of the actual field (in the case of a border I check "empty" fields which is 0 for sure) 2d convolution with a donut-shaped seed. – Daniel F Aug 10 at 8:57 no it doesn't have to be numpy, but I thought that this would be the best solution, just not sure how to get it to work. @DanielF hmm how that? – Dominik Lemberger Aug 10 at 8:58 3 Answers 3 Here is a solution using scipy.signal.convolve2d : scipy.signal.convolve2d import scipy import numpy as np # Input matrix, can be left as boolean mat...

WPF, C#, MVVM Notify ViewModel dynamically in changes from Model

Image
Clash Royale CLAN TAG #URR8PPP WPF, C#, MVVM Notify ViewModel dynamically in changes from Model I have ViewModel that makes some functions. Funcs are initiate by button, i have command on button click. ViewModel.cs ViewModel.cs class WindowViewModel : INotifyPropertyChanged { public WindowViewModel() canExecute = true; public ICommand ApplyKMMCommand //command for button click get return applyKMMCommand ?? (applyKMMCommand = new Commands.CommandHandler(() => ApplyKMMToNewImage(), canExecute)); private bool canExecute; private ICommand applyKMMCommand; public void ApplyKMMToNewImage() ApplyKMM.Init(); //algorithm name public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(string propertyName) PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); public BitmapImage DisplayedImage //displaying image that i work with get return Bitmaps.Filepath; set Bitmaps.Filepath = value; NotifyPropertyChanged(n...

How to get Session ID for PPPOE session?

Image
Clash Royale CLAN TAG #URR8PPP How to get Session ID for PPPOE session? I am using rp-pppoe 3.10. I have configured a PPPoE server and client. How do I find out the PPPoE session ID assigned by the server to client when the session is established? Is it updated in any file in /etc/ppp folder or some where else? 2 Answers 2 pppoe logs this through syslog: pppoe pppoe[2195]: PPP session is 2166 (0x876) Thanks for the reply..In my case, I initiate at a time 26 pppoe sessions. If pppoe session ID is logged in the "/var/log/messages", how can I find the session ID related to specific pppoe session? – Ravi Nov 7 '11 at 6:43 @Ravi: The value in the square brackets next to pppoe is the process ID of the pppoe process, which should allow you to identify a particular instance in the logs. – caf Nov 7 '11 at 9:00 pppoe cat /proc/net/pppoe will give you the session ID, server MAC address and the physical interface device which the PPPoE session is crea...

mysql combine two columns into one in query [closed]

Image
Clash Royale CLAN TAG #URR8PPP mysql combine two columns into one in query [closed] select a.id, a.one, a.two,b.three FROM a left join b on b.three=a.one and b.three=a.two group by a.id Is this query right? I want b.three equal a.one and also a.two a.one and a.two have different values. b.three a.one a.two a.one a.two Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. Could you provide some sample data and expect result? – D-Shih Aug 10 at 8:56 Query will not result any row if a.one and a.two is unequal. – Spidi's Web Aug 10 at 9:02 Given that a.one and a.two have different values b.three can't match both of them at the same time. So perhaps you want on b.three=a...

Syntax Error in Insert to statement for Delphi 10.2 Tokyo

Image
Clash Royale CLAN TAG #URR8PPP Syntax Error in Insert to statement for Delphi 10.2 Tokyo I need help with my coding, I have tried changing variables and displaying the SQL and I still can not see the error Thank you. Here is my code: qryCustomerInformation.SQL.Add('/*The SQL query string from below*/'); showmessage(qryCustomerInformation.SQL.Text); qryCustomerInformation.ExecSQL; Here is my query string: INSERT INTO BasicInformation ( Passwords, CustomerID, Names, Surname, Age, IdentitiyNumber, Address, CardNumber, CSV, Expirey, Image, PhoneNumber ) VALUES ( ''' + CustomerPassword + ''',''' + CustomerId + ''',''' + CustomerName + ''',''' + CustomerSurname + ''',''' + CustomerAge + ''',''' + CustomerIdNumber + ''',''' + CustomerAddress + ''',''' + CustomerCardNumber + '...

How to horizontally center a in another ?

Image
Clash Royale CLAN TAG #URR8PPP How to horizontally center a <div> in another <div>? How can I horizontally center a <div> within another <div> using CSS (if it's even possible)? <div> <div> <div id="outer"> <div id="inner">Foo foo</div> </div> Of those great answers, I just want to highlight that you must give "#inner" a "width", or it will be "100%", and you can't tell if it's already centered. – Jony Nov 7 '17 at 8:22 90 Answers 90 You can apply this CSS to the inner <div> : <div> #inner width: 50%; margin: 0 auto; Of course, you don't have to set the width to 50% . Any width less than the containing <div> will work. The margin: 0 auto is what does the actual centering. width 50% <div> margin: 0 auto If you are targeting IE8+, it might be better to have this instead: #inner display: table; margin: 0 auto; ...

Remove blank lines in a file using sed

Image
Clash Royale CLAN TAG #URR8PPP Remove blank lines in a file using sed France 211 55 Europe Japan 144 120 Asia Germany 96 61 Europe England 94 56 Europe Taiwan 55 144 Asia North Korea 44 2134 Asia The above is my data file. There are empty lines in it. There are no spaces or tabs in those empty lines. I want to remove all empty lines in the data. I did a search Delete empty lines using SED has given the perfect answer. Before that, I wrote two sed code myself: sed -r 's/nn+/n/g' cou.data sed 's/nnn*/n/g' cou.data And I tried awk gsub, not successful either. awk ' gsub(/nn*/, "n"); print ' cou.data But they don't work and nothing changes. Where did I do wrong about my sed code? Possible duplicate of AWK remove blank lines – oliv Aug 10 at 9:10 by default most sed and awk implementations work line by line, strip newline from input and add it back while printing.. so n is never going to match unless you use other features of sed/...

Python Pandas Series.isin doesn't work

Image
Clash Royale CLAN TAG #URR8PPP Python Pandas Series.isin doesn't work I have a Series 8 [11820] 9 [11820] 10 [11820] 11 [11820] 12 [11820] 27 [10599] 28 [10599] 29 [10599] 31 [661, 10599] 32 [661, 10599] 33 [7322] 34 [0] 37 [661] 39 [661] 40 [661] 49 [0, 661, 662, 663] I want to filter this Series with something like points[points.isin([0])] to get points[points.isin([0])] 34 [0] 49 [0, 661, 662, 663] but as a result I get 0 Features. You are searching for lists. .isin() looks for values – lhay86 Aug 10 at 9:12 @lhay86 yes, I want to find all features, which lists contain my value. Not only strict accordance – sailestim Aug 10 at 9:15 Possible duplicate of Python & Pandas: How to query if a list-type column contains something? – Shaido Aug 10 at 9:18 2 Answers 2 Simple way to check, if your value (0) is in the list, is by using apply on your series: apply s = s[s.apply(lambda x: 0 in x)] Some explanation: For every ...

The service “sonata.admin.block.admin_list” has a dependency on a non-existent service “sonata.templating”

Image
Clash Royale CLAN TAG #URR8PPP The service “sonata.admin.block.admin_list” has a dependency on a non-existent service “sonata.templating” I am using Sonata Admin Bundle version 3.31.1, after I updated my composer it started to give the following error The service "sonata.admin.block.admin_list" has a dependency on a non-existent service "sonata.templating". My symfony is 3.4 and here is the composer.json file "name": "msen/api", "license": "proprietary", "type": "project", "autoload": "psr-4": "": "src/" , "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] , "autoload-dev": "psr-4": "Tests\": "tests/" , "require": "php": ">=7.1.6", "ext-intl" : "*", "symfony/symfony": "^3.4", "doctrine/orm...

Move view with keyboard using Swift

Image
Clash Royale CLAN TAG #URR8PPP Move view with keyboard using Swift I have an app that has a text field on the lower half of the view. This means that when I go to type in the text field the keyboard covers the textfield. How would I go about moving the view upwards while typing so I can see what i'm typing and then moving it back down to its original place when the keyboard disappears? I've looked everywhere but all the solutions appear to be in Obj-C which I can't quite convert just yet. Any help would be greatly appreciated. The best way to do this is to place your content inside a UIScrollView , then adjust the scroll view's contentInset property by the height of the keyboard when it's shown. Absolutely do not assume the keyboard height--use the value from the "keyboard will show" notification. – nielsbot Oct 2 '15 at 16:47 In fact, the Apple docs tell you how to do this, under "Managing the Keyboard": developer.apple.com/l...