[mcj]Ubuntu装NVIDIA驱动已经禁用nouveau还是提示:You appear to be running an X server
首先确认严格按照安装步骤: 如果出错,一般会提示:
1 |
ERROR: Installation has failed. Please see the file '/var/log/nvidia-installer.log' for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com. |
打开这个文件之后,会告诉你在/tmp下有文件冲突,比如我这里提示是.X0-lock,所以我们直接删掉这个文件就好了。 &n […]
[mcj]微博接口报错:appkey not bind domain!
微博的写入接口statuses/share在使用的时候报错,具体报错信息:
1 2 3 4 5 6 7 8 9 |
UserInfo={user_data={ error = "appkey not bind domain!"; "error_code" = 10017; request = "/2/statuses/share.json"; }} |
解决方法: 在微博应用管理中添加 安全主页 例如 :www.machunjie.com !然后在分 […]
[mcj]VNC下无法按tab键补全,只能用Ctrl+tab补全
这种多半是因为快捷键冲突导致的,首先打开:
1 |
sudo vi ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml |
找到:<property name=”<Super>Tab” type=”string” val […]
[mcj]libjasper-dev无法安装怎么办?怎样安装libjasper-dev?
安装opencv的两座大山:libjasper-dev和libgtk2.0-dev,前面介绍了如何安装libgtk2.0-dev,具体安装见: 当我们按照前面步骤安装了libgtk2.0-dev之后,其实libjasper-dev就很好安装 […]
[mcj]libgtk2.0-dev无法安装怎么办?怎样安装libgtk2.0-dev?
在安装opencv的时候有需要安装依赖,其中有两个比较难装,一个是libjasper-dev一个是libgtk2.0-dev,这里我们说一下如何安装libgtk2.0-dev,关于另一个的安装,请参考: 首先安装aptitude,然后用它来 […]
[mcj]Ubuntu命令行查看回收站文件并清空回收站
查看回收站文件:
1 |
cd .local/share/Trash |
清空回收站:
1 |
sudo rm -fr files/* |
本文最后更新于2019年6月24日,已超过 1 年没有更新,如 […]
[mcj]WordPress文章内容自动同步到新浪微博
使用: 代码来自张戈博客,之前的代码不能用了,我这里做了一些小修改。 如果不能正确发送,建议采用下面代码进行debug:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
<?php /** * WordPress发布文章同步到新浪微博(DeBUG测试) * 文章地址:https://zhang.ge/5082.html */ ini_set('display_errors', true); require('./wp-blog-header.php'); header("Content-type: text/html;charset=UTF-8"); header('HTTP/1.1 200 OK'); function post_to_sina_weibo_test($post_ID) { $get_post_info = get_post($post_ID); $get_post_centent = get_post($post_ID)->post_content; $get_post_title = get_post($post_ID)->post_title; if ($get_post_info->post_status == 'publish') { $appkey='1484874782'; /* 此处是你的新浪微博appkey,不修改的话就会显示来自张戈博客哦! */ $username='用户名'; $userpassword='密码'; $request = new WP_Http; $keywords = ""; /* 获取文章标签关键词 */ $tags = wp_get_post_tags($post_ID); foreach ($tags as $tag ) { $keywords = $keywords.'#'.$tag->name."#"; } /* 修改了下风格,并添加文章关键词作为微博话题,提高与其他相关微博的关联率 */ $string1 = '【文章发布】' . strip_tags( $get_post_title ).':'; $string2 = $keywords.' 查看全文:'.get_permalink($post_ID); /* 微博字数控制,避免超标同步失败 */ $wb_num = (138 - WeiboLength_test($string1.$string2))*2; $status = $string1.mb_strimwidth(strip_tags( apply_filters('the_content', $get_post_centent)),0, $wb_num,'...').$string2; /* 获取特色图片,如果没设置就抓取文章第一张图片 */ $url = get_mypost_thumbnail($post_ID); /* 判断是否存在图片,定义不同的接口 */ if(!empty($url)){ $api_url = 'https://api.weibo.com/2/statuses/upload_url_text.json'; /* 新的API接口地址 */ $body = array('status' => $status,'source' => $appkey,'url' => $url); } else { $api_url = 'https://api.weibo.com/2/statuses/update.json'; $body = array('status' => $status,'source' => $appkey); } $headers = array('Authorization' => 'Basic ' . base64_encode("$username:$userpassword")); $result = $request->post($api_url, array('body' => $body,'headers' => $headers)); return json_encode($result); } } /* //获取微博字符长度函数 */ function WeiboLength_test($str) { $arr = arr_split_zh_test($str); //先将字符串分割到数组中 foreach ($arr as $v){ $temp = ord($v); //转换为ASCII码 if ($temp > 0 && $temp < 127) { $len = $len+0.5; }else{ $len ++; } } return ceil($len); //加一取整 } /* //拆分字符串函数,只支持 gb2312编码 //参考:http://u-czh.iteye.com/blog/1565858 */ function arr_split_zh_test($tempaddtext){ $tempaddtext = iconv("UTF-8", "GBK//IGNORE", $tempaddtext); $cind = 0; $arr_cont=array(); for($i=0;$i<strlen($tempaddtext);$i++) { if(strlen(substr($tempaddtext,$cind,1)) > 0){ if(ord(substr($tempaddtext,$cind,1)) < 0xA1 ){ //如果为英文则取1个字节 array_push($arr_cont,substr($tempaddtext,$cind,1)); $cind++; }else{ array_push($arr_cont,substr($tempaddtext,$cind,2)); $cind+=2; } } } foreach ($arr_cont as &$row) { $row=iconv("gb2312","UTF-8",$row); } return $arr_cont; } /** * WordPress 获取文章图片加强版 By 张戈博客 */ if(!function_exists('get_mypost_thumbnail')){ function get_mypost_thumbnail($post_ID){ if (has_post_thumbnail()) { $timthumb_src = wp_get_attachment_image_src( get_post_thumbnail_id($post_ID), 'full' ); $url = $timthumb_src[0]; } else { if(!$post_content){ $post = get_post($post_ID); $post_content = $post->post_content; } preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', do_shortcode($post_content), $matches); if( $matches && isset($matches[1]) && isset($matches[1][0]) ){ $url = $matches[1][0]; }else{ $url = ''; } } return $url; } } echo post_to_sina_weibo_test(323); //此处数字改成博客已发布文章的ID即可 ?> |
一些错误解决: 本文最后更新于2019年6月25日, […]
[mcj]WordPress改变后台登陆地址防止暴力破解
最近后台出现好多尝试登陆的信息,不懂这群垃圾人心里咋想的。 修改方法,打开functions.php,增加: 这样我们登陆的时候,必需输入https://yoursite/wp-login.php?word=xxx才可以登陆,否则就会自动返 […]
[mcj]Ubuntu新建用户并赋予超级管理员权限
新建用户 Ubuntu下增加用户的方法有两种,useradd以及adduser,这里我们使用的是useradd。 如果增加普通用户的话,很简单:
1 |
sudo useradd username |
这样生成的用户一般没有hom […]
[mcj]华硕主板如何安装Windows及Ubuntu双系统并正确引导?
1 Windows安装 准备工作: Ubuntu安装盘 Windows安装盘 1.1 BiOS设置 1、重启笔记本按esc或f8进入BIOS设置,将bios改成简体中文,然后按F7进入高级模式,如下图所示; 2、进入高级模式后,按→方向键移 […]