Skip to content

Instantly share code, notes, and snippets.

View AhnSeongHyun's full-sized avatar
🌮
taco is life

안성현 AhnSeongHyun

🌮
taco is life
View GitHub Profile
import pycurl
import re
from StringIO import StringIO
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'https://x.com/api/store/search')
c.setopt(c.POST, True)
c.setopt(c.SSL_VERIFYPEER, False)
c.setopt(pycurl.HTTPHEADER, [
import requests
headers = {
'Authorization': 'Basic YmVhdDpiZWF0X2FwcDswZWU4YTg0NjhmMmVjYjUzMzY2ZGM0MTA4NzUzZxxxxxxx',
'access-token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJCRUFUIiwiaWF0IjoxNTA5MzI1Mzk3LCJ1c2VyX2lkIjoiNVNzUUFkcnhST1NhUlVwMzVRTlBhZ3lQcmsxekk3YXJ5U3kvRldvT0hkOD0iLCJhdWQiOiJCRUFUX0FQUCJ9.z2HKLAazfWZQysOg4gZ64T2nfT7xMjVfsgvQscHN-BM'
}
r = requests.post('https://x.com/api/store/search', json=[], headers=headers)
print(r.elapsed.total_seconds())
print(r.headers)
print(r.json())
class WebRenderTemplateBase(RenderTemplateBase):
base_template_path = 'web'
def render(self):
return self._render_template()
def _render_template(self):
return render_template(self.template_path, **vars(self))
class WebRenderCardViewTemplate(WebRenderTemplateBase):
render_params.update(post_data)
return render_template('web.html', title=title, **render_params)
render_params = {}
render_parmas['title'] = 'test_page'
..
render_parmas['color'] = get_color_code(data)
return render_template('web.html', **render_params)
return render_template('web.html',
title="test_page",
color=template['COLOR'],
ciurl=template['CIURL'],
itemname=template['ITEMNAME'],
amount=template['AMOUNT'],
name=template['NAME'],
duration=template['DURATION'],
cancelurl=template['CANCELURL'],
ad_banner=template['ADBANNER'])
# -*- coding:utf-8 -*-
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
for key in ['train', 'test', 'validation']:
print("mnist.%s :" % key)
minst_dataset= getattr(mnist, key)
print("\tnum_examples : %d" % minst_dataset.num_examples)
print("\timages count : %d" % len(minst_dataset.images))
@AhnSeongHyun
AhnSeongHyun / app.py
Last active June 16, 2017 02:20
jsonify_encoder
def configure_json_encoder(app):
from decimal import Decimal
class CustomJsonEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Decimal):
return str(obj)
if obj is None:
return str('')
return super(CustomJsonEncoder, self).default(obj)
@AhnSeongHyun
AhnSeongHyun / audio5_example.js
Created December 2, 2016 00:13
audio5.js example
var audio_js = new Audio5js({
ready: function () {
this.load('/pos_agent/static/audio/TableOrder_1.mp3');
},
play:function(){
this.play();
}
});