- Pdp 10 zero compressed executable binary
- PHP — running executable binary file through shell and printing output
- How to Building Ubuntu Executable Binary on Windows 10
- How to compile C into an executable binary file and run
- Building an Ubuntu Executable Binary on Windows 10!
- Add_executable create two binaries files instead of one
- Compress a binary matrix
- Store file in executable binary
- An Example of Echoing Binary File Code in PHP
- How to echo and filedownload together in php
- Php read file as binary
- Convert a file to binary php
- file to binary php
- Binary data shell echo generator
Pdp 10 zero compressed executable binary
Question: I have an executable binary which i needs to run and interactively read from it and write to it when it asks for input I’m talking about something like interactive shell, but in a web browser, such that: As soon as the binary produces output, i would like to send it to the browser As soon the binary requests user input, i would like the user to write the input from the browser Convert each cluster to alphanumeric encoding (a-zA-Z0-9_) and join as string How smart/stupid/optimal is this solution?
PHP — running executable binary file through shell and printing output
I have an executable binary which i needs to run and interactively read from it and write to it when it asks for input
I’m talking about something like interactive shell, but in a web browser, such that:
- As soon as the binary produces output, i would like to send it to the browser
- As soon the binary requests user input, i would like the user to write the input from the browser
Now I’ve already did the same thing with proc_open() , I’ve used pipes to communicate with the running process and it worked fine, but i have to pass all required inputs before i run the binary
Here’s the code I’ve written so far:
["pipe", "r"], // stdin is a pipe that the child will read from 1 => ["pipe", "w"], // stdout is a pipe that the child will write to 2 => ["pipe", "w"] // stderr is a pipe to write to ]; $process = proc_open('g++ test.cpp -o test.o && ./test.o', $descriptors, $pipes, "/home/ixcoders/Desktop"); if (is_resource($process)) < $inputs = "4\n5"; fwrite($pipes[0], $inputs); // Add inputs to pipe fclose($pipes[0]); echo stream_get_contents($pipes[1]); // Print Output fclose($pipes[1]); echo stream_get_contents($pipes[2]); // Print Errors fclose($pipes[2]); // It is important that you close any pipes before calling // proc_close in order to avoid a deadlock $return_value = proc_close($process); echo "\n"; echo "Error Code: " . $return_value . "\n"; >
Any help would be highly appreciated
This one is going to be a journey for you and I wish you lots of good fortune.
Generally, you’re going to need to have a persistent connection open to the browser. This is done typically though WebSockets, though beacons and even WebAssembly (pure sockets) has started to be used to facilitate this real time communication. Full disclosure this is a personal repo php sock which has the bare minimum to open a websocket connection using PHP. I’ve also experimented with websocketd which is like a websocket Gui (aka the apache or Nginx for websockets).
Side note your database connections (should you need any in WS) should just be reset/closed with every request. like every time you use it, not just per user connection. This proves to be the best way in my experience with MySQL at least.
Unix & Linux: File descriptors of executable binary file, Unix & Linux: File descriptors of executable binary file and shared libraries in /proc/PID/fd?Helpful? Please support me on Patreon: https://www.patreon.com
How to Building Ubuntu Executable Binary on Windows 10
About Press Copyright Contact us Creators Advertise Developers Terms Privacy Policy & Safety How YouTube works Test new features Press Copyright Contact us …
How to compile C into an executable binary file and run
How to compile C into an executable binary file and run it in Android from Android Shell — Android [ Glasses to protect eyes while coding : https://amzn.to/3
Building an Ubuntu Executable Binary on Windows 10!
A video showing me build an incredibly simple C program for Ubuntu (Linux) on Windows 10 , using the Beautifully named «Bash on Ubuntu on …
Add_executable create two binaries files instead of one
set(protoc_files $/src/google/protobuf/compiler/main.cc ) add_executable(protoc $) target_link_libraries(protoc libprotobuf libprotoc) add_executable(protobuf::protoc ALIAS protoc) set(PROTOC_NAME "protoc") set_target_properties(protoc PROPERTIES VERSION $ OUTPUT_NAME $) if(WIN32) set(PROTOC_SUFFIX ".exe") set_target_properties(protoc PROPERTIES SUFFIX $) else() set(PROTOC_SUFFIX) endif() set(PROTOBUF_PROTOC_EXECUTABLE "$/$$" PARENT_SCOPE)
I have included source of google protocol buffer compiler to my project, and I use previous cmake file for generating runtime binary, but instead of one file I get two executable files: «protoc» and «protoc-3.6.1».
I am using CLion IDE 2018.1.5 with bundled CMake 3.10.3 on Ubuntu 18.04.
On Windows I don’t have a such problem.
As @Tsyvarev said in comment, one of these files is actually a symlink to another one. This is what VERSION property implies.
Adding an executable binary to kernel image, I have a driver (not dealing with any file operations but just a .c file) which reads all clock configuration registers and calculates the clocks present on the board and it will print them on the
Compress a binary matrix
I have to send a large set of data containing biological samples which are two-dimensional SQUARE array of 1’s and 0’s. Say for example:
So- this was 3-dimensional. Mine goes 60-70 and expected to go to 120 rows/columns (max). I have to send this via Ajax/API and also store into database. I could serialise as Json- But I was looking if there was an optimal way to handle things like this. Like, with a series of proper compression/decompression?
One way I could think of it is:
- Join the digits as string
- Divide in clusters of 6 digits. 111111 bin = 63 dec ( A-Z, a-z, 0-9,_ = 26 + 26 + 10 + 1)
- Convert each cluster to alphanumeric encoding (a-zA-Z0-9_) and join as string
How smart/stupid/optimal is this solution? Is something better already out there?
Converting your data structure to JSON, then passing it through a standard compression algorithm like gzdeflate() is about as simple as you can get, and will result in excellent compression ratios. There’s probably no reason to make it any more complicated than that.
(The output of gzdeflate will be binary data. If you need to transfer it over a channel which can’t deal with that, you can base64_encode it; the results will still be smaller than the original JSON for a matrix of any meaningful size.)
«Flattening» the matrix into a single string of 1 s and 0 s (and storing the dimensions of the original matrix alongside the string) before compressing it may give you slightly better compression ratios, but at the expense of making your code more complicated.
Performing alphanumeric encoding on the matrix like you’re describing in your question will result in significantly worse compression ratios, as it will make it very difficult for the DEFLATE algorithm to detect any patterns in your data which don’t «line up» perfectly with the size of your clusters.
Linux — How to know whether executable or binary is, How to know whether executable or binary is processing some request or busy/idle (not RUNNING status) I want to stop/kill the process based on the processing status of the executable.
Store file in executable binary
I’m building a command line app that gives audio feedback. I would like to burn the audio file into the executable binary to make it easier to ship it.
One way to do this is to use go-bindata — this will add an extra compile step when your binary files change.
Sanity of appending data to an executable binary, Is it generally sane to append some random data to an executable binary file? What measures should be taken to ensure safe operation of the resulting executable, like padding before appended data or
An Example of Echoing Binary File Code in PHP
The JavaScript code will transfer the $_GET variables to test.php to initiate a new window for downloading, while displaying a message in the current window. Additionally, using the «split» function with a value of 1 or «.» will split the string into bytes instead of characters, especially when dealing with a multi-byte encoded string.
How to echo and filedownload together in php
As per @Mark Backer’s comment, it is not possible to both echo and download a file simultaneously for a single request. However, there are certain methods that can be used to echo a message and still download the file.
Assume that your code, as provided in the question, is present in a file named test.php. If the user requests the file containing the following code, then the scenario arises.
The JavaScript code will transfer the $_GET variables to test.php, initiate a new window for downloading, and display your message in the current window.
The Best PHP Examples, These are special codes that put characters in your string that represent typically invisible characters. Examples include newlines \n, tabs \t, and actual backslashes \\. You can also embed PHP variables in double quoted strings to have their values added to the string.
Php read file as binary
$data = fopen ($image, 'rb'); $size=filesize ($image); $contents= fread ($data, $size); fclose ($data);
File to binary php Code Example, PHP queries related to “file to binary php” php read binary file; write binary file php; php get binary file; php access to …
Convert a file to binary php
file to binary php
$data = fopen ($image, 'rb'); $size=filesize ($image); $contents= fread ($data, $size); fclose ($data);
Php save binary code to file Code Example, PHP queries related to “php save binary code to file” php read binary file; read file as binary php; php echo binary file; php convert string to binary format; copy env example to .env in laravel; Copy file …
Binary data shell echo generator
Separating concerns, Simplifying code
The function is quite complex as $add is called in every iteration of the for loop. To simplify the series of if statements, a mapping of values to add can be created instead, as demonstrated in $replacements in the sample below. Additionally, $add function seems unnecessary as the loop can easily determine the number of characters to add to $line_length and add the character to $ret .
If the characters were mapped to an array and then split into lines using array_chunk() and implode() , the conditional block at the beginning of the loop could be removed.
Initializing line length variable
The start of the string could be used to initialize the variable $ret .
Instead of using a repeated hard-coded string for the length, it could be set in a different way.
$line_length = strlen("echo -ne '");
It can just reference that string:
It goes without saying that the function’s returned value would need to be updated.
Additionally, this code can be used to reset the line length while inside the loop.
It’s possible that PHP is already handling that as a micro-optimization.
Iterating over the string
To avoid using a standard for loop when iterating over a string, an alternative option is to use an array with a foreach . Generating an array can be achieved through various methods, such as str_split() which will split a multi-byte encoded string into bytes rather than characters. Another option is to use mb_split() .
foreach(str_split($binary) as $i => $curr)
It's unnecessary to manually set $curr within the loop.
Excess continue
At the conclusion of the for loop, there is a continue statement that is unnecessary. Although it has no impact, it may cause confusion for anyone who reads the code, including yourself in the future.
Updated Code
I tried out this code on the website called tehplayground.com.
function encodeChar($char) < //could be declared as a constant $replacements = [ "\\" =>"\\\\", '\'' => '\'\\\'\'', "\n" => "\\n", "\r" => "\\r" ]; // http://www.asciitable.com/ $specialAsciiWhitelist = " !\"#$%&'()*+,-./:;?@[\\]^_`<|>~"; if (isset($replacements[$char])) < return $replacements[$char]; >if (ctype_alnum($char) || strpos($specialAsciiWhitelist, $char) !== false) < return $char; >// some binary-ish or unicode-ish data, hex-escape it.. $hex = bin2hex($char); $hex = str_split($hex, 2); return '\\x' . implode('\\x', $hex); > /** * generate command to echo (binary?) data to stdout * * @param string $binary * the (optionally binary) data to echo * @param int $max_ish_line_length * the circa-max line length for the data (PS! it's not accurate, it wraps at *circa* this length) * @return string */ function generateBinaryEcho(string $binary, int $max_ish_line_length = 50): string < $inner_max_ish_line_length = (- 2) + $max_ish_line_length; $ret = "echo -ne '"; $line_length = strlen($ret); foreach(str_split($binary) as $curr) < if ($line_length >= $inner_max_ish_line_length) < $ret .= "'\\\n'"; $line_length = 1;//strlen("'"); >$encodedChar = encodeChar($curr); $line_length += strlen($encodedChar); $ret .= $encodedChar; > return $ret . "'"; >
Php - binary data shell echo generator, \$\begingroup\$ thanks for reviewing it! several good points, and i'm glad no actual bugs were found. (this next part doesn't really matter, but the overhead of str_split() is much greater than what would be saved with the strlen() optimization, but php 7.1 added const strlen optimization anyway, strlen("'") …