[Thumbnailer Entry] TryExec=imagemagick-thumbnailer Exec=imagemagick-thumbnailer %i %o %s MimeType=image/hdr;image/x-hdr;
#!/bin/sh /usr/bin/convert "$1" -thumbnail 64x64 -gravity center -background white -extent 48x48 png:"$2"
#!/usr/bin/python import os def processdir(path): print "entering " + path for entry in os.listdir(path): if os.path.isdir(path + os.sep + entry): processdir(path + os.sep + entry) elif entry[-4:] == ".svg": print " processing " + path + os.sep + entry f = open(path + os.sep + entry) b = f.read() f.close() b = b.replace( 'stroke="#000"','stroke="#fff"' ) b = b.replace( '#000000;','#ffffff;' ) f = open( path + os.sep + entry,'wb' ) f.write(b) f.close() processdir(os.getcwd())
lftp -e "set net:timeout 10; set ssl:verify-certificate no; set ftp:ssl-protect-data true; get mydir/myfile.sql.gz; bye" -u myusername,mypassword ftp.myserver.com
/usr/bin/mysqldump -u myuser --password=mypassword databasename | /usr/bin/gzip > /home/user/htmldir/mydir/myfile.sql.gz
#!/usr/bin/python import sys,os,time r = os.system("xprintidle") if r != 0: print "Error: xprintidle was not found, and must be installed for this program to run" sys.exit() total_idle = 0 def uptime(): "returns uptime in minutes" with open("/proc/uptime", "r") as f: uptime_seconds = float(f.readline().split()) return int(uptime_seconds)/60 return 0 def idletime(): "returns idle time in minutes" global total_idle r = os.popen("xprintidle") idle_minutes = int(r.read())/60000 if idle_minutes > 1: total_idle += 1 return total_idle def formattime(minutes): "formats atime in minutes to HH:MM" hours = minutes/60 restminutes = minutes%60 return str(hours).zfill(2)+":"+str(restminutes).zfill(2) def writetime(): "writes current activity time to a file" strtime = formattime(uptime() - idletime()) print ("active time: "+strtime) fil = open(os.path.expanduser("~") + os.sep + ".activitytime","wb") fil.write(str(strtime)) fil.close() def readtime(): "reads a temp file and adjusts elapsed idle" global total_idle fpath = os.path.expanduser("~") + os.sep + ".activitytime" if os.path.exists(fpath): fil = open(fpath,"r") r = fil.read() fil.close() t = r.split(":") minutes = int(t)*60 + int(t) print "logged activity time: ",formattime(minutes) print "current uptime: ",formattime(uptime()) total_idle = uptime() - minutes print "logged idle time: ",formattime(total_idle) if __name__ == "__main__": if len(sys.argv) == 1: # if no argument is given, start from zero writetime() else: # with an argument, for ex --append, restart from currently saved time readtime() while True: time.sleep(60) writetime()
dpkg-source -x name-of-dsc-file.dsc
sudo dpkg -i name-of-package.deb
#!/bin/sh if [ -z "$1" ] then find /home/yorik/Dropbox/* -size 0 -type f else if [ -n "$(find /home/yorik/Dropbox/* -size 0 -type f)" ] then notify-send -i important "Dropbox Warning" "0-byte files found" play /home/yorik/.sound/nuclear-alarm.wav fi fi
0 * * * * env DISPLAY=:0 /home/yorik/bin/checkdropbox -n
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=BRXX0232&u=c" | grep -E 'temp=' | cut -d "=" -f3 | head -c 3 | tail -c 2
#!/usr/bin/python #*************************************************************************** #* * #* Copyright (c) 2012 * #* Yorik van Havre
* #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** """This utility checks the current folder and any of its subfolders for jpg, png or exr image sequences, numbered 0001.jpg, 0002.jpg, etc... and checks that no frame number is missing, and that no image is corrupted (sero-size).""" import os,sys from PIL import Image # keeping count of errors errors = 0 # getting working paths homepath = os.path.abspath('.') subpaths =  for p in os.listdir(homepath): ap = homepath + os.sep + p if os.path.isdir(ap): subpaths.append(ap) subpaths.sort() # add current path too subpaths.insert(0,homepath) # checking frames for p in subpaths: print(" ") print("checking folder "+p) frames =  for i in os.listdir(p): if i[-4:].upper() in ['.JPG','.PNG','.EXR']: frames.append(i) if not frames: print(" This folder doesn't contain frames") else: # counting frames and checking numbers frames.sort() try: last = int(frames[-1].split('.')) except: print(" Error: couldn't parse frame numbers in this folder") continue if len(frames) != last: print(" Error: frame numbers differ from frames count in this folder: last frame is "+str(last)+" but contains "+str(len(frames))) ext = frames[-1].split('.') for i in range(1,last+1): fn = str(i).zfill(4)+'.'+ext if not fn in frames: errors +=1 print(" Missing frame: "+fn) # displaying info of first image try: imf = Image.open(p+os.sep+frames) except: print(" Error: cannot open image "+p+os.sep+frames) continue else: print(" "+str(last)+" frames - format: "+imf.format+" - "+str(imf.size)+"x"+str(imf.size)) # checking size for f in frames: fp = p+os.sep+f s = os.path.getsize(fp) if s < 1024: print(" Error: zero-sized file: "+fp) continue # subdir succeeded print " Everything ok" # all tests are done print(" ") if errors: print(str(errors)+" errors found") else: print("Success: All frames are ok") sys.exit()
[Added Associations] x-scheme-handler/trash=pcmanfm.desktop; inode/directory=pcmanfm.desktop; [Default Applications] application/x-directory=pcmanfm.desktop x-scheme-handler/trash=pcmanfm.desktop inode/directory=pcmanfm.desktop
<?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-type type="application/x-extension-ifc"> <sub-class-of type="text/plain"/> <comment>Industry Foundation Classes</comment> <glob pattern="*.ifc"/> </mime-type> </mime-info>
This is a serie of 3 tutorials for architects who wish to use opensource 3D tools (mainly Blender and FreeCAD more effectively, or simply who are curious about programming, and would like a gentle introduction. This is the first tutorial, presenting python in a general way. Read also the second part: about Blender. The third part (about FreeCAD) is yet to be written.
Why would I need to program? You might ask. There are a couple of reaons:
Python is a programming language. It is free, open-source, multiplatform (Windows, Mac, Linux and many others), and it has several features that make it very different than other common programming languages, and very accessible to new users like yourself:
So, hands on! Be aware that what will come next is a very simple introduction, by no means a complete python course. But my hope is that after that you'll get enough basics to explore deeper into the Blender and FreeCAD mechanisms, which will be in parts II and III of this tutorials serie.
Installing python present no difficulty at all, if you are on Linux there are 99% of chances that it is installed already, since it powers many parts of your system (try running "python" from a terminal to check), otherwise just install it from your system's package manager. On Windows and Mac, just download and install the latest version from the official python website. If you have Blender or FreeCAD installed, they already include an embedded python version, and you don't need to install anything.
When installing python, you might be able to choose between several versions. At the time of writing, the globally considered "stable" version is 2.7, but the latest version available is 3.2. I advise you to install the 3.2, or any higher version available. This tutorial is based on 3.2, but normally everything will work just the same with any other version.
Usually, when writing computer programs, you simply open a text editor (such as notepad on Windows) or a special programming environment which is in most case a text editor with several tools around it, write your program, then compile it (that means basically convert it into an executable application) and run it. Most of the time you made errors while writing, so your program won't work, and you will get an error message telling you what went wrong. Then you go back to your text editor, correct the mistakes, run again, and so on until your program works fine.
That whole process, in Python, can be done transparently inside the Python interpreter. The interpreter is a Python window with a command prompt, where you can simply type Python code, that will be executed on-the-fly, without the need to do anything else.
When Python is installed on your computer you will have a Python interpreter in your start menu (usually labelled "Python" or "Python console"). On linux and mac, you can also simply run "python" from a terminal window. Or, simply fire up Blender or FreeCAD, which both have an included python interpreter (also called "python console"). Below are images showing a standalone python console, and the python consoles embedded in FreeCAD and Blender:
The interpreter shows the Python version, then a >>> symbol, which is the command prompt, that is, where you enter Python code. Writing code in the interpreter is simple: one line is one instruction. When you press Enter, your line of code will be executed (after being instantly and invisibly compiled). For example, try writing this:
print is a special Python keyword that means, obviously, to print something on the screen. It is called a function, which means basically "it does something". Like in most programming languages, functions such as this one use parenthesis () that signify "do it with the contents of the parenthesis". So here the whole line means means "print the contents of the parenthesis". When you press Enter, the operation is executed, and the message "hello" is printed. If you make an error, for example let's write:
Python will tell us that it doesn't know what hello is: "NameError: name 'hello' is not defined".
The " characters specify that the content is a string, which is simply, in programming jargon, a piece of text. Without the ", the print command believed hello was not a piece of text but another special Python keyword. I'll explain better below. The important thing is, you immediately get notified that you made an error. By pressing the up arrow, you can go back to the last command you wrote and correct it.
The Python interpreter also has a built-in help system. Try typing:
It will tell us that help is a function, and needs to be used with parenthesis. For example, let's say we don't understand what went wrong with our print hello command above, we want specific information about the print command:
You'll get a long and complete description of everything the print command can do. Press "Q" to exit the help message.
Now we dominate totally our interpreter (yes, there is no more to know than that), we can begin with serious stuff.
Of course, printing "hello" is not very interesting. More interesting is printing stuff you don't know before, or let Python find for you. That's where the concept of variable comes in. A variable is simply a value that you store under a name. For example, type this:
a = "hello" print(a)
I guess you understood what happened, we "saved" the string "hello" under the name a. Now, a is not an unknown name anymore! We can use it anywhere, for example in the print command. We can use any name we want, just respecting simple rules, like not using spaces or punctuation. For example, we could very well write:
hello = "my own version of hello" print(hello)
See? now hello is not an undefined word anymore. What if, by terrible bad luck, we choosed a name that already exists in Python? Let's say we want to store our string under the name "print":
print = "hello"
Python is very intelligent and will tell us that this is not possible. It has some "reserved" keywords that cannot be modified. But our own variables can be modified anytime, that's exactly why they are called variables, the contents can vary. For example:
myVariable = "hello" print(myVariable) myVariable = "good bye" print(myVariable)
We changed the value of myVariable. We can also copy variables:
var1 = "hello" var2 = var1 print(var2)
Note that it is interesting to give good names to your variables, because when you'll write long programs, after a while you won't remember what your variable named "a" is for. But if you named it for example myWelcomeMessage, you'll remember easily what it is used for when you'll see it.
Of course you must know that programming is useful to treat all kind of data, and especially numbers, not only text strings. One thing is important, Python must know what kind of data it is dealing with. We saw in our print hello example, that the print command recognized our "hello" string. That is because by using the "", we told specifically the print command that what it would come next is a text string.
We can always check what data type is the contents of a variable with the special Python keyword type:
myVar = "hello" type(myVar)
It will tell us the contents of myVar is 'str', or string in Python jargon. We have also other basic types of data, such as integer and float numbers:
firstNumber = 10 secondNumber = 20 print(firstNumber + secondNumber) type(firstNumber)
This is already much more interesting, isn't it? Now we already have a powerful calculator! Look well at how it worked, Python knows that 10 and 20 are integer numbers. So they are stored as "int", and Python can do with them everything it can do with integers. Look at the results of this:
firstNumber = "10" secondNumber = "20" print(firstNumber + secondNumber)
See? We forced Python to consider that our two variables are not numbers but mere pieces of text. Python can add two pieces of text together, but it won't try to find out any sum. But we were talking about integer numbers. There are also float numbers. The difference is that integer numbers don't have decimal part, while foat numbers can have a decimal part:
var1 = 13 var2 = 15.65 print("var1 is of type ", type(var1)) print("var2 is of type ", type(var2))
Int and Floats can be mixed together without problem:
total = var1 + var2 print(total) print(type(total))
Of course the total has decimals, right? Then Python automatically decided that the result is a float. In several cases such as this one, Python automatically decides what type to give to something. In other cases it doesn't. For example:
varA = "hello 123" varB = 456 print(varA + varB)
This will give us an error, varA is a string and varB is an int, and Python doesn't know what to do. But we can force Python to convert between types:
varA = "hello" varB = 123 print(varA + str(varB))
Now both are strings, the operation works! Note that we "stringified" varB at the time of printing, but we didn't change varB itself. If we wanted to turn varB permanently into a string, we would need to do this:
varB = str(varB)
We can also use int() and float() to convert to int and float if we want:
varA = "123" print(int(varA)) print(float(varA))
Note on Python commands
You must have noticed that in this section we used the print command in several ways. We printed variables, sums, several things separated by commas, and even the result of other Python command such as type(). Maybe you also saw that doing those two commands:
have exactly the same result. That is because we are in the interpreter, and everything is automatically printed on screen. When we'll write more complex programs that run outside the interpreter, they won't print automatically everything on screen, (in fact, maybe they won't even have a screen to print to, if they run inside another application) so we'll need to use the print command. But from now on, let's stop using it here, it'll go faster. So we can simply write:
myVar = "hello friends" myVar
Another cosmetic detail, you can insert blank spaces where you want, just to make your code easier to read. It's a matter of taste, python doesn't consider whitespaces (unless they are inside a string, of course, otherwise how would you print whole sentences?). For example, these two lines of code are totally identical to python:
print(type(varA+varB)) print ( type ( varA + varB ) )
Another interesting data type is lists. A list is simply a list of other data. The same way as we define a text string by using " ", we define lists by using [ ]:
myList = [1,2,3] type(myList) myOtherList = ["Bart", "Frank", "Bob"] myMixedList = ["hello", 345, 34.567]
You see that it can contain any type of data. Lists are very useful because you can group variables together. You can then do all kind of things within that groups, for example counting them:
or retrieving one item of a list:
myName = myOtherList myFriendsName = myOtherList
You see that while the len() command returns the total number of items in a list, their "position" in the list begins with 0. The first item in a list is always at position 0, so in our myOtherList, "Bob" will be at position 2. We can do much more stuff with lists such as you can read here, such as sorting contents, removing or adding elements.
A funny and interesting thing for you: a text string is actually, internally, a list of characters! Try doing this:
myvar = "hello" len(myvar) myvar
Usually all you can do with lists can also be done with strings. In fact both lists and strings are sequences of elements, and you can do much more with sequences, as we'll see further on.
Outside strings, ints, floats and lists, there are more built-in data types, such as dictionnaries, or you can even create your own data types with classes. Like everything in Python, the basics are small, but it is often extensible as far as your imagination allows.
One big cool use of lists is also browsing through them and do something with each item. For example look at this:
alldaltons = ["Joe", "William", "Jack", "Averell"] for dalton in alldaltons: print (dalton + " Dalton")
We iterated (programming jargon again!) through our list with the "for ... in ..." command and did something with each of the items. Note the special syntax: the for command terminates with : which indicates that what will comes after will be a block of one of more commands. Immediately after you enter the command line ending with :, the command prompt will change to ... which means Python knows that a :-ended line has happened and that what will come next will be part of it.
How will Python know how many of the next lines will be to be executed inside the for...in operation? For that, Python uses indentation. That is, your next lines won't begin immediately. You will begin them with a blank space, or several blank spaces, or a tab, or several tabs. Other programming languages use other methods, like putting everythin inside parenthesis, etc. As long as you write your next lines with the same indentation, they will be considered part of the same for-in block. If you begin one line with 2 spaces and the next one with 4, there will be an error. When you finished, just write another line without indentation, or simply press Enter to come back from the for-in block
Indentation is cool because if you make big ones (for example use tabs instead of spaces because it's larger), when you write a big program you'll have a clear view of what is executed inside what. We'll see that many other commands than for-in can have indented blocks of code too.
For-in commands can be used for many things that must be done more than once. It can for example be combined with the range() command:
serie = range(1,11) total = 0 print ("sum") for number in serie: print (number) total = total + number print ("----") print (total)
Or more complex things like this:
alldaltons = ["Joe", "William", "Jack", "Averell"] for n in range(4): print (alldaltons[n], " is Dalton number ", n)
You see that the range() command also has that strange particularity that it begins with 0 (if you don't specify the starting number) and that its last number will be one less than the ending number you specify. That is, of course, so it works well with other Python commands. For example:
alldaltons = ["Joe", "William", "Jack", "Averell"] total = len(alldaltons) for n in range(total): print (alldaltons[n])
Another interesting use of indented blocks is with the if command. If executes a code block only if a certain condition is met, for example:
alldaltons = ["Joe", "William", "Jack", "Averell"] if "Joe" in alldaltons: print ("We found that Dalton!!!")
Of course this will always print the sentence, because the stuff after "if" is always true ("Joe" is indeed foundin the allDaltons list), but try replacing the second line by:
if "Lucky Luke" in alldaltons:
Then the result of that line is false, and nothing is printed. We can also specify an else: statement:
alldaltons = ["Joe", "William", "Jack", "Averell"] if "Lucky Luke" in alldaltons: print ("We found that Dalton!!!") else: print ( "Such Dalton doesn't exist!" )
The standard Python commands are not many. In current version of Python there are about 30, and we already know several of them (print(), len(), type(), etc...). But imagine if we could invent our own commands? Well, we can, and it's extremely easy. In fact, most the additional modules that you can plug into your Python installation do just that, they add commands that you can use. A custom command in Python is called a function and is made like this:
def square(myValue): print ( str(myValue)+" square meters" ) print ( square(45) )
Extremely simple: the def() command defines a new function. You give it a name, and inside the parenthesis you define arguments that we'll use in our function. Arguments are data that will be passed to the function. For example, look at the len() command. If you just write len() alone, Python will tell you it needs an argument. That is, you want len() of something, right? Then, for example, you'll write len(myList) and you'll get the length of myList. Well, myList is an argument that you pass to the len() function. The len() function is defined in such a way that it knows what to do with what is passed to it. Same as we did here.
The "myValue" name can be anything, and it will be used only inside the function. It is just a name you give to the argument so you can do something with it, but it also serves so the function knows how many arguments to expect. For example, if you do this:
print ( square(45,34) )
There will be an error. Our function was programmed to receive just one argument, but it received two, 45 and 34. We could instead do something like this:
def sum(val1,val2): total = val1 + val2 return ( total ) sum(45,34) myTotal = sum(45,34)
We made a function that receives two arguments, sums them, and returns that value. Returning something is very useful, because we can do something with the result, such as store it in the myTotal variable. Of course, since we are in the interpreter and everything is printed, doing:
will print the result on the screen, but outside the interpreter, since there is no more print command inside the function, nothing would appear on the screen. You would need to do:
to have something printed.
Now that we have a good idea of how Python works, we'll need one last thing: How to work with files and modules.
Until now, we wrote Python instructions line by line in the interpreter, right? What if we could write several lines together, and have them executed all at once? It would certainly be handier for doing more complex things. And we could save our work too. Well, that too, is extremely easy. Simply open a text editor (such as the windows notepad, or gedit on ubuntu), and write all your Python lines, the same way as you write them in the interpreter, with indentations, etc. Then, save that file somewhere, with a .py extension instead of the usual .txt. That's it, you have a complete Python program. Of course, there are much better and much more comfortable editors than notepad (try notepad++ for example), but it is just to show you that a Python program is nothing else than a text file. Also note that on windows, python already comes with an editor named "IDLE", which is also a very comfortable way to write python code.
To make Python execute that program, there are hundreds of ways. In windows, simply right-click your file, open it with Python, and execute it. But you can also execute it from the Python interpreter itself. For this, the interpreter must find your .py file. The easiest way is to place your .py file in a place where python will search by default, such as the folder from where you started the python interpreter. On linux, by default it is your user home directory, on windows it is the folder where you installed python. If you use FreeCAD, you can simply place your .py file in the macros folder.
Here is a simple trick to find, from inside the python console, what is the current directory, which will be a good place to save our script (I'll explain later):
import os os.path.abspath(".")
Then, let's fire our text editor, and write the following text:
def sum(a,b): return (a + b) print( "test.py succesfully loaded" )
and we save it as test.py in the directory found above. Now, let's start our python console, and, write:
without the .py extension. This will simply execute the contents of the file, line by line, just as if we had written it in the interpreter. The sum function will be created, and the message will be printed. There is one big difference: the import command is made not only to execute programs written in files, like ours, but also to load the functions inside, so they become available in the interpreter. In python, that kind of files, made to be imported into other files instead of being simply executed, are called modules.
Normally when we write a sum() function directly in the interpreter, we execute it simply like that:
Like we did earlier. When we import a module containing our sum() function, the syntax is a bit different. We do:
That is, the module is imported as a "container", and all its functions are inside. This is extremely useful, because we can import a lot of modules, and keep everything well organized. So, basically, everywhere you see something.somethingElse, with a dot in between, that means somethingElse is inside something. Now you should understand better what we did with our "os" module above. The os module is a standard module of python, and contains operating system-related functions, and a submodule (simply a module inside a module) named "path" which contains tools to work with files and folders.
We can also throw out the test part, and import our sum() function directly into the main interpreter space, like this:
from test import * sum(12,54)
Basically all modules behave like that. You import a module, then you can use its functions like that: module.function(argument). Almost all modules do that: they define functions, new data types and classes that you can use in the interpreter or in your own Python modules, because nothing prevents you to import modules inside your module!
One last extremely useful thing. How do we know what modules we have, what functions are inside and how to use them (that is, what kind of arguments they need)? We saw already that Python has a help() function. Doing:
Will give us a list of all available modules. We can now type q to get out of the interactive help, and import any of them. We can even browse their content with the dir() command:
import math dir(math)
We'll see all the functions contained in the math module, as well as strange stuff named __doc__, __file__, __name__. The __doc__ is extremely useful, it is a documentation text. Every function of (well-made) modules has a __doc__ that explains how to use it. For example, we see that there is a sin function inside the math module. Want to know how to use it?
print ( math.sin.__doc__ )
which is a simpler version than:
And finally one last little goodie: When we work on programming a new module, we often want to test it. So once we wrote a little piece of module, in a python interpreter, we do something like this, to test our new code:
import myModule myModule.myTestFunction()
But what if we see that myTestFunction() doesn't work correctly? We go back to our editor and modifiy it. Then, instead of closing and reopening the python interpreter, we can simply update the module like this:
By now, you should have a broad idea of how things are programmed in python. As you see, it's basically a matter of writing text files containing your python instructions, and have these files (modules) imported in your favorite application, and executed for example when the user pushes a button. How to achieve that depends from the application, that's what we'll explore in the next parts of this tutorials serie...
In the meantime, if you would like to know more about the basics of python, there are many, many tutorials on the internet. I selected a couple of good, simple and easy ones here. For more advanced ones, just google for "python tutorial", and you'll find plenty, including one from the official python website.
There are also many very complete PDF ebooks:
I hope you liked, if anything is unclear, please tell me by posting a comment below, so I can make it evolve into something better!
To be continued! Read the second part: about Blender.
cd ~/Sources git clone git://github.com/YafaRay/Core.git YafaRay cd YafaRay git clone git://github.com/YafaRay/Blender-2.5-Exporter.git Exporter cp CMakeConfig/UserConfig.template UserConfig.txtChange the following values in UserConfig.txt
set(BUILDRELEASE ON) set(USER_INSTALL_PREFIX "/home/yorik/Apps/YafaRay") set(YAF_PY_VERSION 3.2)Then go on (I prefer to build outside of the source folder):
cd ~/Apps mkdir YafaRay cd YafaRay cmake ../Sources/YafaRay make make installThen link evrything in blender scripts folder:
cd bin ln -s ../src/bindings/yafrayinterface.py ln -s ../src/bindings/_yafrayinterface.so ln -s ../src/bindings/_yafqt.so ln -s ../lib/libyafaraycore.so ln -s ../lib/libyafarayplugin.so ln -s ../lib/libyafarayqt.so ln -s ../lib/yafaray plugins cd ~/.blender/scripts/addons ln -s ~/Sources/YafaRay/Exporter yafaray cd yafaray ln -s ~/Apps/YafaRay/bin
cd myWebSite # go to your website root bzr init # this creates a repository bzr ignore *.xcf # before adding files, ignore everything you won't need to keep track of bzr add . # add everything bzr commit -m "First commit" # commit your changes bzr upload --auto --remember sftp://email@example.comThe last line will upload everything on the server. The upload command is a plugin for bazaar, which you might need to install separately. After that, everytime you commit, the changes will be uploaded (thanks to the --auto switch). but yo ucan also do it manually with:
bzr uploadThe server location will be remembered from last time. In case you have a very large website, and it is online already, you might not want to re-upload everything on first commit. To solve that, there is an easy trick:
bzr upload /home/user/tmp # this will upload everything in a local folder cd /home/user/tmp sftp firstname.lastname@example.org put .bzr-upload.revid exit # exit sftp cd myWebSite # go back to your site root bzr upload --remember sftp://email@example.comNow bazaar will find a bazaar revision id on your remote site, and only upload the changes.
[HKEY_CURRENT_USER\\Control Panel\\Colors] 1309724542 "ActiveBorder"="212 208 200" "ActiveTitle"="10 36 106" "AppWorkSpace"="128 128 128" "Background"="58 110 165" "ButtonAlternateFace"="181 181 181" "ButtonDkShadow"="0 0 0" "ButtonFace"="2 2 2" "ButtonHilight"="40 40 40" "ButtonLight"="12 11 10" "ButtonShadow"="0 0 0" "ButtonText"="128 128 128" "GradientActiveTitle"="166 202 240" "GradientInactiveTitle"="192 192 192" "GrayText"="128 128 128" "Hilight"="255 128 0" "HilightText"="0 0 0" "HotTrackingColor"="0 0 128" "InactiveBorder"="212 208 200" "InactiveTitle"="128 128 128" "InactiveTitleText"="212 208 200" "InfoText"="0 0 0" "InfoWindow"="255 255 225" "Menu"="2 2 2" "MenuBar"="212 208 200" "MenuHilight"="255 128 0" "MenuText"="192 192 192" "Scrollbar"="212 208 200" "TitleText"="255 255 255" "Window"="28 28 28" "WindowFrame"="0 0 0" "WindowText"="255 255 255"
cd /home/yorik/.wine/drive_c/Program Files/Steam if [ "$#" -gt 0 ]; then wine Steam -applaunch "$@" else wine Steam fi
urxvt -e watch -n 0.3 xrefresh -geometry 1x1+500+500 & watchPID=$! cd /home/yorik/.wine/drive_c/Program Files/Google/Google SketchUp 8 wine ./SketchUp kill $watchPIDRetrieved from http://credentiality2.blogspot.com/2010/04/ubuntu-linux-sketchup-using-wine.html
#!/bin/sh BINDIR="/opt/dassault-systemes/draftsight/bin" BASENAME="DraftSight" export GTK_PATH=/usr/lib32/gtk-2.0/ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$BINDIR:$BINDIR/../lib" export QT_PLUGIN_PATH="$BINDIR:$BINDIR/../plugins" if [ -d /usr/lib32/gconv ]; then export GCONV_PATH=/usr/lib32/gconv fi BINARY=$BINDIR/"$BASENAME.bin" cd "$BINDIR" if [ "$#" -gt 0 ]; then "$BINARY" -style gtk "$@" else "$BINARY" -style gtk fi
#!/usr/bin/python import sys, os args = sys.argv[1:] if len(args) == 2: diffusedir = args alphadir = args elif len(args) == 0: diffusedir = 'Diffuse' alphadir = 'Alpha' else: diffusedir = alphadir = None print ''' joinalpha [Diffuse Folder] [Alpha Folder] - joins alpha and diffuse images If no folder is specified, defaults are "Alpha" and "Diffuse" ''' if diffusedir and alphadir: diffusedir = os.getcwd() + os.sep + diffusedir alphadir = os.getcwd() + os.sep + alphadir if os.path.exists(diffusedir) and os.path.exists(alphadir): alphanames = os.listdir(alphadir) diffusenames = os.listdir(diffusedir) if len(alphanames) == len(diffusenames): print 'joining ' + str(len(alphanames)) + ' files...' for i in range(len(alphanames)): f1 = diffusedir + os.sep + diffusenames[i] f2 = alphadir + os.sep + alphanames[i] fn = str(i+1).zfill(4) + '.png' options = '-colorspace RGB -alpha Off -compose copy_opacity -composite' execute = 'convert "' + f1 + '" "' + f2 + '" ' + options + ' "' + fn + '"' print 'creating ' + fn os.system(execute) else: print "Alpha and Diffuse folder have a different number of files" print alphanames, len(alphanames), diffusenames, len(diffusenames) else: print "Couldn't find Alpha or Diffuse folders:",alphadir,diffusedir else: print "No Alpha and Diffuse directories specified, or no 'Alpha' and 'Diffuse' direcories in current folder"
//192.168.0.2/backup/ /media/backup \ cifs credentials=credentials-file,uid=1000,gid=1002,rw,user,noauto 0 0Then, save this in your exec path and make it executable:
#!/bin/sh umount /media/backup if mount /media/backup; then echo "network drive mounted, performing backup... " rsync -rtvx --delete /path/to/my/Worksfolder /media/backup umount /media/backup logger works backup done echo "unmounting... done" else echo "backup failed" logger works backup failed fiThe logger line inserts the text that follows into the syslog, which is useful so you can check later if something went wrong and when. Then, add this to your crontab (using "crontab -e"):
00 * * * * /home/yorik/bin/backupWhich means "run each minute 00" which means run every hour.
deb http://ftp.br.debian.org/debian unstable main contrib non-free deb-src http://ftp.br.debian.org/debian unstable main contrib non-freeThen, either add this to your /etc/apt/apt.conf.d/00defaultrelease file (create if necessary):
APT::Default-Release "testing";But this will simply mark the testing repository with higher prioritary, which means if a package is temporarily unavailable in testing, the unstalbe package will be installed, either add this to your /etc/apt/preferences.d/00Default (create if necessary):
Package: * Pin: release a=testing Pin-Priority: 500 Package: * Pin: release o=Debian Pin-Priority: -10This will give to the testing release a priority of 500 (the normal priority for your main repo), and any other official debian repository a priority of -10, which means: NEVER install from there.
apt-get install packagename/unstableBut be careful when that package pushes a lot of dependencies, because you'll begin to mix much different versions and it can give you headaches later. Better to keep this for emergencies, and with safe packages (that you know well, and that have few or no dependencies).
urxvt*foreground: #f2f2f2 urxvt*background: #101010 urxvt*color0: #101010 urxvt*color1: #f13a21 urxvt*color2: #93f91d urxvt*color3: #ffd00a urxvt*color4: #004f9e urxvt*color5: #ec0048 urxvt*color6: #2aa7e7 urxvt*color7: #f2f2f2 urxvt*color8: #1d202f urxvt*color9: #ff361e urxvt*color10: #ffc005 urxvt*color11: #93ff00 urxvt*color12: #0071ff urxvt*color13: #ef0051 urxvt*color14: #4bb8fd urxvt*color15: #a020f0 urxvt*transparent: true urxvt*shading: 50 urxvt*fading: 50 urxvt*font: xft:Bitstream\ Vera\ Sans\ Mono:style=roman:pixelsize=13 urxvt*scrollBar: false
auto eth1 iface eth1 inet static address 192.168.0.1 netmask 255.255.255.0 post-up /etc/network/if-up.d/firewall.shThis is the firewall script:
#!/bin/sh # Cleans the iptables iptables -F # Enables internet connection sharing modprobe iptable_nat iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE echo 1 > /proc/sys/net/ipv4/ip_forward # Opens some ports (22=SSH, 1080=Socks) iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT iptables -A INPUT -p tcp --destination-port 1080 -j ACCEPT # Allows localhost everywhere iptables -A INPUT -s 127.0.0.1 -j ACCEPT iptables -A OUTPUT -s 127.0.0.1 -j ACCEPT # Opens local network iptables -A INPUT -p tcp --syn -s 192.168.0.0/255.255.255.0 -j ACCEPT # Closes everything else iptables -A INPUT -p tcp --syn -j DROP
Download it here
This python application converts a dwg file to a dxf 2007 file with same name. To use it, you must have wine installed, and set the correct path to the EveryDWG utility by editing this script. The EveryDWG utility can be downloaded free of charge from the opendwg website but you must agree to their license terms before downloading.
Usage: dxfconvert.py path/to/file.dwg
Options: -h, --help: prints this help message
Download it here
This application generates a 128x128px PNG image showing the contents of a DXF file. In order to speed up the image generation process, only a few types of entities are read, so complex files might not get rendered accurately or even fail to render. In order to use this program, you must configure your file manager to use it as a thumbnailer for dxf file type (mime type: image/x-dxf).
For thunar: Download this dxf-thumbnailer.Desktop file and place it in /usr/share/thumbnailers. That's it!
For nautilus: Open the gconf editor and add an entry to desktop->gnome->thumbnailers called
Other file managers: Honestly I don't know, I don't use any other, but most of them have a way of including thumbnailers. If you find a way to make it work, please tell me how and I'll include the instructions here.
# official debian repositories. Beware, there are unstable and experimental there. deb http://ftp.br.debian.org/debian testing main contrib non-free deb-src http://ftp.br.debian.org/debian testing main contrib non-free deb http://security.debian.org/ testing/updates main contrib non-free deb http://ftp.debian.org/debian experimental main deb http://ftp.br.debian.org/debian unstable main contrib non-free deb-src http://ftp.br.debian.org/debian testing main contrib non-free # wine, to get the most recent version, much more updated than offcial debian deb http://www.lamaresh.net/apt squeeze main # google, mainly to get chrome updated deb http://dl.google.com/linux/deb/ testing non-free # debian multimedia, for ffmpeg with all non-free codecs deb ftp://ftp.debian-multimedia.org testing main # spring, a RTS game deb http://ppa.launchpad.net/spring/ubuntu jaunty main # wxwidgets, temporary hack to get a better version deb http://apt.wxwidgets.org/ lenny-wx main # unknown horizons, a CIV-style game deb http://packages.unknown-horizons.org/squeeze weekly main # opera deb http://deb.opera.com/opera/ squeeze non-free # playdeb, almost everything works on debian too deb http://archive.getdeb.net/ubuntu karmic-getdeb games # EKD video editor deb http://download.tuxfamily.org/ekdforum/ekd squeeze contrib
import os, gtk class pseudoTransparentWindow: def __init__(self): self.toolbarheight=19 self.win = gtk.Window() self.win.set_size_request(250, 200) btn1 = gtk.Button("Test Button") fixed = gtk.Fixed() fixed.put(btn1, 20, 30) layout = gtk.ScrolledWindow() layout.set_policy(gtk.POLICY_NEVER,gtk.POLICY_AUTOMATIC) layout.add_with_viewport(fixed) layout.get_child().set_shadow_type(gtk.SHADOW_NONE) self.style(layout.get_child()) self.win.add(layout) self.win.show_all() self.updateBackground() self.win.connect('configure-event', self.updateBackground) def updateBackground(self,args=None,stuff=None): self.style(self.win) def style(self,widget): x,y = self.win.get_position() w,h = self.win.get_size() wpfile = open(os.path.expanduser('~') + os.sep + '.fluxbox/lastwallpaper') pb=gtk.gdk.pixbuf_new_from_file(wpfile.read().split('|')) wpfile.close() crop = gtk.gdk.Pixbuf( gtk.gdk.COLORSPACE_RGB, False, 8, w, h ) pb.copy_area(x, y+self.toolbarheight, w, h, crop, 0, 0) mask = crop.copy() mask.fill(0x00000000) mask.composite(crop, 0, 0, w, h, 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 127) pm,m = crop.render_pixmap_and_mask(255) style = widget.get_style().copy() style.bg_pixmap[gtk.STATE_NORMAL] = pm widget.set_style(style) if __name__ == '__main__': pseudoTransparentWindow() gtk.main()