Skip to content

Instantly share code, notes, and snippets.

View foo4u's full-sized avatar

Scott Rossillo foo4u

View GitHub Profile
@foo4u
foo4u / update.js
Created August 26, 2013 23:45
Editing each element in a MongoDB collection returned by find() using an integer to assign a unique value to a string field.
var foo = 0;
db.collection.find().forEach( function(doc) { doc.slug = (++foo).toString(); db.collection.save(doc); } )
@foo4u
foo4u / mmsagent.service
Last active December 24, 2015 19:09
MongoDB Monitoring Agent systemd service
[Unit]
Description=MongoDB Monitoring Agent
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart=/usr/bin/python /var/lib/mmsagent/mms-agent/agent.py
Restart=always
User=mmsagent
@foo4u
foo4u / headers.sh
Created October 14, 2013 17:40
Simple bash function using wget to print out headers (just add to .bashrc)
function headers {
wget -O /dev/null -S -q $1
}
@foo4u
foo4u / Partitioner.java
Created April 14, 2014 22:20
Provides a solution to the "Minimum Cuts for Palindrome Partitioning" problem http://basicalgos.blogspot.com/2013/03/67-palindrome-partitioning.html
/**
* Provides methods to determine minimum the number of cuts
* required to split a string into palindromes.
*
* @author Scott Rossillo
*/
public final class Partitioner {
/**
@foo4u
foo4u / Wildfly.xml
Last active March 11, 2016 14:10
Wildfly Code Style for IntelliJ
<code_scheme name="Wildfly">
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value>
<package name="org.junit.Assert" withSubpackages="false" static="true" />
<package name="org.rendersnake.HtmlAttributesFactory" withSubpackages="false" static="false" />
<package name="org.mockito.Mockito" withSubpackages="true" static="true" />
@foo4u
foo4u / 30_docker_ports.config
Last active July 6, 2023 00:45
Infinispan on Amazon AWS Beanstalk (should work with vanilla EC2 and ECS)
files:
/opt/elasticbeanstalk/hooks/appdeploy/post/10_docker_nat.sh:
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
set -u # Fail on unset variables
set -e # Fail if any command fails
PATH="$PATH:/sbin:/usr/bin"
public int countClumps(int[] nums) {
int clumps = 0;
int last = -1;
int run = 0;
for(int i = 0; i< nums.length; i++) {
if (last == nums[i]) {
if(run < 1) {
clumps++;
}
run++;
@foo4u
foo4u / docker-install.sh
Last active January 8, 2020 18:32
Building Multi-Architecture Docker Images on ARM 64
#!/bin/bash
# Install Docker and mult-arch dependencies
sudo apt-get install binfmt-support qemu-user-static
sudo apt-get install docker.io
sudo usermod -aG docker $USER
sudo reboot
@foo4u
foo4u / buildx-install.sh
Last active July 6, 2022 23:37
Building Multi-Architecture Docker Images on ARM 64
#!/bin/bash
# Install buildx for arm64 and enable the Docker CLI plugin
sudo apt-get install jq
mkdir -p ~/.docker/cli-plugins
BUILDX_URL=$(curl https://api.github.com/repos/docker/buildx/releases/latest | jq -r '.assets[].browser_download_url' | grep arm64)
wget $BUILDX_URL -O ~/.docker/cli-plugins/docker-buildx
chmod +x ~/.docker/cli-plugins/docker-buildx
@foo4u
foo4u / create-builder.out
Created January 8, 2020 19:08
Building Multi-Architecture Docker Images on ARM 64
$ docker buildx create --name mbuilder
mbuilder
$ docker buildx use mbuilder
$ docker buildx inspect --bootstrap
Name: mbuilder
Driver: docker-container
Nodes: