Skip to content

Instantly share code, notes, and snippets.

@gmanfunky
gmanfunky / dump_flake
Last active February 10, 2018 01:35
dumb flaker
#!/bin/bash
if [ ! -d .venv ]; then
python3 -m virtualenv .venv
source .venv/bin/activate
pip install flake8
else
source .venv/bin/activate
fi
CMD="flake8 --exclude .venv,.git,__pycache__ | tee flake_out.txt"
@gmanfunky
gmanfunky / gist:7b9368a2c2b58a70adfb2302a5742cf6
Created February 7, 2018 17:34
Python unit test - Mocking out a decorator that has a parameter
# Great answer by Danila Ganchar at https://stackoverflow.com/questions/47900727/mock-authentication-decorator-in-unittesting
# mock out check_auth decorator
from functools import wraps
from unittest.mock import patch
def mock_decorator(*args):
def decorator(f):
@gmanfunky
gmanfunky / install
Created January 26, 2018 23:02
aws inspector install script - robust BASH
#!/bin/bash
#By installing the Amazon Inspector Agent, you agree that your use is
# subject to the terms of your existing AWS Customer Agreement or other
# agreement with Amazon Web Services, Inc. or its affiliates governing your
# use of AWS services. You may not install and use the
# Amazon Inspector Agent unless you have an account in good standing with AWS.
# Copyright 2016 Amazon Web Services, Inc. or its affiliates. All Rights Reserved.
# Licensed under the terms of your existing AWS Customer Agreement
@gmanfunky
gmanfunky / Makefile
Last active September 22, 2017 01:21
Windows compatible python Makefile virtualenv venv
# If on windows, you may need to download some custom python wheels for libxml and xmlsec
APP_VENV_PATH ?= ../python-venv
ifeq ($(OS),Windows_NT)
VENV_PATH_BIN := $(addsuffix /Scripts,$(APP_VENV_PATH))
else
VENV_PATH_BIN := $(addsuffix /bin,$(APP_VENV_PATH))
endif
default: install-dev
@gmanfunky
gmanfunky / findbugs-exclude-filter.xml
Created August 26, 2015 20:43
A maven profile section to run findbugs on all maven sub-modules using an exclude filter. Able to toggle on build failure with mvn verify -Pfindbugs -Dfindbugs.failOnError=true
<?xml version="1.0"?>
<!--
This file contains some false positive bugs detected by Findbugs. Their
false positive nature has been analyzed individually and they have been
put here to instruct Findbugs it must ignore them.
Reference:
This file format: http://findbugs.sourceforge.net/manual/filter.html
Bug pattern names and codes: http://findbugs.sourceforge.net/bugDescriptions.html
Bug categories: https://code.google.com/p/findbugs/source/browse/findbugs/etc/findbugs.xml
@gmanfunky
gmanfunky / Chef-dk windows ruby 1.9.3 build instructions.txt
Last active August 29, 2015 14:00
How to almost completely build chef-dk on windows with Ruby 1.9.3. chef-dk currently depends on Ruby >= 2.0. Ruby 1.9.3 is end-of-life early next year.
WARNING: chef-dk currently depends on Ruby >= 2.0 , so these steps are mostly just in-case we have to fall-back and make chef-dk work on Ruby 1.9.3 someday.
Pre-req: you might have to sanitize a pre-existing ruby and git environment.
Reset PATH environment variable to exclude any \Git\bin folders or other “unix utils” which may pollute your dev environment. It may seem all okay until you get 20 minutes into a compile and tar.exe takes a stackdump.
Install ruby 1.9.3 and devkit. I used Chocolatey Nuget package manager.
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
cinst git.install -notSilent
DO elect to adjust path to “Run Git from the Windows Command Prompt”
2014-03-19 06:36:48 DEBUG [qtp1444302650-1149] anonymous org.sonatype.nexus.plugins.ruby.proxy.DefaultProxyRubyRepository - rubygems retrieveItem() :: FOUND rubygems:/prerelease_specs.4.8.gz
2014-03-19 06:36:49 DEBUG [qtp1444302650-1149] anonymous org.sonatype.nexus.plugins.ruby.proxy.DefaultProxyRubyRepository - getTargetsForRequest() :: rubygems:quick/Marshal.4.8/ruby-mysql-2.9.0.gemspec.rz
2014-03-19 06:36:49 DEBUG [qtp1444302650-1149] anonymous org.sonatype.nexus.proxy.targets.DefaultTargetRegistry - Resolving targets for repository='rubygems' for path='quick/Marshal.4.8/ruby-mysql-2.9.0.gemspec.rz'
2014-03-19 06:36:49 DEBUG [qtp1444302650-1149] anonymous org.sonatype.nexus.plugins.ruby.proxy.DefaultProxyRubyRepository - rubygems.retrieveItem() :: ResourceStoreRequest{requestPath='quick/Marshal.4.8/ruby-mysql-2.9.0.gemspec.rz', requestContext=RequestContext{this={request.remoteOnly=false, request.localOnly=false}, parent=null}, pathStack=[], processedRepositories=[], appliedMappings={}}
2014-03-19 06:36:4
//this .observers is a scala.collection.immutable.$colon$colon according to IntelliJ reflection
Observable.localState(state).observers.foreach(o => {
//insert accountName into each record.
println(o) //works
val accountName = o.accountName // produces compile error
val newRecordsWithAccountName = ArrayBuffer.empty[Record]
newRecords.foreach(aRecord => {
//where i will make a new Record object which includes accountName value
I created a folder for vagrant, edited Vagrantfile, created a cookbooks folder and
git clone https://github.com/opscode-cookbooks/mysql.git
git clone https://github.com/opscode-cookbooks/build-essential.git
git clone https://github.com/opscode-cookbooks/openssl.git
and then vagrant up but chef failed.
[2012-11-08T14:52:50+00:00] INFO: *** Chef 10.14.2 ***
[2012-11-08T14:52:50+00:00] INFO: Setting the run_list to ["recipe[build-essential]", "recipe[openssl]", "recipe[mysql]", "recipe[mysql::client]", "recipe[mysql::server]"] from JSON
[2012-11-08T14:52:50+00:00] INFO: Run List is [recipe[build-essential], recipe[openssl], recipe[mysql], recipe[mysql::client], recipe[mysql::server]]
[2012-11-08T14:52:50+00:00] INFO: Run List expands to [build-essential, openssl, mysql, mysql::client, mysql::server]