import pathlib
ROOT_DIR = pathlib.Path(__file__).parent.parent
process, output = run_process(f"python3 {ROOT_DIR / 'something.py'}", ROOT_DIR)
process = run_background(f"python3 {ROOT_DIR / 'something.py'}", ROOT_DIR)
These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).
First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter
(2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.
Finally all remaining files are listed using git ls
, the files to keep are removed from that using grep -v
and the resulting list is passed to git rm
which is invoked by git filter-branch --index-filter
(3.). A bit convoluted but it does the trick.
#!/bin/sh | |
# | |
# msys2-sshd-setup.sh — configure sshd on MSYS2 and run it as a Windows service | |
# | |
# Please report issues and/or improvements to Sam Hocevar <sam@hocevar.net> | |
# | |
# Prerequisites: | |
# — MSYS2 itself: http://sourceforge.net/projects/msys2/ | |
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights | |
# |
#!/bin/sh | |
# | |
# msys2-sshd-setup.sh — configure sshd on MSYS2 and run it as a Windows service | |
# | |
# Please report issues and/or improvements to Sam Hocevar <sam@hocevar.net> | |
# | |
# Prerequisites: | |
# — MSYS2 itself: http://sourceforge.net/projects/msys2/ | |
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights | |
# |
#!/bin/bash
cd /myfiles
while true;
do
sleep_time=10
pwd;
This can be used to backup any directory on your computer (not just Anki). Just take care of the size of the directory you are backing up (in case it is too big you may run out of space).
Requirements:
- MacOS, Windows or Linux with Unix environment tools
bash
zip
rm
cmp
mkdir
tail
- https://stackoverflow.com/questions/13614803/how-to-check-if-html5-audio-has-reached-different-errors
- https://developer.mozilla.org/en-US/docs/Web/API/MediaError
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/error
- https://stackoverflow.com/questions/29681907/check-if-sound-file-exists-javascript
media.addEventListener(
"error",
event => {
let target = event.target;
let message;
let is_running_wrapper = target_function => {
return (...args: any) => {
if (this.is_running_pause) {
return;
}
let result;
this.is_running_pause = true;
try {
result = target_function(...args);
@Test(testName = "Listen for Sound", description = "Check that, when clicking the 'A' key, a sound is played", groups = {"01Drums"}) | |
public void soundPlayTest() throws InterruptedException { | |
driver.findElement(By.xpath("/html/body/div[2]/div[1]")).click(); | |
WebElement aKey = driver.findElement(By.xpath("/html/body/div/div[1]")); | |
Actions builder = new Actions(driver); | |
Action sendAKey = builder.moveToElement(aKey).sendKeys("A").build(); | |
sendAKey.perform(); | |
Thread.sleep(1000); | |
WebElement audio = driver.findElement(By.tagName("audio")); |