Skip to content

Instantly share code, notes, and snippets.

View CodeMath's full-sized avatar
🎯
Focusing

codemath CodeMath

🎯
Focusing
  • Seoul, Korea
View GitHub Profile
@CodeMath
CodeMath / viewset_mixins.py
Created September 3, 2025 04:02
요청과 응답 시리얼라이저가 다른 경우 mixins 을 통해 캡슐화 처리
from rest_framework.response import Response
from django.core.exceptions import ImproperlyConfigured
"""
동일한 패턴에 대한 Mixin 클래스
"""
class CreateUpdatePartialUpdateCustomMixin:
"""
@CodeMath
CodeMath / address_list.py
Created February 10, 2023 05:41
Exchange's specific token amount and price and cap
dacaddress = {
"AAA":[
"0x000000000000000000000000000000000001",
"0x000000000000000000000000000000000002",
"0x000000000000000000000000000000000001",
"0x000000000000000000000000000000000002",
],
}
@CodeMath
CodeMath / lambda.py
Created February 10, 2023 05:34
ERC20, Holder's token amount checker
import json
import os
import requests
from datetime import datetime, timedelta
from address_list import *
import time
contractaddress = "{CONTRACT_ADDRESS}"
def lambda_handler(event, context):
@CodeMath
CodeMath / ajax_djaogn_csrf.js
Created July 12, 2019 11:40
Ajax - Django CSRF token gen cookie
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
@CodeMath
CodeMath / README.md
Last active July 9, 2019 09:21
ubuntu 18.04 - django & nginx settings

aws EC2 ubuntu 18.04 - django & nginx/gunicorn settings

$ sudo apt update
$ sudo apt install python3-pip python3-dev libpq-dev nginx nano file

$ sudo -H pip3 install --upgrade pip
$ sudo -H pip3 install virtualenv

make a virtual enviorment

@CodeMath
CodeMath / graph.py
Created April 10, 2019 07:10
복잡한 트리구조를 꼼수로 이겨내는 길....
import os
import json
from .models import friends
from ssproject.settings import *
def update(request):
with open(os.path.join(BASE_DIR, '/data.json')) as f:
base = json.load(f)
friends = Friends.objects.get(user=request.user)
// 기본 사용자 구조
{
"id":1,
"head":"*",
"contents":"test1",
"children":[]
}
// 위 기본 구조를 토대로 2 연결된 부분의 데이터 들이 key가 'children'인 리스트에 들어갑니다.
// 여기서 contents 에는 사용자 이름이 들어가고, children 의 리스트엔 ManyToMany 로 연결된 User 데이터가 들어갑니다.
@CodeMath
CodeMath / admin.py
Created May 11, 2018 13:45
django - basic User + Profile models.py and admin.py
from .models import Profile
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
from .models import Profile
class ProfileInline(admin.StackedInline):
"""Define an inline admin descriptor for Profile model"""
model = Profile
@CodeMath
CodeMath / algo.md
Created May 4, 2018 03:31
백준 랜덤 알고리즘 문제_20180504
@CodeMath
CodeMath / algo.md
Created May 4, 2018 03:30
백준 랜덤 알고리즘 문제_20180504