Skip to content

Instantly share code, notes, and snippets.

View maowug's full-sized avatar
🏠
Working from whitehouse

u.go maowug

🏠
Working from whitehouse
View GitHub Profile
@maowug
maowug / jp_3_2_sensesJa_refineGlossList.py
Created June 30, 2013 14:58
refine sensesJa gloss list after updating ss_titles. jp_3_2_sensesJa_refineGlossList.py
for e in iter(temp.find()):
new_sensesJa=[]
for ss in e['sensesJa']:
new_gloss=[]
gloss_cp=copy.deepcopy(ss['gloss'])
# combine mis-splited glosses
for idx_gls,gls in enumerate(ss['gloss']):
# if gls ends with KanjiKana and `idx_gls!=len(ss['gloss'])-1:`
# :"一(動バ上二)⇒のびる二(動バ下二)⇒のべる"
@maowug
maowug / lixian encoding problem download.py
Created June 28, 2013 14:54
trivial: lixian encoding problem
File "/home/xunlei/xunlei-lixian/lixian_commands/download.py", line 65, in download1
download()
File "/home/xunlei/xunlei-lixian/lixian_download_tools.py", line 29, in __call__
self.tool(self.client, self.url, self.path, self.resuming)
File "/home/xunlei/xunlei-lixian/lixian_download_tools.py", line 71, in wget_download
raise Exception('wget exited abnormally')
Exception: wget exited abnormally
@maowug
maowug / temp_get_shibashiba.py
Last active December 19, 2015 02:29
mongodb (pymongo) `update` didn't work (using jp.update(_id,{...}) instead) & init from cPickle
#!/usr/bin/env python
#encoding: utf-8
#__author__ = 'actor2019'
# daijirin is much neater than `daijisen`
#conn
from pymongo import *
conn = MongoClient()
# in most cases, less than 3 documents
es= list(jp.find({'title':t}))
if es:
flagNotFound=False
# init the correct_e
the_e=None
# if len(es)==1
if len(es)==1:
@maowug
maowug / daijirin-getPage-v1.py
Created June 24, 2013 03:10
note: getPage of `kotobank daijirin `
def getPage(urlPage):
"""
:param urlPage:
:return:
"""
res = requests.get(urlPage)
urlWords = bs(res.content).select('div#listWrapper a')
BASE_url=r'http://kotobank.jp'
for idx_word,uw in enumerate(urlWords):
@maowug
maowug / dict3-resources-test1.py
Last active December 18, 2015 12:09
Test traversal. Note "@view_config" and leave "name='' " to default view.
#!/usr/bin/env python
#encoding: utf-8
#__author__ = 'actor2019'
# $http.get('/ja/word/あい')
from pyramid.security import (
Allow,
@maowug
maowug / flat-ui-navibar-1.html
Created June 11, 2013 11:37
trivial: flat-ui navibar
<div class="navbar" style="margin-top: 10px">
<div class="navbar-inner">
<div class="container">
<div><button type="button" class="btn btn-navbar" data-toggle="collapse" data-target="#nav-collapse-02">
</button>
<!--todo: class="brand fui-flat"-->
<a href="#" class="brand"><span >Dict3</span></a></div>
<div ng-controller="SearchCtrl">
@maowug
maowug / updateDescriptors.js
Created June 5, 2013 11:53
updateDescriptors with $watch (better do it with back-end)
// $scope.$watch('settingsTogo.advancedSettings.length', function(){
$scope.updateDescriptors = function(){
var ace=$scope.settingsTogo.advancedSettings;
var raw_odList=ace.slice(ace.lastIndexOf('>')+1).split('[\'');//console.log(raw_odList);
var orDescriptorsTemp=[];
var orDscMsgsTemp=[];
_.each(raw_odList,function(rod, idx, list){
// each rod if no ']' return else good push it to orDescriptors
if(rod.length<5||rod.indexOf(']')==-1) return;
//eval od to array=['name',[1,2,3]]
@maowug
maowug / tabelog-init-django.py
Created June 3, 2013 13:59
init django with tabelog data
#!/usr/bin/env python
#encoding: utf-8
from django.conf import settings
from django.db.models import signals
from django.db import transaction
#
# from tbhBase import models as tbhBaseModels
# from tbhBase.models import Rst,Rvw
@maowug
maowug / scatter-chart-ex.js
Created May 31, 2013 03:03
scatter-chart-ex
//works.
//in html
// <div><scatter-chart id-d3="rulesScatterChart" name-d3="scatterChartRulesData"
// class="rnia-scatter-chart" ></scatter-chart></div>
//.