substr

How to let asynchronous readFile method follow order in node.js

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a code like this var fs = require ( 'fs' ); console . log ( "1" ); fs . readFile ( "./index.js" , function ( err , data ) { if ( err ) { console . log ( "err" ); } console . log ( "2" ); }); console . log ( "3" ); and the result will be 1 3 2 But I want 1 2 3 I have look through filesystem's document and it says With the asynchronous methods there is no guaranteed ordering. so the document says if I want my code result 1 2 3 it should be var fs = require ( 'fs' ); console . log ( "1" ); fs . readFile ( "./index.js" ,

Hiveql - RIGHT() LEFT() Function

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a function in Hiveql that is equivalent to Right() or Left() fuction form TSQL? For example, RIGHT(col1,10) to get the first 10 characters from col1. thank you 回答1: There is no right or left function but you can implement same with substr like left (column, nchar) = substr(column, 0, nchar) right (column, nchar) = substr (column, -nchar) 回答2: This works for me for right function: substr (col, -nchar) = right(col, nchar). hive> select substr('adbcefghij',-4); ghij Time taken: 40.839 seconds, Fetched: 1 row(s) Hope this helps. 回答3:

PHP vs MySQL Performance ( if , functions ) in query

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I just see this artice i need to know what's is best berformance in this cases if statment in query SELECT *,if( status = 1 , "active" ,"unactive") as status_val FROM comments VS <?php $x = mysql_query("SELECT * FROM comments"); while( $res = mysql_fetch_assoc( $x ) ){ if( $x['status'] == 1 ){ $status_val = 'active'; }else{ $status_val = 'unactive'; } } ?> Cut 10 from string SELECT * , SUBSTR(comment, 0, 10) as min_comment FROM comments VS <?php $x = mysql_query("SELECT * FROM comments"); while( $res = mysql_fetch_assoc( $x ) ){ $min_comment

PHPExcel Date Format

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting an output from MS SQL server in the '2012-08-09 00:00:00' (without quotes) format. However, when I write it to excel file I'm unable to write it in date format to have dd mmm yyyy formatting on excel. As a result i tried to write in format =date(2012,08,09) as a formula to the respective cells. But I don't want to output it as a formula but rather the value '09 Aug 2012' with the data type integrity intact. How do I do this? Or is there a simpler method? I read through the documentation but it was not clear to me, thought I

力扣算法——140WordBreakII【H】

二次信任 提交于 2019-12-03 08:18:01
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. Note: The same word in the dictionary may be reused multiple times in the segmentation. You may assume the dictionary does not contain duplicate words. Example 1: Input: s = "catsanddog" wordDict = ["cat", "cats", "and", "sand", "dog"] Output: [ "cats and dog", "cat sand dog" ] Example 2: Input: s = "pineapplepenapple" wordDict = ["apple", "pen", "applepen", "pine", "pineapple"] Output:

常用的PHP字符串操作函数

瘦欲@ 提交于 2019-12-03 08:04:36
1.strlen 但是要注意!如果字符串中是汉字等其他字符时候呢? $str = "我"; echo strlen($str); //一个汉字,在UTF8格式下,显示3, ANSI格式下显示2 这样一来,不符合人的自然感觉,于是,有个升级版的函数 2. mb_strlen 1 $str = "我"; 2 echo mb_strlen($str,'utf-8'); //1 要加上第二个参数才行,对待\n等转义字符上同strlen一样,视同一个字符 3. strpos 查找 字符串$needle 在 字符串$haystack 中 首次 出现的位置 stripos和strpos类似,区别是stripos不区分大小写 strrpos和strpos类似,区别是strrpos是找 最后一次 出现的位置 strripos和strrpos类似,区别是它不区分大小写 a needle in a haystack 草垛里的针,needle是针,haystack草垛。就是在草垛里找缝衣针的意思。 mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) 所以,了解英语意思的话,很容易知道怎么去用。查找返回int类型位置,如果没找到返回bool值false 注意几点: 3.1.位置是从0开始的 //位置是从0开始的,a在

vue中使用高德地图搭建实时公交应用(地图 + 附近站点+线路详情 + 输入提示+换乘详情)

主宰稳场 提交于 2019-12-03 05:16:54
本文转载于: 猿2048 网站➵ https://www.mk2048.com/blog/blog.php?id=h12k2bb1hj 最近项目要使用高德地图写了一个实时公交的应用,这边分享一个小应用主要熟悉下高德地图在vue中的使用,常用api,vue的常用指令 先给大家看下页面效果: 如果有需要源码的童鞋请移步我的github地址 vue搭建实时公交 (欢迎star) 实现思路 在vue项目中导入高德地图 具体功能调用相应高德js APi 1.在vue项目中导入高德地图 1.修改webpac.base.conf.js文件 externals: { 'AMap': 'AMap' } 2.引入sdk 引入有两种方式,一种是在index页面直接引入 <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=您申请的key值"></script> 还有一种是异步加载 <script src="http://webapi.amap.com/maps?v=1.3&key=您申请的key值&callback=init"></script> <script> function init(){ var map = new AMap.Map('container', { center: [117.000923

sql盲注脚本--python

孤者浪人 提交于 2019-12-03 04:09:08
1.布尔盲注--方便以后修改,难点仅仅在于使用二分法求name # 1.布尔盲注 # 页面有不同的响应word1,word2 # 可猜解数据库长度、个数、名字、表个数、表长度、名字、字段、 # 长度:length,order by # 个数:count # 名字:ascii,substr import requests import time from math import ceil class SqlInject(object): headers = { "headers":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36" } data= {} @classmethod def judge(cls,url): if bool(SqlInject.data): result = None # print(result) else: result = requests.get(url=url,headers=SqlInject.headers,timeout=5).text return result def __init__(self,url,word1,word2): self.url =

Mongodb concat int and string

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to project FileName and FileSize for all my files in my collection with a size of 50 mb and greater, but I cannot concat a the type FileSize as it has a type of Int I want the projection to be { "result" : [ { "_id" : ObjectId("5652c399a21dad0bb01b6308"), "FileName" : "1234567890.xml", "FileSize" : "11.06 MB" }, { "_id" : ObjectId("5652c399a21dad0bb01b630f"), "FileName" : "2468101214.xml", "FileSize" : "320.48 MB" }, { "_id" : ObjectId("5652c399a21dad0bb01b631f"), "FileName" : "3691215180.xml", "FileSize" : "12.95 MB" } } But so

How can I convert a string to a float with Perl?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there any function like int() which can convert a string to float value? I'm currently using the following code: $input=int(substr($line,1,index($line,",")-1)); I need to convert the string returned by substr to float. 回答1: Just use it. In Perl, a string that looks like a number IS a number. Now, if you want to be sure that the thing is a number before using it then there's a utility method in Scalar::Util that does it: use Scalar::Util qw/looks_like_number/; $input=substr($line,1,index($line,",")-1); if (looks_like_number($input)) {