Skip to content

Instantly share code, notes, and snippets.

Avatar
🐙
Being Inkcellent to Each Other

Ken Collins metaskills

🐙
Being Inkcellent to Each Other
View GitHub Profile
@metaskills
metaskills / gist:893599
Created Mar 29, 2011
A Copy Of sp_MSforeachtable Stored Procedure For Azure, Uses sp_MSforeach_worker
View gist:893599
CREATE proc [dbo].[sp_MSforeachtable]
@command1 nvarchar(2000), @replacechar nchar(1) = N'?', @command2 nvarchar(2000) = null,
@command3 nvarchar(2000) = null, @whereand nvarchar(2000) = null,
@precommand nvarchar(2000) = null, @postcommand nvarchar(2000) = null
AS
declare @mscat nvarchar(12)
select @mscat = ltrim(str(convert(int, 0x0002)))
if (@precommand is not null)
exec(@precommand)
View omniauth.rb
metadata = Rails.root.join 'config', 'myapp_ins-8d2c1e14da9ca2bc.xml'
idpdata = File.read(metadata)
parser = OneLogin::RubySaml::IdpMetadataParser.new
SAML_SETTINGS = parser.parse_to_hash(idpdata)
Rails.application.config.middleware.use OmniAuth::Builder do
provider :saml, SAML_SETTINGS.merge(
issuer: 'myapp'
)
end
View pconcurrency.sh
# Setup
aws application-autoscaling \
register-scalable-target \
--service-namespace "lambda" \
--resource-id "function:myapp:live" \
--min-capacity 5 \
--max-capacity 100 \
--scalable-dimension "lambda:function:ProvisionedConcurrency"
@metaskills
metaskills / wait_until.rb
Last active Oct 21, 2020
Never sleep() using Capybara!
View wait_until.rb
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@metaskills
metaskills / gist:6414713
Created Sep 2, 2013
Jekyll tasks/post to help create a new post.
View gist:6414713
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Usage: provide a title argument."
exit -1
else
title="$@"
fi
d=$(date +"%Y-%m-%d")
@metaskills
metaskills / capysetup.rb
Created Sep 28, 2020
Rails Capybara System Tests Setup
View capysetup.rb
# Gemfile
gem 'selenium-webdriver'
# test/application_system_test_case.rb (or capy setup file)
require 'test_helper'
Capybara.server = :webrick
Webdrivers::Chromedriver.required_version = '2.36'
driver_path = Webdrivers::Chromedriver.update
@metaskills
metaskills / command.sh
Last active Aug 3, 2020
Ubuntu 16.04 Install Latest FreeTDS
View command.sh
$ sudo apt-get install wget
$ sudo apt-get install build-essential
$ sudo apt-get install libc6-dev
$ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.27.tar.gz
$ tar -xzf freetds-1.00.27.tar.gz
$ cd freetds-1.00.27
$ ./configure --prefix=/usr/local --with-tdsver=7.3
$ make
$ make install
@metaskills
metaskills / layer_downloader.rb
Created Jul 25, 2020
Useful for Ruby/Docker SAM Projects
View layer_downloader.rb
require 'yaml'
require 'open-uri'
require 'aws-sdk-lambda'
class LayerDownloader
def download
File.open(zip_file, 'wb') do |f|
URI.open(location) { |zip| f.write(zip.read) }
end
@metaskills
metaskills / event.json
Created Jun 16, 2020
Sample API Gateway HTTP API Version 1 Event
View event.json
{
"version": "1.0",
"resource": "$default",
"path": "/",
"httpMethod": "GET",
"headers": {
"Content-Length": "0",
"Host": "myawesomelambda.example.com",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15",
"X-Amzn-Trace-Id": "Root=1-5e7fe714-fee6909429159440eb352c40",
@metaskills
metaskills / aurora-stack.ts
Last active Jun 7, 2020
Aurora Serverless IaC Example Using CDK & TypeScript
View aurora-stack.ts
// Run `mkdir aurora && cd aurora && cdk init sample-app --language=typescript`
// and replace the `lib/aurora-stack.ts` with this file. May need to remove non-needed
// packages from package.json and add others like "@aws-cdk/aws-rds" and
// "@aws-cdk/aws-secretsmanager"
//
// Running assumes you pass in the following environment variables or hard code values.
//
// * ASCLUSTER_MASTER_USER
// * ASCLUSTER_MASTER_PASS
// * SUBNET_GROUP_NAME
You can’t perform that action at this time.