This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* 공식 트위터 사이트에서는 트윗을 RT한 사람 목록을 볼 수가 있는데 | |
* 숫자가 조금만 많아도 줄여서 보여주기 때문에 모두 확인하기가 어렵다. | |
* | |
* 트위터 API를 써서 모두 확인하는 방법 | |
*/ | |
$tweet_id = '101450759463383041'; // 트위터 사이트에서 트윗한 시간을 누르면 확인 가능 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "./hello.py", line 31, in <module> | |
def hello(name=None): | |
File "./hello.py", line 15, in deco | |
@wraps(f) | |
File "/Users/mckabi/Documents/Sandbox/flask_ex/env/lib/python2.7/site-packages/flask/app.py", line 1013, in decorator | |
self.add_url_rule(rule, endpoint, f, **options) | |
File "/Users/mckabi/Documents/Sandbox/flask_ex/env/lib/python2.7/site-packages/flask/app.py", line 62, in wrapper_func | |
return f(self, *args, **kwargs) | |
File "/Users/mckabi/Documents/Sandbox/flask_ex/env/lib/python2.7/site-packages/flask/app.py", line 984, in add_url_rule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def RC4crypt(data, key): | |
''' | |
http://en.wikipedia.org/wiki/RC4 | |
''' | |
box_range = 256 | |
box = range(box_range) | |
i = 0 | |
for j in range(box_range): | |
i = (i + box[j] + ord(key[j % len(key)])) % box_range |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
print 'weighted_choice test' | |
picked_items = [] | |
weights = {'1st': 50, '2nd': 30, '3rd': 15, '4th': 5, '5th': 0} | |
for i in xrange(100000): | |
picked_items.append(weighted_choice(weights)) | |
for code in sorted(set(picked_items[:])): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListConverter(BaseConverter): | |
def to_python(self, value): | |
if isinstance(value, (set, list, tuple)): | |
return list(value) | |
try: | |
parsed_value = json.loads(value) | |
except: | |
parsed_value = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def convert(obj): | |
if isinstance(obj, dict): | |
return dict((convert(key), convert(value)) for key, value in obj.iteritems()) | |
elif isinstance(obj, list): | |
return [convert(element) for element in obj] | |
elif isinstance(obj, unicode): | |
return obj.encode('utf-8') | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.7 | |
RUN apt-get -qq update && \ | |
apt-get -q -y upgrade && \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y locales locales-all | |
RUN apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
#ENV PYTHONDONTWRITEBYTECODE 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector('input[type=email]').addEventListener('keyup', event => { | |
const element = event.target; | |
const valueParts = element.value.split('@'); | |
if (element.getAttribute('list') && document.getElementById(element.getAttribute('list'))) { | |
document.getElementById(element.getAttribute('list')).remove(); | |
} | |
if (valueParts.length > 1 && valueParts[0] && valueParts[1]) { | |
const suggestionsId = (element.id || element.name) + 'Suggestion'; | |
const suggestions = makeDatalist(suggestionsId, valueParts[0], valueParts[1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelectorAll("td[colspan=full]").forEach(td => { | |
const table = td.closest("table"); | |
const columns = table.querySelector("tr").querySelectorAll("th, td"); | |
const column_count = Array.from(columns).reduce((acc, cell) => acc + (cell.getAttribute('colspan') || 1), 0); | |
td.setAttribute('colspan', column_count); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Django REST Framework router + ViewSet + parameters | |
- https://www.django-rest-framework.org/api-guide/routers/ | |
""" | |
class OriginViewSet(ModelViewSet): | |
... | |
@classmethod | |
def as_custom_viewset(cls, **kwargs): | |
class CustomViewSet(cls): |
OlderNewer