Skip to content

Instantly share code, notes, and snippets.

@allieus
allieus / main.py
Created September 24, 2014 03:18
selenium/phantomjs 를 이용해서, http://www.ncbi.nlm.nih.gov/pubmed/17708774 로 부터 인용횟수 찾기
# brew install phantomjs
# pip install selenium
import re
from selenium import webdriver
url = 'http://www.ncbi.nlm.nih.gov/pubmed/17708774'
driver = webdriver.PhantomJS()
driver.get(url)
@allieus
allieus / main.py
Created November 9, 2014 16:13
개미수열
from itertools import groupby
def fn(s):
if not s:
return '1'
return ''.join('{}{}'.format(n, len(tuple(_iter))) for n, _iter in groupby(s))
s = ''
for i in range(10):
s = fn(s)
@allieus
allieus / result.txt
Created December 3, 2014 10:54
Spiral 숫자 출력
0 1 2 3 4 5 6 7 8 9
29 30 31 32 33 34 35 36 37 10
28 51 52 53 54 55 56 57 38 11
27 50 65 66 67 68 69 58 39 12
26 49 64 63 62 61 60 59 40 13
25 48 47 46 45 44 43 42 41 14
24 23 22 21 20 19 18 17 16 15
@allieus
allieus / AwesomeTextView.java
Last active August 29, 2015 14:10
Font Awesome TTF 폰트를 Andorid TextView 에 적용 ( http://fortawesome.github.io/Font-Awesome/ )
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
public class AwesomeTextView extends TextView {
public AwesomeTextView(Context context) {
super(context);
setFont();
}
@allieus
allieus / MainActivity.java
Created December 20, 2014 13:49
ShareActionProvider 적용 예 (갤S4 킷캣에서 구동 테스트)
import android.support.v7.widget.ShareActionProvider;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem menuItem = menu.findItem(R.id.action_share);
ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
@allieus
allieus / PlaceholderFragment.java
Last active August 29, 2015 14:12
버그 재현 : Fragment 의 onActivityCreated() 에서 initLoader() 를 호출하면, 화면회전이 일어날 때 onLoadFinished() 가 두 번 호출되는 버그가 있다. => Flag 를 통해 해결 (onCreateView 에서 true, onLoadFinished 에서 false) // api 21, min 14
package com.sunkist.udacity20141225;
import android.database.Cursor;
import android.provider.ContactsContract;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.util.Log;
@allieus
allieus / png_strip.sh
Created December 26, 2014 15:17
png strip
#!/bin/sh
find . -type f -name "*.png" -exec convert {} -strip {} \;
@allieus
allieus / patch.css
Created January 15, 2015 01:44
djangoproject.com css patch
.copy-banner {
background-color: #00733a;
}
h1, h1 a:visited,
h2, h2 a:visited,
h3, h3 a:visited,
h4, h4 a:visited,
h5, h5 a:visited,
h6, h6 a:visited {
@allieus
allieus / index.html
Created January 16, 2015 05:29
Google Map with Spreadsheet
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Google Map with Spreadsheet</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style>body { padding-top: 90px; padding-bottom: 90px; } ul { margin: 0; padding: 0; } li { list-style: none;} table thead th { text-align: center; } form label { font-size: 1.2em; }</style>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootswatch/3.1.1/journal/bootstrap.min.css" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" />
<style type="text/css">
@allieus
allieus / spellchecker.py
Last active August 29, 2015 14:13
네이버 자동 띄어쓰기
#!/usr/bin/env python2
# coding: utf-8
from __future__ import print_function
import sys
import re
import json
import urllib
from colorama import init, Fore, Back, Style
URL = 'http://csearch.naver.com/dcontent/spellchecker.nhn'