Skip to content

Instantly share code, notes, and snippets.

View ShinJJang's full-sized avatar
🎯
Focusing

shinjjang ShinJJang

🎯
Focusing
View GitHub Profile
https://jsfiddle.net/afyY2/37/
@ShinJJang
ShinJJang / parameter_local_variable_test.py
Last active August 29, 2015 14:23
To check is same variable with parameter and local variable that have same name
def parameter_local_variable_test(a):
print("init : ", hex(id(a)))
a = 10
print("assign 10 to a : ", hex(id(a)))
a = 5
print("assign different value : ", hex(id(a)))
a = 5
print("same value : " ,hex(id(a)))
# >>> test(10)
@ShinJJang
ShinJJang / merge.py
Last active August 29, 2015 14:25
working merge sort
def merge(array1, array2):
a_index = 0
b_index = 0
result = []
while a_index < len(array1) or b_index < len(array2):
if a_index >= len(array1) or array1[a_index] > array2[b_index]:
result.append(array2[b_index])
b_index+=1
elif b_index >= len(array2) or array1[a_index] <= array2[b_index]:
result.append(array1[a_index])
@ShinJJang
ShinJJang / fail_merge.py
Last active August 29, 2015 14:25
fail merge sort
def merge(array1, array2):
a_index = 0
b_index = 0
result = []
# wrong while condition
while a_index < len(array1) and b_index < len(array2):
if array1[a_index] > array2[b_index]:
result.append(array2[b_index])
b_index+=1
import json
from app.models import People
from django.http import HttpResponse
def add_peoples(request, room_id):
# request.body = '{"peoples": [{name:'a', phone:'001010}, {....}, {....}]}'
json_peoples = json.loads(request.body)
for json_people in json_peoples["peoples"]:
# room is real field name. _id is attr.
people = People.objects.create(name=json_people['name'], phone=json_people['phone'], room_id=room_id)
@ShinJJang
ShinJJang / .inputrc
Created July 27, 2015 14:32
~/.inputrc
set output-meta on
set convert-meta off
@ShinJJang
ShinJJang / .vimrc
Last active August 29, 2015 14:25
~/.vimrc : vim setting file for korean
set tenc=korea
set enc=utf-8
@ShinJJang
ShinJJang / sort.py
Created July 29, 2015 09:20
sort two sorted array, return one sorted array
def sort(a, b):
a_index=0
b_index=0
result = []
while a_index < len(a) or b_index < len(b):
if b_index >= len(b):
result.append(a[a_index])
a_index+=1
elif a_index >= len(a):
result.append(b[b_index])
def mergeSort(alist):
print("Splitting ", alist)
if len(alist)>1:
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]
mergeSort(lefthalf)
mergeSort(righthalf)
@ShinJJang
ShinJJang / vertualenv_python3_windows
Created July 31, 2015 07:59
windows python3 virtualenv
> pip3 install virtualenv # 3.x의 python library virtualenv 설치
> python3 -m venv myenv # python3 환경을 virtual environment를 myenv 폴더에 셋팅
> myenv\Scripts\activate.bat # python3 가상 환경을 적용
> deactivate.bat # 가상 환경 해제