Skip to content

Instantly share code, notes, and snippets.

@justpsvm
justpsvm / 提问的智慧.md
Created Oct 21, 2016 — forked from alsotang/提问的智慧.md
Simplified Chinese edition of "How To Ask Questions The Smart Way"
View 提问的智慧.md
@justpsvm
justpsvm / index.js
Last active Jun 9, 2017
业务 js 模版
View index.js
var Index = function(){
//初始化控件
var initComs = function(){
}
//处理事件
var handleEvent = function(){
}
return {
@justpsvm
justpsvm / springboot_background.sh
Last active Jun 9, 2017
springboot 程序后台运行 #过时 #springboot
View springboot_background.sh
start(){
now=`date "+%Y%m%d%H%M%S"`
exec java -jar /usr/local/pos/cashier-admin.jar 5 >"$now"_bidcheck.log &
#tail -f result.log
}
#停止方法
stop(){
ps -ef|grep java|awk '{print $2}'|while read pid
do
kill -9 $pid
@justpsvm
justpsvm / date_handle.js
Last active Jun 9, 2017
js 简单日期处理
View date_handle.js
/*日期格式化 yyyy-MM-dd*/
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
@justpsvm
justpsvm / mysql_backup_db.bat
Last active Jun 9, 2017
[mysql 数据库备份脚本] for windows #批处理
View mysql_backup_db.bat
rem *******************************Code Start*****************************
@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
mysqldump --opt -uroot -pyake110 hospital > D:\db_backup\hospital_%Ymd%.sql
@echo on
rem *******************************Code End*****************************
@justpsvm
justpsvm / generator.js
Last active Jun 23, 2017
[Hexo 文章置顶] 替换路径 node_modules/hexo-generator-index/lib/generator.js #hexo
View generator.js
'use strict';
var pagination = require('hexo-pagination');
module.exports = function(locals){
var config = this.config;
var posts = locals.posts;
posts.data = posts.data.sort(function(a, b) {
if(a.top && b.top) { // 两篇文章top都有定义
if(a.top == b.top) return b.date - a.date; // 若top值一样则按照文章日期降序排
else return b.top - a.top; // 否则按照top值降序排
}
@justpsvm
justpsvm / HanStrCount.java
Last active Jul 13, 2017
[Java 汉字记数] 利用正则表达式完成 #java
View HanStrCount.java
public static int hanStrCount(String hanStr){
int count = 0;
for (int i = 0; i < hanStr.length(); i++) {
boolean matches = Pattern.matches("^[\u4E00-\u9FA5]{0,}$",String.valueOf(hanStr.charAt(i)));
if (matches) count++;
}
return count;
}
@justpsvm
justpsvm / Hostname.java
Last active Jul 24, 2017
[Java 获取主机名] #java
View Hostname.java
public static String getHostNameForLiunx() {
try {
return (InetAddress.getLocalHost()).getHostName();
} catch (UnknownHostException uhe) {
String host = uhe.getMessage(); // host = "hostname: hostname"
if (host != null) {
int colon = host.indexOf(':');
if (colon > 0) {
@justpsvm
justpsvm / sh-thread-kill.sh
Created Aug 9, 2017
[脚本查找端口并关闭进程] shell 脚本实现 #sh
View sh-thread-kill.sh
#!/bin/sh
if [ $(lsof -t -i:6000) ]; then
echo 'stop'
kill -9 $(lsof -t -i:6000) fi
@justpsvm
justpsvm / replaceAll.js
Created Aug 25, 2017
[js replaceAll 实现] #js
View replaceAll.js
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.replace(new RegExp(search, 'g'), replacement);
};
You can’t perform that action at this time.