PHP snippets
Friendly file size string
public static function bytesToSize($bytes)
{
if ($bytes < 1024) {
return '< 1k';
} else if ($bytes < 1048576) { // 1024 * 1024
return round($bytes/1024, 2) .'K';
} else if ($bytes < 1073741824) { // 1024 * 1024 * 1024
return round($bytes/1048576, 2) .'M';
} else {
return round($bytes/1073741824, 2) .'G';
}
12 }
Duration of the song
public static function secToStr($sec)
{
$hours = floor($sec / 3600);
$minutes = floor(($sec / 60) % 60);
$seconds = $sec % 60; if ($hours > 0) {
return sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds);
} else {
return sprintf("%d:%02d", $minutes, $seconds);
}
}
PHP snippets的更多相关文章
- [OpenCV] Install OpenCV 3.4 with DNN
目标定位 一.开始全面支持 Tensorflow OpenCV3.4 新功能 当前最新进展OpenCV 3.4 dev:https://github.com/opencv/opencv/tree/ma ...
- Code Snippets 代码片段
Code Snippets 代码片段 1.Title : 代码片段的标题 2.Summary : 代码片段的描述文字 3.Platform : 可以使用代码片段的平台,有IOS/OS X/ ...
- Xcode开发中 Code Snippets Library 的相关用法
当在进行项目的时候,总会遇到很多相同的写法.因此,我们可以使用Code Snippets Library 来进行代码小片段的“封装”: 以Xcode中常用的属性为例: 使用步骤如下: 1.在Xcode ...
- 25+ Useful Selenium Web driver Code Snippets For GUI Testing Automation
本文总结了使用Selenium Web driver 做页面自动化测试的一些 tips, tricks, snippets. 1. Chrome Driver 如何安装 extensions 两种方式 ...
- Random Javascript code snippets
MollyPages.org"You were wrong case.To live here is to live." Home Pages / Database / Forms ...
- VS 添加Snippets
Code Snippet 下载文件: propfull.7z copy到C:\Users\哲\Documents\Visual Studio 2013\Code Snippets\Visual C#\ ...
- VS代码段扩展Snippet Designer is a Visual Studio plug in which allows you to create and search for snippets inside the IDE
Snippet Designer is a Visual Studio plug in which allows you to create and search for snippets insid ...
- Xcode开发技巧之Code Snippets Library
http://blog.csdn.net/lin1986lin/article/details/21180007 目录(?)[-] 引言 什么是Code Snippets 如何新建Code Snipp ...
- visual studio snippets风格
snippet挺好用,但是不是我喜欢的那种风格,比如if是这样的 if () { XX } 而我比较习惯这种: if () { XX } 可以这么做: 工具(Tools)——代码段管理器(Code S ...
- Xcode Snippets
在Double Encore,我们写的代码都是干净,可重用的——不过,有时候并不能完全做到.如在使用pragma mark的时候.下面就是一个示例: #pragma mark - UIViewCo ...
随机推荐
- C#中的单体设计模式Singleton
经典的单体设计模式的实现就是 有一个Public的类,在这个类中,有一个私有的private的构造函数. 然后有一个静态方法,这个静态方法返回这个类的实例 举个例子如下 Public class My ...
- Django 的认证系统
Django自带的用户认证 auth 模块 from django.contrib import autu django.contrib.auth 中提供了许多方法, 这里主要介绍其中三个: auth ...
- Vue 学习文档
Vue 学习文档 vue 起步 引包 启动 new Vue(options) options: el 目的地(可以用类名.标签名等,也可以直接用mod元素) #elementId .elementCl ...
- PHP实现把MySQL数据库导出为.sql文件实例(仿PHPMyadmin导出功能)
1. 首先要得到该数据库中有哪些表,所用函数 mysql_list_tables(),然后可以将获取的所有表名存到一个数组.----------------该函数由于被弃用 用show table ...
- python的virtualenv环境与使用
1.安装virtualenv 在安装virtualenv之前,我们需要安装至少有一个版本的Python:因为virtualenv是python的一个第三方模块,必须基于python环境才能安装: 如果 ...
- UPCOJ9526(SG函数打表,nim游戏异或规则)
#include<bits/stdc++.h>using namespace std;int f[1007],SG[1007],S[1007];//f为可以选取的石头个数,SG为sg函数, ...
- Yaf + Smarty 整合笔记
Yaf真的是太简单了,简单到使用mvc的时候在view里面需要手写php脚本.因此考虑整合一下smarty模板引擎.随心所欲也正是yaf的魅力 Yaf 安装 这里简单说一下yaf的安装,已经是非常无脑 ...
- 在 windows 下搭建 IDEA + Spark 连接 Hive 的环境
为了开发测试方便,想直接在 IDEA 里运行 Spark 程序,可以连接 Hive,需不是打好包后,放到集群上去运行.主要配置工作如下: 1. 把集群环境中的 hive-core.xml, hdfs- ...
- nginx 反向代理及负载均衡
假设我们在 192.168.137.11:8080 上有一个web服务,在 192.168.137.12 配置了一台 nginx,我们可以进行如下配置: location / { proxy_p ...
- C#报算术运算导致溢出的错误
如果是在fill datatable时报这个错,是因为所查询的数据中有在数据库中为NUMBER类型的字段,这种类型C#中不能识别,需TO_CHAR转换成字符型,就不会再报这个错了. e.g. SELE ...