반응형
반응형

 

https://www.hani.co.kr/arti/economy/economy_general/1150014.html

 

MS발 먹통 대란에 “빙산의 일각”…취약성 노출한 ‘초연결 세계’

( ☞한겨레 뉴스레터 H:730 구독하기. 검색창에 ’h:730’을 쳐보세요.) 지난 19일(이하 현지시각) 전세계를 강타한 ‘마이크로소프트(MS·엠에스)발 장애 사태’ 이후 ‘인공지능(AI) 클라우드 시대

www.hani.co.kr

 

 

크라우드스트라이크가 알려준 해법은 아래와 같습니다. 혹시 이상이 있다면, 아래 방법을 따라하시면 됩니다.
 

윈도우를 안전 모드로 부팅, 또는 외장 드라이브에 탑재한 윈도우로 부팅
C:\Windows\System32\drivers\CrowdStrike로 이동
C-00000291*.sys 파일 찾아서 삭제
정상적으로 재부팅

반응형
반응형

Pandas는 데이터 분석, 조작 및 시각화를 위한 인기 있는 Python 라이브러리입니다. 구조화된 데이터와 구조화되지 않은 데이터를 포함하여 다양한 형식의 데이터를 쉽고 효과적으로 작업할 수 있는 풍부한 도구와 기능을 제공합니다. 이 문서에서는 Python에서 빠르고 효율적으로 데이터 분석을 수행하는 데 사용할 수 있는 일반적인 pandas 작업과 함수에 대한 치트시트를 제공합니다.

 

import pandas as pd

 

 

Pandas 라이브러리를 가져온 후에는 다음 작업과 함수를 사용하여 일반적인 데이터 분석 작업을 수행할 수 있습니다.

  • pd.read_csv(filename): CSV 파일에서 데이터를 로드합니다.
  • data.head(): 데이터 프레임의 처음 몇 행을 봅니다.
  • data.tail(): 데이터 프레임의 마지막 몇 행을 봅니다.
  • data.describe(): 숫자 열에 대한 요약 통계를 계산합니다.
  • data.info(): 데이터 프레임의 데이터 유형과 메모리 사용량을 확인합니다.
  • data.columns: 데이터 프레임의 열을 봅니다.
  • data['column']: 데이터 프레임의 열을 선택합니다.
  • data.loc[row_index]: 인덱스를 기준으로 데이터 프레임의 행을 선택합니다.
  • data.iloc[row_index]: 위치를 기준으로 데이터 프레임의 행을 선택합니다.
  • data.dropna(): 값이 누락된 행을 삭제합니다.
  • data.fillna(value): 누락된 값을 주어진 값으로 채웁니다.
  • data.rename(columns={'old': 'new'}): 데이터 프레임의 열 이름을 바꿉니다.
  • data.sort_values(by='column'): 열의 값을 기준으로 데이터 프레임을 정렬합니다.
  • data.groupby('column')['column'].mean(): 열의 값으로 데이터 프레임을 그룹화하고 다른 열의 평균을 계산합니다.
  • data.plot.hist(): 수치적 히스토그램을 그리다

반응형
반응형

LEGB Rule

  • 파이썬 변수 scope 룰을 LEGB 룰이라고 불리기도 합니다.
  • 변수가 값을 찾을 때, Local -> Enclosed -> Global -> Built-in
  • local - 가장 가까운 함수안 범위 입니다.
  • Enclosed - 파이썬은 함수 안에 함수가 정의 될수 있는데, 가장 가까운 함수가 아닌 두번째 이상의 함수 가까운 함수범위입니다.
  • Global - 함수 바깥의 변수 또는 import된 module
  • Built-in - 파이썬안에 내장되어 있는 함수 또는 속성들입니다.
>>> a = 5    # Global
>>> b = 10   # Global
>>> def outer():
...     a = 10  # outer함수의 local이며, inner함수의 Enclosed
...     def inner():
...             c=30 # inner 함수의 local
...             print(a, b, c)
...     inner()
...     a = 22  # outer함수의 local이며, inner함수의 Enclosed
...     inner()
... 
>>> outer()
10 10 30  
22 10 30
반응형
반응형

"""_summary_
얕은 복사(shallow copy)
    list의 슬라이싱을 통한 새로운 값을 할당해봅니다.
    아래의 결과와 같이 슬라이싱을 통해서 값을 할당하면 새로운 id가 부여되며, 서로 영향을 받지 않습니다
"""

print("\n","*" * 30, "\n   얕은 복사(shallow copy) \n","*" * 30) 

a = [1, 2, 3]
b = a[:]
print(" a = ", a)
print(" b = ", b)

print(" id(a) : ", id(a)) #다른 주소
print(" id(b) : ", id(b))

print(" a == b : ", a == b)
print(" a is b : ", a is b)

b[0] = 5

print(a)
print(b)

""" 
    하지만, 이러한 슬라이싱 또한 얕은 복사에 해당합니다.
    리스트안에 리스트 mutable객체 안에 mutable객체인 경우 문제가 됩니다.
    id(a) 값과 id(b) 값은 다르게 되었지만, 그 내부의 객체 id(a[0])과 id(b[0])은 같은 주소를 바라보고 있습니다
"""
a = [[1,2],[3,4]]
b = a[:]
print(" id(a) : ", id(a)) #다른 주소
print(" id(b) : ", id(b))

print(" id(a[0]) : ",id(a[0])) #같은 주소
print(" id(b[0]) : ",id(b[0]))


"""깊은 복사(deep copy)
    깊은 복사는 내부에 객체들까지 모두 새롭게 copy 되는 것입니다.
    copy.deepcopy메소드가 해결해줍니다
"""
print("\n","*" * 30, "\n   deepcopy \n","*" * 30)  

import copy

a = [[1,2],[3,4]]
b = copy.deepcopy(a)
a[1].append(5)

print(" a : ", a)
print(" b : ", b)

print(" id(a) : ", id(a)) #다른 주소
print(" id(b) : ", id(b))

 

반응형
반응형

[python] 얕은 복사(shallow copy)와 깊은 복사(deep copy)

 

https://wikidocs.net/16038

 

12. 얕은 복사(shallow copy)와 깊은 복사(deep copy)

## 1. mutable과 immutable 객체 객체에는 mutable과 immutable 객체가 있습니다. ❈ 객체 구분 표 class 설명 구분 l…

wikidocs.net

 

1. mutable과 immutable 객체

객체에는 mutable과 immutable 객체가 있습니다.

❈ 객체 구분 표

class설명구분

list mutable 한 순서가 있는 객체 집합 mutable
set mutable 한 순서가 없는 고유한 객체 집합 mutable
dict key와 value가 맵핑된 객체, 순서 없음 mutable
bool 참,거짓 immutable
int 정수 immutable
float 실수 immutable
tuple immutable 한 순서가 있는 객체 집합 immutable
str 문자열 immutable
frozenset immutable한 set immutable

일반 user가 작성한 class도 대부분 mutable 한 객체 입니다.
immutable한 클래를 만들기 위해서는 특별한 방법이 필요합니다.

https://stackoverflow.com/questions/4828080/how-to-make-an-immutable-object-in-python

  • REPL에서 mutable과 immutable에서 구분해봅시다. 몇가지만 해봅니다.
  • list 는 mutable 입니다.
  • 변수 a 에 1, 2, 3을 원소로 가지는 리스트를 할당하였습니다.
  • id는 변수의 메모리 주소값을 리턴해줍니다.
  • a의 첫번째 원소를 변경한 후에도 id값은 변경없이 a의 변수가 변경되었습니다.
>>> a = [1, 2, 3]
>>> id(a)
4393788808
>>> a[0] = 5
>>> a
[5, 2, 3]
>>> id(a)
4393788808
  • set도 mutable입니다.
  • |= set에서 or 연산입니다. 합집합이 됩니다.
  • 값은 변경되었으나 id는 변함없습니다.
>>> x = {1, 2, 3}
>>> x
{1, 2, 3}
>>> id(x)
4396095304
>>> x|={4,5,6}
>>> x
{1, 2, 3, 4, 5, 6}
>>> id(x)
4396095304
  • str은 immutable 입니다.
  • s 변수에 첫번째 글자를 변경 시도하면 에러가 발생합니다.
  • s에 다른 값을 할당하면, id가 변경됩니다. 재할당은 애초에 변수를 다시할당하는 것이므로 mutable과 immutable과는 다른 문제입니다. list또한 값을 재할당하면 id가 변경됩니다.
>>> s= "abc"
>>> s
'abc'
>>> id(s)
4387454680
>>> s[0]
'a'
>>> s[0] = 's'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
>>> s = 'def'
>>> s
'def'
>>> id(s)
4388970768

2. 변수 간 대입

2-1 mutable한 객체의 변수 간 대입

  • list의 얕은 복사를 확인 해봅니다.
  • b 에 a를 할당하면 값이 할당되는 것이 아니라 같은 메모리 주소를 바라봅니다.
  • b를 변경하면 같이 a도 바뀝니다.
  • mutable한 다른 객체 또한 똑같은 현상이 나타납니다.
>>> a = [1, 2, 3]
>>> b = a # shallow copy
>>> b[0]= 5
>>> a
[5, 2, 3]
>>> b
[5, 2, 3]
>>> id(a)
4396179528
>>> id(b)
4396179528

2-2 immutable한 객체의 변수간 대입

  • str 문자열의 얕은 복사를 확인해봅니다.
  • list와 똑같이 b를 a에 할당하면 같은 메모리 주소를 바라보게 됩니다.
  • 하지만 b에 다른 값을 할당하면 재할당이 이루어지며 메모리 주소가 변경됩니다.
  • 고로 a와 b는 다른 값을 가집니다.
>>> a = "abc"
>>> b = a
>>> a
'abc'
>>> b
'abc'
>>> id(a)
4387454680
>>> id(b)
4387454680
>>> b = "abcd"
>>> a
'abc'
>>> b
'abcd'
>>> id(a)
4387454680
>>> id(b)
4396456400

3. 얕은 복사(shallow copy)

  • list의 슬라이싱을 통한 새로운 값을 할당해봅니다.
  • 아래의 결과와 같이 슬라이싱을 통해서 값을 할당하면 새로운 id가 부여되며, 서로 영향을 받지 않습니다.
>>> a = [1,2,3]
>>> b = a[:]
>>> id(a)
4396179528
>>> id(b)
4393788808
>>> a == b
True
>>> a is b
False
>>> b[0] = 5
>>> a
[1, 2, 3]
>>> b
[5, 2, 3]
  • 하지만, 이러한 슬라이싱 또한 얕은 복사에 해당합니다.
  • 리스트안에 리스트 mutable객체 안에 mutable객체인 경우 문제가 됩니다.
  • id(a) 값과 id(b) 값은 다르게 되었지만, 그 내부의 객체 id(a[0])과 id(b[0])은 같은 주소를 바라보고 있습니다.
>>> a = [[1,2], [3,4]]
>>> b = a[:]
>>> id(a)
4395624328
>>> id(b)
4396179592
>>> id(a[0])
4396116040
>>> id(b[0])
4396116040
  • 재할당하는 경우는 문제가 없습니다. 메모리 주소도 변경되었습니다.
>>> a[0] = [8,9]
>>> a
[[8, 9], [3, 4]]
>>> b
[[1, 2], [3, 4]]
>>> id(a[0])
4393788808
>>> id(b[0])
4396116040
  • 하지만, a[1] 에 값을 변경하면 b[1]도 따라 변경됩니다.
>>> a[1].append(5)
>>> a
[[8, 9], [3, 4, 5]]
>>> b
[[1, 2], [3, 4, 5]]
>>> id(a[1])
4396389896
>>> id(b[1])
4396389896
  • copy 모듈의 copy 메소드 또한 얕은 복사입니다.
>>> import copy
>>> a = [[1,2],[3,4]]
>>> b = copy.copy(a)
>>> a[1].append(5)
>>> a
[[1, 2], [3, 4, 5]]
>>> b
[[1, 2], [3, 4, 5]]

4. 깊은 복사(deep copy)

  • 깊은 복사는 내부에 객체들까지 모두 새롭게 copy 되는 것입니다.
  • copy.deepcopy메소드가 해결해줍니다.
>>> import copy
>>> a = [[1,2],[3,4]]
>>> b = copy.deepcopy(a)
>>> a[1].append(5)
>>> a
[[1, 2], [3, 4, 5]]
>>> b
[[1, 2], [3, 4]]




https://suwoni-codelab.com/python%20%EA%B8%B0%EB%B3%B8/2018/03/02/Python-Basic-copy/

 

반응형
반응형

모든 웹 개발자가 알아야 할 7가지 개념!

https://pinjarirehan.medium.com/7-concepts-every-web-developer-should-know-b32407fda8dc

 

7 Concepts Every Web Developer Should Know!

Whether you’re a seasoned developer or a curious beginner just starting, creating outstanding websites needs more than just stunning…

pinjarirehan.medium.com

 

Whether you’re a seasoned developer or a curious beginner just starting, creating outstanding websites needs more than just stunning animations and interesting effects.

It all comes down to a solid basis in important concepts.

Mastering these bad boys will make you a more effective and flexible developer, ready to take on every task.

So grab your favorite coding cup (coffee for all-nighters, anyone?), and let’s get started!

Have a BIG IDEA in mind? Let’s discuss what we can gain together.

Write at Gmail | LinkedIn

 

01. The Big Three: HTML, CSS & JavaScript

Take these three to be the web’s basic building blocks.

HTML organizes your content, CSS beautifully styles it, and JavaScript adds interaction and personality.

Here is a basic breakdown:

  • HTML (Hypertext Markup Language) is the basis for your website, specifying elements such as headers, paragraphs, and illustrations.
  • CSS (Cascading Style Sheets): CSS makes your website visually attractive. CSS pseudo-classes can offer dynamic effects when a button is hovered over or focused, such as changing its color or adding stunning animations.

Actionable Tip: Use the BEM (Block-Element-Modifier) structure to write clean, maintainable CSS.

  • JavaScript: This is the magic that allows webpages to interact with one another. Learn how to write clean, maintainable JavaScript to avoid code challenges in the future.

02. Responsive Web Design

Imagine how your website looks on a large desktop display but not on a mobile device.

Not cool.

Responsive design guarantees that your website works effortlessly on any device, especially PCs, tablets, and smartphones.

Here is the secret sauce:

  • Media Queries are like magic spells that tell your website to customize its layout depending on screen size.
  • Fluid Grids: Imagine a website layout as a grid. Fluid grids use percentages rather than set pixels, allowing the grid to “flow” and adjust to different displays.
  • Flexible images: Large photos might slow down your mobile page. Use flexible images that resize to fit the screen size.

03. Version Control with Git

Ever worked on a project, made changes, and then accidentally messed things up? Git version control is a savior.

It tracks changes to your code, allowing you to restore to previous versions and interact with others smoothly.

Here’s a crash course on Git basics.

  • Repositories: Think of a repository as the hub for all of your code versions.
  • Commits: These are snapshots of your code at specified moments in time. You can include messages that explain the changes that you made.
  • Branches: Assume you want to test out a new feature without impacting the main code. Branches let you work on changes separately before merging them back into the main codebase once you’re satisfied.

04. HTTP/HTTPS & APIs

The web is all about communication! HTTP (Hypertext Transfer Protocol) is the language that computers use to communicate with one another.

When you visit a website, your browser sends an HTTP request, and the server returns an HTTP response giving the website content.

  • HTTPS (Hypertext Transfer Protocol Secure) is the secure version of HTTP, which encrypts data transport to safeguard your website and user information. Always use HTTPS to ensure security!
  • APIs (Application Programming Interfaces) are similar to waiters at a restaurant. They accept your request (such as collecting user data) and deliver the information you want from another system. Understanding APIs is essential for creating interactive web apps.

05. Basic SEO:

Do you want your website to be the first thing visitors see when searching for something? Basic Search Engine Optimization (SEO) can help!

  • Meta Tags: These are hidden messages for search engines that include information about your website’s content.
  • Keywords: These are the terms that people are likely to look for. Use relevant keywords strategically throughout your website’s content.
  • Website Performance Optimization: A slow website is a sad one. Optimize your website’s image size and code structure for faster loading, which benefits both search engines and visitors.

06. Web Accessibility

The web should be accessible to everyone! Web accessibility means that persons with disabilities can get to and use your website.

  • Semantic HTML means using HTML elements to explain the meaning and purpose of your content, instead of merely displaying it.
  • ARIA Roles are unique properties that give additional information to screen readers used by visually impaired people.
  • Keyboard Navigation: A mouse is not used by everyone. Ensure that your website can be accessed just by keyboard.

07. Performance Optimization

No one loves a slow website! Optimize your website’s speed by reducing HTTP requests (the number of times it asks the server for something), adding caching (storing frequently used items locally), and optimizing images for more quickly loading.

Remember that a quick website means a happy user (and a happy search engine!).

Pro Tips & Best Practices: From a Developer to You

Here are some gold pieces I’ve picked up along my journey.

  • Always comment on your code! Your future self (or someone else) will thank you.
  • Do not let yourself be afraid to experiment! Break things, try new things, and learn from the mistakes you make.
  • The dev community is ready to help! There are many communities and resources out online. Don’t be hesitant to ask questions.

 

반응형

+ Recent posts