首页 文章 精选 留言 我的

精选列表

搜索[任务管理器],共10005篇文章
优秀的个人博客,低调大师

Python多版本管理器pyenv

1.查看Linux版本 [root@web ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@web ~]# uname -a Linux web 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux 2.安装依赖 [root@web ~]# yum -y install gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel git xorg-x11-server-Xvfb bzip gtk3 gtk2 3.安装pyenv [root@web ~]# curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash 4.配置环境变量 [root@web ~]# cd /root [root@web ~]# cp .bash_profile .bash_profile.bak [root@web ~]# vim .bash_profile #pyenv export PATH="~/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" [root@web ~]# source .bash_profile 5.系统自带python版本为2.7.5 [root@web ~]# python -V Python 2.7.5 6.安装的pyenv版本为1.2.15 [root@web ~]# pyenv -v pyenv 1.2.15 7.升级pyenv命令 [root@web ~]# pyenv update 8.查看可用的python版本有哪些 [root@web ~]# pyenv install --list 9.安装python3.6.4、python2.7.2和python3.6.7 [root@web ~]# pyenv install 3.6.4 [root@web ~]# pyenv install 2.7.2 [root@web ~]# pyenv install 3.6.7 10.查看安装的python版本有哪些 [root@web ~]# pyenv versions * system (set by /root/.pyenv/version) 2.7.2 3.6.4 3.6.7 [root@web ~]# 11.配置root用户的python版本为3.6.4 [root@web ~]# cd /root/ [root@web ~]# pyenv virtualenv 3.6.4 root364 [root@web ~]# pyenv activate root364 [root@web ~]# pyenv global 3.6.4 (root364) [root@web ~]# python -V Python 3.6.4 12.去除当前使用的virtualenv (root364) [root@web ~]# pyenv deactivate [root@web ~]# 13.删除某个virtualenv [root@web ~]# pyenv virtualenv-delete root364 pyenv-virtualenv: remove /root/.pyenv/versions/3.6.4/envs/root364? y [root@web ~]# 14.设置/tmp目录的pyenv环境为python3.6.7 [root@web ~]# cd /tmp/ [root@web tmp]# pyenv virtualenv 3.6.7 tmp367 Looking in links: /tmp/tmpshtqhsk6 Requirement already satisfied: setuptools in /root/.pyenv/versions/3.6.7/envs/tmp367/lib/python3.6/site-packages (39.0.1) Requirement already satisfied: pip in /root/.pyenv/versions/3.6.7/envs/tmp367/lib/python3.6/site-packages (10.0.1) [root@web tmp]# pyenv activate tmp367 [root@web tmp]# pyenv local tmp367 (tmp367) [root@web tmp]# python -V Python 3.6.7 (tmp367) [root@web tmp]#

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

Yarn(包管理器) 的基本用法

Yarn是一个快速、可靠、安全的依赖管理工具,是npm的代替品。 Yarn对你的代码来说是一个包管理工具,你可以通过它使用全世界开发者的代码,或者分享自己的代码。 安装Yarn: 操作系统不同,安装方式也有所不同,下面我就以MacOS系统为例。 安装方式一:通过Homebrew包管理工具安装Yarn brew install yarn 如果你还没有安装node.js,Homebrew会自动帮你安装node.js。 安装方式二:通过MacRorts安装Yarn sudo port install yarn 如果你还没有安装Node.MacRorts会自动为你安装。 环境变量配置: 如果未在PATH环境变量中找到yarn,请按照以下步骤添加yarn到PATH环境变量中,使其可以随处运行。 注意:你的配置文件可能是 .profile、.bash_profile、.bashrc、.zshrc等。 (1) 如果你是第一次配置环境变量,在终端中可以使用 touch .bash_profile 命令来创建一个 .bash_profile 隐藏的文件;如果你已经有了配置文件,则可以使用 open -e .bash_profile 命令来打开这个隐藏的文件进行编辑。 (2)将 export PATH="$PATH:/usr/local/bin" 加入到你的配置文件中(路径根据你安装的yarn的位置而定),然后保存退出。 另外一种配置方法就是执行 vi ./.bash_profile 命令进入查看模式,执行'i'进入insert模式,打开下面这个画面进行编辑配置 配置完之后,执行'wq!',执行回车退出保存。 执行 source ./.bash_profile 让环境变量生效。 执行 echo $PATH 查看环境变量是否配置成功。 升级Yarn brew upgrade yarn 查看Yarn 是否安装成功及版本号 yarn --version 初始化一个项目 yarn init 添加依赖包 yarn add [package] yarn add [package]@[version] yarn add [package]@[tag] 将依赖项添加到不同依赖项类别中 分别添加到devDependencies、peerDependencies和optionalDependencies类别中: yarn add [package] --dev yarn add [package] --peer yarn add [package] --optional 升级依赖包 yarn upgrade [package] yarn upgrade [package]@[version] yarn upgrade [package]@[tag] 移除依赖包 yarn remove [package] 安装项目的全部依赖 yarn 或 yarn install

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

Android--文件夹管理器

版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/76255465 直接上代码: import android.content.Context; import android.content.CursorLoader; import android.database.Cursor; import android.media.MediaMetadataRetriever; import android.net.Uri; import android.os.Environment; import android.provider.MediaStore; import android.text.format.DateFormat; import android.text.format.Formatter; import android.webkit.MimeTypeMap; import com.calintat.explorer.R; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.Date; import java.util.Locale; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class FileUtils { public static File copyFile(File src, File path) throws Exception { try { if (src.isDirectory()) { if (src.getPath().equals(path.getPath())) throw new Exception(); File directory = createDirectory(path, src.getName()); for (File file : src.listFiles()) copyFile(file, directory); return directory; } else { File file = new File(path, src.getName()); FileChannel channel = new FileInputStream(src).getChannel(); channel.transferTo(0, channel.size(), new FileOutputStream(file).getChannel()); return file; } } catch (Exception e) { throw new Exception(String.format("Error copying %s", src.getName())); } } //---------------------------------------------------------------------------------------------- public static File createDirectory(File path, String name) throws Exception { File directory = new File(path, name); if (directory.mkdirs()) return directory; if (directory.exists()) throw new Exception(String.format("%s already exists", name)); throw new Exception(String.format("Error creating %s", name)); } public static File deleteFile(File file) throws Exception { if (file.isDirectory()) { for (File child : file.listFiles()) { deleteFile(child); } } if (file.delete()) return file; throw new Exception(String.format("Error deleting %s", file.getName())); } public static File renameFile(File file, String name) throws Exception { String extension = getExtension(file.getName()); if (!extension.isEmpty()) name += "." + extension; File newFile = new File(file.getParent(), name); if (file.renameTo(newFile)) return newFile; throw new Exception(String.format("Error renaming %s", file.getName())); } public static File unzip(File zip) throws Exception { File directory = createDirectory(zip.getParentFile(), removeExtension(zip.getName())); FileInputStream fileInputStream = new FileInputStream(zip); BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream); try (ZipInputStream zipInputStream = new ZipInputStream(bufferedInputStream)) { ZipEntry zipEntry; while ((zipEntry = zipInputStream.getNextEntry()) != null) { byte[] buffer = new byte[1024]; File file = new File(directory, zipEntry.getName()); if (zipEntry.isDirectory()) { if (!file.mkdirs()) throw new Exception("Error uncompressing"); } else { int count; try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { while ((count = zipInputStream.read(buffer)) != -1) { fileOutputStream.write(buffer, 0, count); } } } } } return directory; } public static File getInternalStorage() { //returns the path to the internal storage return Environment.getExternalStorageDirectory(); } //---------------------------------------------------------------------------------------------- public static File getExternalStorage() { //returns the path to the external storage or null if it doesn't exist String path = System.getenv("SECONDARY_STORAGE"); return path != null ? new File(path) : null; } public static File getPublicDirectory(String type) { //returns the path to the public directory of the given type return Environment.getExternalStoragePublicDirectory(type); } public static String getAlbum(File file) { try { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(file.getPath()); return retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM); } catch (Exception e) { return null; } } //---------------------------------------------------------------------------------------------- public static String getArtist(File file) { try { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(file.getPath()); return retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); } catch (Exception e) { return null; } } public static String getDuration(File file) { try { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(file.getPath()); String duration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); long milliseconds = Long.parseLong(duration); long s = milliseconds / 1000 % 60; long m = milliseconds / 1000 / 60 % 60; long h = milliseconds / 1000 / 60 / 60 % 24; if (h == 0) return String.format(Locale.getDefault(), "%02d:%02d", m, s); return String.format(Locale.getDefault(), "%02d:%02d:%02d", h, m, s); } catch (Exception e) { return null; } } public static String getLastModified(File file) { //returns the last modified date of the given file as a formatted string return DateFormat.format("dd MMM yyy", new Date(file.lastModified())).toString(); } public static String getMimeType(File file) { //returns the mime type for the given file or null iff there is none return MimeTypeMap.getSingleton().getMimeTypeFromExtension(getExtension(file.getName())); } public static String getName(File file) { //returns the name of the file hiding extensions of known file types switch (FileType.getFileType(file)) { case DIRECTORY: return file.getName(); case MISC_FILE: return file.getName(); default: return removeExtension(file.getName()); } } public static String getPath(File file) { //returns the path of the given file or null if the file is null return file != null ? file.getPath() : null; } public static String getSize(Context context, File file) { if (file.isDirectory()) { File[] children = getChildren(file); if (children == null) return null; return String.format("%s items", children.length); } else { return Formatter.formatShortFileSize(context, file.length()); } } public static String getStorageUsage(Context context) { File internal = getInternalStorage(); File external = getExternalStorage(); long f = internal.getFreeSpace(); long t = internal.getTotalSpace(); if (external != null) { f += external.getFreeSpace(); t += external.getTotalSpace(); } String use = Formatter.formatShortFileSize(context, t - f); String tot = Formatter.formatShortFileSize(context, t); return String.format("%s used of %s", use, tot); } public static String getTitle(File file) { try { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(file.getPath()); return retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); } catch (Exception e) { return null; } } private static String getExtension(String filename) { //returns the file extension or an empty string iff there is no extension return filename.contains(".") ? filename.substring(filename.lastIndexOf(".") + 1) : ""; } //---------------------------------------------------------------------------------------------- public static String removeExtension(String filename) { int index = filename.lastIndexOf("."); return index != -1 ? filename.substring(0, index) : filename; } public static int compareDate(File file1, File file2) { long lastModified1 = file1.lastModified(); long lastModified2 = file2.lastModified(); return Long.compare(lastModified2, lastModified1); } //---------------------------------------------------------------------------------------------- public static int compareName(File file1, File file2) { String name1 = file1.getName(); String name2 = file2.getName(); return name1.compareToIgnoreCase(name2); } public static int compareSize(File file1, File file2) { long length1 = file1.length(); long length2 = file2.length(); return Long.compare(length2, length1); } public static int getColorResource(File file) { switch (FileType.getFileType(file)) { case DIRECTORY: return R.color.directory; case MISC_FILE: return R.color.misc_file; case AUDIO: return R.color.audio; case IMAGE: return R.color.image; case VIDEO: return R.color.video; case DOC: return R.color.doc; case PPT: return R.color.ppt; case XLS: return R.color.xls; case PDF: return R.color.pdf; case TXT: return R.color.txt; case ZIP: return R.color.zip; default: return 0; } } //---------------------------------------------------------------------------------------------- public static int getImageResource(File file) { switch (FileType.getFileType(file)) { case DIRECTORY: return R.drawable.ic_directory; case MISC_FILE: return R.drawable.ic_misc_file; case AUDIO: return R.drawable.ic_audio; case IMAGE: return R.drawable.ic_image; case VIDEO: return R.drawable.ic_video; case DOC: return R.drawable.ic_doc; case PPT: return R.drawable.ic_ppt; case XLS: return R.drawable.ic_xls; case PDF: return R.drawable.ic_pdf; case TXT: return R.drawable.ic_txt; case ZIP: return R.drawable.ic_zip; default: return 0; } } public static boolean isStorage(File dir) { return dir == null || dir.equals(getInternalStorage()) || dir.equals(getExternalStorage()); } //---------------------------------------------------------------------------------------------- public static File[] getChildren(File directory) { if (!directory.canRead()) return null; return directory.listFiles(pathname -> pathname.exists() && !pathname.isHidden()); } //---------------------------------------------------------------------------------------------- public static ArrayList<File> getAudioLibrary(Context context) { ArrayList<File> list = new ArrayList<>(); Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; String data[] = new String[]{MediaStore.Audio.Media.DATA}; String selection = MediaStore.Audio.Media.IS_MUSIC; Cursor cursor = new CursorLoader(context, uri, data, selection, null, null).loadInBackground(); if (cursor != null) { while (cursor.moveToNext()) { File file = new File(cursor.getString(cursor.getColumnIndex(data[0]))); if (file.exists()) list.add(file); } cursor.close(); } return list; } //---------------------------------------------------------------------------------------------- public static ArrayList<File> getImageLibrary(Context context) { ArrayList<File> list = new ArrayList<>(); Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; String data[] = new String[]{MediaStore.Images.Media.DATA}; Cursor cursor = new CursorLoader(context, uri, data, null, null, null).loadInBackground(); if (cursor != null) { while (cursor.moveToNext()) { File file = new File(cursor.getString(cursor.getColumnIndex(data[0]))); if (file.exists()) list.add(file); } cursor.close(); } return list; } public static ArrayList<File> getVideoLibrary(Context context) { ArrayList<File> list = new ArrayList<>(); Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; String data[] = new String[]{MediaStore.Video.Media.DATA}; Cursor cursor = new CursorLoader(context, uri, data, null, null, null).loadInBackground(); if (cursor != null) { while (cursor.moveToNext()) { File file = new File(cursor.getString(cursor.getColumnIndex(data[0]))); if (file.exists()) list.add(file); } cursor.close(); } return list; } public static ArrayList<File> searchFilesName(Context context, String name) { ArrayList<File> list = new ArrayList<>(); Uri uri = MediaStore.Files.getContentUri("external"); String data[] = new String[]{MediaStore.Files.FileColumns.DATA}; Cursor cursor = new CursorLoader(context, uri, data, null, null, null).loadInBackground(); if (cursor != null) { while (cursor.moveToNext()) { File file = new File(cursor.getString(cursor.getColumnIndex(data[0]))); if (file.exists() && file.getName().startsWith(name)) list.add(file); } cursor.close(); } return list; } public enum FileType { DIRECTORY, MISC_FILE, AUDIO, IMAGE, VIDEO, DOC, PPT, XLS, PDF, TXT, ZIP; public static FileType getFileType(File file) { if (file.isDirectory()) return FileType.DIRECTORY; String mime = FileUtils.getMimeType(file); if (mime == null) return FileType.MISC_FILE; if (mime.startsWith("audio")) return FileType.AUDIO; if (mime.startsWith("image")) return FileType.IMAGE; if (mime.startsWith("video")) return FileType.VIDEO; if (mime.startsWith("application/ogg")) return FileType.AUDIO; if (mime.startsWith("application/msword")) return FileType.DOC; if (mime.startsWith("application/vnd.ms-word")) return FileType.DOC; if (mime.startsWith("application/vnd.ms-powerpoint")) return FileType.PPT; if (mime.startsWith("application/vnd.ms-excel")) return FileType.XLS; if (mime.startsWith("application/vnd.openxmlformats-officedocument.wordprocessingml")) return FileType.DOC; if (mime.startsWith("application/vnd.openxmlformats-officedocument.presentationml")) return FileType.PPT; if (mime.startsWith("application/vnd.openxmlformats-officedocument.spreadsheetml")) return FileType.XLS; if (mime.startsWith("application/pdf")) return FileType.PDF; if (mime.startsWith("text")) return FileType.TXT; if (mime.startsWith("application/zip")) return FileType.ZIP; return FileType.MISC_FILE; } } }

资源下载

更多资源
Mario

Mario

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

腾讯云软件源

腾讯云软件源

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

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

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

用户登录
用户注册