Skip to content

Instantly share code, notes, and snippets.

### i need to add another condition in on the Dir.entries, so that directories do not print out
### having no luck with File.stat(x)file? or File.file?....etc
get '/entry' do
list = Dir["/vagrant/TestRails/RubyPractice/RailsGirls/**/*"]
list.each do |dir|
if File.directory?(dir)
puts "Directory: #{dir}\n"
Dir.entries(dir).reject { |x| p "Entry: #{x}" if x =~ /^[^.].*$/ }
end
@stuartambient
stuartambient / gist:3ece8d44e060f46aa8af44a8505cfd32
Created November 1, 2017 22:36
Nginx and Thin with Sinatra app
# netstat -anp
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ] DGRAM 20453 2767/systemd /run/user/1000/systemd/notify
unix 2 [ ACC ] STREAM LISTENING 20454 2767/systemd /run/user/1000/systemd/private
unix 2 [ ACC ] SEQPACKET LISTENING 9974 1/init /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 17042 1294/postgres /var/run/postgresql/.s.PGSQL.5432
unix 2 [ ACC ] STREAM LISTENING 9780 1/init /run/systemd/private
unix 2 [ ACC ] STREAM LISTENING 9790 1/init /run/systemd/fsck.progress
# Attempt to use rack/reverse proxy to serve up files upon request that exist outside site root
# The full address for the files /vagrant/TestRails/Music/various-subdirectories
# You can see below the Sinatra route which uses the splat.
# I'm confused as to what should be in the reverse_proxy line, having tried a number of different variations
# Sinatra route
get '/file/*' do
slim :search_results
end
class Song < Sequel::Model
plugin :validation_helpers
self.raise_on_save_failure
def validate
super
validates_presence [:title, :length, :released_on, :lyrics]
end
end