This file contains hidden or 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: utf-8 -*- | |
import scipy.spatial.distance as dis | |
import scipy.sparse as sp | |
import numpy as np, scipy.io as io | |
import math | |
def sparse_distance(v1, v2): | |
"""1*Nのベクトル間のユークリッド距離を求める | |
args: |
This file contains hidden or 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:utf-8 -*- | |
import os | |
import sys | |
csv_path = '/home/hoge/user_dic/celebs.csv' # ユーザー辞書の元となるファイル | |
def add_dic(fname): | |
'''MeCabで使う辞書に人名を追加します | |
更新する人名はcsv形式のfname, | |
csvじゃないとき(人名を引数にした時)はそれ自体 | |
更新するユーザー辞書は/home/hoge/user_dic/celebs.csv |
This file contains hidden or 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
#!/usr/local/bin/python | |
# -*- encoding:utf-8 -*- | |
'''YahooApiを用いた検索エンジン | |
''' | |
from urllib import quote | |
from urllib2 import build_opener | |
import cgi | |
from split_result import split_result | |
import cgitb | |
cgitb.enable() |
This file contains hidden or 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:utf-8 -*- | |
import re | |
result_pattern = '<Result>(.+?)</Result>' | |
link_pattern = '<Url>(.*?)</Url>' | |
title_pattern = '<Title>(.*?)</Title>' | |
summary_pattern = '<Summary>(.*?)</Summary>' | |
strip_pattern = r'\\n|\s' | |
catch_result = re.compile(result_pattern, re.S) | |
catch_link = re.compile(link_pattern, re.S) | |
catch_title = re.compile(title_pattern, re.S) |
This file contains hidden or 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:utf-8 -*- | |
'''数値を逆順にするスクリプト | |
文字列操作を使っていない | |
''' | |
import sys | |
def split_int(num): | |
number_list = [] | |
while num > 0: | |
number_list.append(num % 10) |
This file contains hidden or 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
""""""""""""""""""""""""""""""""""""""""" | |
" # | |
" ### | |
" ####### | |
" ########## | |
" ########## | |
" ######## | |
" ### | |
" #### # | |
" #### |
This file contains hidden or 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:utf-8 -*- | |
import urllib2 | |
opener = urllib2.build_opener() | |
opener2 = urllib2.build_opener() | |
opener.addheaders = [\ | |
('Use-Agent', 'Mozilla/5.0 (compatible; googlebot/2.1; \ | |
+ http://www.google.com/bot.html)')] | |
opener2.addheaders = [\ | |
('User-Agent', 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; ja-jp) \ | |
AppleWebKit/417.9(KHTML, like Gecko) Safari/125.9')] |
This file contains hidden or 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 android.annotation.SuppressLint; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.KeyEvent; | |
import android.webkit.WebView; | |
import android.webkit.WebViewClient; | |
public class WebViewFromTextView extends Activity { |
This file contains hidden or 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
(function() { | |
// change to your hatena user name!!! | |
var HATENA_USERNAME = 'petitviolet'; | |
liberator.modules.commands.addUserCommand( | |
["hatena[bookmark]", "hb"], | |
"search from my hatena bookmarks", | |
function(args){ | |
if (args.length === 0) { | |
liberator.echo('input a query!'); | |
return false; |
This file contains hidden or 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
# Description: | |
# Show vim help anywhere! | |
# | |
# Commands: | |
# :help <keyword> - Show <keyword> vim help | |
require 'util' | |
module.exports = (robot) -> | |
robot.hear /:help\s*(.*)$/i, (msg) -> |
OlderNewer