Skip to content

Instantly share code, notes, and snippets.

View basebandit's full-sized avatar
🏠
Working from home

basebandit

🏠
Working from home
View GitHub Profile
@basebandit
basebandit / nexus-provision.groovy
Created June 16, 2023 18:59 — forked from rgl/nexus-provision.groovy
provision nexus users that can push or deploy to any repository (e.g. NuGet or Maven)
// see https://books.sonatype.com/nexus-book/3.0/reference/scripting.html
// see https://github.com/sonatype/nexus-book-examples/tree/nexus-3.0.x/scripting/nexus-script-example
import groovy.json.JsonOutput
import org.sonatype.nexus.security.user.UserSearchCriteria
import org.sonatype.nexus.security.authc.apikey.ApiKeyStore
import org.sonatype.nexus.security.realm.RealmManager
import org.apache.shiro.subject.SimplePrincipalCollection
import org.sonatype.nexus.scheduling.TaskScheduler
import org.sonatype.nexus.scheduling.schedule.Daily

Keybase proof

I hereby claim:

  • I am basebandit on github.
  • I am basebandit (https://keybase.io/basebandit) on keybase.
  • I have a public key ASDrUrKlUQsdqAZyeVUWL7LdYiZztvXa4GUd2v6pqC6k1Qo

To claim this, I am signing this object:

#!/bin/bash
function delete_container() {
if ! which "lxc" >/dev/null 2>&1; then
echo "lxc is not installed"
fi
OUT=$(lxc list -c n --format=json | jq 'length')
if [ "$OUT" -lt 1 ]; then
echo "No containers found"
fi
OUT=$(lxc stop --all 2>&1)
@basebandit
basebandit / Dockerfile
Last active July 8, 2020 18:46
How to wait on another container using docker-compose
# Start from the latest golang base image
FROM golang:1.14-alpine as builder
# Add Maintainer Info
LABEL maintainer="The Basebandit <@the_basebandit>"
# Set the Current Working Directory inside the container
WORKDIR /backend
# Copy everything from the current directory to the Working Directory inside the container
@basebandit
basebandit / copy.go
Created July 30, 2019 07:58
Copy copies file contents from source to destination. If the file already exists it's content will be replaced by the contents of the source file
// copyFile copies a file from src to dst. If src and dst files exist, and are
// the same, then return success. Otherise, copy the file contents from src to dst.
func copyFile(src, dst string) (err error) {
sfi, err := os.Stat(src)
if err != nil {
return
}
if !sfi.Mode().IsRegular() {
// cannot copy non-regular files (e.g., directories,
// symlinks, devices, etc.)
@basebandit
basebandit / primes.go
Last active July 15, 2019 16:05
Get all integer prime numbers from 0 to 100
package main
import (
"fmt"
"math"
)
func main() {
for i := 0; i < 100; i++ {
if isPrime(i) {
@basebandit
basebandit / bcrypt-promise.js
Created October 11, 2018 08:03 — forked from dmh2000/bcrypt-promise.js
Using bcrypt with promises to hash a password and then verify it
let bcrypt = require('bcrypt-nodejs');
let password = "hello";
let stored_hash = "";
// first generate a random salt
function genSalt(password) {
return new Promise((resolve,reject) => {
bcrypt.genSalt(10,function(err,salt) {
if (err) {
@basebandit
basebandit / utils.js
Created August 9, 2018 08:34 — forked from dc198689/utils.js
build/utils.js
exports.cssLoaders = function(options) {
...
...
function resolveResouce(fileName) {
// Absolute Path
return path.resolve(__dirname, '../src/assets/scss/' + fileName)
}
function generateSassResourceLoader() {
var loaders = [
@basebandit
basebandit / after_res_hooks.js
Created July 5, 2018 07:40 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups