This file contains 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/stap | |
// stap -k -v strace.stp | |
// https://sourceware.org/systemtap/examples/#process/strace.stp | |
# suppress some run-time errors here for cleaner output | |
//bin/true && exec stap --suppress-handler-errors --skip-badvars $0 ${1+"$@"} | |
/* configuration options; set these with stap -G */ | |
global follow_fork = 0 /* -Gfollow_fork=1 means trace descendant processes too */ | |
global timestamp = 1 /* -Gtimestamp=0 means don't print a syscall timestamp */ |
This file contains 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
probe begin | |
{ | |
log("begin to probe") | |
} | |
probe syscall.getdents { | |
/* process id 123 */ | |
if (pid() == 123) { | |
file = @cast(task_current(), "task_struct")->files->fdt->fd[$fd] | |
if (!file) |
This file contains 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 selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
profile = webdriver.FirefoxProfile() | |
profile.accept_untrusted_certs = True | |
driver = webdriver.Firefox(firefox_profile=profile) | |
#driver.get("https://10.240.129.198:8443/") | |
#elem = driver.find_element_by_id("viewer") | |
#elem.click() |
This file contains 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 sympy import * | |
n, y, u = symbols('n y u') | |
M = Matrix([[-1*n*y, n*y], [u, -u-(n-1)*y]]) | |
Mt = M.transpose() | |
X=Matrix([[1,1]]) | |
Y=Matrix([1,0]) | |
m = -X.multiply(Mt.inv()).multiply(Y) |
This file contains 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
@RequestMapping( | |
value = "/{id}.json", | |
method = RequestMethod.GET, | |
produces = "application/json") | |
@ResponseBody | |
public Person getDetailsAsJson(@PathVariable Long id) { | |
return personRepo.findOne(id); | |
} | |
@RequestMapping( |
This file contains 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
@RequestMapping(value="/pdfmethod", produces="application/pdf") | |
public void pdfMethod(HttpServletRequest request, HttpServletResponse response){ | |
response.setContentType("application/pdf"); | |
InputStream inputStream = null; | |
OutputStream outputStream = null; | |
try{ | |
inputStream = getInputStreamFromYourPdfFile(); | |
outputStream = response.getOutputStream(); | |
IOUtils.copy(inputStream, outputStream); | |
}catch(IOException ioException){ |
This file contains 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
type CopyCb func(written int64) | |
func CopyWithCb(dst io.Writer, src io.Reader, cb CopyCb) (written int64, err error) { | |
for { | |
n, err := io.CopyN(dst, src, KB) | |
written += n | |
cb(written) | |
if err != nil { | |
if err == io.EOF { | |
return written, nil | |
} |
This file contains 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 webbrowser | |
import os | |
def openWeb(url): | |
webbrowser.open_new_tab(url) | |
def main(): | |
urls = ['http://www.baidu.com', 'http://www.bing.com', 'http://www.zhihu.com'] | |
for url in urls: | |
option = raw_input('open %s Y/N: ' %url) |
This file contains 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
package main | |
import ( | |
"net" | |
"fmt" | |
"io" | |
"bytes" | |
"os" | |
) |
This file contains 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 java.net.InetAddress; | |
import java.net.UnknownHostException; | |
public class TestNet { | |
public static void main(String[] args) throws UnknownHostException { | |
InetAddress[] machines = InetAddress.getAllByName("lbs.yxgslb.netease.com"); | |
for (InetAddress address : machines) { | |
System.out.println(address.getHostAddress()); | |
} |
NewerOlder