capture
How can I capture the stdout from a process that is ALREADY running
True solution for OSX Write the following function to your ~/.bashrc or ~/.zshrc. capture() { sudo dtrace -p “$1” -qn ‘ syscall::write*:entry /pid == $target && arg0 == 1/ { printf(“%s”, copyinstr(arg1, arg2)); } ‘ } Usage: example@localhost:~$ perl -e ‘STDOUT->autoflush; while (1) { print “Hello\n”; sleep 1; }’ >/dev/null & [1] 97755 example@localhost:~$ capture … Read more
Capture incoming traffic in tcpdump
In Bash shell try this: tcpdump -i eth0 tcp and dst host $MyIpAddress and not src net $MyNetworkAddress/$myNetworkBytes or this equivalent formulation: tcpdump -i eth0 ip proto \\tcp and dst host $MyIpAddress and not src net $MyNetworkAddress/$myNetworkBytes On my system this resolves to something like: tcpdump -i eth0 tcp and dst host 10.0.0.35 and not … Read more
How to tell a lambda function to capture a copy instead of a reference in C#?
The only solution I’ve been able to find is to make a local copy first: for (int i = 0; i < 10; ++i) { int copy = i; actions.Add(() => Console.WriteLine(copy)); } But I’m having trouble understanding why putting a copy inside the for-loop is any different than having the lambda capture i.
Java generics “capture of ?”
A wildcard represents an unknown type. wildcard capture is the process of binding the value of a wildcard type to a new type variable. For example: List<?> list = …; shuffle(list); where <T> void shuffle(List<T> list) { … } Here, the unknown value of ? is bound to the new type variable T upon invocation … Read more
How to capture standard output of a shell command in elisp?
Does shell-command-to-string meet your purpose? For example: (shell-command-to-string “/bin/echo hello”) Hope this helps.
Does [=] imply that all local variables will be copied?
No. It just means that all local variables from the ambient scope are available for lookup inside the body of the lambda. Only if you refer to a name of an ambient local variable will that variable be captured, and it’ll be captured by value. The “capture anything” shorthands = and & are just syntactic … Read more
How can I capture which direction is being panned using UIPanGestureRecognizer?
On UIPanGestureRecognizer you can use -velocityInView: to get the velocity of the fingers at the time that gesture was recognised. If you wanted to do one thing on a pan right and one thing on a pan left, for example, you could do something like: – (void)handleGesture:(UIPanGestureRecognizer *)gestureRecognizer { CGPoint velocity = [gestureRecognizer velocityInView:yourView]; if(velocity.x … Read more
Capturing image from webcam in java?
This JavaCV implementation works fine. Code: import org.bytedeco.javacv.*; import org.bytedeco.opencv.opencv_core.IplImage; import java.io.File; import static org.bytedeco.opencv.global.opencv_core.cvFlip; import static org.bytedeco.opencv.helper.opencv_imgcodecs.cvSaveImage; public class Test implements Runnable { final int INTERVAL = 100;///you may use interval CanvasFrame canvas = new CanvasFrame(“Web Cam”); public Test() { canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); } public void run() { new File(“images”).mkdir(); FrameGrabber grabber = new OpenCVFrameGrabber(0); // … Read more
Regex group capture in R with multiple capture-groups
str_match(), from the stringr package, will do this. It returns a character matrix with one column for each group in the match (and one for the whole match): > s = c(“(sometext :: 0.1231313213)”, “(moretext :: 0.111222)”) > str_match(s, “\\((.*?) :: (0\\.[0-9]+)\\)”) [,1] [,2] [,3] [1,] “(sometext :: 0.1231313213)” “sometext” “0.1231313213” [2,] “(moretext :: 0.111222)” … Read more