Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jquery mobile link test</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
@zeraf29
zeraf29 / python_namespace.py
Created January 8, 2017 12:03
Python - namespace
animal = 'fruitbat'
def print_global():
print('inside print_global:', animal, id(animal))
def change_local():
animal = 'wombat_local' #지역 네임스페이스로 animal 선언
print('inside change_local:', animal, id(animal))
# 로컬 네임스페이스 상에 animal 이라는 변수로 새로 할당
# 전역 변수와 id값이 다르다
# 로컬 변수는 수행 후 함수가 종료되면 사라짐
@zeraf29
zeraf29 / python_namespace2.py
Created January 8, 2017 12:24
Python namespace function example
#파이썬 네임스페이스 접근 함수
#locals() 로컬 네임스페이스 내용 딕셔너리 반환
#globals() 글로벌 네임스페이스 내용 딕셔너리 반환
animal = 'fruitbat'
def change_local():
animal = 'wombat' # local variable
print('locals:',locals())
print('globals:',globals())
@zeraf29
zeraf29 / python_class_example1.py
Last active February 12, 2017 13:54
Python Class example 1
class Person():
def __init__(self, name):
self.name = name
# __init__()은 클래스 생성자(초기화)
# __init__()은 모든 클래스 정의에서 선언할 필요는 없음
# __init__()을 정의할 떄 반드시 첫번째 매개변수는 self
#__init__()을 정의할 때 첫 번째 매개변수는 self
hunter = Person('Tester Kim')
@zeraf29
zeraf29 / python_class_example2(override).py
Created February 12, 2017 14:07
python class override exmapl2
class Car():
def exclaim(self):
print("I'm a Car!")
class Yugo(Car): #상속 받을 부모 클래스의 명칭을 ()에 기입
pass
class Yugo2(Car):
def exclaim(self): #부모클래스 Car의 exclaim 메서드를 오버라이드
print("I'm a Yugo2!")
@zeraf29
zeraf29 / python_class_example3.py
Created February 12, 2017 14:18
python class example3
class Car():
def exclaim(self):
print("I'm a Car!")
class Yugo(Car): #상속 받을 부모 클래스의 명칭을 ()에 기입
def exclaim(self):
print("I'm a Yugo!") #method override
def need_a_push(self):
print("A little hlpe here?") #추가 선언
@zeraf29
zeraf29 / findunpairedvlue.py
Created February 19, 2017 13:56
리스트 내 쌍을 이루지 않은 정수값 찾기 소스
def findUnpairedValue(list) : #리스트 내 쌍을 이루지 않은 정수값
list.sort() #리스트 값을 정렬한다.
#리스트 범위 내에 2개의 값씩 서로 같은지 비교한다.
#이미 정렬을 했기 때문에 쌍을 이루는 값일 경우 해당 순서값과 다음값이 서로 같아야 한다.
#다들 경우 해당 값은 쌍을 이루지 않고 있으므로, 해당 값을 바로 리턴.
#시간복잡도 O(N) or O(N*log(N))
cnt = len(list)
i = 0
while i < cnt :
if (i+1) >= cnt or list[i] != list[i+1]:
@zeraf29
zeraf29 / binarysearch.js
Last active March 1, 2017 13:50
자바스크립트를 이용한 배열 내 요소 검색 이진검색 함수(칸 아카데미 응용: 이진검색 내용)
/*하위 내용은 칸 아카데미-알고리즘 강의 내 이진 검색 부분의 퀴즈 내용을 정리한
* https://ko.khanacademy.org/computing/computer-science/algorithms/binary-search/e/running-time-of-binary-search
*Below source is a way by me about Khan academy.org 's algorithms-binary search quiz
*/
/* Returns either the index of the location in the array,
or -1 if the array did not contain the targetValue */
var doSearch = function(array, targetValue) {
var min = 0;
var max = array.length - 1;
var guess;
@zeraf29
zeraf29 / insert_example.js
Created March 26, 2017 14:39
[칸 아카데미] 알고리즘-삽입정렬 : 삽입구현 소스
var insert = function(array, rightIndex, value) {
//Compare values between array[rightIndex] and value.
//if value is smaller than array[rightIndex], that array's value will be copied to array[rightIndex+1].
//This work keep going until finding value is bigger than array[i]("for" loop)
//if find smaller array value or i reach 0, loop will be end and value will be copied to array[i+1]
var i;
for(i=rightIndex;i>=0&&array[i]>value;i--){
array[i+1]=array[i];
}
array[i+1]=value;
@zeraf29
zeraf29 / insert_example.js
Created March 26, 2017 14:39
[칸 아카데미] 알고리즘-삽입정렬 : 삽입구현 소스
var insert = function(array, rightIndex, value) {
//Compare values between array[rightIndex] and value.
//if value is smaller than array[rightIndex], that array's value will be copied to array[rightIndex+1].
//This work keep going until finding value is bigger than array[i]("for" loop)
//if find smaller array value or i reach 0, loop will be end and value will be copied to array[i+1]
var i;
for(i=rightIndex;i>=0&&array[i]>value;i--){
array[i+1]=array[i];
}
array[i+1]=value;