Random snippets of all sorts of code, mixed with a selection of help and advice.
Performing operations inside a function on dataframe with pipe workflow
12 July 2025 @ 2:18 am
I have the following dataframe:
df <- data.frame(ID=1:3, col1=1:3, col2=4:6, col3=7:9, col4=10:12, col5=13:15, col6=16:18, col7=19:21)
I need to create a function that essentially does the following:
df_new <- df %>% select(ID, c(col1:col5)) %>% mutate(col1=col1/col2, col3=col3/col2, col4=-col4, col5=-col5)
With the result:
> df_new
ID col1 col2 col3 col4 col5
1 1 0.25 4 1.75 -10 -13
2 2 0.40 5 1.60 -11 -14
3 3 0.50 6 1.50 -12 -15
I write a function to do this:
genUIR_test = function(df, arg1, arg2, arg3, arg4, arg5){
arg1 <- substitute(arg1)
arg2 <- substitute(arg2)
arg3 <- substitute(arg3)
arg4 <- substitute(arg4)
arg5 <- substitute(arg5)
df_new = df %>% select(ID, c(arg1:arg5)) %>%
mutate(arg1=arg1/arg2, arg3=arg3/arg2, arg4=-arg4, arg5=-arg5)
return(df_new)
}
And when
#error "Please port gnulib freadahead.c to your platform!" while compiling openwrt
12 July 2025 @ 2:12 am
Im trying to build old version of openwrt and Im getting this error #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."Tried ubuntu 14.04, 16.04, 18.04 same error, tried installing newer version of m4 from source like mentioned here I have m4 (GNU M4) 1.4.19 but still same error, also there is some patch mentioned here but it's for different software but in it the codedefined _IO_ftrylockfile is replaced by defined _IO_EOF_SEEN I tried that and here is snipped of code mentioned in error
#elif
Populate a combobox list items blank except for the last item
12 July 2025 @ 2:08 am
I am trying to populate a raize combobox using the following code:
'''
Procedure RefreshCB();
begin
SPDBForm.SPDB.Connected := True;
try
SPDBForm.SPQ.Close;
SPDBForm.SPQ.SQL.clear;
SPDBForm.SPQ.SQL.Text := 'SELECT * FROM Contacts';
SPDBForm.SPQ.Open;
SPCRMAddClientForm.SPSubCB.Clear;
Try
SPDBForm.SPQ.First;
Try
SPCRMAddClientForm.SPSubCB.Items.BeginUpdate;
while not SPDBForm.SPQ.Eof do
Begin
SPCRMAddClientForm.SPSubCB.items.Add(SPDBForm.SPQ.FieldByName('CompanyName').AsString);
SPDBForm.SPQ.Next;
End;
Finally
SPCRMAddClientForm.SPSubCB.Items.EndUpdate;
End;
Finally
SPDBForm.SPQ.Close;
End;
finally
SPDBForm.SPDB.Connected := False;
end;
'''
What I end up with is several blank lines except for the last one which po
Error compiling CSS asset / NameError: uninitialized constant Sprockets::Autoload::SassC
12 July 2025 @ 2:01 am
I am running the ArchivesSpace 4.1.1 application that has bundled ruby files. When I attempt to visit the public user interface, I get the following two errors. I know very little about Ruby and since the files are bundled with the application installation I am hesitant to uninstall or install anything that might cause further issues. Any thoughts on what might be causing these two issues?



Linux ls gives nothing but there are subdirectories in it that are accessible by cd [closed]
12 July 2025 @ 1:56 am
So I was told by project collaborator to access to a specific subdirectory under a path.
Entering the very path I found ls -l gives nothing listed and the disk usage is 0, same for du -h.
Nevertheless, I surprisingly found I can actually cd ./foo into the subdirectory deemed to be there by my collaborator.
I wonder what is the mechanism that does it? Is it counterpart of MS Windows’s hidden files to Linux? How to set it?
Wordpress: Exclude sub folder with a web app
12 July 2025 @ 1:54 am
I have a web application developed in flutter in the folder /app. I would like to install Wordpress on to host all the regular content pages. However, when a user interacts with the /app pages, Wordpress interferes and throws a Page not Found error.
The suggested "solution" places the app in an iFrame, which creates its own issues.
Therefore, I am trying to exclude the /app sub folder from WP processing.
By far the most odd arithmetic operation problem I have encountered. Please help :')
12 July 2025 @ 1:29 am
I'm coding a chess AI and for that you need a way to count the pieces to figure out how good a position is. And when I tested my method that counts the pieces I noticed it was a little slow so I tested it part by part to see what was taking so long and I found something extremely strange. For the piece of code I have written below when I run 7 or less out of the 10 lines of code it runs extremely quickly only about 10 milli seconds to run 100 million times. But when I run all 10 lines of code it takes a whole 1000 milli seconds to run 100 million times, that's a 100x slowdown when I run the full thing. And it does not matter which 3 lines I eliminate to speed it up, I have tried many permutations and as long as I have 7 or less of the 10 lines it goes fast and if I have more than 7 it goes slow every time. I asked chatGPT and it told me it was JIT optimizations that was causing the fluctuations but that does not make any sense because the way I made my speed test I added up the tota
Need a Batch script to rename files
11 July 2025 @ 11:58 pm
dailySalesSummaryArw_(retailernumber)_(DateYearMonthday)
I have files in a windows folder with this naming convention:
0682241_Daily_Sales_Summary_5-24-2025
I can change the file manually, but there are over 100+ files and I think a windows batch script (because I do not have any other options) so a user can run it and it will rename the files to the following naming convention:
dailySalesSummaryArw_0682241_20250524.csv
The number of underscores in the original file are set. However, the example value of '0682241' will be different for other files but will always be 7 characters in length.
I've searched google but don't know enough to put one of these together. Does anybody have any suggestions?
Uncaught ReferenceError: exports is not defined even I don't use it
11 July 2025 @ 9:42 pm
I have Electron application with overlay over the loaded website in React and I get error:
Uncaught ReferenceError: exports is not defined
at index.js:2:23
this is on second line: Object.defineProperty(exports, "__esModule", { value: true });
even I don't use any NodeJS modules inside React app.
This is my project structure:
/src
|--assets/
|--electron/
|--overlay/
|--shared/
|-.eslintrc.cjs
|-.gitignore
|-package.json
|-postcss.config.js
|-tailwind.config.js
|-tsconfig.electron.json
|-tsconfig.overlay.json
Basically assets contains images, electron contains backend code in typescript, overlay contains React code, shared contains types shared between backend and frontend.
This is how my build looks like in package.json:
"build": "bun run build:css && bun run build:overlay && bun run build:
How can I dynamically create a Likert-scale matrix from user-defined input?
11 July 2025 @ 9:36 am
For a questionnaire in LimeSurvey v6 I need to implement a two-part question.
In question 1 the respondent should be able to enter the name of organizations they work with, one per row. Ideally the respondent can add as many rows as needed, dynamically. Each row contains just a text field for the name of the organization.
In question 2 I want to display a matrix where each row corresponds to one organization entered in the previous question. There are three columns representing a Likert-type scale from 1 to 7 to assess different aspects (importance, influence, current collaboration).
I used a "Multiple short text" question type in Question 1 with predefined sub-questions and JavaScript to reveal more fields with a button (up to 10 rows). In Question 2 I created an "Array (Numbers)" question and used {question1_SQ001} to {question1_SQ010} as sub-question texts. I used JavaScript in Question 2 to hide rows where the co