`
文章列表

strstr的实现

    博客分类:
  • PHP
function _strstr($haystack,$needle) { $len = strlen($haystack); $firststr = $needle[0]; for($i= 0; $i < $len; $i++) { if($haystack[$i] == $firststr) { $str = ''; for($j= $i; $j < $len; $j++) { $str .= $haystack[$j]; if($str == $needle) { r ...
相关php原生函数有sort sort($array,SORT_NUMERIC) function array_sort($array) { $return = array(); $no = count($array); $max_key = 0; for($i = 0; $i < $no; $i++) { $tmp=0; foreach ($array as $key => $num) { if($num > $tmp) { $tmp = $num; $maxkey = $key; } ...
require_once 'PHPUnit/Framework/TestCase.php'; echo "Note: these tests might take up to a minute. Don't worry :-)\n"; class Redis_Test extends PHPUnit_Framework_TestCase { const HOST = '127.0.0.1'; const PORT = 6379; const AUTH = NULL; //replace with a string to use Redis a ...
find /data/app/site1/ -type d -name .svn -exec rm -fr {} \; >/dev/null 2>&1
先随机生成json数据文件 <?php set_time_limit(0); $fp =fopen('userinfos.json','w'); fclose($fp); $fp =fopen('userinfos.sql','w'); fclose($fp); $maxNum = 1000000; $sql = "TRUNCATE TABLE `user`;\r\n"; for($i=1; $i < $maxNum; $i++) { $userInfo = array( 'name' => uniqid() ...
db.system.users.find() db.users.count() db.users.ensureIndex({password:-1}) use test db.users.getIndexes() db.repairDatabase() show users show dbs db.users.find({username:{$in:['4d81a82398790']}}).explain() db.users.dropIndexes() db.users.find().count() db.users.find().limit(5) db.use ...
GET方式返回couchDB的所有数据库 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:5984/_all_dbs'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); curl_close($ch); print_r(json_decode($result,true)); PUT方式向songs数据库插入一首歌曲信息 $putString = json_encode(array('na ...
本文章中的示例代码是在 CentOS 5.4 64 位环境下运行通过的,在其它 unix 系统上没有测试过。 Linux 操作系统中的命令实际上是编译好的可执行程序,比如说 ls 这个命令,这个文件位于 /bin 目录下面,当我们用 file /bin/ls 命令查看的时候会有以下输出: [root@localhost ~]# file /bin/ls /bin/ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses ...
<?php function base64UrlDecode($input) { return base64_decode(strtr($input, '-_', '+/')); } function base64UrlEncode($input) { return base64_encode(strtr($input, '+/', '-_')); } // 生成令牌 function parseSignedRequest($signed_request, $secret='4f5fcdc6514f7ee25ec4fa7c7853e8e1') { ...
#include <stdio.h> #include <stdlib.h> #define N 100000 int a[N]; void gen_rand(int hash_num) { int i; for(i=0; i<N; i++) { a[i] = rand() % hash_num; } } int how_many(int num) { int count=0; int i; for(i=0; i<N ;i++) ...
cat */* | awk -F'|' '{++S[$3];C[$3]+=$4} END{for(a in S) print S[a],"\t",C[a],"\t",a}' | sort -nr 此shell可用于查询日志类的数据 需要按指定列分组并汇总分组的数据并排序,类似于sql中的 SELECT COUNT(money) AS totalCost FROM user_consume GROUP BY username ORDER BY num DESC 此sql可按用户汇总消费并按用户消费总额排序
#include <mysql/mysql.h> #include <stdlib.h> #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { MYSQL mysql; MYSQL_ROW row; MYSQL_RES *result; unsigned int num_fields; unsigned int i; mysql_init(&mysql); ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> int readFile(char *fname,char *buff); int writeFile(char *fname,char *buff); int main(int argc,char *ar ...
#include <stdio.h> #include <stdlib.h> #include <curl/curl.h> int main(int argc,char *argv[]) { CURL *curl; CURLcode res; if(argc != 2) { printf("Usage file <url>\n"); exit(1); } // 初始化curl curl ...
Global site tag (gtag.js) - Google Analytics