首页 文章 精选 留言 我的

精选列表

搜索[反射调用],共10000篇文章
优秀的个人博客,低调大师

JavaScript外部调用Js(自己理解加参考百度)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="qwe.js"></script> </head> <body> </body> <script type="text/javascript" src="qwe.js"></script> 是重点 通过HTML的script标签加载JavaScript文件 一般非关键的js文件都是放在网页底部即,</body>标签前面 其他的比较重要的放在<head>中 qwe.js文件内容 function sayScript() { alert("士大夫"); } sayScript(); JavaScript文件外部加载的好处: 避免使用 避免使用CDATA。 统一定义JavaScript代码,方便查看,方便维护。 使代码更安全,可以压缩,加密单个JavaScript文件。 浏览器可以缓存JavaScript文件,减少宽带使用(当多个页面同时使用一个JavaScript文件的时候,通常只需下载一次)。

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

openstack 调用API 实现云主机的IO 控制,CGroup 策略

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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 # vim: tabstop= 4 shiftwidth= 4 softtabstop= 4 # Copyright (c) 2011 X.commerce, a business unit of eBay Inc. # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License" ); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http: //www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # Single virtual machine io limit , reader 70 /MB , writer 50 /MB "" " curl -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "admin"}}}' -H "Content-type: application/json" http: //127.0.0.1:35357/v2.0/tokens | python -m json.tool curl -v -d '{"ioctlAction": {"instance_name":"instance-0000000c","limit_reader":"40MB","limit_writer":"60MB"}}' -i http: //127.0.0.1:8774/v2/ba5a6a86a8224a70ba0ffde747d8a724/servers/e6b9cae7-8732-405d-9aaf-575643b4bbef/action -X POST -H "X-Auth-Project-Id: ba5a6a86a8224a70ba0ffde747d8a724" -H "Accept: application/json" -H "X-Auth-Token: 6f0c37595f384fd4a18766825cf49013" -H "Content-Type: application/json" "" " import time,sys,os,libvirt, trace back,re,subprocess,json from nova import log as logging from nova import flags from nova.periodic.blkio import config from nova import utils from nova.periodic.blkio import utils as blkio_utils FLAGS = flags.FLAGS LOG = logging.getLogger(__name__) class ActionIoctl(object): def __init__(self,instance_name,limit_reader,limit_writer): self.conn = libvirt.open(None) self.limitReader = int (limit_reader[ 0 :- 2 ]) self.limitWriter = int (limit_writer[ 0 :- 2 ]) self.name = instance_name self.path = FLAGS.instances_path def diskDeviceNum(self,disk): "" " Func info: Returns the number of hard disk,other is 8:0 " "" if disk == '/dev/sda1' or disk == '/dev/hda1' or disk[:- 1 ] == '/dev/sda' or disk[:- 1 ] == '/dev/hda' : return '8:0' elif disk == '/dev/sdb1' or disk == '/dev/hdb1' or disk[:- 1 ] == '/dev/sdb' or disk[:- 1 ] == '/dev/hdb' : return '8:16' elif disk == '/dev/sdc1' or disk == '/dev/hdc1' or disk[:- 1 ] == '/dev/sdc' or disk[:- 1 ] == '/dev/hdc' : return '8:32' elif disk == '/dev/sdd1' or disk == '/dev/hdd1' or disk[:- 1 ] == '/dev/sdd' or disk[:- 1 ] == '/dev/hdd' : return '8:48' else : return '8:16' def vmsPIDall(self): "" " Getting all vm port, return to " "" pid = list() try : cmds = "" "ps -ef |grep uuid|grep -v grep |awk '{print $2}'" "" pid=os.popen(cmds).readlines() return pid except Exception,e: LOG.error(_( '[-william-] Error %s' %e)) return def cgroupPath(self): '' ' Func info : Return Cgroup path ,Because the system is not the same, the Cgroup path is different also. By default , have RedHat, Centos, Ubuntu linux ... osType : The current system version , And return to ... Cpath : Cgroup path '' ' osType = open( '/etc/issue' ).readlines() for i in osType: if re.match( 'Ubuntu' ,i): Cpath = '/sys/fs/cgroup/' return Cpath elif re.match( 'CentOS' ,i): Cpath = '/cgroup/' return Cpath elif re.match( 'Red Hat' ,i): Cpath = '/cgroup/' return Cpath else : return '/sys/fs/cgroup/' def exeCmd(self,cmds): '' ' Perform system command ' '' LOG.info(_( 'exeCmd %s' %cmds)) try : exec_process = subprocess.Popen(cmds, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) exec_process.wait() rest = exec_process.stdout.read() err = exec_process.stderr.read() if err == '' : return rest else : LOG.error(_( '[-william-] return values is null' )) except Exception,e: LOG.error(_( '[-william-] Error %s' ) %e) return '' ' Geting vmName name and pid ' '' def get_vm_pid(self,name): pid = self.conn.listDomainsID() try : pid = os.popen( "" "ps -ef |grep %s |grep -v grep |awk '{print $2}'" "" %name).readlines() return int (pid[ 0 ]) except: LOG.error(_( '[-william-] Error %s' \ % trace back.format_exc())) return def _vm_pids(self): try : return os.popen( 'pidof kvm' ).read().split() except: return def work(self): "" " Func info : working func ................ Cpath : is _Cpath function return values ... path : The current virtual machine IMG file path vm_count: All of the current node number of virtual machines size : Limit size mountInfo : mounting point "" " Cpath = self.cgroupPath() vm_pid = self.get_vm_pid(self.name) LOG.info(_( '[- william -] %s , %s' %(self.name,vm_pid))) r_size = self.limitReader * 1000 * 1000 w_size = self.limitWriter * 1000 * 1000 device = blkio_utils.instance_path(self.path) diskDeviceNum = self.diskDeviceNum(device) vmTaskPath = "%s/blkio/%s" %(Cpath,self.name) utils.execute( "mkdir" , "-p" ,vmTaskPath,run_as_root=True) utils.execute( "tee" , "%s/blkio.throttle.read_bps_device" %vmTaskPath,\ process_input = "%s %s" %(diskDeviceNum,r_size),\ run_as_root=True) utils.execute( "tee" , "%s/blkio.throttle.write_bps_device" %vmTaskPath, \ process_input = "%s %s" %(diskDeviceNum,w_size) ,\ run_as_root=True) LOG.info(_( "" " [-william-] echo '%s, %s, %s , %s , %s ' write oK " "" %(self.path , device, diskDeviceNum, w_size, r_size))) utils.execute( 'tee' , '%s/tasks' %vmTaskPath,\ process_input= str(vm_pid) ,\ run_as_root=True) LOG.info(_( '[- william-] append pid %s in task' %vm_pid)) if __name__ == "__main__" : sc = ActionIoctl( 'instance-0000000c' , '40MB' , '30MB' ) sc.work() 本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1412022

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

[Android Pro] Android中全局Application的onCreate多次调用问题

一般来说Application的onCreate方法只会执行一次, 如果应用中采用多进程方式,oncreate方法会执行多次,根据不同的进程名字进行不同的初始化, 就是在application中多添加几个if else String processName = OsUtils.getProcessName(this, android.os.Process.myPid()); if (processName != null) { boolean defaultProcess = processName.equals(Constants.REAL_PACKAGE_NAME); if (defaultProcess) { initAppForMainProcess(); } else if (processName.contains(":webbrowser")) { initAppForWebBrowseProcess(); } else if (processName.contains(":wallet")) { } } /** * @return null may be returned if the specified process not found */ public static String getProcessName(Context cxt, int pid) { ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> runningApps = am.getRunningAppProcesses(); if (runningApps == null) { return null; } for (RunningAppProcessInfo procInfo : runningApps) { if (procInfo.pid == pid) { return procInfo.processName; } } return null; } 分类: Android Pro 本文转自demoblog博客园博客,原文链接http://www.cnblogs.com/0616--ataozhijia/p/4203433.html如需转载请自行联系原作者 demoblog

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

Redis配置-主从服务器-phpredis-phpRedisAdmin-php调用

1.准备开发环境 yumgroupinstall-y"DevelopmentTools""ServerPlatformDevelopment" 2.更新时间 3.下载redis-3.2.1.tar.gz,网站地址是:www.redis.io 4.编译安装 tarxfredis-3.2.1.tar.gz cdredis-3.2.1 make 启动redis服务,默认的端口号是6379 注意:有时因为redis配置文件不一样的原因,我们在启动服务配置文件时候,需要指定配置文件,不指定为默认配置文件 切换目录至源码包文件中 [root@centos7src]#pwd /root/redis-3.2.1/src [root@centos7src]#redis-server./../redis.conf 查看是否开启服务 [root@centos7src]#netstat-tunlp|grep6379 tcp000.0.0.0:63790.0.0.0:*LISTEN 1387/redis-server0 进入交互式命令 [root@centos7src]#redis-cli-p6379 127.0.0.1:6379> 配置一个主从服务器,master/slave其实配置都是雷同的,因此简单点直接克隆刚才配置的服务器 刚才的服务器的ip地址为192.168.1.104 克隆后的ip地址为192.168.1.107,作为一个slave服务器 编辑slave服务器的配置文件/root/redis-3.2.1/redis.conf,修改以下相关参数 bind0.0.0.0 daemonizeyes slaveof192.168.1.1046379 保存退出后开启redis服务即可 回到192.168.1.104的master主机上进行测试 [root@centos7src]#redis-cli-p6379 127.0.0.1:6379>info #Replication role:master connected_slaves:1 slave0:ip=192.168.1.107,port=6379,state=online,offset=631,lag=1 master_repl_offset:631 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:2 repl_backlog_histlen:630 在192.168.1.107的slave主机上进行测试 [root@centos7src]#redis-cli-p6379 127.0.0.1:6379>info #Replication role:slave master_host:192.168.1.104 master_port:6379 master_link_status:up------->连接成功 master_last_io_seconds_ago:7 master_sync_in_progress:0 slave_repl_offset:617 slave_priority:100 slave_read_only:1 connected_slaves:0 master_repl_offset:0 repl_backlog_active:0 repl_backlog_size:1048576 repl_backlog_first_byte_offset:0 repl_backlog_histlen:0 master服务器可写,例如 在192.168.1.104master上 127.0.0.1:6379>settoday1 OK 127.0.0.1:6379>gettoday "1" 127.0.0.1:6379> 在192.168.1.107slave上 127.0.0.1:6379>gettoday "1" 127.0.0.1:6379> 下面测试lamp环境中的使用 准备环境: yuminstall-yaprapr-utilhttpdphpphp-develphp-mysqlmariadbmariadb-server lamp主机为192.168.1.106 安装phpredis的扩展, 下载地址:wget https://github.com/phpredis/phpredis/archive/2.2.7.tar.gz 解压后进入phpredis中需要生成配置文件,因此执行phpize 配置编译安装 ./configure--with-php-config=/usr/bin/php-config--enable-redis make makeinstall 配置php加载扩展 vim/etc/php.ini 在extension处添加extension=redis.so 在web根目录下添加一个首页(注意httpd.conf中添加DirectoryIndex index.php) cat/var/www/html/index.php <?php phpinfo(); ?> 在浏览器中查看是否有扩展 验证php是否能使用redis 在根目录下创建一个文件夹为Redis mkdirredis catredis/test.php <?php $redis=newRedis(); $redis->connect('192.168.1.104','6379'); $redis->set('name','xuelong'); echo$redis->get('name'); ?> 查看http://192.168.1.106/redis/test.php phpRedisAdmin后台管理配置 下载地址:wget https://github.com/ErikDubbelboer/phpRedisAdmin/archive/v1.1.0.tar.gz 下载后解压到web目录下,进入phpRedisAdmin-1.1.0目录 克隆一个文件到phpRedisAdmin-1.1.0下,命令为: gitclonehttps://github.com/nrk/predis.gitvendor 配置连接服务器地址的配置文件在phpRedisAdmin-1.1.0/includes/config.sample.inc.php,因此备份该文件,且重名为config.inc.php 修改配置文件为: array( 'name'=>'Remoteserver',//--->自己随意命名. 'host'=>'192.168.1.104',--->Redis服务器的地址 'port'=>6379,--->端口号 'filter'=>'*' //OptionalRedisauthentication. //'auth'=>'redispasswordhere'//Warning:Thepasswordissentinplain-texttotheRedisserver. ), php会话保存在redis中 编辑192.168.1.104web主机上的/etc/php.ini文件,定义session的存储方式为: session.save.handler=redis session.save_path="tcp://192.168.1.104:6379" 或者,redis.conf提供认证的时候使用以下的方式; session.save_path="tcp://192.168.1.104:6379?auth=password

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

Hermes Agent:从协议驱动函数调用到自进化数字员工

Hermes Agent 是 Nous Research 于 2026 年 2 月开源的 MIT 协议 AI 智能体框架,核心代码基于 Python,当前稳定版本为 v0.14.0。与传统对话式 AI 不同,它采用任务驱动架构,具备技能自动沉淀、持久化记忆、原生多工具链与并行子智能体能力。截至 2026 年 10 月,Hermes 累计被克隆超过 2400 万次,Nous Research 也完成了 9000 万美元 B 轮融资,估值达 15 亿美元。

资源下载

更多资源
Mario

Mario

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

腾讯云软件源

腾讯云软件源

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

Nacos

Nacos

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

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册