Skip to content

Instantly share code, notes, and snippets.

View cjvirtucio87's full-sized avatar

CJ Virtucio cjvirtucio87

View GitHub Profile
@cjvirtucio87
cjvirtucio87 / rootless_crictl.sh
Created June 25, 2023 00:40
bash script for calling crictl on the containerd unix socket; useful when running k3s in rootless mode
#!/usr/bin/env bash
function main {
set -eo pipefail
local main_pid
main_pid="$(systemctl show --property MainPID --user k3s-rootless | cut -d '=' -f2 | tr -d '\n')"
local exe_pid
for f in /proc/*/status; do
function mygo {
MINGW_GIT="$WINDOWS_GIT/mingw64/bin";
PATH=$MINGW_GIT:$PATH;
printf "Running go with the Windows installation of Git.\n";
$GOBIN/go $@;
PATH=`echo $PATH | sed "s,$MINGW_GIT\:,,g"`;
printf "Resetting \$PATH.";
}
alias go=mygo
start := time.Now()
getElapsed := func (start time.Time) {
elapsed := time.Now().Sub(start).Seconds()
log.Printf("Completed in %s seconds.", strconv.FormatFloat(elapsed, 'E', -1, 64))
}
defer getElapsed(start)
@cjvirtucio87
cjvirtucio87 / dumpgrate.sh
Created January 28, 2018 15:39
A bash script to dump and migrate data from a MySQL database to one on your own machine.
#!/bin/bash
host=abc-prod-db
dbs=(a_metrics b_metrics c_metrics)
ignored_table=irrelevant_table
time=$(date +'%H%M%S')
day=$(date +'%F')
migrate_cache=/tmp/migrate_cache
// Old
if ((additionalFiles != null) && !additionalFiles.isEmpty()) {
listOfNonSyncFiles.put(Constants.ADDITIONAL_FILES, additionalFiles.stream().map(
// just the filename
doc -> doc.getName().toLowerCase())//.filter(s -> !s.startsWith(Constants.MANIFEST_FILENAME))
.sorted().collect(Collectors.toList()));
additionalFiles.stream().forEach(s -> log.info(s.getName() + ""));
}
<?xml version="1.0" encoding="UTF-8"?>
<e:list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:e="http://www.loandox.org/ExamSchema" xsi:schemaLocation="http://www.loandox.org/ExamSchema ExamSchema.xsd ">
<e:file>
<e:name>absurdlyLargeFile.pdf</e:name>
</e:file>
<e:file>
<e:name>anotherAbsurdlyLargeFile.pdf</e:name>
</e:file>
<e:file>
<e:name>aThirdAbsurdlyLargeFile.pdf</e:name>
// org.yournamespace.Store.java
@Service
public class Store {
private Map<String, Info> fileState;
public Store(Map fileState) {
this.fileState = fileState;
}
@Bean
@Controller
public class Uploads {
// ...
@RequestMapping(value="/uploads", method={ RequestMethod.HEAD })
public ResponseEntity<?> headUploads(
@RequestHeader(value="Upload-Metadata") String meta,
@RequestHeader(value="Tus-Resumable") String ver
) {
// ...
try {
User user = getAuthenticatedUser();
FileInfo fileInfo = InfoFactory.createFileInfo(
uploadLength,
uploadMetadata,
user != null ? user.getUsername() : "",
null
);
@PostMapping("/resumable_uploads")
@Timed
public ResponseEntity<?> createResumableUpload(
@RequestHeader(value="Content-Length") Long contentLength,
@RequestHeader(value="Upload-Length") Long uploadLength,
@RequestHeader(value="Tus-Resumable") String protocolVer,
@RequestHeader(value="Upload-Metadata") String uploadMetadata
) throws URISyntaxException {