Skip to content

Instantly share code, notes, and snippets.

View astyfx's full-sized avatar

Jacob Kim astyfx

View GitHub Profile
@astyfx
astyfx / tshelpful.tsx
Created January 31, 2018 10:05
styled-components TS way
export function withProps<U>() {
return <P, T, O>(
fn: ThemedStyledFunction<P, T, O>,
): ThemedStyledFunction<P & U, T, O & U> =>
fn as ThemedStyledFunction<P & U, T, O & U>;
}
interface StyledAlertProps {
isAttachable?: boolean;
status?: string;
@astyfx
astyfx / styled-ts.js
Created January 30, 2018 08:07
Styled-Components TypeScript Help
const StyledAlert = styled.div`
padding: 13px 24px;
line-height: 1;
margin-bottom: 1rem;
font-size: 15px;
border: 1px solid transparent;
border-radius: 4px;
a {
color: #aaeaf4;
text-decoration: underline;
@astyfx
astyfx / tutorial-build-a-messaging-app-using-react-native1.js
Last active October 23, 2017 03:08
tutorial-build-a-messaging-app-using-react-native
var React = require('react-native');
var {
AppRegistry
} = React;
var Main = require('./src/main')
AppRegistry.registerComponent('SendBirdSample', () => Main);
@astyfx
astyfx / Output
Created November 28, 2016 06:02 — forked from DazWorrall/Output
Testing file upload handling in Flask
in upload handler
in file close
..
----------------------------------------------------------------------
Ran 2 tests in 0.021s
OK
@astyfx
astyfx / 094607.md
Created July 26, 2016 03:55 — forked from marocchino/094607.md
ES6시대의 JavaScript

ES6시대의 JavaScript

안녕하세요. 사원사업부의 마루야마@h13i32maru입니다. 최근의 Web 프론트엔드의 변화는 매우 격렬해서, 조금 눈을 땐 사이에 점점 새로운 것이 나오고 있더라구요. 그런 격렬한 변화중 하나가 ES6이라는 차세대 JavaScript의 사양입니다. 이 ES6는 현재 재정중으로 집필시점에서는 Draft Rev31이 공개되어있습니다.

JavaScript는 ECMAScript(ECMA262)라는 사양을 기반으로 구현되어있습니다. 현재 모던한 Web 브라우저는 ECMAScript 5.1th Edition을 기반으로 한 JavaScript실행 엔진을 탑재하고 있습니다. 그리고 다음 버전인 ECMAScript 6th Edition이 현재 재정중으로, 약칭으로 ES6이라는 명칭이 사용되고 있습니다.

@astyfx
astyfx / generate_build.py
Created July 19, 2016 06:26 — forked from moomoohk/generate_build.py
Cactus (http://cactusformac.com/) plugin that generates an external build folder that doesn't overwrite your git files. Perfect for usage with GitHub pages, just stick your .git in the generated build folder.
import distutils.dir_util
import shutil
import os
def copytree(src, dst):
for item in os.listdir(src):
s, d = os.path.join(src, item), os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, False, None)
else:

Python 내용 정리

  • “%r” % anything
    • 무엇이든가에 출력하라 ( formatting string)
    • RAW data를 그대로 출력한다(디버깅에 용의)
    • representation → repr
  • argv
    • argument variable
  • Magic Method
  • class TestClass(object):
@astyfx
astyfx / gist:3fe88fa78567b0ea9d46
Created January 21, 2015 03:28
Decorator for flask-HTTPAuth authentication header. In AngularJS for prevent basic authentication popup
def set_authentication_header(f):
'''
Decorator for flask-HTTPAuth authentication header.
In AngularJS for prevent basic authentication popup
:param f:
:return:
'''
@wraps(f)
def decorated(*args, **kwargs):
res = f(*args, **kwargs)
$.clearhash = function (e) {
var cst = $('body').scrollTop();
location.hash = "";
$('body').scrollTop(cst);
};
filtered = [x['min_field'] for x in Model.objects.filter(filter_conditions).values('same_field').annotate(Count('same_field', distinct=True)).annotate(min_field=Min('min_field')).distinct()]
result = Model.objects.filter(field__in=filtered)