This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; | |
| import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; | |
| import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; | |
| import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; | |
| import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; | |
| import org.elasticsearch.action.bulk.BulkRequestBuilder; | |
| import org.elasticsearch.action.search.SearchRequestBuilder; | |
| import org.elasticsearch.action.search.SearchResponse; | |
| import org.elasticsearch.client.Client; | |
| import org.elasticsearch.client.transport.TransportClient; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bs4 import BeautifulSoup | |
| import requests | |
| def get_csrf_token(url): | |
| response = requests.get(url) | |
| soup = BeautifulSoup(response.text) | |
| csrf_param = soup.find("meta", {"name" : "csrf-param"})['content'] | |
| csrf_token = soup.find("meta", {"name" : "csrf-token"})['content'] | |
| return csrf_param, csrf_token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.elasticsearch.action.search.SearchResponse; | |
| import org.elasticsearch.client.Client; | |
| import org.elasticsearch.client.transport.TransportClient; | |
| import org.elasticsearch.common.settings.ImmutableSettings; | |
| import org.elasticsearch.common.settings.Settings; | |
| import org.elasticsearch.common.transport.InetSocketTransportAddress; | |
| import org.elasticsearch.common.unit.TimeValue; | |
| import org.elasticsearch.index.query.MultiMatchQueryBuilder; | |
| import org.elasticsearch.index.query.QueryBuilders; | |
| import org.elasticsearch.search.SearchHit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'tempfile' | |
| def getImageFile(dataURL) | |
| file = Tempfile.new(['image', '.png']) | |
| file.binmode | |
| file.write Base64.decode64(data) | |
| file | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getBase64Image(img) { | |
| var canvas = document.createElement("canvas"); | |
| canvas.width = img.width; | |
| canvas.height = img.height; | |
| var ctx = canvas.getContext("2d"); | |
| ctx.drawImage(img, 0, 0); | |
| var dataURL = canvas.toDataURL("image/png"); | |
| return dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Wechat | |
| class SignatureValidator | |
| attr_accessor :token, :params | |
| def initialize(token, params) | |
| @token = token | |
| @params = params | |
| end | |
| def calculate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: utf-8 | |
| require "watir" | |
| email, password = ARGV[0], ARGV[1] | |
| puts "email: #{email}" | |
| puts "password: #{password}" | |
| browser = Watir::Browser.new | |
| browser.goto("http://zhe800.com") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require "mechanize" | |
| require 'logger' | |
| logger = Logger.new(STDOUT) | |
| TEST_URL = "http://baidu.com" | |
| Entry = Struct.new(:host, :port) do | |
| attr_accessor :alive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen 7977; | |
| server_name example.com; | |
| set_real_ip_from 127.0.0.1; | |
| real_ip_header X-Real-IP; | |
| location /ip { | |
| default_type text/plain; | |
| echo "$remote_addr"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function SendDeleteRequest($url) { | |
| try { | |
| $request = [Sytem.Net.WebRequest]::Create("$url") | |
| $request.Method = "DELETE" | |
| $request.GetResponse() | |
| } | |
| catch | |
| { | |
| Write-Host "Fail to send DELETE request to $url" | |
| } |