Skip to content

Instantly share code, notes, and snippets.

View lajunta's full-sized avatar
🌴
On vacation

lajunta lajunta

🌴
On vacation
View GitHub Profile
function insert_medias(s){
//var app_path="/kpy/dc";
var app_path="";
if(s==1){
jsonurl=app_path+"/tempmedias/show";
see_prefix=app_path+"/new_see/";
$.getJSON(jsonurl, function(data) {
var items = [];
$.each(data, function(index, media) {
mediasrc=see_prefix+media.grid_id;
有没有这样一个需求:
同时向几十上百台Linux服务器上传文件并执行命令,如果一个个来,那你就真是挨踢民工。程序员要发挥自己懒惰的个性,借用Net::SSH和net::SCP用Ruby写个脚本你会发现非常简单。
Net::SSH和Net::SCP是两个Ruby操作SSH的gem包。Net::SSH相当于cmd,专门用于执行命令;Net::SCP专门用于传输文件。它们俩结合,可以做任何SSH client能做的事情。
安装:
gem install net-ssh
gem install net-scp
以下所有代码都引用这段代码
dpkg-reconfigure tzdata
@lajunta
lajunta / gist:7315509
Last active February 28, 2020 17:02
check ddos ip
netstat -an|grep ESTABLISHED|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|awk '{ printf("%s\t%s\t",$2,$1); for (i = 0; i < $1; i++) {printf("*")}; print ""}'
netstat -alpn | grep :80 | awk '{print $5}' |awk -F: '{print $(NF-1)}' |sort | uniq -c | sort -n
netstat -anp |grep ‘tcp\|udp’ | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort –n
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh"
#encoding: utf-8
require "json"
require "rest_client"
def get_access_token
appid="your appid"
appsecret="your appsecret"
uri = "https://api.yixin.im/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{appsecret}"
res = RestClient.get(uri)
hsh = JSON.parse(res)
#encoding: utf-8
require "net/http"
require "json"
require "xmlsimple"
def get_access_token
appid="your appid"
appsecret="your appsecret"
uri_string="https://api.yixin.im/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{appsecret}"
uri=URI.parse(uri_string)
#encoding: utf-8
require "net/http"
require "json"
require "xmlsimple"
class YixinController < ApplicationController
layout nil
skip_before_filter :verify_authenticity_token
<xml>
<ToUserName>#{@to_user}</ToUserName>
<FromUserName>#{@from_user}</FromUserName>
<CreateTime>#{Time.now.to_i}</CreateTime>
<MsgType>news</MsgType>
<ArticleCount>#{@articles.count}</ArticleCount>
<Articles>
- @articles.each do |article|
- unless article.media_infos.blank?
- theone=article.media_infos.sample
<xml>
<ToUserName>#{@to_user}</ToUserName>
<FromUserName>#{@from_user}</FromUserName>
<CreateTime>#{Time.now.to_i}</CreateTime>
<MsgType>news</MsgType>
<ArticleCount>1</ArticleCount>
<Articles>
<item>
<Title>凤城文化节有奖问答</Title>
<Description>快来参加吧</Description>