Skip to content

Instantly share code, notes, and snippets.

View andycopley's full-sized avatar

Andy Copley andycopley

View GitHub Profile
@jlouros
jlouros / aws.upload-folder-to-s3.js
Last active September 8, 2023 22:48
Upload folder to S3 (Node.JS)
const AWS = require("aws-sdk"); // from AWS SDK
const fs = require("fs"); // from node.js
const path = require("path"); // from node.js
// configuration
const config = {
s3BucketName: 'your.s3.bucket.name',
folderPath: '../dist' // path relative script's location
};
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@orendon
orendon / vagrant_rails_provisioner.sh
Created May 14, 2014 10:43
basic vagrant shell provisioner for Rails apps https://github.com/orendon/vagrant-rails
#!/bin/sh
# A Ubuntu 14.04 install aimed for Ruby on Rails development
# This box start with a basic Ubuntu 14.04 (trusty) based on phusion/ubuntu-14.04-amd64
# And it adds the following packages aimed for rails development
# - rbenv and ruby-build
# - ruby 2.1.2 with bundler
# - Git 1.9.1
@hvasconcelos
hvasconcelos / gen_keys.sh
Last active September 19, 2023 23:14
Create an Sinatra SSL Server
# Generate a self-signed Certificate and a Private Key
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout pkey.pem -out cert.crt
@jtomaszewski
jtomaszewski / god.cap.rb
Last active March 7, 2022 01:21
God tasks for Capistrano v3
# Thanks to http://makandracards.com/makandra/1431-resque-+-god-+-capistrano for an idea and v2 version.
namespace :god do
def god_is_running
capture(:bundle, "exec god status > /dev/null 2>&1 || echo 'god not running'") != 'god not running'
end
# Must be executed within SSHKit context
def config_file
"#{release_path}/config/god.rb"
@thoop
thoop / .htaccess
Last active January 27, 2024 14:07
Official prerender.io .htaccess for Apache.
# Change YOUR_TOKEN to your prerender token
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@romansklenar
romansklenar / REAME.md
Last active May 31, 2024 18:30
How to set up your VPS with Chef Solo

How to set up your VPS with Chef Solo

1. What is it?

There are many different provisioning tools out there, the most popular of which are Chef and Puppet. Chef uses Ruby, Puppet uses a DSL (Domain Specific Language), there are others that use simple bash too, but today we're going to focus on Chef Solo.

2. Dependencies

To get Chef working properly on your local machine you need a few things.

Make sure you use Ruby 1.9.x and not Ruby 2.x as you will get errors with the json 1.6.1 gem on 2.x. Use rbenv or RVM to manage several different Rubies on the one machine.

@dhrrgn
dhrrgn / core.py
Last active March 2, 2022 04:16
Tired of doing db.session.add and db.session.commit to save your records? Have no fear, save is here. Note: This is for use with Flask-SQLAlchemy
from .user import User
def init_db(db):
"""Add a save() function to db.Model"""
def save(model):
db.session.add(model)
db.session.commit()
db.Model.save = save
@carolineschnapp
carolineschnapp / gist:5397337
Last active January 20, 2023 10:11
Sample JavaScript file added with ScriptTag resource. This sample file is meant to teach best practices. Your app will load jQuery if it's not defined. Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
/* Sample JavaScript file added with ScriptTag resource.
This sample file is meant to teach best practices.
Your app will load jQuery if it's not defined.
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
Your app does not change the definition of $ or jQuery outside the app.
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2'
once the app is installed, even if the app uses jQuery 1.9.1:
jQuery.fn.jquery => "1.4.2"
$.fn.jquery -> "1.4.2"
*/
@joost
joost / ruby_google_analytics_server_to_server.md
Last active November 27, 2023 15:43
Google Analytics API (server-to-server) using Ruby