Skip to content

Instantly share code, notes, and snippets.

@mateor
mateor / publish_jars_to_s3.diff
Last active June 29, 2019 23:21
Pantsbuild: Configure Ivy to publish jars to s3
--- a/build-support/ivy/publish.ivysettings.xml
+++ b/build-support/ivy/publish.ivysettings.xml
@@ -14,13 +14,22 @@ Licensed under the Apache License, Version 2.0 (see LICENSE).
<properties file="${user.home}/.gnupg/pgp.properties"/>
<settings defaultResolver="main" />
+ <!--
+ Custom s3resolver to allow pushing published artifacts directly to an s3 bucket
+ Credentials are loaded from default AWS location, ~/.aws/credentials.
+ -->
+ <typedef name="s3resolver" classname="co.actioniq.ivy.s3.S3URLResolver"/>
@mateor
mateor / gist:e82226832edb63c20be5aa693318a43b
Last active January 29, 2018 07:26
Go-thrift Buildgen
mateo-2:pants mateo$ git add contrib/
mateo-2:pants mateo$ git diff HEAD contrib/go/src/python/pants/contrib/go/tasks/
diff --git a/contrib/go/src/python/pants/contrib/go/tasks/go_buildgen.py b/contrib/go/src/python/pants/contrib/go/tasks/go_buildgen.py
index 9e9c377da..cae3500d2 100644
--- a/contrib/go/src/python/pants/contrib/go/tasks/go_buildgen.py
+++ b/contrib/go/src/python/pants/contrib/go/tasks/go_buildgen.py
@@ -22,6 +22,7 @@ from pants.util.dirutil import safe_mkdir, safe_open
from pants.contrib.go.subsystems.fetcher_factory import FetcherFactory
from pants.contrib.go.targets.go_binary import GoBinary
from pants.contrib.go.targets.go_library import GoLibrary
@mateor
mateor / watcher.py
Created November 27, 2017 18:15
Pants onchange
# coding=utf-8
# Copyright 2013 Foursquare Labs Inc. All Rights Reserved.
from __future__ import (nested_scopes, generators, division, absolute_import, with_statement,
print_function, unicode_literals)
import argparse
from threading import Event
import subprocess
import sys
@mateor
mateor / amm.txt
Created August 30, 2016 21:45
ammonite pprint error
Welcome to the Ammonite Repl 0.7.5
(Scala 2.11.8 Java 1.8.0_40-ea)
@ import $ivy.`org.spire-math::spire:0.8.0`
import $ivy.$
@ import spire.math._
import spire.math._
@ pprint.pprintln(Rational.one)
scala.reflect.internal.Types$TypeError: value <none> is not a member of Object{implicit lazy val derive$macro$41(): pprint.PPrint[spire.math.Rational]; def derive$macro$56(): pprint.PPrint[spire.math.Rational]}
scala.tools.nsc.typechecker.Contexts$ThrowingReporter.handleError(Contexts.scala:1402)
scala.tools.nsc.typechecker.Contexts$ContextReporter.issue(Contexts.scala:1254)
@mateor
mateor / local_publish.mkdn
Last active June 8, 2016 17:48
local publish with Pants

Local Publish

  1. Create a local directory and set it up to serve jars:

      mkdir -p ~/.m2-local/repository/
      python -m SimpleHTTPServer 8000
    
  2. Publish the jars to that location.

    • We use a (somewhat hacky) custom task called pom_publish but I assume you have a process.
  • ./pants publish.jar
@mateor
mateor / print_slow.sh
Created May 20, 2016 16:07
bash profile to ~slowly cat a file. Good for ASCII art burns.
function print_slow(){
IFS=$'\n' && array=($(<$1))
for line in ${array[@]};
do echo $line
sleep .05
done
}
# If you have a cowboy file (like I do!)
alias cowboy='print_slow ~/dev/snippets/whoa_cowboy.sh'
@mateor
mateor / get_python_library.py
Last active October 27, 2020 13:21
Function to programmatically generate the list of importable modules that shipped with the invoking Python distribution.
# The MIT License (MIT)
# Copyright (c) 2016 mateor
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions
# of the Software.
@mateor
mateor / patch.diff
Created May 5, 2016 21:58
Add buildgen to an arbitrary pants project
diff --git a/.gitignore b/.gitignore
index a61ace7..0ced64a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@
.#*
.DS_Store
.artifact_cache
+.buildgen_timestamp
.cache
@mateor
mateor / Python.tmpl
Created April 21, 2016 05:14
A python template - can be used with the Sublime FileHeader plugin.
# coding=utf-8
# The MIT License (MIT)
# Copyright (c) {{ create_time }} {{ author }}
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
@mateor
mateor / FileHeader.sublime-settings
Last active April 21, 2016 05:42
Settings that I use with FileHeader Sublime plugin to create headers for new python files.
{
/*
options
=======
*/
/*
The datetime format.
0: "%Y-%m-%d %H:%M:%S"