line

Determine Active NIC address using python console commands

自闭症网瘾萝莉.ら 提交于 2019-12-25 09:11:09
问题 I am trying to find an active NIC, an active NIC is one where the command wil return UP for me. In my command: # cat /sys/class/net/eth0/operstate I am returned a value of UP In another command, I type: # cat /sys/class/net/eth1/operstate I get a value of DOWN Overall I have 4 eth's. I basically have to use the command to determine UP or DOWN /sys/class/net/eth[0|1|2|3]/operstate = up | down I want to be able to write a program where I will be able to return the eth[0|1|2|3] value that is UP.

Silverlight Toolkit chart: Multiple series with bar and line

心已入冬 提交于 2019-12-25 08:02:21
问题 I am having problem to show the grid in a way that I wanted. But I am also not sure whether it is possible to do that in the Silverlight toolkit chart. So any help or direction on this would be appreciated. <Grid x:Name="LayoutRoot" Background="White"> <charting:Chart x:Name="myChart" Width="600" Height="400"> <charting:BarSeries Title="Tasks" ItemsSource="{Binding Path=Data1}" IndependentValueBinding="{Binding Month}" DependentValueBinding="{Binding Task}" DependentRangeAxis="{Binding

Collision of a line and object ( Corona SDK )

ぃ、小莉子 提交于 2019-12-25 05:24:27
问题 I am developing a game when there is a line and physics object The line code is: And the interesting thing is that when i code print ("collision is here") (for ex) they some how don't even collide! Both line and obj bodies are static How can make this collision happed? thanks in advance! 回答1: Static bodies can't collide with each other, but this question has a solution. 回答2: IF both lines are static make a function where you detect the x and y of both object and make equation accordingly, for

Get line number that contains a string

 ̄綄美尐妖づ 提交于 2019-12-25 05:15:45
问题 How to get a line number that contains a specified string in a text file? Example text file contains: Red White Yellow Green How to get "Yellow" line number? and can i write a string in a specified line, lets say i want to write a string in line 2? 回答1: To find a line in a text file, you need to read the lines from the start of the file until you find it: string fileName = "file.txt"; string someString = "Yellow"; string[] lines = File.ReadAllLines(fileName); int found = -1; for (int i = 0; i

Codeigniter generate simple array from database

爱⌒轻易说出口 提交于 2019-12-25 05:02:04
问题 i have database with two values id and val so i want to ask how i can generate simple array like this array('value', 'value2', 'value3'...); I have $query = $this->db->query('SELECT val FROM table'); echo $query->result_array(); But it will result something like that: Array ( [0] => Array ( [val] => value ) [1] => Array ( [val] => value2 ) ) And i want it in one array so please if you can help me. Thanks for all answers :) 回答1: $query = $this->db->query('SELECT val FROM table')->result_array(

3d line-intersection code not working properly

痴心易碎 提交于 2019-12-25 04:27:41
问题 I created this piece of code to get the intersection of two 3d line-segments. Unfortunately the result of this code is inaccurate, the intersection-point is not always on both lines. I am confused and unsure what I'm doing wrong. Here is my code: --dir = direction --p1,p2 = represents the line function GetIntersection(dirStart, dirEnd, p1, p2) local s1_x, s1_y, s2_x, s2_y = dirEnd.x - dirStart.x, dirEnd.z - dirStart.z, p2.x - p1.x, p2.z - p1.z local div = (-s2_x * s1_y) + (s1_x * s2_y) if div

Find a point along an angled line

不打扰是莪最后的温柔 提交于 2019-12-25 03:46:15
问题 I'm trying to figure out how to find a point along a line (half way, to be precice). I need this to put a particle emitter in the correct location to leave a smoke-trail after bullets. I've got point A and point C. Point A is the barrel-muzzle, and point C is found using ray-cast. Now, in order to put the emitter in the right location I need to find point D. How do one do this? I attached a picure to make it more visual. No, I could not attach the picture, but here's a link. Thanks in advance

python 3 print function

给你一囗甜甜゛ 提交于 2019-12-25 03:22:47
问题 So I want to print this: * ** *** **** ***** And my code is: for row in range(1,6): for col in range(row): print('*', end="") print('') My question is about print function, since it includes new line. Knowing some C before, I just can't figure it out what the last print('') does, and why my code doesn't work without it. 回答1: The end='' parameter to the first call to print suppresses printing a newine after the * , and the second call to print prints only a newline. 回答2: The extra print line

Change line colour and thickness in grid.curve. R

偶尔善良 提交于 2019-12-25 03:00:24
问题 How do I change the colour and thickness of the curve plotted with the grid.curve function? I've tried adding arguments to the function parameters but they're not supported. Can I somehow change the default par()? library(grid) plot.new() #main viewport vp=viewport(x=0.5,y=0.5,width=1, height=1) pushViewport(vp) #Circle grid.circle(x=0.5, y=0.5, r=0.4) grid.curve(0.5,0.9,0.9,0.5,curvature=arcCurvature(90),ncp=10) 回答1: Figured it out! I had to add the argument gp=gpar(col="red",lwd=10). grid

Input from the execution line in the terminal in c

 ̄綄美尐妖づ 提交于 2019-12-25 02:42:54
问题 The problem that i have is that i have to write a hanois tower game in c and the input for the number of the rings must not be in the programm but the code must read the number of rings in the execution. Example: ./ hanoistower 3 And the code should get the 3 as the input. How can i do that? 回答1: Command line arguments are propagated as strings through the main() function of your C program. In int main(int argc, char *argv[]) argc is the number of arguments, and argv is an array of strings