View async_tests.rb
This file contains 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
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem 'concurrent-ruby', '~> 1.1.6' |
View split.sh
This file contains 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 | |
# based on https://stackoverflow.com/a/61525373/520567 | |
# you can play with -metadata and file name as you see fit | |
set -efu | |
videoFile="$1" | |
ffprobe -hide_banner \ |
View FFMETADATAFILE.example
This file contains 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
;FFMETADATA1 | |
major_brand=mp42 | |
minor_version=0 | |
compatible_brands=mp42mp41 | |
title=Sharks Group Video Film.mp4 | |
comment=some comment | |
encoder=Lavf58.76.100 | |
[CHAPTER] | |
TIMEBASE=1/1000 |
View print_only_cuke_filter.rb
This file contains 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
require 'cucumber/core/filter' | |
# put inside features/support/ | |
class PrintOnlyCukeFilter < Cucumber::Core::Filter.new | |
def test_case(test_case) | |
announce | |
print_file_for(test_case) | |
end | |
private |
View rack_server.rb
This file contains 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
require "rack" | |
def pp(hash) | |
hash["HTTP_ACCEPT"].include?("text/html") ? pp_html(hash) : pp_plain(hash) | |
end | |
def pp_plain(hash) | |
hash.map {|key,value| "#{key}: #{value}"}.sort.join("\n") | |
end |
View rails_dump_config.rb
This file contains 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
def dump_config(object = Rails.application.config.class.class_variable_get(:@@options)) | |
case object | |
when Array | |
object.map { |v| dump_config(v) } | |
when Hash | |
Hash[ object.map { |key, value| [key, dump_config(value)] } ] | |
when TrueClass, FalseClass, Numeric | |
object | |
else | |
object.to_s |
View fonts_find.sh
This file contains 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 | |
# example: ./font_find.sh 🎩︎ | |
# credits: David Baynard, https://unix.stackexchange.com/a/393740/14907 | |
param="$1" | |
char=${param:0:1} | |
printf '%x' \'"$char" | xargs -I{} fc-list ":charset={}" |
View amicable.rb
This file contains 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
# https://www.jdoodle.com/execute-ruby-online/ | |
def amicable?(int1, int2) | |
sum_proper_divisors(int1) == int2 && sum_proper_divisors(int2) == int1 | |
end | |
def sum_proper_divisors(num) | |
(1..num/2).select { |i| | |
num%i == 0 | |
}.sum |
View pretty_print_json.rb
This file contains 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
INDENT_SIZE = 2 | |
def pretty_jsonify(struct, indent=0) | |
case struct | |
when Array | |
"[\n" + indent_str("", indent+INDENT_SIZE) + | |
struct.map { |value| | |
pretty_jsonify(value, indent+INDENT_SIZE) | |
}.join(",\n#{indent_str('', indent+INDENT_SIZE)}") + |
View jenkins cancel running builds
This file contains 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 jenkins.model.Jenkins | |
def numCancels = 0; | |
Jenkins.instance.getAllItems(Job.class).each{ | |
def job = it | |
for (build in job.builds) { | |
if (build.isBuilding()) { build.doStop(); numCancels++; } | |
} | |
} |
NewerOlder