Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
for pid in $(ps -ef | awk '{print $2}'); do
if [ -f /proc/$pid/smaps ]; then
echo "* Mem usage for PID $pid"
echo "-- Size:"
@rubnet
rubnet / nginx_compile_install.sh
Last active September 27, 2019 10:57
Building nginx with ngx_brotli, openssl and pagespeed from Sources
#!/bin/bash
#PS_NGX_EXTRA_FLAGS="--with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc"
PS_NGX_EXTRA_FLAGS=""
DOWNTMP=/data/
#[check the https://www.modpagespeed.com/doc/release_notes for the latest version]
NPS_VERSION=1.13.35.2-stable
cd $DOWNTMP
wget https://github.com/apache/incubator-pagespeed-ngx/archive/v${NPS_VERSION}.zip
@rubnet
rubnet / bili_down_merge.sh
Last active May 19, 2019 14:08
合并 bilibili 安卓 客户端 下载文件 cd 到要合并的av号目录下运行
#!/bin/bash
# ffmpeg -safe 0 -f concat -i list.txt -c copy ../lua.flv.bili2api.80_remux.mp4
for num in $(pwd)/*; do
if [ -d $num ]; then
cd "$num/lua*"
if [ -f list.txt ]; then
unlink list.txt
fi
for file in ./*lv ; do
@rubnet
rubnet / sum_column
Last active October 28, 2019 06:40
sum column all number
str=``;
a=0;
str.trim().split('\n').forEach(e=>a+=Number(e.trim().split(/\s+/)[5].slice(0,-1)));
console.log(a);
@rubnet
rubnet / ApplicationContextHolder.java
Created September 22, 2019 11:10 — forked from ufuk/ApplicationContextHolder.java
Utility bean for getting Spring beans from static context.
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class ApplicationContextHolder implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@rubnet
rubnet / dmesg_ctime.sh
Last active October 6, 2019 03:54
Translate dmesg timestamps to human readable format
#!/bin/bash
# Translate dmesg timestamps to human readable format
# https://blog.sleeplessbeastie.eu/2013/10/31/how-to-deal-with-dmesg-timestamps/
# desired date format
date_format="%a %b %d %T %Y"
# uptime in seconds
uptime=$(cut -d " " -f 1 /proc/uptime)
# -*- encoding: utf-8 -*-
# Author: Epix
#
# Ban Xunlei IP for deluge
# This script will check deluge connected peers per 30 seconds.
# When an IP with UA in `BAN_PATTERNS` is found, the IP will be added to `BLOCK_LIST_FILE`.
# However if the IP is uploading or reporting 100% progress, it will say "WTF?"
import logging
@rubnet
rubnet / upload.php
Last active December 19, 2019 04:07 — forked from taterbase/upload.php
Simple file upload in php
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
"use strict";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, co
@rubnet
rubnet / CentOS6-Base.repo
Last active July 20, 2021 11:24
1. Make a backup of the existing CentOS 6.10 Base repository file. cp -pr /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.OLD
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra