I'm looking for a random quote script for my website?
So I've got a very large numbered list of quotes. I want to set up a little text thing on my website's homepage so it displays a randomly selected quote from the list which changes every day. Can anyone write me a script to do this? I had one, but it stopped working and no one's been able to help me fix it (I've tried to get help with that more times than I care to remember) and I decided that it would be better to just get a new script.
I have a random script, but it also seems to not be working the way it was originally written, it now outputs a number 1 along with the intended output.
Take a peek here, there is a rotator script I am about to use on a site I am workng on.
http://www.marcofolio.net/
Gary
Similar Messages
-
Suggestions for simple random image script
Would like to randomly display one of five new JPG banner each time page is loaded.
Your experience would be appreciated.
ThanksSince no one replied, I am posting solution I found.for future inquiries.
Simple PHP Random Image Script
This can be done in one line of text directly in your HTML and a collection of images.
The first step is to gather together the images you wish to have randomly rotated.
Change all of their file names to a numerical order, starting with the number 1.
* 1.jpg
* 2.jpg
* 3.jpg
* 4.jpg
Be sure each image has the same extension (either all jpg, png, or gif),
and that there are no gaps in the numbers.
Also, place these images in their own folder to keep everything organized.
Write the Code
In the HTML of your page, insert the following code where you want an image to display:
<img src="path/<?php echo rand(1,n);?>.jpg" alt="Random Image" />
The “rand” operator will display a randomly generated number between 1 and ‘n’.
Change ‘n’ to the total amount of pictures you have arranged numerically
(or the highest numbered picture you have).
In the example above I only have 4 pictures, therefor I would change it to: rand(1,4); -
Tutorial announcement .:: Building Random Quote Script ::.
Hello everyone...
today in this tutorial we will make an easy and fast :: random quote application :: this application will help you to retrieve random data from your database, text, images, links, with un sorted order.
if you have very large number of records in your database and hardly find the way to sort them, the best way is to randomly view it.
this application contains:
1- Insert new record to the database.
2- view random text each time you refresh your page.
:: Go to tutorial ::
:: Online Demo ::Hi Purple Edge,
it would be great if you could figure out a way to determine file size before attempting an upload.
PHP can only access file data (e.g. size) after it´s been uploaded -- one would have to use Flash for this, as this technology is indeed capable to check such data immediately.
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver -
A simple script for you, a giant script for me-
I like scripts very much but scripting does not seems to like me! Can anyone help me and write a script for me? What I need is this:
1. Ungroup everything in a spread
2. A loop that goes through every text frame in the spread and, at the end of the text contained in each of those frames inserts a blank paragraph. (The frames contains text and inline graphics)
This may seems strange but is what I need.
Best regards and thank you in advance
MariaI like scripts very much but scripting does not seems to like me! Can anyone help me and write a script for me? What I need is this:
It's much easier for you to show us what you have and then we'll fix it for you or tell you what is wrong. Then you'll learn something to!
1. Ungroup everything in a spread
This one's easy -- unless you're worried about groups inside groups?
app.activeWindow.activeSpread.groups.everyItem().ungroup()
If it's groups all-the-way-down, on the other hand, well, it might be more than one line... -
Looking for the adjoin.sh script for LDAP. `
Anyone have a link to download?
Thanks,
BradChris, have you googled on XML and weather conditions? I
think you also could find more detailed information through weather
dot com by looking down for "developers" if I remember this
correctly. But you can take a look at weather-related websites and
they usually give you pretty much fundmental self-explantory simple
instructions on how to set it up on your website.
quote:
Originally posted by:
Newsgroup User
First and foremost this probably isn't the right forum to
post such a topic
in but everyone in this forum is so helpful to me that it
just made more
sense. Anyhow I would like to get an XML feed from
weather.com to put on
this site I am building so I can allow users to view the
weather conditions
for wherever they choose. I am certainly not an XML
programmer and even
though I have weather.com's software development kit for
there XML data
feeds on the weather I think it would take me forever to
create something
right? Anyhow I use PHP on my server and I'm wondering if
anyone knows of
any good pre-made scripts to allow me to easily add the XML
weather to my
site...
Thanks!
Chris Jumonville -
Looking for Federal Financials Test Scripts for R12 or 11i
Hello, we are under the gun to finish test scripts by 30 April 09. I have created several standard test scripts, but need scripts on the Federal Financials side (i.e. appropriations, apportionments, re-apportionments, allotments, transfers, IPAC, SF224, FACTS I & II, SF 133)
Please send any scripts you might have to [email protected]
Thank you!
LisaMariePlease clarify that you are looking to test Oracle Forms.
-
Can anyone please point me at a javascript that will display
a random quote
when the page is loaded?You miss the point bonehead. What I meant was, surely amongst
this vast
experienced community, some of these coders have experience
with a script as
requested; I was asking for pointers to those specifically,
as it would have
been about as much typing to say "go to www.whatever.com to
look at this one
I've used" as to type "do a google search for it". Don't need
anyone to do
any work for me, just point me at scripts you've had actual
experience at.
Easy 'nuff to understand now?
"Walt F. Schaefer" <[email protected]> wrote in
message
news:f4nsbq$oe8$[email protected]..
> Yeah, I feel your pain Rachel. I too hate it when others
are too lazy to
do
> my work for me.
>
> --
>
> Walt
>
>
> "Rachael Caldwell" <[email protected]> wrote in
message
> news:f4mv46$mfq$[email protected]..
> > Yeah, I'm googling away, but was rather hoping that
those with
experience
> > with specific scripts would share, rather than just
get a lot of lazily
> > posted "do a google search" . . . thanks for this
pointer! : }
> >
> > "geschenk" <[email protected]>
wrote in message
> > news:f4ltjq$bn0$[email protected]..
> >> one example can be found
http://www.computerhope.com/j15.htm,
and
you?ll
> > find plenty of related stuff when googling for
"javascript random quote"
> >
> >
>
> -
Hello,
I'm looking for a simple eem script for enabling an SVI if its goes down. we have some issue is NX-OS running 6.0.2.(1) where we occure a SVI down for itself.
Regard
AdilUnfortunately, this is not possible on NX-OS. EEM on NX-OS is EEM by name only. The feature is very different than it is on IOS. What you could do is use an IOS box as a proxy. That is, send a trap using EEM from your NX-OS box, then have IOS do the telnet to the other NX-OS box to perform the necessary commands.
-
Tool Bar script for generating Email
Hi experts,
I have made the following script for sending a custom email.
And i've the required jar files in the ftp drive on the same server where E-sourcing is installed.
If anyone can look at this code and tell me whats wrong with it, i'll be realy grateful .
addClassPath("D:/FTPHOME/MailJar/activation.jar");
addClassPath("D:/FTPHOME/MailJar/javac.mail.jar");
addClassPath("D:/FTPHOME/MailJar/mail.jar");
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
// Recipient's email ID needs to be mentioned.
String to = "Email add of recipient";
// Sender's email ID needs to be mentioned
String from = "Email add of sender";
// Assuming you are sending email from localhost
String host = "IP address of the host ";
// Get system properties
Properties properties = System.getProperties();
// Setup mail server
properties.setProperty("mail.smtp.host", host);
// Get the default Session object.
Session session1 = Session.getDefaultInstance(properties);
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session1);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set Subject: header field
message.setSubject("This is the Subject Line!");
// Now set the actual message
message.setText("This is actual message");
// Send message
try{
Transport.send(message);
catch(Exception e)
print(e);
Thanks,
AbhijitI'd like to get from somewhere Oracle tool for
generating simple SQL script for generating table,
indexes, constraint (like Toad) and it has to be
Oracle tool but not Designer.
SQL Developer is similar to Toad and is an Oracle tool.
http://www.oracle.com/technology/products/database/sql_developer/index.html -
Script for Free Space in Datafiles
Hi
Got the below script from metalink [130866.1] to identify free space within a data file.Couple of questions
1)Is dba_Free_Space an exact indicator of how much space is available in a file.
2) What is the significance of using blocks in vs using bytes.
cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;
Thanks in advance for you help.
Script for checking backwards for free space at end of file
REM Script is meant for Oracle version 9 and higher
REM -----------------------------------------------
set serveroutput on
exec dbms_output.enable(1000000);
declare
cursor c_dbfile is
select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
from dba_data_files f,
dba_tablespaces t
where f.tablespace_name = t.tablespace_name
and t.status = 'ONLINE'
order by f.tablespace_name,f.file_id;
cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;
/* variables to check settings/values */
dummy number;
checkval varchar2(10);
block_correction number;
/* running variable to show (possible) end-of-file */
file_min_block number;
/* variables to check if recycle_bin is on and if extent as checked is in ... */
recycle_bin boolean:=false;
extent_in_recycle_bin boolean;
/* exception handler needed for non-existing tables note:344940.1 */
sqlstr varchar2(100);
table_does_not_exist exception;
pragma exception_init(table_does_not_exist,-942);
begin
/* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
begin
select value into checkval from v$parameter where name = 'recyclebin';
if checkval = 'on'
then
recycle_bin := true;
end if;
exception
when no_data_found
then
recycle_bin := false;
end;
/* main loop */
for c_file in c_dbfile
loop
/* initialization of loop variables */
dummy :=0;
extent_in_recycle_bin := false;
file_min_block := c_file.blocks;
begin
<<check_free>>
for c_free in c_freespace(c_file.file_id)
loop
/* if blocks is an uneven value there is a need to correct with -1 to compare with end-of-file which is even */
block_correction := (0-mod(c_free.max_block,2));
if file_min_block = c_free.max_block+block_correction
then
/* free extent is at end so file can be resized */
file_min_block := c_free.block_id;
else
/* no more free extent at end of file, file cannot be further resized */
exit check_free;
end if;
end loop;
end;
/* check if file can be resized, minimal size of file 16 blocks */
if (file_min_block = c_file.blocks) or (c_file.blocks <= 16)
then
dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('cannot be resized no free extents found');
dbms_output.put_line('.');
else
/* file needs minimal no of blocks which does vary over versions */
if file_min_block < 16
then
file_min_block := 16;
end if;
dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');
/* below is only true if recyclebin is on */
if recycle_bin
then
begin
sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
execute immediate sqlstr into dummy;
if dummy > 0
then
dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
end if;
exception
when no_data_found
then null;
when table_does_not_exist
then null;
end;
end if;
dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');
dbms_output.put_line('.');
end if;
end loop;
end;
Example output for Oracle version 9 and higher:
Tablespace: TEST Datafile: /oradata/v112/test01.dbf
cannot be resized no free extents found
Tablespace: UNDOTBS1 Datafile: /oradata/v112/undotbs01.dbf
current size: 9384960K can be resized to: 106496K (reduction of: 98.87 %)
SQL> alter database datafile '/oradata/v112/undotbs01.dbf' resize 106496K;
Tablespace: USERS Datafile: /oradata/v112/users01.dbf
current size: 328960K can be resized to: 117248K (reduction of: 64.36 %)
Extents found in recyclebin for above file/tablespace
Implying that purge of recyclebin might be needed in order to resize
SQL> purge tablespace USERS;
SQL> alter database datafile '/oradata/v112/users01.dbf' resize 117248KHi
Got the below script from metalink [130866.1] to identify free space within a data file.Couple of questions
1)Is dba_Free_Space an exact indicator of how much space is available in a file.
2) What is the significance of using blocks in vs using bytes.
cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;
Thanks in advance for you help.
Script for checking backwards for free space at end of file
REM Script is meant for Oracle version 9 and higher
REM -----------------------------------------------
set serveroutput on
exec dbms_output.enable(1000000);
declare
cursor c_dbfile is
select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
from dba_data_files f,
dba_tablespaces t
where f.tablespace_name = t.tablespace_name
and t.status = 'ONLINE'
order by f.tablespace_name,f.file_id;
cursor c_freespace(v_file_id in number) is
select block_id, block_id+blocks max_block
from dba_free_space
where file_id = v_file_id
order by block_id desc;
/* variables to check settings/values */
dummy number;
checkval varchar2(10);
block_correction number;
/* running variable to show (possible) end-of-file */
file_min_block number;
/* variables to check if recycle_bin is on and if extent as checked is in ... */
recycle_bin boolean:=false;
extent_in_recycle_bin boolean;
/* exception handler needed for non-existing tables note:344940.1 */
sqlstr varchar2(100);
table_does_not_exist exception;
pragma exception_init(table_does_not_exist,-942);
begin
/* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
begin
select value into checkval from v$parameter where name = 'recyclebin';
if checkval = 'on'
then
recycle_bin := true;
end if;
exception
when no_data_found
then
recycle_bin := false;
end;
/* main loop */
for c_file in c_dbfile
loop
/* initialization of loop variables */
dummy :=0;
extent_in_recycle_bin := false;
file_min_block := c_file.blocks;
begin
<<check_free>>
for c_free in c_freespace(c_file.file_id)
loop
/* if blocks is an uneven value there is a need to correct with -1 to compare with end-of-file which is even */
block_correction := (0-mod(c_free.max_block,2));
if file_min_block = c_free.max_block+block_correction
then
/* free extent is at end so file can be resized */
file_min_block := c_free.block_id;
else
/* no more free extent at end of file, file cannot be further resized */
exit check_free;
end if;
end loop;
end;
/* check if file can be resized, minimal size of file 16 blocks */
if (file_min_block = c_file.blocks) or (c_file.blocks <= 16)
then
dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('cannot be resized no free extents found');
dbms_output.put_line('.');
else
/* file needs minimal no of blocks which does vary over versions */
if file_min_block < 16
then
file_min_block := 16;
end if;
dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');
/* below is only true if recyclebin is on */
if recycle_bin
then
begin
sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
execute immediate sqlstr into dummy;
if dummy > 0
then
dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
end if;
exception
when no_data_found
then null;
when table_does_not_exist
then null;
end;
end if;
dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');
dbms_output.put_line('.');
end if;
end loop;
end;
Example output for Oracle version 9 and higher:
Tablespace: TEST Datafile: /oradata/v112/test01.dbf
cannot be resized no free extents found
Tablespace: UNDOTBS1 Datafile: /oradata/v112/undotbs01.dbf
current size: 9384960K can be resized to: 106496K (reduction of: 98.87 %)
SQL> alter database datafile '/oradata/v112/undotbs01.dbf' resize 106496K;
Tablespace: USERS Datafile: /oradata/v112/users01.dbf
current size: 328960K can be resized to: 117248K (reduction of: 64.36 %)
Extents found in recyclebin for above file/tablespace
Implying that purge of recyclebin might be needed in order to resize
SQL> purge tablespace USERS;
SQL> alter database datafile '/oradata/v112/users01.dbf' resize 117248K -
Hello,
Can anybody let me know if it is possible to enable document management for entities through PowerShell script for Dynamic CRM 2013 on premises.
I want power shall script where user will give the entity (Accounts, Contacts etc.) for the CRM.
The script should enable the document management for the entity.
Thank you for your support.Hi Jeff,
Any updates? If you have any other questions, please feel free to let me know.
A little clarification to the script:
function _ErrObject{
Param($name,
$errStatus
If(!$err){
Write-Host "error detected"
$script:err = $True
$ErrObject = New-Object -TypeName PSObject
$Errobject | Add-Member -Name 'Name' -MemberType Noteproperty -Value $Name
$Errobject | Add-Member -Name 'Comment' -MemberType Noteproperty -Value $errStatus
$script:ErrOutput += $ErrObject
$errOutput = @()
_ErrObject Name, "Missing External Email Address"
$errOutput
_ErrObject Name "Missing External Email Address"
$errOutput
If you have any feedback on our support, please click here.
Best Regards,
Anna Wang
TechNet Community Support -
How to get SQL script for generating table, constraint, indexes?
I'd like to get from somewhere Oracle tool for generating simple SQL script for generating table, indexes, constraint (like Toad) and it has to be Oracle tool but not Designer.
Can someone give me some edvice?
Thanks!
m.I'd like to get from somewhere Oracle tool for
generating simple SQL script for generating table,
indexes, constraint (like Toad) and it has to be
Oracle tool but not Designer.
SQL Developer is similar to Toad and is an Oracle tool.
http://www.oracle.com/technology/products/database/sql_developer/index.html -
Hi All,
i got this following requiring requirement for the modifying a script for packing list,
this is the logic i have to include:
b. Remove the carton ID & box ID from the print out, the line item should just print the total delivery quantity, do not split the printing by different box ID or carton ID.
<b>i. Delivery Item= LIPS-POSNR
ii. Delivery Qty for Item = LIPSD-G_LFIMG= LIPSD-PIKMG</b>
<b>c. Add Total Boxes for each item, this should be a calculation field for each material HUMV4-MATNR, count how many handling unit VEKPVB-EXIDV has been used to pack the same material , output the total boxes for each delivery item.
</b>d. <b>Add Gross Weight for each item , retrieve data from LIPS-BRGEW</b>
e. Add Net weight to the print out, below the gross weight retrieve data from LIKP-NTGEW
f. For Net Weight & Gross Weight all convert to KG before output on the print out
can any body help me what the exact bussiness flow i have to follow and any necessary hints on this
Message was edited by:
ram gHi Ram,
You have to take the help of the functional consultant also and take the printout of the existing form for the packing list and note down all the changes to be done on the hard copy taken first.
then search in the script for the respective windows and for the respective fields in textelements of the script
One delivery may have multiple Handling Units
the link is VEPO-VBELN = LIPS-VBELN
from HU item table VEPO take the delivery no and link it with LIPS and LIKP table
What I understood is In Packing list the present data is coming from Delivery
but they wants to print certain things based on delivery and certain based on Handling Unit data
1.Remove the HU number from the print(Box id)-VEKP-EXIDV
2.Qty is printing based on HU remove that
now just print the qty based on delivery(sum of all items LIPS-LFIMG)
3. Add total boxes for each item(means no of HU's for each Delivery)
4. Take the Item wise gross weight from LIPS (brgew)
5.Take netweight from LIKP
6.Convert the unit of the Weight to KG
using a fun module UNIT_CONVERSION_SIMPLE
There may be already data fetching from the respective tables in the script check for the same and use
Otherwise to write the code you have to use the external subroutines to write some small program if extra coding is required to get the data from other tables
Hope this helps
Regards
Anji -
A script for setting a random wallpaper
I've cooked up this small bash script for changing the wallpaper to a random one from a specified directory (it is recursive)
The script tries to be smart in determining whether the wallpaper should be scaled, centered or tiled.
Just configure it and try it out.
Anyway, here goes:
#!/bin/bash
# Random wallpaper setter, by moljac024
# Configuration
# Wallpaper directory
wpDir="$HOME/Wallpapers"
# Wallpaper list path
wpList=$HOME/.wallpaper-list
# Folders to be skipped, you can put as many as you like
#wpSkip=("Dir1/" "Dir2/")
# Scale images that have a lower resolution than that of the screen (yes or no)
scaleLowerRes="yes"
#scaleLowerRes="no"
# Screen resolution
resWidth=1280
resHeight=800
# Command for tiling the wallpaper
cmdTile="feh --bg-tile"
#cmdTile="nitrogen --set-tiled --save"OA
#cmdTile="xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-style -s 2 && xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s"
#cmdTile="gconftool-2 -t str --set /desktop/gnome/background/picture_options "wallpaper" -t str --set /desktop/gnome/background/picture_filename"
# Command for scaling the wallpaper
cmdScale="feh --bg-scale"
#cmdScale="nitrogen --set-scaled --save"
#cmdScale="xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-style -s 3 && xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s"
#cmdScale="gconftool-2 -t str --set /desktop/gnome/background/picture_options "zoom" -t str --set /desktop/gnome/background/picture_filename"
# Command for centering the wallpaper
cmdCenter="feh --bg-center"
#cmdCenter="nitrogen --set-centered --save"
#cmdCenter="xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-style -s 1 && xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s"
#cmdCenter="gconftool-2 -t str --set /desktop/gnome/background/picture_options "centered" -t str --set /desktop/gnome/background/picture_filename"
# End of configuration
setTiled ()
`$cmdTile "$1"`
if [ "$?" = "0" ]; then
echo "Wallpaper tiled."
else
echo "Wallpaper not set!"
exit 1
fi
setScaled ()
`$cmdScale "$1"`
if [ "$?" = "0" ]; then
echo "Wallpaper scaled."
else
echo "Wallpaper not set!"
exit 1
fi
setCentered ()
`$cmdCenter "$1"`
if [ "$?" = "0" ]; then
echo "Wallpaper centered."
else
echo "Wallpaper not set!"
exit 1
fi
createList ()
# Go to the wallpaper directory
cd "$wpDir"
# Load the list of pictures to a variable
wpDirList=`(find . -regex ".*\([jJ][pP][gG]\|[jJ][pP][eE][gG]\|[gG][iI][fF]\|[pP][nN][gG]\|[bB][mM][pP]\)$" -type f)`
# Save the list to disk
if [[ ( -w "$wpList" ) ]]; then
echo -n "$wpDirList" > "$wpList"
# Filter out unwanted folders
if [[ "$dontSkip" == "false" ]]; then
for dir in "${wpSkip[@]}"
do
grep -Ev "$dir" "$wpList" > ~/.wallpapers-tmpr; mv ~/.wallpapers-tmpr "$wpList"
done
fi
# Output result
echo "Wallpaper list saved."
else
echo "Can't write wallpaper list, aborting!"
exit 1
fi
getImage ()
# Count number of pictures in the wallpaper list by counting number of lines.
# Check if the wallpaper list exists, is not empty and we have read persmission on it
if [[ ( -s "$wpList" && -f "$wpList" ) && -r "$wpList" ]]
then
wpListNumber=$(wc -l < "$wpList")
else
echo "Can't read wallpaper list, aborting!";
exit 1
fi
# Counter for bad entries in wallpaper list
badMax=100
while true; do
# Get a seed for the random number generator from /dev/urandom
SEED=$(head -1 /dev/urandom | od -N 1 | awk '{ print $2 }')
RANDOM=$SEED
# Find a random line number in the wallpaper list
# Random number from 1..n.
#r=$((RANDOM % $wpListNumber + 1))
r=$(echo $RANDOM%"$wpListNumber"+1 | bc)
# Print what the line number is
# Print the r'th line.
imgPath=`sed -n "$r{p;q;}" "$wpList"`
# #./ crops that substring but it doesn't matter if it left there
wpPath="${wpDir}${imgPath#./}"
# Check if the chosen file exists
if [ -f "$wpPath" ]; then
break
else
echo -e ""$wpPath": doesn't exist!\n"
badMax=$(( $badMax - 1 ))
if [ "$badMax" == "0" ]; then
echo "Too many non-valid entries found in wallpaper list, aborting!"
exit 1
else echo "Choosing new image..."
fi
continue
fi
done
# Calculate size and aspect for chosen image and print out information
imgHeight=$(identify -format "%h" "$wpPath")
imgWidth=$(identify -format "%w" "$wpPath")
imgAspect=$(echo "scale=1; "$imgWidth"/"$imgHeight"" | bc)
echo -e "Image: "$wpPath"\n"
echo -e "Resolution: "$imgWidth"x"$imgHeight""
echo -e "Aspect: "$imgAspect":1\n"
setWallpaper ()
# Calculate resolution aspect ratio
resAspect=$(echo "scale=1; "$resWidth"/"$resHeight"" | bc)
# If the image is smaller than the resolution and is not a tile then scale it, otherwise look at aspect
if [[ ("$scaleLowerRes" == "yes") && ( "$imgAspect" != "1.0" && ("$imgWidth" -lt "$resWidth" || "$imgHeight" -lt "$resHeight") ) ]]
then
setScaled "$wpPath"
else
case $imgAspect in
1.0)
setTiled "$wpPath"
1.5 | 1.6 | 1.7 | 1.8)
if [[ "$resAspect" < "1.5" ]]; then
setCentered "$wpPath"
else
setScaled "$wpPath"
fi
if [[ "$resAspect" < "1.5" ]]; then
setScaled "$wpPath"
else
setCentered "$wpPath"
fi
esac
fi
checkConfig ()
# Initial errors
errorsPresent="no"
dontSkip="false"
# Check if all variables are set
if [[ !( ( -n "$wpDir" ) && ( -n "$wpList" ) && ( -n "$resWidth" ) && ( -n "$resHeight" ) && ( -n "$scaleLowerRes" ) && ( -n "$cmdTile" ) && ( -n "$cmdScale" ) && ( -n "$cmdCenter" ) ) ]]
then
echo -e "\nOne or more options not set, aborting!"
exit 1
fi
# Check if there is a trailing backslash in the wallpaper directory
spDir=`echo -n "$wpDir" | tail -c -1`
if [[ !( "$spDir" == "/" ) ]]
then
wpDir=""$wpDir"/"
fi
# Check if there is read permission on wallpaper directory and if it is a directory
if [[ !( ( -r "$wpDir" ) && ( -d "$wpDir" ) ) ]]
then
echo "Can't read wallpaper directory!"
errorsPresent="yes"
fi
# Check if the specified wallpaper list is a regular file and not a directory
touch "$wpList" &> /dev/null
if [[ ( -d "$wpList" ) ]]
then
echo "Specified wallpaper list is a directory, not a file!"
errorsPresent="yes"
fi
# Check if variables are set correctly
if [[ !( "$scaleLowerRes" == "yes" || "$scaleLowerRes" == "no" ) ]]
then
echo "Specified option for scaling the wallpaper is not valid!"
errorsPresent="yes"
fi
if $(echo ""$resWidth"" | grep [^0-9] &>/dev/null)
then
echo "Specified resolution width is not a number!"
errorsPresent="yes"
fi
if $(echo ""$resHeight"" | grep [^0-9] &>/dev/null)
then
echo "Specified resolution height is not a number!"
errorsPresent="yes"
fi
# Check if any of the tests failed
if [[ "$errorsPresent" == "yes" ]]
then
echo -e "\nOne or more errors found, aborting!"
exit 1
fi
ignoreWPSkip()
dontSkip="true"
printUsage ()
echo -e "Invalid command line argument(s)!\nUsage:\n"
echo -e "`basename "$0"` [options]\n"
echo -e "Options:\n"
echo -e "-s | --set \tSet a wallpaper without updating the list"
echo -e "-u | --update \tUpdate the list without setting a wallpaper"
echo -e "-ua | --update-all\tUpdate the list without setting a wallpaper, but don't skip any folders"
echo -e "-su | --set-update\tUpdate the list and set a wallpaper"
exit 1
if [ "$#" == "1" ]; then
case "$1" in
"-s" | "--set")
checkConfig
getImage
setWallpaper
exit 0
"-u" | "--update")
checkConfig
createList
exit 0
"-ua" | "--update-all")
checkConfig
ignoreWPSkip
createList
exit 0
"-su" | "--set-update")
checkConfig
createList
getImage
setWallpaper
exit 0
printUsage
exit 1
esac
else
printUsage
exit 1
fi
Last edited by moljac024 (2009-09-14 21:02:13)I did something similar a couple of months ago, but instead of attempting to be clever and guessing what the background image is supposed to be, I just write it in the filename. Since some pictures just end up being too bright (or whatever) when used as a background to a urxvt terminal, I added some extra parameters for setting gamma, brightness, tint and the direction the image should be rendered. It relies on hsetroot for actually rendering the picture.
#!/usr/bin/python
# set-background
import sys, os, string, re
patterns = [ (re.compile("t-([a-f\d]+)"), lambda x: "-tint \#" + x)
, (re.compile("b-([\d]+)"), lambda x: "-brightness -0." + x)
, (re.compile("g-([\d]+)"), lambda x: "-gamma "+ x)
, (re.compile("f-(v|h|d)"), lambda x: "-flip" + x)
def buildCommand(file):
output = ["hsetroot"]
output.append("-" + (string.split(file,".")[-2]))
output.append(file)
for token in string.split(file,".")[1:-2]:
for (pat,f) in patterns:
if pat.match(token):
output.append( f(pat.findall(token)[0]))
return string.join(output)
print buildCommand(img)
os.system(buildCommand(img))
# vim:set et:
So for instance, an image with the name background.t-704214.f-v.full.jpg would be rendered as a stretched image, flipped vertically with a sepia tint. The files are required to be in the following format NAME.(MODIFIER.)*TYPE.SUFFIX, where the the order and number of modifiers are unimportant. The gamma values are somewhat unintuitive, but I guess you'll just have to play around with it to get it right.
And to randomize the whole thing, I just used the following script in my .xinitrc to randomly pick a image from a folder.
#!/bin/bash
bg_folder="$HOME/.backgrounds";
pics=($(ls $bg_folder))
let "n = $RANDOM % ${#pics[@]}"
(cd $bg_folder; set-background ${pics[$n]}) -
- Looking for Drop Down menu script w/ semi-transparent backgrounds...
Looking for a dropdown menu script that will allow
semi-transparent
backgrounds (so we can partly see what the list is displaying
over).
I've Googled this to death using all the obvious keywords,
but have yet to
find what I'm looking for.
Thanks.Yes. I understand and agree. Good point.
Thanks.
Al Sparber - PVII
http://www.projectseven.com
Extending Dreamweaver - Nav Systems | Galleries | Widgets
Authors: "42nd Street: Mastering the Art of CSS Design"
"T.Pastrana - 4Level" <[email protected]> wrote in message
news:[email protected]...
>I posted mainly for the benefit of Reese, I know you know
this.
>
>
> --
> Best Regards,
> ..Trent Pastrana
> www.fourlevel.com
>
>
>
>
>
>
> "Al Sparber- PVII" <[email protected]>
wrote in message
> news:[email protected]...
>> Actually, it's not an error. But we do happen to
have it in a CC on
>> that page because the last time I posted that page
on this forum it
>> was criticized for "failing" the W3C CSS validator.
>>
>>
http://www.projectseven.com/foxy.gif
>>
>> The Firefox console simply would report it as a
warning - not an
>> error. It would have no affect on the page. But
thanks for pointing
>> that out.
>>
>> --
>> Al Sparber - PVII
>>
http://www.projectseven.com
>> Extending Dreamweaver - Nav Systems | Galleries |
Widgets
>> Authors: "42nd Street: Mastering the Art of CSS
Design"
>>
>>
>>
>>
>> "T.Pastrana - 4Level" <[email protected]> wrote in
message
>> news:[email protected]...
>>> If you want your page to validate you might want
to separate the
>>> properties. Some modern browsers like Firefox
will throw an error
>>> with the filter property.
>>>
>>> #menu li {
>>> opacity: 0.85;
>>> }
>>>
>>> <!--[if IE]><style
type="text/css">#menu li {filter:
>>>
alpha(opacity=85);}</style><![endif]-->
>>>
>>>
>>> --
>>> Best Regards,
>>> ..Trent Pastrana
>>> www.fourlevel.com
>>>
>>>
>>>
>>>
>>> "Al Sparber- PVII"
<[email protected]> wrote in message
>>> news:[email protected]...
>>>> If, for example, you are using an unordered
list for your menu, set
>>>> opacity on the LI, like so:
>>>>
>>>> #menu li {
>>>> opacity: 0.85;
>>>> filter: alpha(opacity=85);
>>>> }
>>>>
>>>> As far as I know, there are no
"off-the-shelf" menu tools of worth
>>>> that offer this as an automatic option. You
should pick yourself a
>>>> good menu system then set opacity on the
relevant element. The
>>>> menu "script" or "system" really has nothing
to do with it.
>>>>
>>>> If you need a good base menu system, you can
find free ones and
>>>> commercial ones on our site. Here is an
example of one with
>>>> transparency:
>>>>
>>>>
http://www.projectseven.com/products/menusystems/pmm/css_tweaks/opacity/
>>>>
>>>>
>>>>
>>>> --
>>>> Al Sparber - PVII
>>>>
http://www.projectseven.com
>>>> Extending Dreamweaver - Nav Systems |
Galleries | Widgets
>>>> Authors: "42nd Street: Mastering the Art of
CSS Design"
>>>>
>>>>
>>>>
>>>>
>>>> "Reese" <[email protected]> wrote in message
>>>> news:[email protected]...
>>>>> Looking for a dropdown menu script that
will allow
>>>>> semi-transparent backgrounds (so we can
partly see what the list
>>>>> is displaying over).
>>>>>
>>>>> I've Googled this to death using all the
obvious keywords, but
>>>>> have yet to find what I'm looking for.
>>>>>
>>>>> Thanks.
>>>>>
>>>>
>>>
>>>
>>
>
>
Maybe you are looking for
-
Whenever this happens, I have been able to click "deny" and it has gone away. However, when trying to play a game on Facebook, it will not go away and allow me to play the game. How do I get rid of this little message? Looks like I'm being hacked as
-
Two questions about my new Mac Pro
Just got my new Mac Pro up and running and have two questions (issues) First, I had to buy the DVI to ADC Display adapter to hook up my Cinema Display but now I can't turn the computer on from the monitor like I use to. Is that right? It's no big dea
-
I can't sign in to iCloud on my computer but can on my phone.
Hello to all. Starting friday when i did a clean install i tried to sign in to icloud. It gave me an error which can be found here. Http://Tinypaste.Com/ece6d1dc i then checked that all of my stuff was correct by signing in to apple store and oth
-
Copy/Cut/Paste is not available in Mozilla and Firefox. Do you want more information about this issue? Yes!
-
Where can i find Old Value?
When i edit user and i save it, everytime IDM shows me the changes of the user's variables, there are columns Old Value and New Value. In a Workflow i want to access to these Old Value variables and manipulate it.