跳至主要内容

博文

mongo db mongodb search index engine

创建全文索引 考虑以下 posts 集合的文档数据,包含了文章内容(post_text)及标签(tags): { "post_text" : "enjoy the mongodb articles on Runoob" , "tags" : [ "mongodb" , "runoob" ] } 我们可以对 post_text 字段建立全文索引,这样我们可以搜索文章内的内容: > db . posts . ensureIndex ({ post_text : "text" }) 使用全文索引 现在我们已经对 post_text 建立了全文索引,我们可以搜索文章中的关键词 runoob: > db . posts . find ({ $text :{ $search : "runoob" }})

javascript数组删除指定元素 remove index array specific

定义和用法 splice() 方法向/从数组中添加/删除项目,然后返回被删除的项目。 注释: 该方法会改变原始数组。 语法 arrayObject.splice(index,howmany,item1,.....,itemX) 参数 描述 index 必需。整数,规定添加/删除项目的位置,使用负数可从数组结尾处规定位置。 howmany 必需。要删除的项目数量。如果设置为 0,则不会删除项目。 item1, ..., itemX 可选。向数组添加的新项目。 返回值 类型 描述 Array 包含被删除项目的新数组,如果有的话。 说明 splice() 方法可删除从 index 处开始的零个或多个元素,并且用参数列表中声明的一个或多个值来替换那些被删除的元素。 如果从 arrayObject 中删除了元素,则返回的是含有被删除的元素的数组。

onsen ui example splitter side menu swipe

<!DOCTYPE html> <html> <head> <title>TheyTube - Watch free video online</title> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css"> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">   <script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>   <script type="text/javascript">   ons.platform.select('android')   </script> </head> <body> <ons-splitter>   <ons-splitter-side id="menu" side="left" width="220px" collapse swipeable>     <ons-page>       <ons-list>         <ons-list-item onclick="fn.load('home.html')" tappable>           Home         </ons-list-item>         <ons-list-item onclick="fn.load('settings.html')" tappable>     ...

onsen ui example - tabbar tab

<!DOCTYPE html> <html> <head> <title>TheyTube - Watch free video online</title> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css"> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">   <script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>   <script type="text/javascript">   ons.platform.select('android')   </script> </head> <body> <ons-page>   <ons-toolbar>     <div class="center">Tab 1</div>   </ons-toolbar>   <ons-tabbar position="auto">     <ons-tab page="tab1.html" label="Tab 1" icon="ion-home, material:md-home" badge="7" active>     </ons-tab>     <ons-tab page="tab2.html" label="Tab 2" icon="md-settings...

onsen ui example - navigator

<!DOCTYPE html> <html> <head> <title>TheyTube - Watch free video online</title> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css"> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">   <script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>   <script type="text/javascript">   ons.platform.select('android')   </script> </head> <body> <ons-navigator swipeable id='mNavigator' page='page1.html'></ons-navigator> <template id="page1.html">   <ons-page id="page1">     <ons-toolbar>       <div class="center">Page 1</div>     </ons-toolbar>     <p>This is the first page.</p>     <ons-button id="push-button">Push page</ons-button...

android lauch time fast app activity

资源加载 首先尽量避免将耗时操作直接写在Application的onCreate()中,可以采用异步或者IntentService的方式加载资源。 不要以静态变量的方式在Application中保存数据 画面渲染 为启动的Activity自定义一个Theme,指定一个闪屏画面相同的背景图片 < style name = "AppSplash" > < item name = "android:windowBackground" > @mipmap/splash_bg </ item > </ style > 将新的Theme应用到设置到AndroidManifest.xml中LauncherActivity中 < activity android:name = ".MainActivity" android:theme = "@style/AppWelcom" > < intent-filter > < action android:name = "android.intent.action.MAIN" /> < category android:name = "android.intent.category.LAUNCHER" /> </ intent-filter > </ activity > 在MainActivity中需要设置回原来的Theme public class MainActivity extends AppCompatActivity { @Override protected void onCreate( Bundle savedInstanceState) { setTheme( R .style. AppTheme ); super .onCreate(savedInstanceState); setContentView( R .lay...

go spider example hello golang crawler

package main import ( "github.com/PuerkitoBio/goquery" "github.com/hu17889/go_spider/core/common/page" "github.com/hu17889/go_spider/core/pipeline" "github.com/hu17889/go_spider/core/spider" ) type MyPageProcesser struct { } func NewMyPageProcesser() *MyPageProcesser { return &MyPageProcesser{} } // Parse html dom here and record the parse result that we want to Page. // Package goquery (http://godoc.org/github.com/PuerkitoBio/goquery) is used to parse html. func (this *MyPageProcesser) Process(p *page.Page) { query := p.GetHtmlParser() query.Find("td div[class='flex-middle']").Each(func(i int, s *goquery.Selection) { println(s.Text()) }) } func (*MyPageProcesser) Finish() { } func main() { spider.NewSpider(NewMyPageProcesser(), "TaskName"). AddUrl("http://101.200.54.63/", "html").    // start url, html is the responce type ("html" or "json...

python socket

//client import socket cl=socket.socket(socket.AF_INET,socket.SOCK_STREAM) cl.connect(("101.200.54.63",80)) cl.send("GET / HTTP/1.1\r\nHost: 101.200.54.63\r\n\r\n") rp=cl.recv(4096) print rp

css html hover on mouse over on active onmouse

<!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> .one{ padding: 10px; cursor: pointer; box-shadow: 2px 2px 2px #aaa; } .one:hover{ box-shadow: 3px 3px 3px #aaa; z-index: 2; } .one:active{ box-shadow: 1px 1px 1px #aaa; } .one::selection{ background: #aaa; } </style> </head> <body style="font-family: sans-serif;"> <a href="new.html">hello</a> <span class="one">Hello</span> </body> </html>