This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sub_str($str,$start=0,$length=60,$left="...",$charset="utf-8") | |
| { | |
| if($charset=="utf-8"){ | |
| $index=0; | |
| $index1=0; | |
| $result=""; | |
| $haslen=0; | |
| for($i=0;$i<$length;$i++) | |
| { | |
| $index1=$index; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 合并排序 | |
| ----------------------------------- | |
| $lista = array(3,8,4); | |
| $listb = array(5,6,2); | |
| print_r(mergeSort($lista, $listb)); | |
| function mergeSort($la,$lb) { | |
| //sort two sub-lists | |
| sort($la); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $newfname = __DIR__.'/1.wmv'; | |
| $reqBaseURL = 'http://translate.google.com/translate_tts?tl=en&q=how%20do%20you%20do'; | |
| $remote_file = fopen($reqBaseURL, "rb"); | |
| if ($remote_file){ | |
| $newf = fopen($newfname, "wb"); | |
| if ($newf){ | |
| while(!feof($remote_file)){ | |
| fwrite($newf, fread($remote_file, 1024 * 8),1024 * 8); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Screen Resolution stuck at 640x480 after installing | |
| In /etc/X11/xorg.conf, look for these two lines : | |
| HorizSync 28.0 - 33.0 | |
| VertRefresh 43.0 - 72.0 | |
| and replace them with | |
| HorizSync 30.0 - 83.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).click(function(e){ | |
| // Check if click was triggered on or within #menu_content | |
| if( $(e.target).closest("#menu_content").length > 0 ) { | |
| return false; | |
| } | |
| // Otherwise | |
| // trigger your click function | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 消息队列(message queue)也是Linux系统进程间通信的一种方式。 | |
| 除了现有的一些消息队列解决方案以外,PHP对共享内存段的操作有两组函数:System V IPC和Shared Memory。 其中System V IPC由AT&T的贝尔实验室对早期的UNIX系统贡献而来,现在的linux系统都完美的继承了下来,该系列函数能够更方便的操作数据,无需像Shared Memory那样必须自己掌握读写时的偏移量、长度等,也不用序列化/反序列化来回转换(因为Shared Memory函数只支持字符串格式的数据参数)。但是System V IPC系列不支持Windows,所以如果要在win环境下使用,只能选Shared Memory。 | |
| PHP的System V msg模块是对Linux系统支持的System V IPC中的System V消息队列函数族的封装。我们需要利用sysvmsg模块提供的函数来进进程间通信。 | |
| <?php | |
| $message_queue_key = ftok(__FILE__, 'a'); | |
| $message_queue = msg_get_queue($message_queue_key, 0666); | |
| var_dump($message_queue); | |
| $message_queue_status = msg_stat_queue($message_queue); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| protected function _strip_text($data, $type=false){ | |
| if(is_array($data)){ | |
| foreach($data as $key=>$val){ | |
| $data[$key] = $this->_strip_text($val, $type); | |
| } | |
| }elseif(is_object($data)){ | |
| foreach(get_object_vars($data) as $property => $val) { | |
| $data->$property = $this->_strip_text($val, $type); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class encrypt | |
| { | |
| private $key; | |
| private $uword; | |
| private $eword; | |
| private $letters; | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " 一般设定 | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " 设定主题 | |
| set t_Co=256 | |
| syntax enable | |
| set background=dark | |
| colorscheme molokai | |
| " 设定默认解码 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <curl/curl.h> | |
| #define POSTURL "http://127.0.0.1" | |
| #define LOGFILE "post.log" | |
| #define RESOURCE_KEY "" | |
| #define CUSTOM_VALUE "" | |
| #define UPLOAD_TOKEN "" |