-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP of all oracle features for TTATC
- Loading branch information
Eric Stiens
committed
Jul 14, 2018
0 parents
commit 70a81a6
Showing
33 changed files
with
25,114 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.5.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
require 'pp' | ||
require 'serialport' | ||
require 'pry' | ||
|
||
class TTy | ||
def initialize | ||
# defaults params for arduino serial | ||
baud_rate = 9600 | ||
data_bits = 8 | ||
stop_bits = 1 | ||
parity = SerialPort::NONE | ||
|
||
# serial port | ||
@sp = nil | ||
@port = nil | ||
end | ||
|
||
def open(port) | ||
@sp = SerialPort.new(port, @baud_rate, @data_bits, @stop_bits, @parity) | ||
end | ||
|
||
def shutdown(reason) | ||
return if @sp.nil? | ||
return if reason == :int | ||
|
||
printf("\nshutting down serial (%s)\n", reason) | ||
|
||
# you may write something before closing tty | ||
@sp.write(0x00) | ||
@sp.flush | ||
printf("done\n") | ||
end | ||
|
||
def read | ||
@sp.flush | ||
message = @sp.read | ||
puts message | ||
match = /\X:\((.*)\)Y:\((.*)\)Z:\((.*)\)/x.match(message) | ||
if match && match.length == 4 | ||
x = match[1].to_f | ||
y = match[2].to_f | ||
z = match[3].to_f | ||
return { x: x, y: y, z: z } | ||
end | ||
end | ||
|
||
def write(c) | ||
@sp.putc(c) | ||
@sp.flush | ||
printf("# W : 0x%02x\n", c.ord) | ||
end | ||
|
||
def flush | ||
@sp.flush | ||
end | ||
end | ||
|
||
# serial port should be connected to /dev/ttyUSB* | ||
# ports = Dir.glob('/dev/ttyUSB*') | ||
# if ports.size != 1 | ||
# printf('did not found right /dev/ttyUSB* serial') | ||
# exit(1) | ||
# end | ||
|
||
tty = TTy.new | ||
tty.open('/dev/ttyACM0') | ||
|
||
at_exit { tty.shutdown :exit } | ||
trap('INT') { tty.shutdown :int; exit } | ||
|
||
@counter = 0 | ||
|
||
# just read forever | ||
loop do | ||
@counter = 0 if @counter > 10 | ||
@counter += 1 | ||
|
||
if @counter == 1 | ||
@min_x = @min_y = @min_z = 1000 | ||
@max_x = @max_y = @max_z = -1000 | ||
end | ||
|
||
if @counter == 10 | ||
x_var = @max_x - @min_x | ||
y_var = @max_y - @min_y | ||
z_var = @max_z - @min_z | ||
puts x_var | ||
puts y_var | ||
puts z_var | ||
puts 'BELL RANG' if x_var > 4 || y_var > 4 || z_var > 4 | ||
end | ||
|
||
hash = tty.read | ||
if hash | ||
@min_x = hash[:x] if hash[:x] < @min_x | ||
@max_x = hash[:x] if hash[:x] > @max_x | ||
@min_y = hash[:y] if hash[:y] < @min_y | ||
@max_y = hash[:y] if hash[:y] > @max_y | ||
@min_z = hash[:z] if hash[:z] < @min_z | ||
@max_z = hash[:z] if hash[:z] > @max_z | ||
end | ||
sleep(0.25) | ||
end | ||
|
||
sleep 500 | ||
tty.shutdown |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'faye' | ||
|
||
Faye::WebSocket.load_adapter('thin') | ||
Faye.logger = Logger.new(STDOUT) | ||
faye = Faye::RackAdapter.new(mount: '/faye', :timeout => 5) | ||
run faye |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'faye' | ||
require 'eventmachine' | ||
|
||
endpoint = 'http://0.0.0.0:9292/faye' | ||
|
||
EM.run do | ||
puts "Connecting to #{endpoint}" | ||
|
||
client = Faye::Client.new(endpoint) | ||
|
||
subscription = client.subscribe '/fortune' do |message| | ||
puts message | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
=> [32m#<Faye::Client:0x000055b4ea7022f0[0m | ||
@advice[32m=[0m{[31m[1;31m"[0m[31mreconnect[1;31m"[0m[31m[0m=>[31m[1;31m"[0m[31mretry[1;31m"[0m[31m[0m, [31m[1;31m"[0m[31minterval[1;31m"[0m[31m[0m=>[1;35m0.0[0m, [31m[1;31m"[0m[31mtimeout[1;31m"[0m[31m[0m=>[1;35m60000.0[0m}, | ||
@channels[32m=[0m[32m#<Faye::Channel::Set:0x000055b4ea6e6708[0m @channels[32m=[0m{}[32m>[0m, | ||
@dispatcher[32m=[0m | ||
[32m#<Faye::Dispatcher:0x000055b4ea68b1c8[0m | ||
@alternates[32m=[0m{}, | ||
@client[32m=[0m[32m#<Faye::Client:0x000055b4ea7022f0[0m ...[32m>[0m, | ||
@cookies[32m=[0m[32m#<CookieJar::Jar:0x000055b4ea68a8e0[0m @domains[32m=[0m{}[32m>[0m, | ||
@disabled[32m=[0m[], | ||
@endpoint[32m=[0m[32m#<URI::HTTP http://localhost:9292/faye>[0m, | ||
@envelopes[32m=[0m{}, | ||
@headers[32m=[0m{}, | ||
@listeners[32m=[0m{[31m[1;31m"[0m[31mmessage[1;31m"[0m[31m[0m=>[[32m#<Proc:0x000055b4ea5bda70 (lambda)>[0m]}, | ||
@max_request_size[32m=[0m[1;34m2048[0m, | ||
@proxy[32m=[0m{}, | ||
@retry[32m=[0m[1;35m5.0[0m, | ||
@scheduler[32m=[0m[1;34;4mFaye[0m::[1;34;4mScheduler[0m, | ||
@state[32m=[0m[1;34m0[0m, | ||
@timeout[32m=[0m[1;35m60.0[0m, | ||
@transports[32m=[0m{}, | ||
@ws_extensions[32m=[0m[][32m>[0m, | ||
@listeners[32m=[0m{}, | ||
@message_id[32m=[0m[1;34m0[0m, | ||
@response_callbacks[32m=[0m{}, | ||
@state[32m=[0m[1;34m1[0m[32m>[0m |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
require 'marky_markov' | ||
require 'pry' | ||
require 'yaml' | ||
require 'literate_randomizer' | ||
|
||
class String | ||
def titlecase | ||
split(/([[:alpha:]]+)/).map(&:capitalize).join | ||
end | ||
end | ||
|
||
def setup | ||
@markov = MarkyMarkov::Dictionary.new("#{rand(10000)}asdf") | ||
# @markov.parse_file 'text/iching.txt' | ||
@markov.parse_file 'text/iching-words.txt' | ||
@markov.parse_file 'text/tarot-words.txt' | ||
@markov.parse_file 'text/mckenna.txt' | ||
@markov.parse_file 'text/rilke-words.txt' | ||
@markov.save_dictionary! | ||
|
||
@seeds_one = YAML.load(File.open('symbols/arcana.yml', 'r+')) | ||
@seeds_two = YAML.load(File.open('symbols/dreams.yml', 'r+')) | ||
@seeds_three = YAML.load(File.open('symbols/qualities.yml', 'r+')) | ||
@seeds_four = YAML.load(File.open('symbols/hexagrams.yml', 'r+')) | ||
|
||
@random = LiterateRandomizer.create(source_material_file: "#{Dir.pwd}/text/tarot-words.txt") | ||
|
||
@counter = 0 | ||
end | ||
|
||
def get_seed_word | ||
words = [@seeds_one, @seeds_two, @seeds_three, @seeds_four].sample | ||
words.sample | ||
end | ||
|
||
def find_sentence_for_word | ||
1000.times do | ||
sentence = @markov.generate_n_sentences(rand(3)) | ||
return sentence if sentence.downcase.include?(@seed_word.downcase) | ||
end | ||
nil | ||
end | ||
|
||
def find_sentence | ||
sentence = nil | ||
@seed_word = get_seed_word | ||
sentence = find_sentence_for_word | ||
return sentence if sentence | ||
@counter += 1 | ||
return @random.sentence if @counter > 10 | ||
find_sentence | ||
end | ||
|
||
def modifiers | ||
[ | ||
'leads to', | ||
'follows', | ||
'perplexes', | ||
'shifts towards', | ||
'obstructs', | ||
'enhances', | ||
'brings about', | ||
'comes first, then', | ||
'is a possibility, but so is', | ||
'cannot stop', | ||
'can turn into', | ||
'can never stop', | ||
'seems likely, but so does', | ||
'can only lead to hesitation. Instead go for' | ||
] | ||
end | ||
|
||
setup | ||
|
||
loop do | ||
gets.chomp | ||
sentence = find_sentence | ||
sentence = sentence.sub(/\w+/) { |m| m.capitalize } | ||
sentence = sentence.gsub(/#{Regexp.escape(@seed_word)}/i, @seed_word.titlecase) | ||
rand = rand(1..100) | ||
if rand <= 4 | ||
puts "TYPE 1" | ||
puts "#{get_seed_word.titlecase} #{modifiers.sample} #{get_seed_word.downcase}." | ||
elsif rand <= 7 | ||
puts "TYPE 2" | ||
sentence = sentence.split('.').first | ||
sentence = sentence.split(',').first if sentence.split(' ').length > 10 | ||
puts "#{sentence}." | ||
elsif rand <= 10 | ||
puts "TYPE 3" | ||
puts "(#{get_seed_word.titlecase}) #{sentence.split('.').first}." | ||
else | ||
puts sentence.gsub(/#{Regexp.escape(@seed_word)}/i, @seed_word.upcase) | ||
end | ||
end |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
gem 'sinatra' | ||
gem 'sinatra-asset-pipeline' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
GEM | ||
specs: | ||
coffee-script (2.4.1) | ||
coffee-script-source | ||
execjs | ||
coffee-script-source (1.12.2) | ||
concurrent-ruby (1.0.5) | ||
execjs (2.7.0) | ||
ffi (1.9.25) | ||
mustermann (1.0.2) | ||
rack (2.0.5) | ||
rack-protection (2.0.3) | ||
rack | ||
rake (12.3.1) | ||
rb-fsevent (0.10.3) | ||
rb-inotify (0.9.10) | ||
ffi (>= 0.5.0, < 2) | ||
sass (3.5.6) | ||
sass-listen (~> 4.0.0) | ||
sass-listen (4.0.0) | ||
rb-fsevent (~> 0.9, >= 0.9.4) | ||
rb-inotify (~> 0.9, >= 0.9.7) | ||
sinatra (2.0.3) | ||
mustermann (~> 1.0) | ||
rack (~> 2.0) | ||
rack-protection (= 2.0.3) | ||
tilt (~> 2.0) | ||
sinatra-asset-pipeline (2.1.0) | ||
coffee-script (~> 2.4) | ||
rake (~> 12.3) | ||
sass (~> 3.5) | ||
sinatra (~> 2.0) | ||
sprockets (~> 3.7) | ||
sprockets-helpers (~> 1.2) | ||
sprockets (3.7.2) | ||
concurrent-ruby (~> 1.0) | ||
rack (> 1, < 3) | ||
sprockets-helpers (1.2.1) | ||
sprockets (>= 2.2) | ||
tilt (2.0.8) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
sinatra | ||
sinatra-asset-pipeline | ||
|
||
BUNDLED WITH | ||
1.16.2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'sinatra' | ||
require 'sinatra/asset_pipeline' | ||
|
||
register Sinatra::AssetPipeline | ||
|
||
get '/' do | ||
erb :index | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function increaseSpeed() { | ||
speed = window.pJSDom[0].pJS.particles.move.speed | ||
console.log(speed); | ||
if (speed < 20) | ||
speed += 3; | ||
else | ||
speed = 3; | ||
clearInterval(increaseSpeed); | ||
window.pJSDom[0].pJS.particles.move.speed = speed | ||
} | ||
|
||
function showText(text) { | ||
$('#fortune').text(text); | ||
$('#fortune').fadeIn(500); | ||
setTimeout($('#fortune').fadeOut(5000), 25000) | ||
} | ||
|
||
function fortuneTeller(message) { | ||
interval = setInterval(function(){ | ||
speed = window.pJSDom[0].pJS.particles.move.speed | ||
console.log(speed); | ||
if (speed < 30) { | ||
speed += 1 | ||
} | ||
else { | ||
speed = 3; | ||
clearInterval(interval); | ||
showText(message) | ||
} | ||
window.pJSDom[0].pJS.particles.move.speed = speed | ||
}, 200) | ||
} | ||
|
||
$( document ).ready(function() { | ||
console.log('hello') | ||
var url = 'http://0.0.0.0:9292/faye' | ||
var client = new Faye.Client(url, {retry: 5}); | ||
client.disable('websocket'); | ||
console.log('subscribing') | ||
client.subscribe('/fortune', function(message) { | ||
fortuneTeller(message.text); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#particles-js { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
background: linear-gradient(to bottom, rgba(117, 114, 113, 0.8) 10%, rgba(40, 49, 77, 0.8) 30%, rgba(29, 35, 71, 0.8) 50%, rgba(19, 25, 28, 0.8) 80%, rgba(15, 14, 14, .8) 100%); | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
background-position: 50% 50%; | ||
} | ||
|
||
#fortune { | ||
position: absolute; | ||
width: 100%; | ||
text-align: center; | ||
padding-top: 200px; | ||
display: none; | ||
font-size: 3em; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.