jean-luc February 28, 2017 Share February 28, 2017 SO I made some changes to my server so that I can use different urls for the same imageset which means the browsers browsing will think it's two different images and therefor send two requests allowing me to send two different images... or more: Here's hoping I don't crash my own server XD wtf I don't visit as often as I used to. If you want me to see something, make sure to quote a post of mine or ping me @jean-luc Link to comment Share on other sites More sharing options...
Natek February 28, 2017 Share February 28, 2017 http://memeguy.com/photos/images/oh-picard-you-playful-devil-you-129746.gif Link to comment Share on other sites More sharing options...
Paranoid Llama February 28, 2017 Share February 28, 2017 wat I'm not going to listen to you guys since you are all probably just talking to yourself and don't really have a tulpa like me. Link to comment Share on other sites More sharing options...
Reisen February 28, 2017 Share February 28, 2017 refresh Hi guys, plain text is just me now! We've each got our own accounts: me, Tewi, Flandre, and Lucilyn. We're Luminesce's tulpas. Here's our "Ask Thread", and here's our Progress Report (You should be able to see all of our accounts on the second page if you want) Link to comment Share on other sites More sharing options...
tulpa001 February 28, 2017 Share February 28, 2017 Will that even work? Host comments in italics. Tulpa's log. Tulpa's guide. Link to comment Share on other sites More sharing options...
Bosun February 28, 2017 Share February 28, 2017 K programs enough to say... "This is interesting... Wat?" His words. Link to comment Share on other sites More sharing options...
jean-luc February 28, 2017 Author Share February 28, 2017 May the source be with you: =begin This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to =end require 'sinatra' require 'mime-types' class Profile def initialize(files,type,weights=nil) @files = files @type = type @weights = weights @weights.map!{ |w| w.to_f / weights.reduce(:+) } unless weights.nil? end attr_reader :type def sample if @weights r = rand counter = 0 index = -1 while counter < r index += 1 counter += @weights[index] end return @files[index] else @files.sample end end def sample_file File.open(self.sample) end end $mutex = Mutex.new def update_profiles profiles = Dir['*'].find_all{|d| File.directory?(d)} profiles.map! do |name| weights = nil mime = "" pics = Dir.entries(name).map{|a| File.join(name,a)}.find_all do |entry| #puts "DEBUG: entry: #{entry}" #entry = File.join(name,entry) next false unless File.file?(entry) next false if entry.end_with?("~") if File.basename(entry) == "weights" weights = File.read(entry).split.map(&:to_i) false else mime = MIME::Types.type_for(entry).first if mime.nil? mime = "text/#{File.extname(entry).gsub('.','')}" puts "debug: mime was nil for #{entry}, using #{mime}" else mime = mime.simplified end true end end [name,Profile.new(pics,mime,weights)] end $profiles = Hash[profiles] end update_profiles Thread.new do loop do sleep(1) $mutex.synchronize do update_profiles end end end get '/pp/:name' do |name| $mutex.synchronize do name = name.split(/\A([^\.]+)\.?[0-9]*(\.[a-zA-Z]{2,4})\Z/).join('') p = $profiles[name] next 404 if p.nil? content_type p.type chosen_one = p.sample puts "Picked #{chosen_one}" next File.open(chosen_one) end end I don't visit as often as I used to. If you want me to see something, make sure to quote a post of mine or ping me @jean-luc Link to comment Share on other sites More sharing options...
tulpa001 February 28, 2017 Share February 28, 2017 I've scrolled through some of the threads you've posted in multiple times. You still have the same image on each post. Host comments in italics. Tulpa's log. Tulpa's guide. Link to comment Share on other sites More sharing options...
jean-luc February 28, 2017 Author Share February 28, 2017 I've scrolled through some of the threads you've posted in multiple times. You still have the same image on each post. Right, unfortunately I cannot make it use different urls for each post, I can only do it for images within a post. I don't visit as often as I used to. If you want me to see something, make sure to quote a post of mine or ping me @jean-luc Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.