kx | Interactively switch between kubernetes | Command Line Interface library
kandi X-RAY | kx Summary
kandi X-RAY | kx Summary
kx is a utility to switch interactively between kubernetes contexts without any external dependencies and bash witchcraft. Written in Rust :crab:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of kx
kx Key Features
kx Examples and Code Snippets
kx : list the contexts
kx : switch to context
kx -c, --current : show the current context name
kx -u, --unset : unset the current context
Community Discussions
Trending Discussions on kx
QUESTION
I am trying to make a tic-tac-toe game, and I currently have a 3x3 tiled board
grid to represent the game. When a user clicks a square, the program sets board[x][y]
to 1
.
board = [[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
Unfortunately, whenever I click a tile, it seems to ignore whatever x
value I put; every time I click a tile, it sets the entire row instead of a single tile. So, essentially, if I set board[0][y]
to 1
, it will set board[0][y]
, board[1][y]
, and board[2][y]
all to 1
.
I tried to create a minimal reproducible example, but when I took out the drawing function game
, (and set the board
variable to a 3x3 grid of 0s manually) the program failed to change the last two rows of board
upon clicking on what would have been a tile.
ANSWER
Answered 2022-Apr-07 at 15:58Actually, you don't create a grid, you create a list of references to the same line. To create a grid you need 2 nested loops:
QUESTION
I want to generate 2D travelling sine wave. To do this, I've set the parameters for the plane wave and generate wave for any time instants like as follows:
...ANSWER
Answered 2022-Apr-01 at 19:58This is not that much a problem of programming. It has to do more with the fact that you are using the physical quantities in a somewhat unusual way. Your plots are absolutely fine and correct.
What you seem to have misunderstood is the fact that you are talking about a 2D problem with a third dimension added for time. This is by no means wrong but if you try to append the snapshot of the 2D wave side-by-side you are using (again) the x spatial dimension to represent temporal variations. This leads to an inconsistency of the use of that coordinate axis. Now, to make this more intuitive, consider the two time instances separately. Does it not coincide with your intuition that all points on the 2D plane must have different amplitudes (unless of course the time has progressed by a multiple of the period of the wave)? This is the case indeed. Thus, when you try to append the two snapshots, a discontinuity is exhibited. In order to avoid that you have to either use a time step equal to one period, which I believe is of no practical use, or a constant time step that will make the phase of the wave on the left border of the image in the current time equal to the phase of the wave on the right border of the image in the previous time step. Yet, this will always be a constant time step, alternating the phase (on the edges of the image) between the two said values.
The same applies to the 1D case because you use the two coordinate axes to represent the wave (x is the x spatial dimension and y is used to represent the amplitude). This is what can be seen in your last plot.
Now, what would be the solution you may ask. The solution is provided by simple inspection of the mathematical formula of the wave function. In 2D, it is a scalar function of three variables (that is, takes as input three values and outputs one) and so you need at least four dimensions to represent it. Alas, we can't perceive a fourth spatial dimension, but this is not a problem in your case as the output of the function is represented with colors. Then there are three dimensions that could be used to represent the temporal evolution of your function. All you have to do is to create a 3D array where the third dimension represents time and all 2D snapshots will be stored in the first two dimensions.
When it comes to visual representation of the results you could either use some kind of waterfall plots where the z-axis will represent time or utilize the fourth dimension we can perceive, time that is, to create an animation of the evolution of the wave.
I am not very familiar with Python, so I will only provide a generic naive implementation. I am sure a lot of people here could provide some simplification and/or optimisation of the following snippet. I assume that everything in your first two blocks of code is available so changes have to be done only in the last block you present
QUESTION
I have implemented a Convolutional Neural Network in C and have been studying what parts of it have the longest latency.
Based on my research, the massive amounts of matricial multiplication required by CNNs makes running them on CPUs and even GPUs very inefficient. However, when I actually profiled my code (on an unoptimized build) I found out that something other than the multiplication itself was the bottleneck of the implementation.
After turning on optimization (-O3 -march=native -ffast-math
, gcc cross compiler), the Gprof result was the following:
Clearly, the convolution2D
function takes the largest amount of time to run, followed by the batch normalization and depthwise convolution functions.
The convolution function in question looks like this:
...ANSWER
Answered 2022-Mar-10 at 13:57Looking at the result of Cachegrind, it doesn't look like the memory is your bottleneck. The NN has to be stored in memory anyway, but if it's too large that your program's having a lot of L1 cache misses, then it's worth thinking to try to minimize L1 misses, but 1.7% of L1 (data) miss rate is not a problem.
So you're trying to make this run fast anyway. Looking at your code, what's happening at the most inner loop is very simple (load-> multiply -> add -> store), and it doesn't have any side effect other than the final store. This kind of code is easily parallelizable, for example, by multithreading or vectorizing. I think you'll know how to make this run in multiple threads seeing that you can write code with some complexity, and you asked in comments how to manually vectorize the code.
I will explain that part, but one thing to bear in mind is that once you choose to manually vectorize the code, it will often be tied to certain CPU architectures. Let's not consider non-AMD64 compatible CPUs like ARM. Still, you have the option of MMX, SSE, AVX, and AVX512 to choose as an extension for vectorized computation, and each extension has multiple versions. If you want maximum portability, SSE2 is a reasonable choice. SSE2 appeared with Pentium 4, and it supports 128-bit vectors. For this post I'll use AVX2, which supports 128-bit and 256-bit vectors. It runs fine on your CPU, and has reasonable portability these days, supported from Haswell (2013) and Excavator (2015).
The pattern you're using in the inner loop is called FMA (fused multiply and add). AVX2 has an instruction for this. Have a look at this function and the compiled output.
QUESTION
I have an issue while connecting to a FTPS server with TLS/SSL Implicit encryption via PROXY.
I am following the custom Apache FTPS Client (commons-net-3.8.0) solution provided from Java FTPS client through HTTP proxy
My server connection is working, but unable to list or file transfer, getting below error:
425 Can't open data connection for transfer of ""
Data connection / File transfer is working fine from Windows WinSCP and Linux LFTP.
WinSCP Log:
...ANSWER
Answered 2022-Feb-07 at 15:21I do not know your network/proxy setup, so I cannot really explain the behaviour of FTPClient
. Your server seems to return IP address of the proxy in the PASV
response. The default NAT resolver of FTPClient
decides that the address is wrong (is it a local network host address?) and choses to use original FTP server's address instead.
While WinSCP does not do that and connects to the IP that the server returned.
To avoid the NAT resolver from messing with the address, use FTPClient.setPassiveNatWorkaround
(though that's deprecated):
QUESTION
I'm trying to figure out how to connect to a data feed.
The data feed is at
...ANSWER
Answered 2022-Jan-02 at 15:09Stunnel can be used to encrypt or decrypt any TCP SSL connection, including websockets.
To get KDB to connect to a secure websocket, you need to use stunnel in client mode.
This is the config that worked for me. You can then open the decrypted websocket on your localhost at ws://localhost:80
QUESTION
I'm trying to simulate the 2D Schrödinger equation using the explicit algorithm proposed by Askar and Cakmak (1977). I define a 100x100 grid with a complex function u+iv, null at the boundaries. The problem is, after just a few iterations the absolute value of the complex function explodes near the boundaries.
I post here the code so, if interested, you can check it:
...ANSWER
Answered 2022-Jan-01 at 18:58I'd try setting your dt
to a smaller value (e.g. 0.001) and increase the number of integration steps (e.g fivefold).
The wavefunction looks in shape also at Ntsteps=150
and well beyond when trying out your code with dt=0.001
.
Checking integrals of the motion (e.g. kinetic energy here?) should also confirm that things are going OK (or not) for different choices of dt
.
QUESTION
Goal: Print variable number of bytes using a single format specifier.
Environment: x86-64 Ubuntu 20.04.3 LTS running in VM on an x86-64 host machine.
Example:
Let %kmagic
be the format specifier I am looking for which prints k
bytes by popping them from the stack and additing them to the output. Then, for %rsp
pointing to a region in memory holding bytes 0xde 0xad 0xbe 0xef
, I want printf("Next 4 bytes on the stack: %4magic")
to print Next 4 bytes on the stack: deadbeef
.
What I tried so far:
%khhx
, which unfortunately just results ink-1
blank spaces followed by two hex-characters (one byte of data).%kx
, which I expected to print k/2 bytes interpreted as one number. This only prints 8 hex-characters (4 bytes) prepended by k - 8 blank spaces.
The number of non-blank characters printed matches the length of the format specifiers, i.e. the expected length of %hhx
is 2, which is also the number of non-blank characters printed. The same holds for %x
, which one expects to print 8 characters.
Question: Is it possible to get the desired behavior? If so, how?
...ANSWER
Answered 2021-Nov-27 at 12:01Is it possible to get the desired behavior? If so, how?
There does not exist printf
format specifier to do what you want.
Is it possible
Write your own printf
implementation that supports what you want. Use implementation-specific tools to create your own printf
format specifier. You can take inspiration from linux kernel printk %*phN
format speciifer.
QUESTION
Recently, I have been trying to use widgets to interact with my plots. I have created a function that takes in two parameters to make my plots and it works perfectly, producing different plots depending on the value of the given parameters.
However, when I try to create FloatSlider widgets for these parameters, only one of them works. The other sort of "gets stuck" - I just can't move the slider (here is a link of a GIF showing what happens when I try to move the cursor of the slider).
Do you guys have any idea on what could be causing this issue?
Here is the code I'm using:
...ANSWER
Answered 2021-Nov-25 at 16:35First, thankyou for the complete runnable example (with imports!)
I think this might be to do with the minimum value or step size the float widget can support.
Try to move this widget, I can't get it to change:
widgets.FloatSlider(min=5e-7,max=10e-7,step=1e-7,readout_format='.1e')
I wonder whether this is simply due to floating point rounding down small numbers to zero.
I tried having the input as integer, and applying the scale factor in the body of the code and it seemed to work fine. Would this work as an alternative:
QUESTION
Following the documentation, I tried to do the following:
...ANSWER
Answered 2021-Nov-15 at 17:26The simplest way to achieve column deletion in place is using qSQL:
t:([]a:1 2 3;b:4 5 6;c:`d`e`f)
delete a,b from `t
-- here, the backtick before t
makes the change in place.
QUESTION
I am following test tickerplant and feedhandler setup instructions. However, when I try to run q tick.q someTable tick_log -p 5555
I get the following error: 'timesym
. There is nothing about it in the above mentioned "C API for kdb+" white paper. What I did:
- downloaded https://github.com/KxSystems/kdb-tick/blob/master/tick.q
mkdir tick
- put u.q from https://github.com/KxSystems/kdb-tick/blob/master/tick/u.q into
tick/
- put
someTable
schema intotick/someTable.q
(containssym
andtime
columns) mkdir tick_log
- ran the above
q tick.q someTable tick_log -p 5555
command
Could you please help me to understand what is the meaning of the timesym
variable and how I should supply it? Am I missing some steps?
Thank you very much for your help!
...ANSWER
Answered 2021-Nov-09 at 20:27'timesym
is an error thrown by the tickerplant if the first two columns in the table being consumed are not time
& sym
respectively. You can spot where the error is occuring on line 30 of tick.q, in the .u.tick
function (search for timesym
).
In order to resolve this issue, you need to ensure time
& sym
are the first two columns of the table (in this order). Alternatively, you could change the tickerplant code to suit your table.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install kx
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page