Skip to content

Instantly share code, notes, and snippets.

View clichedmoog's full-sized avatar
😇

서명석(MS Seo) clichedmoog

😇
View GitHub Profile
@clichedmoog
clichedmoog / badge_count.py
Created January 26, 2024 15:12
롱 폴링을 이용한 알림 확인 코드 예제
# 로그이 필요 데코레이터
# REST API에 오류철 핸들러 데코레이터
@decorators.ajax_error_response_v2
@decorators.ajax_login_required_v2
def notifications(request):
data = {}
user = request.user
# 파라메터에 따라 몇 가지 동작을 지원함
if request.method == 'GET':
# count 파라메터는 곧바로 뱃지 갯수 가져오기
@clichedmoog
clichedmoog / url_add_query.py
Created January 3, 2018 12:37 — forked from leonsmith/url_add_query.py
Django template tag to append a query string to a url
from urlparse import urlsplit, urlunsplit
from django import template
from django.http import QueryDict
register = template.Library()
@register.simple_tag
def url_add_query(url, **kwargs):
"""
@clichedmoog
clichedmoog / date_extension.js
Created December 15, 2017 18:05
add clone, add for javascript Date object
Date.prototype.clone = function () {
return new Date(this.getTime());
};
Date.prototype.add = function (val, unit) {
d = new Date(this.getTime());
switch (unit) {
case 'year':
case 'years':
d.setYear(d.getYear() + val);
@clichedmoog
clichedmoog / get_script_path.js
Created September 1, 2017 18:42
get javascript path dynamically
function getScriptPath(filename) {
var scripts = document.getElementsByTagName('script');
if (scripts && scripts.length > 0) {
for (var i in scripts) {
if (scripts[i].src && scripts[i].src.match(new RegExp(filename+'\\.js$'))) {
return scripts[i].src.replace(new RegExp('(.*)'+filename+'\\.js$'), '$1');
}
}
}
};
@clichedmoog
clichedmoog / merge_partial_files.py
Last active December 28, 2016 09:19
merge two partial files in binary mode like uncompleted torrent download.
#!/usr/bin/python
import sys,getopt
def str_or(s1,s2):
# convert strings to a list of character pair tuples
# go through each tuple, converting them to ASCII code (ord)
# perform or on the ASCII code
# then convert the result back to ASCII (chr)
# merge the resulting array of characters as a string
//
// UIView.swift
// AirKlass
//
// Created by TENMA on 2016. 5. 19..
// Copyright © 2016년 Quriously. All rights reserved.
//
import UIKit