Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / gist:938183
Created April 23, 2011 02:28
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
@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)
@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
@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
@Tristor
Tristor / iptables.sh
Last active December 22, 2023 20:19
Simple IPtables script for an OpenVPN server
#!/bin/bash
# Flushing all rules
iptables -F FORWARD
iptables -F INPUT
iptables -F OUTPUT
iptables -X
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

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
@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
@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
@egorsmkv
egorsmkv / metrials-go.md
Last active April 20, 2024 12:43
Материалы по Go (golang): мануалы, статьи, книги и ссылки на сообщества

Материалы по Go (golang)

На русском языке

Мануалы и туториалы

  • [Введение в программирование на Go][1]
  • [Маленькая книга о Go][3]
  • [Эффективный Go][2]
  • Есть еще [Краткий пересказ Effective Go на русском языке][4], но 2009 года
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