Skip to content

Instantly share code, notes, and snippets.

@grodowski
grodowski / run_ci.sh
Created January 31, 2017 14:11
Golang - recursive tests + coverage
#!/bin/bash
shopt -s globstar
rootdir=`pwd`
for dir in **/ ; do
cd $dir
exec 5>&1
out=$(go test -v -coverprofile=cov_part.out | tee >(cat - >&5))
if [ $? -eq 1 ] ; then
if [ $(cat $out | grep -o 'no buildable Go source files') == "" ] ; then
@grodowski
grodowski / script.sh
Created January 10, 2017 11:12
Set "View as icon" option as default in Apple Mail
#!/bin/bash
defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
@grodowski
grodowski / .bash_profile
Created November 27, 2016 15:06
Dotfiles
# Some colors
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
# Dev shortcuts
alias be="bundle exec"
alias dkc='docker-compose'
alias dkcr='docker-compose run'
alias dkr='docker run'
@grodowski
grodowski / application.rb
Created November 16, 2016 15:29
Rails middleware to provide information about errors during requests
module MyApp
class Application < Rails::Application
if Rails.env == 'test'
require 'diagnostic'
config.middleware.use(MyApp::DiagnosticMiddleware)
end
end
end
@grodowski
grodowski / source.js
Created November 7, 2016 13:28
JS sample for Medium
function Foo() {
this.bacon = “Bacon!”;
}
Foo.prototype.say = function() {
console.log(this.bacon);
}
function onExit(astChild: ts.Node, child: types.Node) {
switch (astChild.kind) {
case ts.SyntaxKind.ModuleDeclaration:
case ts.SyntaxKind.ClassDeclaration:
case ts.SyntaxKind.SourceFile:
this.namespaceStack.pop()
break
// BinaryExpression may contain a prototype function declaration, which
// should be given a NAMESPACE role. It's indicated by the state of
var Foo = function() {
return 0;
}
function Foo() {
return 1;
}
Foo.prototype.speak = function () {
return 2;
@grodowski
grodowski / pipes.rb
Created November 27, 2015 10:03
codequest_pipes idea
# Sample controller
def create
ctx = Pipes::Context.new(…..)
flow.call(ctx)
render json: ctx.project, status: :ok
# no need for handling specific exceptions of multiple types
resuce Pipes::Error => e
render json: {errors: e.message}
end
@grodowski
grodowski / clean-docker.sh
Created October 30, 2015 10:51
Docker Machine cleanup commands
docker rm `docker ps -a | grep Exited | awk '{print $1 }'`
docker rmi `docker images -aq`
@grodowski
grodowski / sidekiq.rb
Created September 25, 2015 09:16
Sidekiq process heap dump to a TCP socket
if ENV["PROFILE"]
require "objspace"
ObjectSpace.trace_object_allocations_start
Sidekiq.logger.info "allocations tracing enabled"
module Sidekiq
module Middleware
module Server
class Profiler
# Number of jobs to process before reporting