How does this script generate a random image? - image

I found this script by accident: http://lorempixel.com/250/250/business/?a=7
But I have zero idea how it works. There is nothings in the code. If I try to save the page I only get the image save pop up. Can someone give me a hint, because this is absolutely fantastic!

In the code I found this line:
img ...(some crapy css styles)... src="http://lorempixel.com/250/250/business/?a=7"
So, how it works:
You choose a size and category of pictures (adress shows that you are navigating to folders "250", "250" and then "businnes", I guess the numbers stand for the size.
Then, in this folder, lays a script that returns an image, you are passing parameter "7" into it, it can stand for a visitor ID, or it just represents some seed for the generator.
The script generates some random number and returns image associated with this number (you can imagine there's a 1000 of JPEGs named 1.jpg, 2.jpg and so on). Alternatively, it asks some search engine for pictures that matches those criteria (size, category) and returns them (again, "show me picture numer x after searching for business category and certain size").
Thing that can be confusing tho is, even refreshing the page with the same parameter (in this case 7), causes the page to load different pictures. Perhabs it remembers recently shown pictures for a specified IP number or something that identificates you (f.e. session ID stored in a cookie) and prevents the page from loading the same pictures), or the randomizing algorithim can be built in a way that it's very unprobable to get the same outcome even with the same seed or parameter (imagine you are adding numbers of miliseconds from now since last Monday, it constantly changes, right?).

you can have an array of image names perhaps. Each time you open the page, a random number from 0 to size of the array is generated. And the display the page with the name in the element of the array, with the random index?
say you have an array with 3 names: pic1.png pic2.jpg pic3.gif.
have a var pic=array[Math.floor(3*Math.random())];
and a img src=pic;

Related

BIRT - How to List the Contents of Page Variable

I have a report with page variable implemented to display current/total page numbers for each customer. I have another requirement - Display a list of customer names and the respective page numbers contained in the report on the last page of the report(such as Company A - 3 pages, Company B - 4 pages).
It has to be proper looking with border lines.
I was able to implement the page variable by simply borrowing the code I've found on the Internet, but have no idea how to display the contents(customer names and page numbers) as a list at the end of the report.
Would someone help me to accomplish this requirement?
I don't think this is possible with BIRT.
In similar cases, and only for the special case of PDF output, we are using a post-processing approach, but it requires Java programming:
First, we let BIRT generate Table-of-Content entries ("outline" in PDF speech) for the companies.
The second-step is post-processing: we read the PDF using iText and examine the TOC. That way we get the information about which company starts at which page number. Together with the total page number it is easy to compute how many pages each company takes.
Then iText can generate and add a visible TOC (as you described) to the PDF.

limiting the number of images you can upload

UPDATED QUESTION
OK new idea.
.on('deleteComplete', function(event, id, fileName, responseJSON) {
}
how can I call the sessionRequestComplete function. I think this might "refresh" the array and solve this issue.
Matt
I am trying to limit the number of images a person can upload.
I also need to include the ability to have the orginal file plus two scaled images.
When I tired to use the
validation: {
itemLimit:6
}
option I needed to triple the number of items since I was have the system upload three images.
I got this all to work but the issue I am having is if I delete an image and then add a new image and to this a couple of times, the system will then alert me that I have exceeded the itemlimit.
is there a way to "refresh" the items in the current session of the uploader in the deleteComplete function.
thanks.
Matt
The itemLimit validation rule is quite literal. You'll need to keep this in mind when you determine a proper number. if you are using it with scaled image generation turned on.
If you are looking to adjust this value dynamically, or expect it to work differently, please open up a feature request.

Automatically assign profile pics to pages in phpfox

Followed by my last question: Automatically create pages in phpfox
Now I'm trying to assign a list of pre-uploaded images to some pages as their profile picture in phpfox.
After checking data changes in the database, I only realized changes in these two fields:
image_path in table of phpfox_pages (which take a an address to the image file)
user_image in table of phpfox_user (which take a string of "user_id+%s".file_extension)
But by inserting data in these two fields in records for a page that has a default profile pic, it's profile pic would not change.
Is there any other fields or options that I should change?
Look at the file /module/pages/include/service/process.class.php In there look for the function update and around line 442 find this
if ($this->_bHasImage)
This piece of code handles setting an image for the page, notice how it creates three thumbnails, maybe the problem you're having is that you didn't create all the needed thumbs. You also need to update the column image_server_id.
Hope it helps
look phpfox_photo table in that you will find is_profile_photo attribute that is always 1 for the profile picture

selecting a page content in apple script

I want to go through a MS Word document page by page and generate images of all pages. I am stuck in the very beginning. Although I can compute total number of pages I cannot get the content of say page 1 into selection object.
I want something like
select page 1 of active document
or
set myRange to create range active document page 1
or
create range active document start (start of page 1) end (end of page 1)
Of course I have the page count and I want to loop on it and generate images page by page but please help me first to get page content into a selection object so that I can proceed.
If anybody has some other idea of accomplishing the job them I am all for it.
I have solved it.
The steps are.
Convert word document to pdf through apple script.
Make a work flow in automater to render pdf as images.
Call the word flow through shell command from apple script.
I will make a tutorial in few days and post some where.

Facebook Game Function, Optimizin a Call, and Loading Bar

I am attempting to make a Facebook game and trying to replicate a common function that I usually find in many other Facebook game (a call to my website and illusionary image that is a loading bar).
The function should do the following:
User clicks on Button
Animated Gif Appears (Loading Bar)
Button Update User's Status
Animated Gif Disappears
Facebook Canvas page is updated
The code I currently have can be found at <dead link>
I am having trouble thinking of Step 2 and 4.
I need to optimize Step 5.
To clarify what happens on Step 5. I have Box 1 which has my stats. And Box 2 which has my points. I click on Box 1. This should update Box 1 with 1 points, and update Box 2; minus a point. (Clicking on Box 1, concurrently update both boxes)
I have successfully done this, but it is quite slow. I was wondering if there are alternative way that may be faster than what I am currently doing.
Script Updated with Mark-up. <dead link>
I've found a quick way to optimize the call. Rather than querying for data that I already have query, I will be using the first query to grab most of my data rather than querying it when I update.
It would help greatly to see the document markup (XHTML) where you have your elements and the calls to your javascript functions.
For steps 2 and 4 I recommend using the visibility attribute rather than display, or having the loading bar in an fb:js-string and using elem.setInnerFbml when you begin loading and once you have your response data, simply update it to the new content (you don't need an explicit loading_finish function in this case).
In your get_skillpoint function, you set parameters in an object and then you specify the action parameter again in the URL you are posting to as a URL query param - you may end up with one value overwriting the other, depending on how you access these values on the server side. I would recommend using different names for these two parameters if they are not the same. Also, why are you trying to send separate GET and POST variable sets? You should put everything in the POST and simply leave out the URL query string. I vaguely remember losing data that way in the past (vaguely, mind you).
If you can post your markup I'll update my answer with any light it sheds on the problem. It might be slow simply because Facebook isn't blinding fast when it comes to FBJS and AJAX. Also, FBML being returned must be preprocessed in the FB proxy before your app gets it, which adds a bit of lag; it's a bit faster to return JSON and just pull the data needed out of it, then place the appropriate pieces into an existing element or make use of fb:js-string.

Resources