Skip to content

Instantly share code, notes, and snippets.

@steve-jansen
steve-jansen / main.sh
Created February 14, 2017 21:24
Bulk invite Slack users to a channel
for u in $(jq --raw-output ". | .[]" < members.json); do
clear;
echo Inviting user ${u};
curl -i -X GET "https://slack.com/api/channels.invite?token=${API_TOKEN}&channel=${CHANNEL}&user=${u}" | head -n 20;
sleep 1;
done;
@steve-jansen
steve-jansen / git-diff-add
Last active September 19, 2018 21:37
A custom script for git to interactively run "git difftool" against each modified and untracked file, then prompt to stage (add) the change, undo (checkout) the change, or ignore (skip) the change.
#!/bin/bash
# query the root of the repo because git status prints
# relative paths within the repo
if ! pushd "`git rev-parse --show-toplevel`" >/dev/null
then
echo "git rev-parse --show-toplevel failed to return the root dir of the repo"
exit 1
else
gitroot=`pwd`
@steve-jansen
steve-jansen / demo.sh
Created November 18, 2016 20:13
Parse Terraform state file for AWS security group rules
jq '.modules[].resources | to_entries[] | select(.value.type == "aws_security_group_rule" or .value.type == "aws_security_group")' test.json

Keybase proof

I hereby claim:

  • I am steve-jansen on github.
  • I am stevejansen (https://keybase.io/stevejansen) on keybase.
  • I have a public key ASA_OhoiYVixB58rBEiRJl_9CcBjl0xT2QsAbM-ponCvsAo

To claim this, I am signing this object:

@steve-jansen
steve-jansen / WINFILETIME.sh
Created September 28, 2016 15:56
Convert a Windows FILETIME value to a localized date string
# 131194047065676512 is an example FILETIME value
ruby -e 'puts Time.at((Integer(ARGV[0]) - 116444736000000000) / 10000000)' -- 131194047065676512
@steve-jansen
steve-jansen / bookmarklet.js
Last active August 19, 2016 23:15
Bookmarklet to create a terraform.tfvars file from an Atlas Terraform environment variables page
javascript:var s='';for(i=0;;i++){k=document.forms[0]["runtime_configuration[tf_vars_attributes]["+i+"][key]"];v=document.forms[0]["runtime_configuration[tf_vars_attributes]["+i+"][value]"]; if(k && v){s+=[k.value,'=',v.value,'\n'].join('');}else{break};};window.location="data:text/plain;base64,"+btoa(s);
@steve-jansen
steve-jansen / ResourceInterceptor.cs
Last active December 30, 2015 15:28
A custom implementation of the `Awesomium.Windows.Forms.ResourceDataSourceProvider` functionality. This interceptor supports using the standard `http://` protocol scheme instead of Awesomium's use of the custom `asset://` scheme, which can cause problems with cross origin requests in Chromium, as well as third party services like Google APIs whi…
using System;
using System.IO;
using System.Reflection;
using Awesomium.Core;
namespace MyApp
{
/// <summary>
/// A custom implementation of the `Awesomium.Windows.Forms.ResourceDataSourceProvider` functionality.
/// This interceptor supports using the standard `http://` protocol scheme instead of Awesomium's use of the
@steve-jansen
steve-jansen / Global.asax
Created August 14, 2013 19:32
Preventing IIS Integrated Windows Authentication from prompting authenticated users for a new username/password when permission to a URL is denied.
<Script language="C#" runat="server">
void Application_EndRequest() {
// rewrite HTTP 401s to HTTP 403s if the user is authenticated using
// integrated Windows auth with impersonation, but,
// the user lacks permissions to the requested URL
if (Context.User != null &&
Context.User.Identity != null &&
Context.User.Identity.IsAuthenticated &&
Context.User is System.Security.Principal.WindowsPrincipal &&
Context.Response.StatusCode == 401)
@steve-jansen
steve-jansen / yeoman.cmd
Created June 24, 2013 02:46
A script to run yeoman on Windows with dependencies managed in source tree. This script assumes that Ruby, NodeJS, and PhantomJS are under source control, while the yeoman and grunt node modules can be downloaded via npm.
:: Name: yeoman.cmd
:: Purpose: Convenience script to run yeoman on windows
:: Author: Steve Jansen
:: Revision: January 2013
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET /A ERR=0
PUSHD %~dps0\.. > NUL
@steve-jansen
steve-jansen / TestData.cmd
Created June 24, 2013 02:44
A helpful way to import or export data from SQL Server to bcp.exe binary flat files. This can be helpful for storing relatively small sets of test data in source control, dropbox, etc for multiple environments.
:: Name: TestData.cmd
:: Purpose: Convenience script to use SQL Server bcp.exe to import or export
:: sample data as binary files in ~/src/Database/TestData
:: Author: Steve Jansen
:: Revision: December 2012
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
:: default values