Skip to content

Instantly share code, notes, and snippets.

@aghyad
aghyad / installing_passenger_nginx_ror_on_ubuntu_without_rvm_rbenv
Last active March 19, 2018 10:42
A quick tutorial on installing passenger, Nginx, Ruby and Rails on Ubuntu 12.04 (without RVM/without rbenv)
When installing passenger, Nginx, Ruby and Rails on Ubuntu 12.04 (without RVM/without rbenv):
First: installing Ruby (without RVM):
sudo apt-get update
sudo apt-get install ruby1.9.1 ruby1.9.1-dev \
rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \
build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev
@yomybaby
yomybaby / mongodb-s3-backup.sh
Last active July 16, 2019 15:15 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS) (using bitnami image)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
FROM alpine:3.4
##################### Base dependencies #################################
RUN apk --no-cache add ruby ruby-irb ruby-json git ruby-bigdecimal ruby-rake \
ruby-io-console ruby-bundler libstdc++ tzdata postgresql-client nodejs \
libxml2 libxslt libgcrypt sqlite-libs pcre curl postgresql bash procps openssh \
&& cp /usr/bin/pg_dump /usr/bin/pg_restore /tmp/ \
&& apk del --purge postgresql \
&& mv /tmp/pg_dump /tmp/pg_restore /usr/bin/ \
&& echo "gem: --no-document" > /etc/gemrc
@mariodian
mariodian / bitcoind.service
Created July 6, 2016 06:17
Bitcoind Systemd script
[Unit]
Description=Bitcoin's distributed currency daemon
After=network.target
[Service]
User=pi
Group=pi
Type=forking
PIDFile=/var/lib/bitcoind/bitcoind.pid
@kzaitsev
kzaitsev / carrierwave.rb
Created January 15, 2014 19:44
Carrierwave + Selectel
CarrierWave.configure do |config|
if Rails.env.development? || Rails.env.test?
config.storage = :file
else
config.storage = :fog
config.fog_credentials = {
:provider => 'OpenStack',
:openstack_auth_url => 'https://auth.selcdn.ru/v1.0',
:openstack_username => Rails.application.secrets.openstack_username,
:openstack_api_key => Rails.application.secrets.openstack_api_key
@nmnp
nmnp / composer-config.md
Last active March 8, 2022 11:08
Could not authenticate against github.com composer error

Could not authenticate against github.com

This could be related to GitHub rate limits being reached. Specify your GitHub API token to avoid it.

For example by the following command:

composer config --global github-oauth.github.com <TOKEN> or inside your composer.json file:

@seyhunak
seyhunak / devise_helper.rb
Created September 16, 2013 10:50
Devise Error Messages Twitter Bootstrap style
# /app/helpers/devise_helper.rb
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t('errors.messages.not_saved',
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)

CloudFormation snippet to create a VPC to be used for lambda functions. Qualities of the VPC:

  • 4 subnets: 2 public, 2 private (lambda functions should be attached to the private ones).
  • 2 Elastic IPs that can be used to identify traffic coming from lambda functions (e.g. for firewall holes).
  • Security group that can be used for lambda functions.

Notes:

  • uses regions us-east-1a, us-east-1b
  • uses ip block of 10.15.0.0/16 for VPC
@mayorova
mayorova / README.md
Created August 10, 2017 14:44
Mutual SSL in NGINX

Securing traffic to upstream servers with client certificates

Info: https://www.nginx.com/resources/admin-guide/nginx-https-upstreams/

Creating and Signing Your Certs

Source: http://nategood.com/client-side-certificate-authentication-in-ngi

This is SSL, so you'll need an cert-key pair for you/the server, the api users/the client and a CA pair. You will be the CA in this case (usually a role played by VeriSign, thawte, GoDaddy, etc.), signing your client's certs. There are plenty of tutorials out there on creating and signing certificates, so I'll leave the details on this to someone else and just quickly show a sample here to give a complete tutorial. NOTE: This is just a quick sample of creating certs and not intended for production.

@sethryder
sethryder / blackbox.yml
Last active April 17, 2023 06:49
monitor multiple blackbox modules with a single job
modules:
https_2xx:
prober: http
timeout: 5s
http:
method: GET
no_follow_redirects: false
fail_if_ssl: false
fail_if_not_ssl: true
preferred_ip_protocol: "ipv4"