Skip to content

Instantly share code, notes, and snippets.

@harssh
harssh / vscode-tunnel-daemon-oracle-cloud.md
Created April 29, 2025 13:20 — forked from nonkronk/vscode-tunnel-daemon-oracle-cloud.md
Setup an Always-on VSCode Tunnel on Ubuntu Server

Setup an Always-on VSCode Tunnel on Oracle Cloud Always-free Instance

Access Oracle Cloud VM from any browser on any devices

Install VSCode for arm64

wget -O vscode.deb https://code.visualstudio.com/sha/download\?build\=stable\&os\=linux-deb-arm64 && sudo apt install ./vscode.deb --fix-broken -y && rm vscode.deb
@harssh
harssh / vscode-tunnel-daemon-oracle-cloud.md
Created April 29, 2025 13:20 — forked from nonkronk/vscode-tunnel-daemon-oracle-cloud.md
Setup an Always-on VSCode Tunnel on Ubuntu Server

Setup an Always-on VSCode Tunnel on Oracle Cloud Always-free Instance

Access Oracle Cloud VM from any browser on any devices

Install VSCode for arm64

wget -O vscode.deb https://code.visualstudio.com/sha/download\?build\=stable\&os\=linux-deb-arm64 && sudo apt install ./vscode.deb --fix-broken -y && rm vscode.deb
@harssh
harssh / rvm_ruby.sh
Created June 27, 2024 15:54
Install ruby on Ubuntu
#https://deanpcmad.com/2024/installing-older-ruby-versions-on-ubuntu-24-04-and-22-04/
rvm get head
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
tar zxvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --prefix=$HOME/.openssl/openssl-1.1.1g --openssldir=$HOME/.openssl/openssl-1.1.1g

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:"[email protected]"
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
@harssh
harssh / warning.rb
Created February 28, 2024 20:40
warning.rb
# Define a "warnings" validation bucket on ActiveRecord objects.
#
# @example
#
# class MyObject < ActiveRecord::Base
# warning do |vehicle_asset|
# unless vehicle_asset.description == 'bob'
# vehicle_asset.warnings.add(:description, "should be 'bob'")
# end
# end
# 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