Skip to content

Instantly share code, notes, and snippets.

View DerekCrosson's full-sized avatar
💛
Blessed

Derek Crosson DerekCrosson

💛
Blessed
View GitHub Profile
@dmccuk
dmccuk / Ansible_Assert.txt
Last active December 2, 2024 19:28
Prove ansible did what is said it did!
-- Ansible testing using Assert
When we run Ansible to manage server configurations, we assume (if there is no red errors) that it worked. But if you are developing ansible modules for your systems, and want to take the DevOps approach and work on CICD pipelines, you need to have some tests in there to prove that what you asked ansible to do has actually worked.
One of the best ways to do this within ansible, is to use the Assert module. It asserts that a given expression is true. When you combine this with the output of a command that’s registered to a variable, there is almost no limit to what you can test.
I’m going to use the TDD (Test driven development) method where we create the tests before we start writing any ansible code to manage our systems. I expect the tests to fail. Then we’ll write ansible to pass the tests. That’s it.
This demo will cover the following:
• Create some tests using the command and assert modules.
@caendekerk
caendekerk / Gemfile
Created March 4, 2021 10:48
Rails API only with Okta but without Devise
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.0'
# Shorten boot time
gem 'bootsnap'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', github: 'rails/jbuilder'
[
{
"metadata": {
"id": "b689fcc8-d494-4dbf-a228-2c694a578afc",
"publisherId": "alefragnani.Bookmarks",
"publisherDisplayName": "alefragnani"
},
"name": "Bookmarks",
"publisher": "alefragnani",
@nazariyv
nazariyv / MyFlashLoan.sol
Created September 13, 2020 13:39
Full template of a contract that can flashloan from Aave. You also need to add your own logic in terms of what you want to do with the lent amounts in the executeOperation function
pragma solidity ^0.6.6;
import "https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/FlashLoanReceiverBase.sol";
import "https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/ILendingPoolAddressesProvider.sol";
import "https://github.com/aave/flashloan-box/blob/Remix/contracts/aave/ILendingPool.sol";
contract Flashloan is FlashLoanReceiverBase {
constructor(address _addressProvider) FlashLoanReceiverBase(_addressProvider) public {}
/**
@crazyoptimist
crazyoptimist / install-docker.sh
Last active April 30, 2024 20:33
Install the latest version of docker engine on Ubuntu machines
#!/bin/bash
# Uninstall all conflicting packages:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg --purge -y; done
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl -y
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
@tombruijn
tombruijn / README.md
Last active March 26, 2025 08:03
Retry until fail script

Until fail

Retry a command until it fails.

Debugging brittle specs is annoying and time consuming work. Let's automate finding those brittle specs by retrying them until they fail.

Accompanying blog post.

Usage

@rahularity
rahularity / work-with-multiple-github-accounts.md
Last active March 16, 2026 08:44
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@LukeMathWalker
LukeMathWalker / audit.yml
Last active March 14, 2026 09:18
GitHub Actions - Rust setup
name: Security audit
on:
schedule:
- cron: '0 0 * * *'
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
@ingeniousgenius
ingeniousgenius / README.md
Last active September 1, 2025 23:38
Rails API Social Login

Rails API-Only Social Login

This is another piece of code I've extrapolated from a Ruby on Rails project I'm currently working on. The code implmenets social login with a RoR API-based application, targeted at API clients.

The setup does not involve any browser-redirects or sessions as you would have to use working with Omniauth. Instead, what it does is takes an access_token generated on client-side SDKs, retireves user info from the access token and creates a new user and Identity in the database.

This setup works with native applications as described in the Google iOS Sign In Docs (see Authenticating with a backend server)

@Brandongoodman615
Brandongoodman615 / csv_creator.rb
Created December 6, 2019 15:53
Generating CSV files from an API data
# Run this file to auto generate a csv file based on the data passed in the products
# variable. I created this based on an API call that I parsed in the format of an array
# of hashes like the example in order to quickly generate a csv file for uploading.
require "csv"
products = [{"sku"=>"sku001", "name"=>"Item 1", "dimensions"=>"1 x 1 x 1"},
{"sku"=>"sku002", "name"=>"Item 2", "dimensions"=>"2 x 2 x 2"},
{"sku"=>"sku003", "name"=>"Item 3", "dimensions"=>"3 x 3 x 3"},
{"sku"=>"sku004", "name"=>"Item 4", "dimensions"=>"4 x 4 x 4"}]