Skip to content

Instantly share code, notes, and snippets.

const controllers = import.meta.glob('../../components/**/index.(js|jsx)', {
eager: true
});
Object.keys(controllers).forEach(path => {
const mod = controllers[path].default;
if (mod) {
const splittedPath = path.split('/');
const identifier = splittedPath[splittedPath.length - 2];
app.register(identifier, controllers[path].default);
@benbonnet
benbonnet / nginx_source_pagespeed_passenger_ubuntu.md
Last active March 9, 2021 16:39
nginx from source with pagespeed and passenger on ubuntu 16.04 and above
sudo apt-get -y update
sudo apt-get install -y build-essential libcurl4-openssl-dev unzip software-properties-common git libpcre3-dev libpcre3

adding zlib, openssl and pcre

cd && mkdir sources && cd sources
wget https://downloads.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz && tar xzvf pcre-8.41.tar.gz
### Keybase proof
I hereby claim:
* I am benbonnet on github.
* I am deemx (https://keybase.io/deemx) on keybase.
* I have a public key ASB17ro6GMH93r9zzIH9RYSsdZLgb0UplwE2VT2z334Iywo
To claim this, I am signing this object:
ACTIONS = %i[index get create update]
class BaseClass; end
class ObjectEngine
attr_reader :item, :schema
def initialize(item)
@item = item
# @schema = item.application.schema
end
function createPgInstance() {
export BASE_PATH=$HOME/postgres-storage;
export INSTANCES_COUNT=$(find $BASE_PATH -maxdepth 1 -type d | wc -w);
export PORT=$1
export PG_USERNAME=$2
export PG_PASSWORD=$3
export DBNAME=postgres$PORT
export INSTALLFOLDER=$BASE_PATH/$DBNAME/data;
export LOG_FOLDER=$BASE_PATH/$DBNAME/$DBNAME.log;
export SYSTEMDFILE=/etc/systemd/system/$DBNAME.service;
function createRedisInstance() {
export BASE_PATH=$HOME/redis-storage;
export INSTANCES_COUNT=$(sudo find $BASE_PATH -maxdepth 1 -type d | wc -w);
export PORT=$1
export REDIS_PASSWORD=$2
export DBNAME=redis$PORT;
export INSTALLFOLDER=$BASE_PATH/$DBNAME;
export CONFIGFILE=$INSTALLFOLDER/redis.conf;
export SYSTEMDFILE=/etc/systemd/system/$DBNAME.service;
export PIDFILE=$INSTALLFOLDER/redis.pid;
@benbonnet
benbonnet / gcrgc.sh
Created July 21, 2019 02:07 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@benbonnet
benbonnet / gist:87ead45d11f2ba9c076531391930cc41
Last active May 20, 2019 10:04
Ubuntu18 / Ruby 2.6.1 / Nginx Lua Auto SSL
upstream railsapp {
server unix:///path/to/app/shared/tmp/sockets/puma.sock;
}
location / {
proxy_pass http://railsapp;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
@benbonnet
benbonnet / app-graphql-ruby.rb
Last active April 19, 2019 12:08
Basic graphql ruby implementation, using Query, Input, Resolvers, Types and Mutations
require 'graphql'
require 'awesome_print'
#########
# TYPES #
#########
module Types
class BaseObject < GraphQL::Schema::Object
end
export DOMAIN=docker-metal.ngx.host
export APP_ADDRESS=localhost:8080
docker run -d \
--name nginx-auto-ssl \
--restart on-failure \
--network host \
-e ALLOWED_DOMAINS="$DOMAIN" \
-e SITES="$DOMAIN=$APP_ADDRESS" \
-v ssl-data:/etc/resty-auto-ssl \