This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Exit on error | |
set -e | |
# Enable null_glob option to handle no matches | |
setopt null_glob | |
# Function to handle errors | |
handle_error() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to build tree-sitter from source and get the Ruby parser to work with it. | |
mkdir -p $HOME/workspace/ | |
cd $HOME/workspace/ | |
# clone tree-sitter itself | |
git clone git@github.com:tree-sitter/tree-sitter.git | |
# clone the Ruby parser | |
git clone git@github.com:tree-sitter/tree-sitter-ruby.git | |
# Build & install the tree-sitter CLI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Show server's certificate in a human-readable form. | |
# | |
# Usage: $ show-cert HOST [PORT] | |
# | |
exec <&- # close stdin to suppress `read:errno=0` from openssl | |
exec openssl x509 -noout -text \ | |
-in <(openssl s_client -connect "$1":"${2:-443}" -showcerts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.include?("-h") || ARGV.include?("--help") | |
puts "USAGE: check_cert [HOSTNAME] [TLS_VERSION] [VERIFY]" | |
puts " default: check_cert rubygems.org auto VERIFY_PEER" | |
puts " example: check_cert github.com TLSv1_2 VERIFY_NONE" | |
exit 0 | |
end | |
host = ARGV.shift || "rubygems.org" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'English' | |
`git diff-files --quiet` | |
unless $CHILD_STATUS.success? | |
puts 'You have uncommitted changes. Doing nothing' | |
exit(1) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# This hook will cause a push to fail if any Jasmine (JavaScript) or rspec tests fail. | |
# If this script exits with a non-zero status nothing will be pushed. | |
# | |
# This hook is called with the following parameters: | |
# | |
# $1 -- Name of the remote to which the push is being done | |
# $2 -- URL to which the push is being done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# Pre-commit hook that runs rubocop against all modified ruby files | |
require 'json' | |
rb_files = `git diff --name-only --staged`.split().reject{|f| !f.end_with?('.rb')} | |
exit(0) if rb_files.empty? | |
str = "rubocop -F -f json #{rb_files*" "}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Search all jar files in the current directory and below for the given string | |
# usage: ffjar <pattern> | |
# Requires GNU parallel and the_silver_searcher | |
function ffjar() { | |
jars=(./**/*.jar) | |
print "Searching ${#jars[*]} jars for '${*}'..." | |
parallel --no-notice --tag unzip -l ::: ${jars} | ag ${*} | awk '{print $1, ":", $5}' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.function.ToIntFunction; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
import static java.lang.System.out; | |
public class FunctionalJava { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
cd ~/workspace/harbor | |
rake build | |
cd ~/temp | |
gem install ~/workspace/harbor/pkg/harbor-1.0.gem | |
rm -r ht | |
harbor setup ht | |
cd ht | |
rackup |
NewerOlder