Skip to content

Instantly share code, notes, and snippets.

# coding:utf8
# pip install simplejson
# pip install beautifulsoup4
# sudo apt-get install python-bs4
import urllib3
import re
from bs4 import BeautifulSoup
url = "http://qingmang.me/magazines/"
print "first method"
@herohenu
herohenu / anlyze-log.rb
Last active January 5, 2017 03:57
分析日志 提取名称并对结果排序
require 'date'
require 'net/http'
require 'uri'
require 'json'
argv = ARGF.argv
gap = argv[0].to_s.to_i || 0
day = (Date.today - gap ).strftime("%Y-%m-%d")
puts
adx_requests=Hash.new(0)
daydirs = Dir["log/*watch*"].sort
@herohenu
herohenu / get_location_from_ip.rb
Created December 30, 2016 12:59
通过ip查询国家
require 'net/http'
require 'json'
require 'uri'
i = 0
f=File.open("us_ip_result.txt", "a+")
File.open("us.log" ).each do |line|
i = i + 1
ip = line.split(",").last.gsub(/\s+/, "")
if ip != ""
@herohenu
herohenu / xml2json.js
Created June 12, 2016 09:28
读取xml的内容,并输出到屏幕
var parser = require('xml2json');
var fs = require('fs');
content = fs.readFileSync('mmg.xml')
console.log("content is:",content)
// xml to json
var xml =content;
var json = parser.toJson(xml); //returns a string containing the JSON structure by default
console.log(json);
json = JSON.parse(json)
@herohenu
herohenu / ruby-call-ruby-or-shell.rb
Created June 2, 2016 08:45
each day to call task
require 'date'
(Date.parse("20160416")..Date.parse("20160430")).each do |day |
day= day.strftime("%Y%m%d")
#exec( "echo ruby send-dev2es.rb #{day}" )
exec_command = " ruby send-dev2es.rb #{day}"
system exec_command
sleepcmd = "sleep 0.05"
system sleepcmd
end
@herohenu
herohenu / ruby-crontab.rb
Last active June 2, 2016 08:45
crontab task by ruby
require 'rufus-scheduler'
require 'date'
#实现上传统计任务,第一个任务执行完成后输出结果,第二个任务对输出结果处理上传
#两个任务分别重复执行一次,防止执行失败。
scheduler = Rufus::Scheduler.new
puts Time.new
scheduler.cron '25 0,3 * * *' do
@herohenu
herohenu / gist:63fd54596ddb56e49ec47ef896b08f2d
Created May 26, 2016 06:14 — forked from the42/gist:1956518
GZip encoding for GO V1 using custom responsewriter
package main
import (
"compress/gzip"
"io"
"net/http"
"strings"
)
type gzipResponseWriter struct {
@herohenu
herohenu / multipart_upload.go
Created May 9, 2016 05:56 — forked from mattetti/multipart_upload.go
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@herohenu
herohenu / ecb.go
Created April 8, 2016 07:00 — forked from DeanThompson/ecb.go
Golang AES ecb mode
package utils
import "crypto/cipher"
type ecb struct {
b cipher.Block
blockSize int
}
func newECB(b cipher.Block) *ecb {
@herohenu
herohenu / gist:2bd94589595c44459769
Created February 24, 2016 10:07
Sublime Text 3 Build 3083 License Key - CRACK
### yo probe esta:
—– BEGIN LICENSE —–
J2TeaM
2 User License
EA7E-940282
45CB0D8F 09100037 7D1056EB A1DDC1A2
39C102C5 DF8D0BF0 FC3B1A94 4F2892B4
0AEE61BA 65758D3B 2EED551F A3E3478C
C1C0E04E CA4E4541 1FC1A2C1 3F5FB6DB