Thursday, July 12, 2007

Les Scripts HTA


Les applications 'hta' sont de simples fichiers html ayant pout extension 'hta'.
Leur intérêt, entre autre, est qu'il sont interprétes par Windows comme de véritables
applications. Ils permettent ainsi l'utilisation de tous les composants 'html' dans les
scripts écrits en vbscript ou tout autre langage supporté par wsh.


<html>
<head>
<title>Running a Script from Text</title>
<HTA:APPLICATION
ID="objScriptFromText"
APPLICATIONNAME="Running a Script from Text"
SCROLL="auto"
SINGLEINSTANCE="yes"
>
</head>

<SCRIPT Language="VBScript">

Sub RunScript
Msgbox "The script has run."
End Sub

Sub Pointer
document.body.style.cursor = "hand"
End Sub

Sub DefaultCursor
document.body.style.cursor = "default"
End Sub

</SCRIPT>

<body bgcolor="buttonface">

<span id="ClickableSpan" onClick="RunScript" onmouseover="Pointer"
onmouseout="DefaultCursor">
Click here to run the script</span>

</body>
</html>

Tuesday, June 5, 2007

XNA - Boo

Voci un exemple pour Boo, adapté de C# par Cédric Vidier.

Voci un exemple pour Boo, adapté de C# par Cédric Vidier.


namespace SimpleExample

import System
import System.Collections.Generic
import Microsoft.Xna.Framework
import Microsoft.Xna.Framework.Audio
import Microsoft.Xna.Framework.Content
import Microsoft.Xna.Framework.Graphics
import Microsoft.Xna.Framework.Input
import Microsoft.Xna.Framework.Storage


///
/// When run, you'll see an empty blue screen. This code can
/// be run in both Mono.Xna and Microsoft XNA without changing
/// any code.
///

class SimpleExampleGame(Microsoft.Xna.Framework.Game):
graphics as GraphicsDeviceManager
content as ContentManager

def constructor():
graphics = GraphicsDeviceManager(self)
content = ContentManager(Services)


/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.

protected override def Initialize():
// TODO: Add your initialization logic here
super()


/// Load your graphics content. If loadAllContent is true, you should
/// load content from both ResourceManagementMode pools. Otherwise, just
/// load ResourceManagementMode.Manual content.

/// Which type of content to load.
protected override def LoadGraphicsContent(loadAllContent as bool):
if loadAllContent:
// TODO: Load any ResourceManagementMode.Automatic content
pass
// TODO: Load any ResourceManagementMode.Manual content


/// Unload your graphics content. If unloadAllContent is true, you should
/// unload content from both ResourceManagementMode pools. Otherwise, just
/// unload ResourceManagementMode.Manual content. Manual content will get
/// Disposed by the GraphicsDevice during a Reset.

/// Which type of content to unload.
protected override def UnloadGraphicsContent(unloadAllContent as bool):
if unloadAllContent:
content.Unload()


/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input and playing audio.

/// Provides a snapshot of timing values.
protected override def Update(gameTime as GameTime):
// Allows the default game to exit on Xbox 360 and Windows
if GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed:
Exit()

// TODO: Add your update logic here
super(gameTime)


/// This is called when the game should draw itself.

/// Provides a snapshot of timing values.
protected override def Draw(gameTime as GameTime):
graphics.GraphicsDevice.Clear(Color.CornflowerBlue)

// TODO: Add your drawing code here
super(gameTime)

Sunday, June 3, 2007

XNA - IronPython

IronPython et la version du célèbre langage (mon favori en fait) porté sur la plateforme .NET.
Xna et le framework de développement de jeux pour XBOX et Windows .Net. Voici un petit exemple écrit par Leaf:


import clr
clr.AddReference('Microsoft.Xna.Framework')
clr.AddReference('Microsoft.Xna.Framework.Game')

from Microsoft.Xna.Framework import *
from Microsoft.Xna.Framework.Graphics import *
from Microsoft.Xna.Framework.Content import *

class MyGame(Game):
def __init__(self):
self.spriteX = self.spriteY = 0
self.spriteSpeedX = self.spriteSpeedY = 1
self.InitializeComponent()

def InitializeComponent(self):
self.graphics = GraphicsDeviceManager(self)
self.content = ContentManager(self.Services)

def LoadGraphicsContent(self, loadAllContent):
if loadAllContent:
self.texture = Texture2D.FromFile(self.graphics.GraphicsDevice, "sprite.jpg")
self.spriteBatch = SpriteBatch(self.graphics.GraphicsDevice)

def UnloadGraphicsContent(self, unloadAllContent):
if unloadAllContent:
self.texture.Dispose()
self.spritebatch.Dispose()

def Update(self, gameTime):
self.UpdateSprite()

Game.Update(self, gameTime)

def UpdateSprite(self):
self.spriteX += self.spriteSpeedX
self.spriteY += self.spriteSpeedY

maxX = self.graphics.GraphicsDevice.Viewport.Width - self.texture.Width
if self.spriteX > maxX:
self.spriteSpeedX *= -1
self.spriteX = maxX
elif self.spriteX < 0:
self.spriteSpeedX *= -1
self.spriteX = 0

maxY = self.graphics.GraphicsDevice.Viewport.Height - self.texture.Height
if self.spriteY > maxY:
self.spriteSpeedY *= -1
self.spriteX = maxY
elif self.spriteY < 0:
self.spriteSpeedY *= -1
self.spriteY = 0

def Draw(self, gameTime):
self.graphics.GraphicsDevice.Clear(Color.CornflowerBlue)

self.DrawSprite()

Game.Draw(self, gameTime)

def DrawSprite(self):
self.spriteBatch.Begin()
self.spriteBatch.Draw(self.texture, Rectangle(self.spriteX,
self.spriteY, self.texture.Width, self.texture.Height), Color.White)
self.spriteBatch.End()

game = MyGame()
game.Run()

Friday, March 30, 2007

Jython - SSH

Ganymed est une librairie java qui implémente le protocole SSH.
Et bien sûr on peut parfaitement l'utiliser sous Jython :-)
Voici un exemple de servlet Jython utlisant Ganymed.

http://www.ganymed.ethz.ch/ssh2/



from javax.servlet.http import HttpServlet
from ch.ethz.ssh2 import Connection,Session,StreamGobbler
from java.io import BufferedReader, InputStreamReader

hostname = '127.0.0.1'
username = 'admin'
password = 'Yu8KL%'

class MonServeur (HttpServlet):
def doGet(self,request,response):
self.doPost (request,response)
def doPost(self,request,response):
sortie = []
conn = Connection(hostname)
conn.connect()
isConnected = conn.authenticateWithPassword(username, password);
sess = conn.openSession()
sess.execCommand("uname -a && df -k")
stdout = StreamGobbler(sess.getStdout())
inputStreamReader = InputStreamReader(stdout)
br = BufferedReader(inputStreamReader)
toClient = response.getWriter()
response.setContentType ("text/html")
while (1):
line = br.readLine()
if line == None:
break
sortie.append(line)
toClient.println (sortie)

Wednesday, March 21, 2007

Utiliser Jython développer en Java

Jython est l'implémentation en Java du langage de programmation Python.
Il permet d'avoir accés à toutes les classes Java. En outre on peut très facilement
créer des applets, servlets, beans avec toute la simplicité du langage Python: le rêve.

Si vous voulez tester voici un lien qui explique comment par exemple
déployer une servlet Jython sur Tomcat. (J'ai testé cela marche très bien).

http://linuxgazette.net/issue97/tougher.html

Jython inclue la servlet "Pyservlet" qui permet de modifier la servlet et de l'exécuter sans recompilation !!!

Sunday, February 18, 2007

Saturday, February 17, 2007

Modules musicaux

Je viens de rajouter quelques morceaux de musique. Ne vous arrêtez aux premières mesures :-)
Malheureusement, la conversion au format mp3 réduit de façon notable la qualité du son et des effets. Mais bon c'est le prix à payer.
Si vous désirez en savoir un peu plus sur l'origine de ces oeuvres musicales, je vous conseille de visiter ce site : http://www.modarchive.org.

Bonne écoute...