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
# | |
apt-get update | apt-get upgrade | |
# Install ant and dependancies. [Ignore errors about "libjli.so" missing; it appears to be a soft vs hard float java issue. We will replace Java in a later step.] | |
apt-get install ant -y | |
# Download Oracle Jdk 8 for Linux 32bit from: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html | |
# ... The download should be a file like: jdk-8u20-linux-i586.tar.gz |
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
# Download Oracle Jdk 8 for Linux 32bit from:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-arm-downloads-2187472.html | |
# ... The download should be a file like: jdk-8u33-linux-arm-vfp-hflt.tar.gz | |
# Download JRuby from: http://www.jruby.org/download | |
# ... The download should be a file like: jruby-bin-1.7.18.tar.gz, jruby-bin-9.0.0.0.pre1.tar.gz | |
# Install 'GNURoot' and 'GNURoot Wheezy x86' from app store, see: | |
# [gnuroot app](https://play.google.com/store/apps/details?id=champion.gnuroot&hl=en) | |
# [gnuroot repo](https://github.com/corbinlc) | |
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/ruby | |
# FILENAME: av_splitter.rb | |
# | |
# DESCRIPTION: Convert and split an audio/video file into 5 minute intervals of the specified target format and compression quality. | |
# | |
# USAGE: | |
# Put your audio/video files into the "in" sub-folder, then run the 'audio_splitter.rb' ruby script w/syntax: | |
# ruby -s audio_splitter.rb <format_out> '<bit_rate_info>' <debug_level> | |
# |
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
# Official site for the Ruby language: "https://www.ruby-lang.org/" | |
class C1 | |
attr :a, :b | |
def initialize(a) | |
@a = a | |
end | |
def self.hi | |
puts 'hello world' |
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
# GIST: "pw_from_console.rb" under "https://gist.github.com/drhuffman12" | |
# If you're dealing with a Java character array (such as password characters that you read from the console), you can convert it to a JRuby string with the following Ruby code: | |
jconsole = Java::java.lang.System.console() | |
password = jconsole.readPassword() | |
ruby_string = '' | |
password.to_a.each {|c| ruby_string << c.chr} | |
# .. do something with 'password' variable .. | |
puts "password_chars: #{password_chars.inspect}" |
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/ruby | |
=begin | |
## USAGE: | |
# Ruby: | |
ruby gem-fetch-dependencies.rb fetch <gem_name> --dependencies | |
# JRuby: | |
jruby gem-fetch-dependencies.rb fetch <gem_name> --dependencies |
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
=begin | |
https://gist.github.com/drhuffman12/a5ad839b71e8ca334a2a | |
Problem statement: | |
Create a class named PalindromeDetector. Within that class, implement a | |
static function named GetPalindromeYears that takes a start and end date as parameters and | |
returns a distinct set of Dates in chronological order(inclusive of start and end dates) | |
that, when formatted as MMddyyyy, are palindromes. |
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 | |
me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" | |
# echo $me | |
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] | |
then | |
echo | |
echo 'To create a Ruby app folder and configure it for RVM usage, use the following syntax:' | |
echo | |
echo ' bash --login './$me 'PROJ_ROOT PROJ_NAME PROJ_RUBY_VER PROJ_GEMSET_NAME' | |
echo |
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 "benchmark" | |
require "big" | |
# def fib(n : BigInt) | |
# n < 2 ? n : fib(n-1) + fib(n-2) | |
# end | |
struct BigInt | |
def add!(other : BigInt) : BigInt | |
LibGMP.add(self, self, other) |
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
# based on http://stackoverflow.com/questions/29718767/check-if-array-elements-are-power-of-two | |
require 'benchmark' | |
class Po2 | |
def self.via_to_s(n) | |
(n.to_s(2) =~ /^10*$/) ? 0 : 1 # faster for more than about 100 numbers | |
end | |
def self.via_log(n) |
OlderNewer