Skip to content

Instantly share code, notes, and snippets.

View drhuffman12's full-sized avatar

Daniel Huffman drhuffman12

View GitHub Profile
@drhuffman12
drhuffman12 / pw_from_console.rb
Last active August 29, 2015 14:12
Get password from console via Java and JRuby
# 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}"
@drhuffman12
drhuffman12 / sample_objs.rb
Last active August 29, 2015 14:10
Simple Object-oriented example in Ruby
# 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'
@drhuffman12
drhuffman12 / av_splitter.rb
Last active August 29, 2015 14:08
Convert and split an audio/video file into 5 minute intervals of the specified target format and compression quality.
#!/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>
#
@drhuffman12
drhuffman12 / gnuroot_wheezyx_to_jessie_jruby
Last active February 6, 2018 05:54
Upgrade gnuroot wheezyX on android ARM to jessie and add java and jruby
# 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)
@drhuffman12
drhuffman12 / gnuroot_wheezy86_to_jessie_jruby
Last active August 29, 2015 14:07
Upgrade gnuroot wheezy on android x86 to jessie and add Java, JRuby, Android SDK, and Ruboto gem
#
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