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 matplotlib.pyplot as plt | |
from matplotlib import font_manager, rc | |
fontname = u'/usr/share/fonts/nhn-nanum/NanumGothic.ttf' #plt.font_manager.get_fontconfig_fonts()[0] | |
fontname = font_manager.FontProperties(fname=fontname).get_name() | |
plt.style.use('seaborn-white') | |
rc('font', family=fontname) |
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 org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
public class Application { | |
public static void main(String args[]) throws JSONException { | |
String result = "{ \"code\": 100, \"data\": [ { \"audioKey\": \"3be93db8c30c45261c64799d9c180b0e\", \"author\": { \"dispname\": \"Evenloop\", \"image\": \"\", \"username\": \"evenloop\" }, \"channel_image\": \"\", \"count_listen\": 0, \"count_recommend\": 0, \"created_at\": 1439563223, \"is_recommended\": 0, \"title\": \"test title\" }, { \"audioKey\": \"d83ebae5058b36a264fd16772b5eaeb6\", \"author\": { \"dispname\": \"Evenloop\", \"image\": \"\", \"username\": \"evenloop\" }, \"channel_image\": \"\", \"count_listen\": 1, \"count_recommend\": 1, \"created_at\": 1438153623, \"is_recommended\": 1, \"title\": \"test title\" } ], \"mesg\": \"success\", \"method\": \"ge |
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 heapq | |
topK = 10 | |
item_score_dict = {'1': 3,'2':2,'3':5,'4':1, '8':3} | |
ranklist = heapq.nlargest(topK, item_score_dict, key=item_score_dict.get) |
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
# /home/username/.ipython/profile_default/startup/alias.py | |
import subprocess | |
lines = subprocess.check_output('source bashrc; alias',shell=True).split(b'\n') | |
manager = get_ipython().alias_manager | |
for line in lines: | |
line = line.decode("utf-8") | |
split_index = line.find('=') | |
cmd = line[split_index+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
# -*- encoding: utf8 -*- | |
def send_log_to_slack(text): | |
channel = '<channel_name>' | |
import datetime | |
from slacker import Slacker | |
token = "<token>" | |
slack = Slacker(token) | |
attachments_dict = dict() | |
attachments_dict['pretext'] = text |
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
namespace: "polyaxon" | |
rbac: | |
enabled: true | |
ingress: | |
enabled: true | |
annotations: | |
ingress.kubernetes.io/ssl-redirect: "false" | |
ingress.kubernetes.io/rewrite-target: / | |
ingress.kubernetes.io/add-base-url: "true" |
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 pickle | |
a = {'hello': 'world'} | |
with open('filename.pickle', 'wb') as handle: | |
pickle.dump(a, handle, protocol=pickle.HIGHEST_PROTOCOL) | |
with open('filename.pickle', 'rb') as handle: | |
b = pickle.load(handle) |
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 get_df(cols, filename, sep='\t'): | |
# filename = 'filename' | |
iter_csv = pd.read_csv(filename,iterator=True, chunksize=1000, sep=sep, names=cols) | |
# df = pd.concat([chunk[chunk['field'] > constant] for chunk in iter_csv]) | |
df = pd.concat([chunk for chunk in iter_csv]) | |
return df |
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
# ArrayType()을 multiple columns으로 변환하는 방법 | |
df = hc.createDataFrame(sc.parallelize([['a', [1,2,3]], ['b', [2,3,4]]]), ["key", "value"]) | |
df.printSchema() | |
df.show() | |
''' | |
root | |
|-- key: string (nullable = true) | |
|-- value: array (nullable = true) |
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 django.contrib import admin | |
from .models import Question | |
class QuestionAdmin(admin.ModelAdmin): | |
fieldsets = [ | |
(None, {'fields': ['question_text']}), | |
('Date information', {'fields': ['pub_date']}), | |
] |
NewerOlder