Skip to content

Instantly share code, notes, and snippets.

View gist:068a4aed3c502667c9c09727e7cbf0fa
### 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:
View ClassCreator.rb
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
View postgres.auto.sh
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;
View redis.auto.sh
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 Jul 21, 2019 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
View gcrgc.sh
#!/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
Ubuntu18 / Ruby 2.6.1 / Nginx Lua Auto SSL
View gist:87ead45d11f2ba9c076531391930cc41
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 Apr 19, 2019
Basic graphql ruby implementation, using Query, Input, Resolvers, Types and Mutations
View app-graphql-ruby.rb
require 'graphql'
require 'awesome_print'
#########
# TYPES #
#########
module Types
class BaseObject < GraphQL::Schema::Object
end
View Scaleway deployment docker
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 \
@benbonnet
benbonnet / kubernetes.sh
Last active Mar 19, 2019
kubernetes on Ubuntu 18.10
View kubernetes.sh
# Source : https://mherman.org/blog/setting-up-a-kubernetes-cluster-on-ubuntu/
# on all nodes
sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update && sudo apt install -qy docker-ce
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update && sudo apt-get install -y kubeadm kubelet kubectl
View signin.js
const signin = `
input SigninInput {
email: String!
token: String!
refreshtoken: String!
firstname: String!
lastname: String!
}
mutation Authenticate($signin: SigninInput!) {
authenticate(input: $signin) {