跳至主要内容

博文

目前显示的是 2017的博文

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>           Setti

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>

css font ttf family set third party

<!DOCTYPE html> <html> <head>   <title></title>   <style type="text/css">     @font-face{       font-family: "YuWei";       src:url(YuWei.ttf) format("truetype");     }   </style> </head> <body style="font-family: 'YuWei'"> <h1>贺卡上的</h1> </body> </html>

javascript json

var text = ' { "sites" : [ ' + ' { "name":"Runoob" , "url":"www.runoob.com" }, ' + ' { "name":"Google" , "url":"www.google.com" }, ' + ' { "name":"Taobao" , "url":"www.taobao.com" } ]} ' ; obj = JSON . parse ( text ) ; document . getElementById ( " demo " ) . innerHTML = obj . sites [ 1 ] . name + " " + obj . sites [ 1 ] . url ;

javascript on respone done xmlhttpresponse ajax

<script>   function goLogin() { var xhr =new XMLHttpRequest() var fd=new FormData(document.getElementById("mForm")) xhr.onreadystatechange=function() { document.getElementById("result").innerHTML=xhr.responseText } xhr.open("POST", "http://127.0.0.1:8090/login", true) xhr.send(fd) } </script> </head> <body> <form id="mForm" action="http://127.0.0.1:8090/login" method="post" enctype="multipart/form-data"> <div class="flex-center flex-vertical top-gap"> <div class="unit-0"><input type="hidden" name="state" value="LOGIN"></div> <div class="unit-0">邮箱:<input type="text" name="email"></div> <div class="unit-0">密码:<input type="password" name="password"></div> <div class="unit-0

golang client http

package main import ( "bytes" "fmt" "io" "log" "mime/multipart" "net/http" "os" "path/filepath" ) // Creates a new file upload http request with optional extra params func newfileUploadRequest ( uri string , params map [ string ] string , paramName , path string ) (* http . Request , error ) { file , err := os . Open ( path ) if err != nil { return nil , err } defer file . Close () body := & bytes . Buffer {} writer := multipart . NewWriter ( body ) part , err := writer . CreateFormFile ( paramName , filepath . Base ( path )) if err != nil { return nil , err } _ , err = io . Copy ( part , file ) for key , val := range params { _ = writer . WriteField ( key , val ) } err = writer . Close () if err != nil { return nil , err } req , err :=