Skip to content

Instantly share code, notes, and snippets.

Increasing LVM Disk Space (Ubuntu)

Increase live Ubuntu server disk space (requires LVM) without any downtime.

All of the commands below need to be executed as root user.

  1. Create a new partition using unallocated space.

    First we'll need to determine exactly which disk was added or had its size increased.

Feature: Facebook Connect
Scenario: Sign in with Facebook
When I go to the sign in page
And I press "Sign in with Facebook"
And Facebook returns uid:"123", nickname:"chunky.bacon", first_name:"Chunky", last_name:"Bacon", email:"bacon@mysite.co.nz"
Then I should see "Your mysite account was successfully created"
...
gem 'devise',
:git => 'https://github.com/plataformatec/devise.git',
:branch => 'omniauth'
gem 'oa-oauth', :require => 'omniauth/oauth'
...
@harssh
harssh / omniauth_macros.rb
Created May 16, 2024 21:30 — forked from kinopyo/omniauth_macros.rb
Integration test with Omniauth. This example is using twitter, and assume you've installed rspec and capybara. Official document is here: https://github.com/intridea/omniauth/wiki/Integration-Testing
# in spec/support/omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:twitter] = {
'provider' => 'twitter',
'uid' => '123545',
'user_info' => {
'name' => 'mockuser',
module Devise
module Models
# Registerable is responsible for everything related to registering a new
# resource (ie user sign up).
module Registerable
extend ActiveSupport::Concern
module ClassMethods
# A convenience method that receives both parameters and session to
# initialize a user. This can be used by OAuth, for example, to send
# requires :password_reset_token and :password_reset_token_expires_at fields
module PasswordResetable
extend ActiveSupport::Concern
included do
before_validation do
if password_reset_token_expires_at && password_reset_expires_at.past?
expire_password_reset!
end
end
@harssh
harssh / README.md
Created September 26, 2023 02:58 — forked from noelbundick/README.md
Optimizing Rust container builds

Optimizing Rust container builds

I'm a Rust newbie, and one of the things that I've found frustrating is that the default docker build experience is extremely slow. As it downloads crates, then dependencies, then finally my app - I often get distracted, start doing something else, then come back several minutes later and forget what I was doing

Recently, I had the idea to make it a little better by combining multistage builds with some of the amazing features from BuildKit. Specifically, cache mounts, which let a build container cache directories for compilers & package managers. Here's a quick annotated before & after from a real app I encountered.

Before

This is a standard enough multistage Dockerfile. Nothing seemingly terrible or great here - just a normal build stage, and a smaller runtime stage.

@harssh
harssh / ractors.rb
Created August 26, 2023 19:54 — forked from Kukunin/ractors.rb
Ruby Ractors vs Threads benchmark
require 'benchmark'
require 'etc'
Ractor.new { :warmup } if defined?(Ractor)
def fibonacci(n)
return n if (0..1).include? n
fibonacci(n - 1) + fibonacci(n - 2)
end
@harssh
harssh / iam_fog.rb
Created August 17, 2023 18:40 — forked from zapnap/iam_fog.rb
Using Amazon IAM with Fog (example)
require 'fog'
username = 'testuser'
bucket = 'uniquebucketname1234'
aws_credentials = {
:aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
:aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY'
}
@harssh
harssh / aws.rb
Created August 17, 2023 18:11 — forked from peterwells/aws.rb
This Gist shows how I was able to implement AWS assume role functionality within my application using the Ruby AWS SDK, Fog, and Carrierwave. Currently Fog has no concept of one role assuming another. They do, however, have an existing mechanism for re-negotiating soon-to-expire credentials. By monkey-patching this function, we can leverage the …
#resides in app/models/connectors/
class Connectors::Aws
attr_reader :aws_access_key_id, :aws_secret_access_key, :aws_security_token, :expires_at
def initialize
if ENV.has_key?('AWS_SECURITY_TOKEN') #localhost
@aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
@aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
@aws_security_token = ENV['AWS_SECURITY_TOKEN']
@expires_at = Time.now + 10.hours