1,259 karma · joined July 16, 2012
$ cat bbb.ml
#!/usr/bin/env -S "/home/user/.local/bin/o c a m l" -no-version
print_endline "ok";;
$ ls -lh ~/.local/bin/"o c a m l"
lrwxrwxrwx 1 user user 14 Feb 27 07:26 '/home/user/.local/bin/o c a m l' -> /usr/bin/ocaml
$ chmod a+rx bbb.ml
$ ./bbb.ml
ok
$
But if it didn't work, you can get pretty good mileage out of abusing sh to get the job done for many popular languages.I'd give this a try, works with any language:
#!/usr/bin/env -S "/path/with spaces/my interpreter" --flag1 --flag2
Only if my env didn't have -S support, I might consider a separate launch script like: #!/bin/sh
exec "/path/with spaces/my interpreter" "$0" "$@"
But most decent languages seems to have some way around the issue.Python
#!/bin/sh
""":"
exec "/path/with spaces/my interpreter" "$0" "$@"
":"""
# Python starts here
print("ok")
Ruby #!/bin/sh
exec "/path/with spaces/ruby" -x "$0" "$@"
#!ruby
puts "ok"
Node.js #!/bin/sh
/* 2>/dev/null
exec "/path/with spaces/node" "$0" "$@"
*/
console.log("ok");
Perl #!/bin/sh
exec "/path/with spaces/perl" -x "$0" "$@"
#!perl
print "ok\n";
Common Lisp (SBCL) / Scheme (e.g. Guile) #!/bin/sh
#|
exec "/path/with spaces/sbcl" --script "$0" "$@"
|#
(format t "ok~%")
C #!/bin/sh
#if 0
exec "/path/with spaces/tcc" -run "$0" "$@"
#endif
#include <stdio.h>
int main(int argc, char **argv)
{
puts("ok");
return 0;
}
Racket #!/bin/sh
#|
exec "/path/with spaces/racket" "$0" "$@"
|#
#lang racket
(displayln "ok")
Haskell #!/bin/sh
#if 0
exec "/path/with spaces/runghc" -cpp "$0" "$@"
#endif
main :: IO ()
main = putStrLn "ok"
Ocaml (needs bash process substitution) #!/usr/bin/env bash
exec "/path/with spaces/ocaml" -no-version /dev/fd/3 "$@" 3< <(tail -n +3 "$0")
print_endline "ok";;Add this to ~/.bashrc :
# bind Alt-e on the command line to replace text with command
_aichat_bash() {
if [[ -n "$READLINE_LINE" ]]; then
READLINE_LINE=$(aichat -e "$READLINE_LINE")
READLINE_POINT=${#READLINE_LINE}
fi
}
bind -x '"\ee": _aichat_bash'
In the example you gave i get: find . -type f -name "*.mp4" -exec ffmpeg -i {} -c:v libaom-av1 -crf 30 -b:v 0 -c:a copy ~/Videos/{}.mkv \;
But if you don't like that you can press Ctrl-Shift-_ (bash has emacs keybindings) to undo and try something else. You can also put a # mark in front and hit enter, then up arrow then Alt-e so you know what created the command. $ cat tst.c
int main () {
int x[10];
return *(x+20);
}
$ gcc -Wall -O2 tst.c
tst.c: In function ‘main’:
tst.c:3:10: warning: array subscript 20 is outside array bounds of ‘int[10]’ [-Warray-bounds=]
3 | return *(x+20);
| ^~~~~~~
tst.c:2:7: note: at offset 80 into object ‘x’ of size 40
2 | int x[10];
| ^ library(readr)
library(dplyr)
library(purrr)
data <- read_csv("input.csv")
chunk_size <- 500
chunks <- split(data, ceiling(seq_along(1:nrow(data))/chunk_size))
iwalk(chunks, ~write_csv(.x, sprintf("data-%04d.csv", .y))) #!/usr/bin/perl -CSD -w -Mstrict -Mwarnings -MText::CSV
# chunk.pl -- split csv files into chunks
# Usage message and exit if needed
if (!@ARGV || $ARGV[0] eq '-h') {
print "Usage: $0 input_csv [chunk_size] [output_filename_format] [separator]\n";
print "Example: $0 input.csv 500 'input-%08d.csv' ','\n";
exit;
}
# Set command-line arguments
my ($INFILE, $CHUNKSIZE, $FMT, $SEP) = @ARGV;
$CHUNKSIZE //= 500;
$FMT //= "data-%08d.csv";
$SEP //= ",";
# Initialize CSV, file handles, and counters
my $csv = Text::CSV->new({ binary => 1, auto_diag => 1, sep_char => $SEP, eol => "\n" });
my ($i, $f, $out) = (0, 1, undef);
open my $in, "<:encoding(UTF-8)", $INFILE or die "Cannot open $INFILE: $!";
# Main loop
while (my $row = $csv->getline($in)) {
if ($i % $CHUNKSIZE == 0) {
close $out if defined $out;
open $out, ">:encoding(UTF-8)", sprintf($FMT, $f++) or die "Cannot open output file: $!";
}
$csv->print($out, $row) or die "Failed to write row: $!";
$i++;
}
# Clean up: close file handles
close $out if defined $out;
close $in;Here is mine : https://pastebin.com/ZVWYcpyU , but a lot of GNU Screen muscle memory fails for various reasons.
The main reasons I'm trying to switch are: better scrollback support, and better mouse support (both for tmux itself and for pass-through to terminal applications). Having used GNU Screen for 32 years, it's difficult for me to even think about what keys I'm hitting, it's below the level of conscious recognition at this point.
> "Was the president strong at writing essays when JFK was a high school freshman? Read this essay to find out!"
You write:
> "when the president was a high school freshman"
These are very different circumstances, of course.
If the original sentence had "reigning" before the word "president", then I would absolutely agree with the given interpretation.
I've noticed that Americans call ex-presidents "president", and ex-governors "governor", so that merely adds to the confusion. English is not my native language, and I'm not American, so perhaps I fall into the "lack fluency" category. Conferring with other native speakers nearby, every American immediately reads it as intended, whereas Brits and Canadians do not.
I conclude that the original sentence is poorly written, and that I misread it.
Yes, you can deduce that, since the question is nonsensical (trivial) if "the president" refers to JFK in that context.
> If you flip it to "was JFK strong at writing essays when the president was a high school freshman"
This is a perfect illustration of why the original sentence can be read as referring to JFK, since in speech it is common to have ill-defined references that are later clarified, and there's no formal rule that enforces that all terms must be defined before use.
> How tall was the president when JFK was born?
I infer that "JFK" is being referred to as "the president", regardless of what stage of life he's at. Therefore the correct answer would be the length of his body as a newborn, with nothing to do with who was the president at the moment of his birth.
For example, given the headline: "Was the president strong at writing essays when JFK was a high school freshman? Read this essay to find out!", would you expect an essay from Herbert Hoover while he was in office, or an essay from JFK when he was in grade 9?
They say once in 7.5 million years, so why don’t they show the previous 7.5 million years?
If that's not possible, and we only have 1989-2023 data, then the 7.5 million year comment is particularly ridiculous, as is making any generalization with data for only 0.0001% of the time span in question.
Generally things like carrots, apples, or milk would be an occasional indulgence for this kind of diet. One serving is 10g+ of carbs (one apple, 1 cup of raw carrot, one glass of milk), which is over half the daily budget, so most would simply avoid them almost completely.
Another option is to do every-other-day fasting, which on eating days doubles your carb budget to still maintain a low average intake of carbs.
The typical ratio of macros in terms of calories is roughly 80% fats and 15-20% protein, with under 100 calories per day coming from carbs, so less than 5%.
gpt: The tenth word in the given sentence is "great!"
me: Try harder
gpt: I apologize for the confusion. The sentence "Life is great!" contains only three words. There is no tenth word in the provided sentence.
My personal preference is the PDF link.
Your request was perfectly polite, I was simply wondering what your rationale was for it.
I have spent about a decade of my life being the primary caregiver for my aging parents so far; I'm in my mid 40's. And yes, I hope my kids do the same for me.
We don't outsource raising our children (homeschooling) or caring for our parents; having tutors, coaches, or domestic help is fine on occasion, but not wholesale replacement of family care.