✅ 1. 내부 IP (로컬 IP) 확인
터미널에서 다음 명령어 입력:
ip addr show
혹은 간단하게
ip a
인터페이스 별로 확인하려면:
ip -4 addr show eth0
✅ 2. 외부 IP (공인 IP) 확인
외부 서버에 요청해서 확인:
curl ifconfig.me
또는
curl ipinfo.io/ip
터미널에서 다음 명령어 입력:
ip addr show
혹은 간단하게
ip a
인터페이스 별로 확인하려면:
ip -4 addr show eth0
외부 서버에 요청해서 확인:
curl ifconfig.me
또는
curl ipinfo.io/ip
import 부터 하자.
import matplotlib.pyplot as pyplot
하나는 x 축, 다른 하나는 y 축으로 리스트 두개를 가지고 그린다. 예를 보자. scatter()를 썼다.
names = ['Bamtol', 'Mong', 'Justin', 'Jay']
bomb = [8, 1, 12, 10]
pyplot.title('Super Mario Cart 8 Deluxe Score')
pyplot.xlabel('Name')
pyplot.ylabel('Score')
pyplot.scatter(names, bomb, color='green')
pyplot.show()
위의 그래프는 막대 그래프가 더 나아보인다. bar()로 막대 그래프를 그래보자. 각각의 색도 바꿔보자.
names = ['Bamtol', 'Mong', 'Justin', 'Jay']
bomb = [8, 1, 12, 10]
pyplot.title('Super Mario Cart 8 Deluxe Score')
pyplot.xlabel('Name')
pyplot.ylabel('Score')
pyplot.bar(names, bomb, color=[ 'blue', 'red', 'gray', 'green' ])
pyplot.show()
barh()를 쓰면 누은 그래프가 나온다. xlabel()과 ylabel() 바꿔주자.
names = ['Bamtol', 'Mong', 'Justin', 'Jay']
bomb = [8, 1, 12, 10]
pyplot.title('Super Mario Cart 8 Deluxe Score')
pyplot.xlabel('Score')
pyplot.ylabel('Name')
pyplot.barh(names, bomb, color=[ 'blue', 'red', 'gray', 'green' ])
pyplot.show()
plot()을 쓰면 선 그래프가 나온다.
weigh = [ 3.26, 4.5, 5.6, 7.2, 8.9, 10.4, 12.6, 14.2, 16.1, 17.4, 16.8, 16.3, 16.5, 17.0]
pyplot.plot(weigh)
pyplot.title("Bamtol's weigh")
pyplot.xlabel('Days')
pyplot.ylabel('Kg')
pyplot.show()
그려진 그래프의 시작이 1이 아닌 0 부터임에 주의하자. 이걸 1부터로 바꾸고, x 축 찍는 위치도 바꾸고, 마커도 넣어보자.
weigh = [ 3.26, 4.5, 5.6, 7.2, 8.9, 10.4, 12.6, 14.2, 16.1, 17.4, 16.8, 16.3, 16.5, 17.0]
axis_x = list(range(1, 15))
pyplot.title("Bamtol's weigh")
pyplot.xlabel('Days')
pyplot.ylabel('Kg')
pyplot.plot(axis_x, weigh, marker = '.', color = 'green')
pyplot.xticks([1, 4, 7, 10, 13])
pyplot.show()
파이 차트를 그릴 때는 pie()를 이용한다.
names = ['Bamtol', 'Mong', 'Justin', 'Jay']
bomb = [8, 1, 12, 10]
pyplot.title('Results: Score', fontdict={'fontsize': 24})
pyplot.pie(bomb, labels=names, autopct='%1.1f%%', colors=['lightblue','pink','yellow','lightgreen'])
ip -f inet6 route add default dev rmnet1
ip -f inet6 route show table local
리눅스 커널은 scnprintf 라는 함수를 제공하는데, 이 함수는 snprintf의 일종이라고 볼 수 있다.
snprintf 는 C99 표준에 의해서 버퍼에 실제로 쓰여진 길이를 리턴하지 않고, 쓰여지고자 했던 길이를 리턴하도록 되어 있다. 예를 들어 다음과 같은 소스 코드가 있다면,
int main(void)
{
char buffer[10] = { 0, };
int output = 0;
output = snprintf(buffer, sizeof(buffer), “%ld”, 1234567890123l);
printf(“buffer: %s, output: %d\n”, buffer, output);
return 0;
}
대부분 생각하는 출력은 아마도 “buffer: 123456789, output:9” 와 같을텐데, 이 소스 코드에 해당하는 프로그램은 다음과 같이 output으로 원래 찍으려고 했었던 수의 출력 길이인 13을 출력한다.
그래서 커널은 snprintf 말고도 scnprintf 함수를 제공한다.
요즘은 Device driver의 제어를 위해 ioctl 함수보다는 sysfs 를 이용하는 추세인데, 이를 위한 sysfs의 show 함수에서는 scnprintf를 사용하도록 하고 있다(Documentation/filesystems/sysfs.txt).
참고 : http://lwn.net/Articles/69419/