Script for "random quote"
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"
> >
> >
>
>
Similar Messages
-
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]}) -
Script for making random thumbnails from single image
Hi all,
I need something like a hundred different thumbnails from each image in a series of images, that is, hundred random sections of the same image, saved in a folder as jpg, and i was hoping that i could find a script for this.
What the script has to do is:
select the size of the crop (this would also be the dimensions of the thumbnail saved)
rotate crop selection in a random orientation and place the crop randomly on the canvas
save the image as a jpg in a folder
return to original image,
repeat process x times before quitting script.
I dont think this should be to difficult to make a script for, but unfortunately i don´t know how to code.
Is there anybody that could help me with this?
This would save me a lot of time!You can give this a try:
// create copies with pseudo random clipped and rotated parts of image;
// thanks to xbytor;
// 2012, use at your own risk;
#target photoshop
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// set name for folder to save jpgs to;
var folderName = "rotatedJpgs";
// set number of jpgs;
var theNumber = 100;
// width and height;
var theWidth = 500;
var theHeight = 500;
// calculate some values;
var theDiagonal = Math.sqrt ((theWidth * theWidth) + (theHeight * theHeight));
var diagAngle = angleFromRadians(Math.acos((theWidth) / (theDiagonal)));
// get file name and path;
var myDocument = app.activeDocument;
var docName = myDocument.name;
try {
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
var docPath = myDocument.path;
catch (e) {
basename = docName;
var docPath = "~/Desktop";
// create folder if it does not exist yet;
if (Folder(docPath + "/" + folderName).exists == true) {
var docPath = docPath + "/" + folderName;
else {
var theFolder = Folder(docPath + "/" + folderName).create();
var docPath = docPath + "/" + folderName;
// document dimensions;
var docWidth = myDocument.width;
var docHeight = myDocument.height;
// jpg options;
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 10;
jpegOptions.embedColorProfile = true;
jpegOptions.matte = MatteType.NONE;
// duplicate image;
var theCopy = myDocument.duplicate (theCopy, true);
var origResolution = theCopy.resolution;
theCopy.resizeImage(undefined, undefined, 72, ResampleMethod.NONE);
var docHalfWidth = theCopy.width / 2;
var docHalfHeight = theCopy.height / 2;
var theLayer = smartify2010(theCopy.layers[0]);
theCopy.resizeCanvas (theWidth, theHeight, AnchorPosition.MIDDLECENTER);
var theHistoryState = theCopy.activeHistoryState;
// do the variations;
for (var m = 0; m < theNumber; m++) {
var theAngle = Math.random() * 360;
theLayer.rotate (theAngle, AnchorPosition.MIDDLECENTER);
//theCopy.resizeCanvas (theWidth, theHeight, AnchorPosition.MIDDLECENTER);
// get tolerance offset;
var theHor1 = Math.abs(Math.cos(radiansOf(theAngle + diagAngle)) * theDiagonal / 2);
var theVer1 = Math.abs(Math.sin(radiansOf(theAngle + diagAngle)) * theDiagonal/ 2);
var theHor2 = Math.abs(Math.cos(radiansOf(theAngle - diagAngle)) * theDiagonal / 2);
var theVer2 = Math.abs(Math.sin(radiansOf(theAngle - diagAngle)) * theDiagonal / -2);
// calculate max offset for unrotated overall rectangle;
var thisHalfWidth = docHalfWidth - Math.max(theHor1, theHor2);
var thisHalfHeight = docHalfHeight - Math.max(theVer1, theVer2);
// calculate random offset for unrotated overall rectangle;
var randomX = thisHalfWidth * (Math.random() - 0.5) * 2;
var randomY = thisHalfHeight * (Math.random() - 0.5) * 2;
var aDiag = Math.sqrt (randomX * randomX + randomY * randomY);
var anAngle = angleFromRadians(Math.asin((randomY) / (aDiag))) + theAngle;
anAngle = anAngle + Math.floor(Math.random() * 2) * 180;
// calculate offset for rotated overall rectangle;
var offsetX = Math.cos(radiansOf(anAngle)) * aDiag;
var offsetY = Math.sin(radiansOf(anAngle)) * aDiag;
//alert (theAngle+"\n\n"+offsetX +"\n"+ offsetY+"\n\n"+ thisHalfWidth+"\n"+thisHalfHeight);
theLayer.translate(offsetX, offsetY);
theCopy.resizeImage(undefined, undefined, origResolution, ResampleMethod.NONE);
theCopy.saveAs((new File(docPath+"/"+basename+"_"+bufferNumberWithZeros(m+1, 3)+".jpg")),jpegOptions,true);
theCopy.activeHistoryState = theHistoryState;
// clean up;
theCopy.close(SaveOptions.DONOTSAVECHANGES);
app.preferences.rulerUnits = originalRulerUnits;
////// radians //////
function radiansOf (theAngle) {
return theAngle * Math.PI / 180
////// radians //////
function angleFromRadians (theRad) {
return theRad / Math.PI * 180
////// buffer number with zeros //////
function bufferNumberWithZeros (number, places) {
var theNumberString = String(number);
for (var o = 0; o < (places - String(number).length); o++) {
theNumberString = String("0" + theNumberString)
return theNumberString
////// function to smartify if not //////
function smartify2010 (theLayer) {
// make layers smart objects if they are not already;
app.activeDocument.activeLayer = theLayer;
// process pixel-layers and groups;
if (theLayer.kind == "LayerKind.GRADIENTFILL" || theLayer.kind == "LayerKind.LAYER3D" || theLayer.kind == "LayerKind.NORMAL" ||
theLayer.kind == "LayerKind.PATTERNFILL" || theLayer.kind == "LayerKind.SOLIDFILL" ||
theLayer.kind == "LayerKind.TEXT" || theLayer.kind == "LayerKind.VIDEO" || theLayer.typename == "LayerSet") {
var id557 = charIDToTypeID( "slct" );
var desc108 = new ActionDescriptor();
var id558 = charIDToTypeID( "null" );
var ref77 = new ActionReference();
var id559 = charIDToTypeID( "Mn " );
var id560 = charIDToTypeID( "MnIt" );
var id561 = stringIDToTypeID( "newPlacedLayer" );
ref77.putEnumerated( id559, id560, id561 );
desc108.putReference( id558, ref77 );
executeAction( id557, desc108, DialogModes.NO )
return app.activeDocument.activeLayer
if (theLayer.kind == LayerKind.SMARTOBJECT || theLayer.kind == "LayerKind.VIDEO") {return theLayer};
////// get an angle, 3:00 being 0˚, 6:00 90˚, etc. //////
function getAngle (pointOne, pointTwo) {
// calculate the triangle sides;
var width = pointTwo[0] - pointOne[0];
var height = pointTwo[1] - pointOne[1];
var sideC = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
// calculate the angles;
if (width+width > width) {theAngle = Math.asin(height / sideC) * 360 / 2 / Math.PI}
else {theAngle = 180 - (Math.asin(height / sideC) * 360 / 2 / Math.PI)};
if (theAngle < 0) {theAngle = (360 + theAngle)};
return theAngle -
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 -
Hi,
I'm brand new to writing FrameScript. I'm looking for example scripts that I can piece together or perhaps you can give me a quote for your cost to write the script for me. Here is a description of basically what needs doing. We have .book files than contain say a cover.fm, multiple chapter.fms, and possibly multiple appendix.fms. (They actually contain more types, but I can expand the script for that.) I don't think here is a consistent way to automatically determine which .fms are of which type, so I was thinking of popping up a dialog box that showed the files in the book and asked the user to identify which files were of which type. This asking could be done all at once, or it could iteratively ask for the first type then run all the processing then ask for the second type, etc, etc.
The processing of each file goes like this:
1) Delete the paragraph and character catalog contents
2) Import all formats, including the new paragraph and character catalogs from correct template file (chapter.fm, appendix.fm, etc)
3) Remap the old paragraph and character tags to the new ones, preferably based on an internal predefined, hard-coded table, but possibly using the "use a remapping table that is in another .fm file" method. It's just that the latter method requires the user to open two more .fms in addition to the several other template files they'll already (correct?) have to have open.
4) Report to the user all tags that are in their file that are not in the new catalogs
Can you point me to pieces? Write the whole thing? Recommend someone who can?
Thanks,
DaveDave, if you haven't yet check it out, do visit the Framescript users group, here:
http://groups.yahoo.com/group/framescript-users/
There are several folks who do contract FS work who post their contact info as part of that group (I believe there's a webring also). Also, Rick Quatro has a good e-book "Crash Course" about learning FrameScript (although the book refers to an earlier version, almost all of the concepts are still applicable to the current versions of FS and FM) , check it out at
http://www.frameexpert.com
Sheila -
A script for adding the current date to file name?
I am working in Indesign CS3. I frequently save file as PDFs into a designated folder. I was hoping for help in writing a script that would apply the current date to the end of the file name, when saved into this folder. Some days, I save the same file several times, into this folder. I was also hoping there was a way to add a date and version, for example "filename_2.25.11(1).pdf" Is this possible? Can someone help me?
ok, I ended up with this test routine:
on adding folder items to this_folder after receiving added_items
tell application "Finder"
repeat with this in added_items
my checkifopened(this)
display dialog (name of this) as text
end repeat
end tell
end adding folder items to
on checkifopened(this)
set a to POSIX path of (this as alias)
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
exit repeat
else
say "still opened"
end if
end repeat
end checkifopened
this is a folder action that tests if the added file is still opened by an application... there is no delay between each test-loop since lsof takes some time to execute...
And after adding a timeout (just in case) to this function the final script looks like this:
on adding folder items to thefolder after receiving added_items
tell application "Finder"
set folderkind to kind of thefolder
set myfiles to every item of thefolder whose name does not contain "#" and kind is not folderkind
repeat with myfile in myfiles
set myfile_datestring to my get_datestring(creation date of myfile)
set myfilename to name of myfile
if (count of every character of myfilename) > 4 and (character -4 of myfilename) as text is "." then
set filestatus to my checkifopened(myfile, 60)
if filestatus = false then
display dialog "timeout on folder action"
else
set tmp to ((characters 1 through -5 of myfilename) & "#" & myfile_datestring & (characters -4 through -1 of myfilename)) as text
set myfilename to my checknamewith_pdfsuffix(tmp, thefolder, false)
set name of myfile to myfilename
end if
end if
end repeat
end tell
end adding folder items to
on get_datestring(mydate)
return year of mydate & "-" & (characters -2 through -1 of (("0" & (month of mydate as integer)) as text)) & "-" & (characters -2 through -1 of (("0" & (day of mydate as integer)) as text)) as text
end get_datestring
on checknamewith_pdfsuffix(n, D, looped)
--check if filename exists in D
-- so if "A File.pdf" exists it names it "A File 1.pdf","A File 2.pdf",...
#n = string of the filename
#D = file reference to the directory to check
#looped = boolean used for recursive loop...
tell application "Finder"
set thefiles to name of every item of (D as alias)
end tell
if thefiles contains n then
if looped = false then
set n to ((characters 1 through -5 of n) & "(1)" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
else
set tmp to (last word of ((characters 1 through -5 of n) as text) as integer)
set tmpcount to (count of characters of (tmp as text)) + 5
set tmp to tmp + 1
set n to ((characters 1 through (-1 * tmpcount) of n) & "(" & tmp & ")" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
end if
else
return n
end if
end checknamewith_pdfsuffix
on checkifopened(this, mytimeout)
## this file reference
## timeout in seconds
set a to POSIX path of (this as alias)
set startdate to current date
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
return true
else if ((current date) - startdate) > mytimeout then
return false
else
##say "still opened"
end if
end repeat
end checkifopened
to use this save this script in /Library/Scripts/Folder Action Scripts
and add this as a folder action to your folder...
The script processes all files inside that folder each time a new files is added... -
[Req.] script for updating links in Indesign using spotlight
hi,
i've got a challange, can somebody please help me?
I'm a graphic designer from holland and I work with lots of Indesign documents
whose links are missing because they are moved, so they are somewhere on our server.
I have several scripts to relink missing links but they are slow,
because they search every directory and every subdirectory. This takes a while.
The search engine from apple, spotlight, is much much faster.
So I think i have this brilliant idea, i thought of the following:
I select one missing link in the linkpanel in Indesign.
Then I start the script.
The path of the missing link is copied and trimmed to just the name of the file
The filename is then copied to the clipboard.
The script then opens the dialog window to relink the missing link.
There the name of the picture is pasted in the spotlight search engine.
There the script stops.
Click on the correct file (if there are more choises) and the relink is made.
I think this way of relinking can be much faster.
And you can also work with pre-defined clever windows (to limit the results), for example:
- one witch only shows jpg
- one witch only shows tiff
- one witch only shows pdf
I know a tiny little bit of scripting, but this one I cant figure out yet.
Can somebody give me a help please?
Kind regards, Eric
ps. I still work in CS4try this,
could just test it with ID CS3 and Mac OS 10.4.11
--startpoint here is a selected graphicframe (which of course should inlude the missing link)
set myFolder to choose folder with prompt "Where to search for the missing link?" --select a mounted volume, folder ...
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
tell application "Adobe InDesign CS3"
set myGraphicFilePath to (file path of (item link of (item 1 of all graphics of (item 1 of selection))) as text)
end tell
set myGraphicName to text item -1 of myGraphicFilePath
set myGraphicFilePath to quoted form of POSIX path of myGraphicFilePath
set AppleScript's text item delimiters to return
set PathToAllFiles to every text item of (do shell script "mdfind -onlyin '" & quoted form of POSIX path of myFolder & "'" & space & " -name '" & myGraphicName & "'")
set PathToAllFiles to my cleanList(myGraphicName, PathToAllFiles)
repeat with i from 1 to count of PathToAllFiles
set theItem to (item i of PathToAllFiles)
if button returned of (display dialog theItem with title "Relink this file?" buttons {"OK", "Cancel", "Go on"}) is "OK" then
tell application "Adobe InDesign CS3"
relink (item link of (item 1 of all graphics of (item 1 of selection))) to POSIX file theItem
end tell
end if
end repeat
set AppleScript's text item delimiters to tid
on cleanList(fileName, listOfFilePaths)
set myCleanList to {}
set AppleScript's text item delimiters to "/"
repeat with p from 1 to count of listOfFilePaths
set aName to (text item -1 of (item p of listOfFilePaths))
if aName is equal to fileName then set end of myCleanList to (item p of listOfFilePaths)
end repeat
return myCleanList
end cleanList
Hans-Gerd Classen -
Hi,
I have written shell script for below scenarios, can you please guide me to write this as correct way, requirment is,
1. i need to connect the database which is on unix server , but before connecting the DB some of the files needs to be removed from \tmp directory.
2. once removed the script need to connect the database and call the sql file which is in \tmp directory.
3. the output files will be stored in \tmp directory start with DB name.
4. finally csv files needs to be transferred to local windows with help of FTP. please find below the script
#!/bin/sh
rm -f /tmp/dbmon/DB1*
CONNSTRING=username/PASSWORD@service
sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
EXIT;
EOF
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxxx'
FILE='E:\STATS\DB1.*'
cd /tmp/dbmon
ftp -n -v $HOST << EOT
user $USER $PASSWD
prompt
mput $FILE
bye
EOT
EXIT;
EOF
Thanks
Edited by: ASP on Nov 18, 2011 4:45 PMHi ASP
It's always a good idea to write entries to timestamped log file without which you will never know where the script went wrong or failed.
This is not tested but just a small example
#!/bin/sh
export LOG_DIR=/tmp/log
export LOGFILE=$LOG_DIR/`basename $0`_${TIMESTAMP}.log
if [ ! -d $LOG_DIR ]
then
mkdir $LOG_DIR
fi
echo "Removing the temporary files from /tmp/dbmon at `date +%Y%m%d_%H:%M:%S`" | tee -a $LOG_FILE
rm -f /tmp/dbmon/DB1*
CONNSTRING=username/PASSWORD@service
echo "Run SQLPlus file" | tee -a $LOG_FILE
sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
EXIT;
EOF
echo "Now FTP the files to windows box " | tee -a $LOG_FILE
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxxx'
cd /tmp/dbmon
ftp -vn $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
ascii
cd E:\STATS
mput DB1.*
bye
EOF -
Is there a script for CS5 to export a multi-page InDesign Document to single page InDesign documents
Hello,
I am having trouble finding a script or utility that would allow me to export each page of an InDesign CS5 document as multiple single page InDesign documents. I have found one script that does this for CS3, but nothing for CS5. Thank you for any help.Generally speaking, if a script doesn't run in a later version, you can put it in a subfolder withteh correct version number as the name and it will work. For CS3 that would be "Version 5.0 Scripts" without the quotes.
That said, if you have Acrobat pro, it's probably easier to use the extract pages command... -
How to make an insert script for CLOB data types?
I need to have an insert script for Oracle 11g where I insert large texts into a CLOB field
I exported data from a source table using TOAD's export dataset and the insert statements option, so it generates a script of just simple insert into statements with the clob strings in the values clause within single quotes.
While most of the inserts succeed, several fail with the error: string literal too long
How can I insert long texts into clobs?
One workaround I was considering, is maybe breaking up those inserts which are too big, so that it inserts a chunk, and then does an update to append additional chunks? not sure if that would work either
first wanted to get any ideas from the oracle experts here in case there is a much easier, non-manual labor intensive way.Thank you for that informative link, Raj
I wouldn't be able to use SQL Loader for this though, this is something that gets submitted to a DBA in a request and it must be in a script that can be run in Sql Plus, and it cannot pull it from a table or file. -
Where to dowload table script for demo table EMPLOYEE
Hello!
I'm reading the book "Oracle PL/SQL Programming, Fourth Edition"
By Steven Feuerstein.
And I can't find the script for the employee table ..
Where can I get it?
Regards
TobiasCopy this script in notepad and then save in .sql format and then run
rem
rem Header: hr_main.sql 09-jan-01
rem
rem Copyright (c) 2001, Oracle Corporation. All rights reserved.
rem
rem Owner : ahunold
rem
rem NAME
rem hr_main.sql - Main script for HR schema
rem
rem DESCRIPTON
rem HR (Human Resources) is the smallest and most simple one
rem of the Sample Schemas
rem
rem NOTES
rem Run as SYS or SYSTEM
rem
rem MODIFIED (MM/DD/YY)
rem ahunold 08/28/01 - roles
rem ahunold 07/13/01 - NLS Territory
rem ahunold 04/13/01 - parameter 5, notes, spool
rem ahunold 03/29/01 - spool
rem ahunold 03/12/01 - prompts
rem ahunold 03/07/01 - hr_analz.sql
rem ahunold 03/03/01 - HR simplification, REGIONS table
rem ngreenbe 06/01/00 - created
SET ECHO OFF
PROMPT
PROMPT specify password for HR as parameter 1:
DEFINE pass = &1
PROMPT
PROMPT specify default tablespeace for HR as parameter 2:
DEFINE tbs = &2
PROMPT
PROMPT specify temporary tablespace for HR as parameter 3:
DEFINE ttbs = &3
PROMPT
PROMPT specify password for SYS as parameter 4:
DEFINE pass_sys = &4
PROMPT
PROMPT specify log path as parameter 5:
DEFINE log_path = &5
PROMPT
-- The first dot in the spool command below is
-- the SQL*Plus concatenation character
DEFINE spool_file = &log_path.hr_main.log
SPOOL &spool_file
REM =======================================================
REM cleanup section
REM =======================================================
DROP USER hr CASCADE;
REM =======================================================
REM create user
REM three separate commands, so the create user command
REM will succeed regardless of the existence of the
REM DEMO and TEMP tablespaces
REM =======================================================
CREATE USER hr IDENTIFIED BY &pass;
ALTER USER hr DEFAULT TABLESPACE &tbs
QUOTA UNLIMITED ON &tbs;
ALTER USER hr TEMPORARY TABLESPACE &ttbs;
GRANT CONNECT TO hr;
GRANT RESOURCE TO hr;
REM =======================================================
REM grants from sys schema
REM =======================================================
CONNECT sys/&pass_sys AS SYSDBA;
GRANT execute ON sys.dbms_stats TO hr;
REM =======================================================
REM create hr schema objects
REM =======================================================
CONNECT hr/&pass
ALTER SESSION SET NLS_LANGUAGE=American;
ALTER SESSION SET NLS_TERRITORY=America;
-- create tables, sequences and constraint
@?/demo/schema/human_resources/hr_cre
-- populate tables
@?/demo/schema/human_resources/hr_popul
-- create indexes
@?/demo/schema/human_resources/hr_idx
-- create procedural objects
@?/demo/schema/human_resources/hr_code
-- add comments to tables and columns
@?/demo/schema/human_resources/hr_comnt
-- gather schema statistics
@?/demo/schema/human_resources/hr_analz
spool off -
Script for forward mail as attachment
Hi,
I think there is no direct call for creating forward mail as attachment. I tried "forward" reply and other things.Its working fine.
Please let me know if any one have idea for creating script for apple mail "forward as attachment".hm... perhaps these two functions do what you wanna do :-/
on createmail_emlx_files_attachment_ofselection()
tell application "Mail"
-- get the mail selection
set myMessages to selection
--do it to every selected mail
repeat with m in myMessages
--get the folder where the emlx file is stored in
set mypath to quoted form of POSIX path of ((account directory of account of mailbox of m) as alias)
--get the id of that message (should be unique within each account)
set myid to id of m
--find the folder where this unique email (by id) is stored in
set myfolder to quoted form of (paragraph 1 of (do shell script "find " & mypath & " -name '" & myid & ".emlx' -exec dirname {} \\;"))
--create a compressed tar archive of this message and open this gzipped files with Apple Mail (-> attach it to a new message).
do shell script "cd " & myfolder & ";tar -rf " & myid & ".tar " & myid & ".emlx;gzip " & myid & ".tar;mv " & myid & ".tar.gz /tmp/;open -a /Applications/Mail.app /tmp/" & myid & ".tar.gz"
end repeat
end tell
end createmail_emlx_files_attachment_ofselection
on createmail_source_attachment_ofselection()
tell application "Mail"
-- get the mail selection
set myMessages to selection
--do it to every selected mail
repeat with m in myMessages
set myid to id of m
set mysource to quoted form of ((source of m) as text)
do shell script "cd /tmp/;echo " & mysource & "|cat>/tmp/" & myid & ".txt;gzip " & myid & ".txt;open -a /Applications/Mail.app " & myid & ".txt.gz"
end repeat
end tell
end createmail_source_attachment_ofselection -
I want to have a random quote (chosen from a separate file)
displayed on our site that changes on a daily basis. I have about
100+ quotes that are in a already in a HTML file using a table. Do
they need to be in a different format eg SQL file.
How do I get it to place one quote in a certain place, and
choose a new quote the next day all automatically? I have seen SSI
in use, but I'm not sure if this can do what I want.
If anybody has a way to do this with very little input after
it's set up I would really appreciate it.
Thanks
PakmanPut the script on your page, it will produce a random quote
each time the
page is loaded.
Place linked text between <a href=http://www.google.com
and </a> like so:
Quotation[0] = "<a href=http://www.google.com>Truth is
beauty;</a>
beauty,truth";
Quotation[1] = "The time has come, <a
href=http://www.yahoo.com>the Walrus
said</a> to speak of many things";
If this isn't robust enough, there a many more scripts
available at dynamic
drive. This one uses Ajax to rotate include files.
http://www.dynamicdrive.com/dynamicindex17/ajaxrotate.htm
--Nancy O.
Alt-Web Design & Publishing
www.alt-web.com
A child of five would understand this. Send someone to fetch
a child of
five.
-- Groucho Marx (1890 - 1977)
"Pakman36" <[email protected]> wrote in
message
news:g230ib$irm$[email protected]..
> Hi Nancy
>
> This looks great, but I need the quote to automatically
display on the
page at
> the start of each day rather than having the end user
'Clicking' the
button!
> and the quotes have a book title with the appropriate
link contained in
them.
> Can the quotes have a link in the script?
> -
A small wrapper script for setting the lib32-gtk environment.
Hi all,
i've created a small script [1], which sets the gtk2 environment for
lib32 applications.
Thanks to buttons and alexwizard...
just put run_bin32_gtk before the app command.
I use this script for QT4 apps mostly, for instance:
run_bin32_gtk opera
or
run_bin32_gtk skype --disable-cleanlooks
so it fits best in my gnome environment...
best wishes
[1] http://aur.archlinux.org/packages.php?ID=27419I 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]}) -
[solved]Need help with a bash script for MOC conky artwork.
I need some help with a bash script for displaying artwork from MOC.
Music folders have a file called 'front.jpg' in them, so I need to pull the current directory from MOCP and then display the 'front.jpg' file in conky.
mocp -Q %file
gives me the current file playing, but I need the directory (perhaps some way to use only everything after the last '/'?)
A point in the right direction would be appreciated.
thanks, d
Last edited by dgz (2013-08-29 21:24:28)Xyne wrote:
You should also quote the variables and output in double quotes to make the code robust, e.g.
filename="$(mocp -Q %file)"
dirname="${filename%/*}"
cp "$dirname"/front.jpg ~/backup/art.jpg
Without the quotes, whitespace will break the code. Even if you don't expect whitespace in any of the paths, it's still good coding practice to include the quotes imo.
thanks for the tip.
here it is, anyhow:
#!/bin/bash
filename=$(mocp -Q %file)
dirname=${filename%/*}
cp ${dirname}/front.jpg ~/backup/art.jpg
then in conky:
$alignr${execi 30 ~/bin/artc}${image ~/backup/art.jpg -s 100x100 -p -3,60}
thanks for the help.
Last edited by dgz (2013-08-29 21:26:32)
Maybe you are looking for
-
Ipod not recognized in itunes, error message: repair disk
When I connect my ipod to my mac I get an error message saying my mac cannot repair the disk, its asking me to back up the disk and reformat asap. My ipod is not being recognized in itunes but it is in the finder. help!
-
Large number of JSP performance [repost for grandemange]
Hi, a colleague of me made tests with a large number of JSP and identified a performance problem. I believe I found a solution to his problem. I tested it with WLS 5.1 SP2 and SP3 and MS jview SDK 4. The issue was related to the duration of the initi
-
Snow Leo is blocking ports!
Hello dear folks! I've got some nasty persistent problem with my mac. Neither of my torrent clients can establish connection; whenever I open preferences, it does say "port XXX : blocked". I've tried everything, enabling/disabling the FW, adding all
-
Simplepass export to other program
First I have to say that I absolutely love(d) having a fingerprint scanner on my laptop. However, the SimplePass software just really isn't up to snuff. That being said, I just got a new work laptop and would like to store my SimplePass passwords on
-
Custom Redirect After Account Creation
By default, a user is automatically redirected to a "welcome page" after his/her account is created. I would like to modify this behaviour. Specifically, I would like to redirect a user to the portal home page after his/her account is created. Is thi