Skip to content

Instantly share code, notes, and snippets.

@adamjmurray
adamjmurray / gist:3154437
Created July 21, 2012 03:18
Managing Ruby gems programmatically
# Environment, set GEM_HOME & GEM_PATH. For example, we can launch JRuby like this:
# GEM_HOME=/Users/amurray/tmp/gems/ GEM_PATH=/Users/amurray/tmp/gems java -jar ~/Downloads/jruby-complete-1.7.0.preview1.jar -S irb
# =====================
# LISTING gems
puts Gem::Specification.find_all.to_s
puts Gem::Specification.find_all.map{|spec| "#{spec.name} (#{spec.version})" }
# =====================
# USING (a specific version of) gems
@mbbx6spp
mbbx6spp / README.md
Last active May 28, 2024 13:52
Gerrit vs Github for code review and codebase management

Gerrit vs Github: for code review and codebase management

Sure, Github wins on the UI. Hands down. But, despite my initial annoyance with Gerrit when I first started using it almost a year ago, I am now a convert. Fully. Let me tell you why.

Note: This is an opinionated (on purpose) piece. I assume your preferences are like mine on certain ideas, such as:

  • Fast-forward submits to the target branch are better than allowing merge commits to the target branch. The reason I personally prefer this is that, even if a non-conflicting merge to the target branch is possible, the fact that the review/pull request is not up to date with the latest on the target branch means feature branch test suite runs in the CI pipeline reporting on the review/PR may not be accurate. Another minor point is that forced merge commits are annoying as fuck (opinion) and clutter up Git log histories unnecessarily and I prefer clean histories.
  • Atomic/related changes all in one commit is something worth striving for. Having your dev
legacy_opts = {
:default_action => 'gem_install',
:version => (ENV['PUPPET_VERSION'] || '3.8.1'),
}
aio_opts = {
:default_action => 'gem_install',
:version => (ENV['PUPPET_AGENT_VERSION'] || '1.1.0'),
}
@op-ct
op-ct / catalog_dump_from_spec_test.rb
Last active January 13, 2016 10:04 — forked from spiette/gist:5280394
Dumping the catalog from within a Puppet spec test
# WARNING: massive screen scroll
$stdout.puts self.catalogue.to_yaml
# Save to file
File.open( '_catalog.yaml', 'w'){ |f| f.puts self.catalogue.to_yaml }
require 'webrick'
require 'json'
include WEBrick
def start_webrick(config = {})
config.update(:Port => 9001)
server = HTTPServer.new(config)
yield server if block_given?
['INT', 'TERM'].each {|signal|
@natemccurdy
natemccurdy / clear-jruby-pools.sh
Last active May 13, 2016 00:25
Clear the jruby pools in puppetserver
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/13e3b2d8477dbd6bd01d
# Run this on a puppetserver to delete its JRuby pools to clear their cache.
# A response of "HTTP/1.1 204 No Content" means it worked.
#
# https://docs.puppetlabs.com/puppetserver/latest/admin-api/v1/jruby-pool.html
CONFDIR="$(puppet master --configprint confdir)"
CERT="$(puppet master --confdir "${CONFDIR}" --configprint hostcert)"
@natemccurdy
natemccurdy / windows_dev_node.pp
Last active March 8, 2017 00:09
Bootstrap to make editing code on Windows better
# GETTING STARTED
# 1. Install the Puppet agent from http://downloads.puppetlabs.com/windows/puppet-agent-1.3.6-x64.msi
# 2. puppet module install chocolatey-chocolatey
# 3. puppet module install cyberious-apm
# 4. puppet apply windows_dev_node.pp
include chocolatey
$choco_packages = [
'git',

Basic

import code; code.interact(local=locals())

Advanced

IPython with embed()

@Kirkman
Kirkman / ansi_art_converter.py
Last active August 26, 2016 01:33 — forked from jdiaz5513/ascii_arty.py
Console ANSI Art Generator
#! /usr/bin/env python2
# -*- coding: utf-8 -*-
#
# This routine is adapted from: https://gist.github.com/jdiaz5513/9218791
#
# Things I changed:
# * Cache the results of color_distance() lookups, for a big speed-up.
# * Adjusted the RGB values for ANSI_COLORS to match original CGA values
# * Changed default fill character to a PC-ANSI shaded block character
# * Added some timer code to help with optimizing the conversion routine
@blabber
blabber / reduce.g
Created June 13, 2016 21:07
GVPR script to extract subgraphs
BEGIN{
if (ARGC != 2) {
print("This script takes exactly two parameter. 1: name of node, 2: number of hops");
exit(1);
}
void reduce_in(graph_t _g, node_t _n, edge_t _e, int _d){
_e = fstin(_n);
while (_e != NULL) {
clone(_g, _e);