首页 文章 精选 留言 我的

精选列表

搜索[设置],共10023篇文章
优秀的个人博客,低调大师

CentOS设置定时清除buff/cache的脚本

注意:此方法不能用于解决统物理内存占用过高,导致部分服务被强制关闭的问题 要从根本上解决服务器内存占用过高的问题,参考这篇文章(https://www.idaobin.com/archives/345) 用root用户创建定时任务 切换到root用户 su - root 创建脚本文件 touch cleanCache.sh vim cleanCache.sh 添加如下内容: #!/bin/bash #每两小时清除一次缓存 echo "开始清除缓存" sync;sync;sync #写入硬盘,防止数据丢失 sleep 10 #延迟10秒 echo 3 > /proc/sys/vm/drop_caches 创建定时任务 crontab -e //弹出配置文件 添加如下内容:(按需修改) 0 */2 * * * ./cleanCache.sh 保证crond启动以及开机自启 systemctl start crond.service systemctl enable crond.service 查看buff/cache情况 free -m 查看定时任务是否被执行 cat /var/log/cron | grep cleanCache 注意:只要任务创建了,即使退出用户登录,任务还是会执行 最后:此方法清理缓存只是紧急临时用的,不建议在生产环境中使用此方法

优秀的个人博客,低调大师

android 26 设置项目有多个入口Activity。

第一个activity package com.sxt.day04_11; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } 第二个activity package com.sxt.day04_11; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class SecondActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.second, menu); return true; } } 系统描述文件: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sxt.day04_11" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > 项目有2个入口 <activity android:name="com.sxt.day04_11.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.sxt.day04_11.SecondActivity" android:label="@string/title_activity_second" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/4886827.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android下使用Properties文件保存程序设置

废话不说,直接上代码。 读取.properties文件中的配置: StringstrValue=""; Propertiesprops=newProperties(); try{ props.load(context.openFileInput("config.properties")); strValue=props.getProperty(keyName); System.out.println(keyName+""+strValue); } catch(FileNotFoundExceptione){ Log.e(LOG_TAG,"config.propertiesNotFoundException",e); } catch(IOExceptione){ Log.e(LOG_TAG,"config.propertiesIOException",e); } 相信上面这段代码大部分朋友都能看懂,所以就不做过多的解释了。 向.properties文件中写入配置: Propertiesprops=newProperties(); try{ props.load(context.openFileInput("config.properties")); OutputStreamout=context.openFileOutput("config.properties",Context.MODE_PRIVATE); Enumeration<?>e=props.propertyNames(); if(e.hasMoreElements()){ while(e.hasMoreElements()){ Strings=(String)e.nextElement(); if(!s.equals(keyName)){ props.setProperty(s,props.getProperty(s)); } } } props.setProperty(keyName,keyValue); props.store(out,null); Stringvalue=props.getProperty(keyName); System.out.println(keyName+""+value); } catch(FileNotFoundExceptione){ Log.e(LOG_TAG,"config.propertiesNotFoundException",e); } catch(IOExceptione){ Log.e(LOG_TAG,"config.propertiesIOException",e); } 上面这段代码,跟读取的代码相比,多了一个if判断以及一个while循环。主要是因为Context.Mode造成的。因为我的工程涉及到多个配置信息。所以只能是先将所有的配置信息读取出来,然后在写入配置文件中。 Context.Mode的含义如下: 1.MODE_PRIVATE:为默认操作模式,代表该文件是私有数据,只能被应用本身访问,在该模式下,写入的内容会覆盖原文件的内容。 2.MODE_APPEND:代表该文件是私有数据,只能被应用本身访问,该模式会检查文件是否存在,存在就往文件追加内容,否则就创建新文件。 3.MODE_WORLD_READABLE:表示当前文件可以被其他应用读取。 4.MODE_WORLD_WRITEABLE:表示当前文件可以被其他应用写入。 注:.properties文件放置的路径为/data/data/packagename/files 本文转自 sw840227 51CTO博客,原文链接:http://blog.51cto.com/jerrysun/804789,如需转载请自行联系原作者

优秀的个人博客,低调大师

redis服务器及采集端设置

redis(logstash).conf内容 #服务端配置,logstash抓取redis数据,配置名自取 例一 #从redis读数据 input { redis { host => "127.0.0.1" port => 6379 type => "redis-input" data_type => "list" key => "logstash:redis" } } output {#输出到ela stdout {} elasticsearch { cluster => "elasticsearch" codec => "json" protocol => "http" } } 例二 #从redis读数据 input{ redis{ host=>'192.168.233.130' data_type=>'list' port=>"6379" key=>'logstash:redis' type=>'redis-input' } } output{ #输出到ela elasticsearch{ embedded=>true } } logstash-kibama 9292 logstash-redis 6379 logstash-elasticsearch9200 kibana5601 #vimredis(logstash).conf #日志收集端配置,logstash集被监听日志文件数据,配置名自取 input{#收集监控端日志文件 file{ type=>"producer" path=>"/soft/apache.log" } file{ type=>"php-log" path=>"/soft/php.log" } } filter{#日志内容里面只要有匹配mysql或GET或error的内容就会被过滤出来,发送到logstashindex grep{ match=>["@message","mysql|GET|error"] } } output{#将收集的日志文件发送到redis redis{ host=>'192.168.233.130' data_type=>'list' key=>'logstash:redis' } } 测试程序发送数据->Redis消息队列->Logstash->Elasticsearch集群 通过管线化的思路增加索引速度 为了解决Redis队列的瓶颈问题,使用多管线机制,来增加整个系统的吞吐量,为此,我们同时部署了多个Redis实例,和对应数量的Logstash实例: 测试程序发送数据 -> Redis消息队列1 ->Logstash1-> Elasticsearch集群 测试程序发送数据 -> Redis消息队列2 ->Logstash2 -> Elasticsearch集群 测试程序发送数据 -> Redis消息队列3 ->Logstash3 -> Elasticsearch集群 ... 采用管线机制的好处是,扩展性是显而易见的 本文转自 wdy198622 51CTO博客,原文链接:http://blog.51cto.com/weimouren/1732075

优秀的个人博客,低调大师

android:ListView:convertView.setTag()来设置数据

void android.view.View.setTag(Objecttag) public voidsetTag(Object tag) Since: API Level 1 Sets the tag associated with this view. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. Tags can also be used to store data within a view without resorting to another data structure. Parameters an Object to tag the view with also see getTag() setTag(int, Object) public View getView(int position, View convertView, ViewGroup parent) { final int cc = position; ViewHolder holder = null; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.itemrow, null); holder.tagcolor = (ImageView) convertView.findViewById(R.id.itemrowiamge); holder.itemname = (TextView) convertView.findViewById(R.id.itemrowtext); holder.cb = (CheckBox) convertView.findViewById(R.id.itemrowcb); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } //获取ViewHolder中所填入的数据 holder.tagcolor.setBackgroundResource((Integer) itemList.get(position).get("IMG")); holder.itemname.setText((String) itemList.get(position).get("ITEMNAME")); holder.ckd = (String) itemList.get(position).get("CHECKED"); //单个项目中的CheckBox的按键监听函数 holder.cb.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { setC(cc);//当被按下后调用函数改变状态 } }); if (holder.ckd.equals("t")) holder.cb.setChecked(true); else holder.cb.setChecked(false); return convertView; } 设一个holder类 import android.widget.CheckBox; import android.widget.ImageView; import android.widget.TextView; //ViewHolder类用以储存每一条项目所需的数据 public class ViewHolder { public ImageView tagcolor;//单条项目中的图片 public TextView itemname;//单条项目中的文本 public CheckBox cb;//单条项目中的CheckBox public String ckd;//单条项目中用以标识CheckBox状态的字符串变量 } 即可。 本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/05/22/2512491.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。