Skip to content

Instantly share code, notes, and snippets.

@adampats
adampats / setup.ps1
Created August 2, 2018 21:45
Windoze dev setup
mkdir temp
cd temp
# Configure Windows
Set-WindowsExplorerOptions `
-EnableShowHiddenFilesFoldersDrives `
-EnableShowProtectedOSFiles `
-EnableShowFileExtensions `
-EnableShowFullPathInTitleBar
@adampats
adampats / rubygems.sh
Last active July 25, 2018 04:53
Get rubygems api token for ~/.gem/credentials
user="adampats"
curl -u "$user" "https://rubygems.org/api/v1/api_key.yaml" > ~/.gem/credentials
chmod 0600 ~/.gem/credentials
@adampats
adampats / Jenkinsfile
Last active June 1, 2017 23:43
Jenkinsfile Shared Library
@Library('jenkinsfile-library')
import com.foo.Methods
node {
def m = new com.foo.Methods()
def ip = m.getPublicIP()
echo ip
}
@adampats
adampats / nested.rb
Created May 17, 2017 00:01
Multi nested ruby hash array
h = [{:form_name=>nil,
:form_fields=>
[{:type=>"text", :name=>"hostname", :value=>"test\n"},
{:type=>"text", :name=>"syslog", :value=>""},
{:type=>"text", :name=>"time_server", :value=>"pool.ntp.org\n"},
{:type=>"hidden", :name=>"task", :value=>"3"},
{:type=>"hidden", :name=>"task_action", :value=>"save"},
{:type=>nil,
:name=>"resolv",
:value=>"nameserver\n\n"},
@adampats
adampats / logger.rb
Created April 13, 2017 19:09
stdout within class method
require 'ruby_expect'
require 'timeout'
require 'pry'
@verbose = true
log_name = "#{Time.now.utc.strftime('%Y-%m-%d-%H%M%SZ')}-#{@prog_name}.log"
timeout_seconds = '600'
class Log
def initialize(log_path)
@adampats
adampats / env_vars.sh
Last active March 17, 2017 16:07
Set environment variables from key/value file
export $(cat config.env | grep -v ^# | xargs)
@adampats
adampats / ledocker.sh
Created March 15, 2017 20:29
Install docker on Ubuntu
apt-get update
apt-get install -y linux-image-extra-$(uname -r) \
linux-image-extra-virtual \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@adampats
adampats / newvar.groovy
Created March 15, 2017 04:44
Groovy / Jenkinsfile create variable name from arbitrary string
// requires Jenkins - Groovy Sandbox to be turned OFF
new_var = "varname"
new GroovyShell(this.binding).evaluate("${new_var} = 'skittles'")
println varname
@adampats
adampats / creds.groovy
Created July 27, 2016 05:00
Jenkins Credentials Binding pipeline groovy
try {
err = null
currentBuild.result = "SUCCESS"
node {
stage 'One'
// using a single secret Jenkins credential
withCredentials([[$class: 'StringBinding', credentialsId: 'my-api-token', variable: 'API_TOKEN']]) {
sh '''
set +x
@adampats
adampats / get_user_repos.py
Created May 26, 2016 23:13
PyGithub with GHE
from github import Github
g = Github("user", "pass", base_url="https://github.foo.net")
u = g.get_user('user')
print u.name