Skip to content

Instantly share code, notes, and snippets.

View varrix's full-sized avatar

Logan Speck varrix

  • Ontario, Canada
  • 05:50 (UTC -04:00)
View GitHub Profile
@varrix
varrix / whereami.sh
Last active October 31, 2020 19:03
Convenience function for checking if you're in a screen and outputting the id of it if so.
#!/bin/bash
############
# whereami #
############
# Req. -> screen
# Convenience function for checking if you're in a screen and outputting the id of it if so.
function whereami {
if [[ $(echo $STY) ]]; then
echo "You're in the screen: $STY"
@varrix
varrix / grab_terraform.sh
Created April 27, 2018 00:22
Simple script to download, unzip, and relocate the terraform binary for v0.11.7
#!/bin/sh
# ensure we have the unzip on the CLI
sudo apt-get install unzip
# what version of terraform do we want?
VER=0.11.7
# download $VER of terraform
wget https://releases.hashicorp.com/terraform/$VER/terraform_$VER_linux_amd64.zip
@varrix
varrix / AutoRollback.java
Created February 17, 2018 05:59
AutoRollback class implementing AutoCloseable for some interesting commit changes for a finally-block. Source: https://stackoverflow.com/a/37122747
import java.sql.SQLException;
import java.sql.Connection;
public class AutoRollback implements AutoCloseable {
private Connection conn;
private boolean committed;
public AutoRollback(Connection conn) throws SQLException {
this.conn = conn;
@varrix
varrix / Credentials.java
Created February 17, 2018 00:00
An Immutable credentials object written in Java.
package <your_package>;
import org.apache.commons.lang3.Validate;
import java.util.Optional;
import javax.annotation.Nullable;
/** Immutable object containing the credentials for a database. */
public final class Credentials {
/** Host of this login */
@varrix
varrix / hello_world.bf
Created January 17, 2018 20:30
Hello world in brainfuck.
++++++++ Set Cell #0 to 8
[
>++++ Add 4 to Cell #1; this will always set Cell #1 to 4
[ as the cell will be cleared by the loop
>++ Add 2 to Cell #2
>+++ Add 3 to Cell #3
>+++ Add 3 to Cell #4
>+ Add 1 to Cell #5
<<<<- Decrement the loop counter in Cell #1
] Loop till Cell #1 is zero; number of iterations is 4
@varrix
varrix / ex_cp_and_rationale_java.md
Created September 20, 2017 02:16
Source: https://stackoverflow.com/a/9260565 (see comments for rationale on particular counter-points one might have against this approach).
try(Connection con = getConnection()) {
   try (PreparedStatement prep = con.prepareConnection("Update ...")) {
       //prep.doSomething();
       //...
       //etc
       con.commit();
   } catch (SQLException e) {
       //any other actions necessary on failure
 con.rollback();
@varrix
varrix / SampleCodeForCPsWithTransactions.java
Created September 20, 2017 01:55
If you want to use pooled connection in transaction, you should use it in this way. This sample code handles setting autocommit values. Source: https://stackoverflow.com/a/28719870
try (Connection conn = source.getConnection()) {
conn.setAutoCommit(false);
SQLException savedException = null;
try {
// Do things with connection in transaction here...
conn.commit();
} catch (SQLException ex) {
savedException = ex;
conn.rollback();
} finally {

down vote I contend that images (files) are NOT usually stored in a database base64 encoded. Instead, they are stored in their raw binary form in a binary (blob) column (or file).

Base64 is only used as a transport mechanism, not for storage. For example, you can embed a base64 encoded image into an XML document or an email message.

Base64 is also stream friendly. You can encode and decode on the fly (without knowing the total size of the data).

While base64 is fine for transport, do not store your images base64 encoded.

sudo docker logs 79494
Preparing to run Artifactory in Docker
=====================================
2017-06-20 21:31:26 [42 entrypoint-artifactory.sh] Checking open files and processes limits
2017-06-20 21:31:26 [45 entrypoint-artifactory.sh] Current max open files is 1048576
2017-06-20 21:31:26 [57 entrypoint-artifactory.sh] Current max open processes is unlimited
2017-06-20 21:31:26 [67 entrypoint-artifactory.sh] Checking if /var/opt/jfrog/artifactory is mounted
2017-06-20 21:31:26 [72 entrypoint-artifactory.sh] /var/opt/jfrog/artifactory is mounted
2017-06-20 21:31:26 [78 entrypoint-artifactory.sh] Setting up data directories if missing
Here are some guidelines for people who want to contribute their code
to this software.
(0) Decide what to base your work on.
In general, always base your work on the oldest branch that your
change is relevant to.
- A bugfix should be based on 'maint' in general. If the bug is not
present in 'maint', base it on 'master'. For a bug that's not yet